all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* export to LaTeX with TOC but without numbers
@ 2013-06-04  7:34 Andreas Leha
  2013-06-04 11:47 ` Eric S Fraga
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas Leha @ 2013-06-04  7:34 UTC (permalink / raw)
  To: emacs-orgmode

Hi all,

How can I export to LaTeX with the combined effect of toc:t and num:nil?

Setting num:nil results in an empty TOC.

I guess, I am looking for a way to automatically add
#+begin_latex
  \addcontentsline{toc}{<the level>}{<the heading>}
#+end_latex
to the exported document.

Regards,
Andreas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04  7:34 export to LaTeX with TOC but without numbers Andreas Leha
@ 2013-06-04 11:47 ` Eric S Fraga
  2013-06-04 11:55   ` Andreas Leha
  0 siblings, 1 reply; 12+ messages in thread
From: Eric S Fraga @ 2013-06-04 11:47 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Hi all,
>
> How can I export to LaTeX with the combined effect of toc:t and num:nil?
>
> Setting num:nil results in an empty TOC.
>
> I guess, I am looking for a way to automatically add
> #+begin_latex
>   \addcontentsline{toc}{<the level>}{<the heading>}
> #+end_latex
> to the exported document.
>
> Regards,
> Andreas

Andreas,

the problem is that setting num:nil tells org to use the second form of
sectioning, as specified in org-latex-classes.  The unnumbered section
headings do not generate TOC information so no TOC is available.  It's a
latex issue, not org.

There are workarounds but they involve using latex directly (to add
entries to a TOC basically).


-- 
: Eric S Fraga, GnuPG: 0xC89193D8FFFCF67D
: in Emacs 24.3.50.1 and Org release_8.0.3-195-gd7e884

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04 11:47 ` Eric S Fraga
@ 2013-06-04 11:55   ` Andreas Leha
  2013-06-04 15:10     ` Eric S Fraga
  2013-06-04 19:01     ` Nick Dokos
  0 siblings, 2 replies; 12+ messages in thread
From: Andreas Leha @ 2013-06-04 11:55 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

thanks for your answer.

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi all,
>>
>> How can I export to LaTeX with the combined effect of toc:t and num:nil?
>>
>> Setting num:nil results in an empty TOC.
>>
>> I guess, I am looking for a way to automatically add
>> #+begin_latex
>>   \addcontentsline{toc}{<the level>}{<the heading>}
>> #+end_latex
>> to the exported document.
>>
>> Regards,
>> Andreas
>
> Andreas,
>
> the problem is that setting num:nil tells org to use the second form of
> sectioning, as specified in org-latex-classes.  The unnumbered section
> headings do not generate TOC information so no TOC is available.  It's a
> latex issue, not org.
>
> There are workarounds but they involve using latex directly (to add
> entries to a TOC basically).

I am aware of that.  Sorry for being unclear.  I would like to automate
exactly that.

I use several LaTeX export classes and I would like that possibility
(TOC with unnumbered sections/subsections/...) in each of these classes.
Thus, I am searching for a (more) general approach, that I could 'switch on'
and have it insert the latex statement on its own.

Best,
Andreas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04 11:55   ` Andreas Leha
@ 2013-06-04 15:10     ` Eric S Fraga
  2013-06-04 19:56       ` Andreas Leha
  2013-06-04 19:01     ` Nick Dokos
  1 sibling, 1 reply; 12+ messages in thread
From: Eric S Fraga @ 2013-06-04 15:10 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:

[...]

>> There are workarounds but they involve using latex directly (to add
>> entries to a TOC basically).
>
> I am aware of that.  Sorry for being unclear.  I would like to automate
> exactly that.
>
> I use several LaTeX export classes and I would like that possibility
> (TOC with unnumbered sections/subsections/...) in each of these classes.
> Thus, I am searching for a (more) general approach, that I could 'switch on'
> and have it insert the latex statement on its own.
>
> Best,
> Andreas

Ah, I see.  Well, you could do something along these lines (completely
untested and likely to be wrong...):

#+latex_header: \newcommand{\mysection}[1]{\section*{#1}\addcontentsline{toc}{section}{#1}}

and similar for subsection, subsubsection, ...

Then customise org-latex-classes and replace, for instance,
\\section*{%s} by \\mysection{%s}.

However, you'll probably need to put a bit more TeX in the
addcontentsline bit if you want some proper formatting (have a look at
latex.ltx [around line 5659 in my version of this file] to see how
content lines are handled by default...).

Not trivial but also not impossible!

I would suggest you look at latex-specific fora for answers to the more
general question of generating tables of contents for unnumbered
headings as I can imagine that there are simpler solutions.

HTH,
eric

-- 
: Eric S Fraga, GnuPG: 0xC89193D8FFFCF67D
: in Emacs 24.3.50.1 and Org release_8.0.3-193-g334581

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04 11:55   ` Andreas Leha
  2013-06-04 15:10     ` Eric S Fraga
@ 2013-06-04 19:01     ` Nick Dokos
  2013-06-04 20:10       ` Andreas Leha
  1 sibling, 1 reply; 12+ messages in thread
From: Nick Dokos @ 2013-06-04 19:01 UTC (permalink / raw)
  To: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Hi Eric,
>
> thanks for your answer.
>
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>
>>> Hi all,
>>>
>>> How can I export to LaTeX with the combined effect of toc:t and num:nil?
>>>
>>> Setting num:nil results in an empty TOC.
>>>
>>> I guess, I am looking for a way to automatically add
>>> #+begin_latex
>>>   \addcontentsline{toc}{<the level>}{<the heading>}
>>> #+end_latex
>>> to the exported document.
>>>
>>> Regards,
>>> Andreas
>>
>> Andreas,
>>
>> the problem is that setting num:nil tells org to use the second form of
>> sectioning, as specified in org-latex-classes.  The unnumbered section
>> headings do not generate TOC information so no TOC is available.  It's a
>> latex issue, not org.
>>
>> There are workarounds but they involve using latex directly (to add
>> entries to a TOC basically).
>
> I am aware of that.  Sorry for being unclear.  I would like to automate
> exactly that.
>
> I use several LaTeX export classes and I would like that possibility
> (TOC with unnumbered sections/subsections/...) in each of these classes.
> Thus, I am searching for a (more) general approach, that I could 'switch on'
> and have it insert the latex statement on its own.
>

Instead of adding toc entries, you can use latex to delete section
numbers:

--8<---------------cut here---------------start------------->8---
#+LATEX_HEADER: \setcounter{secnumdepth}{0}

* foo
This is foo.

** subfoo1
This is foo.1
** subfoo2
This is foo.2

* bar
This is bar.
--8<---------------cut here---------------end--------------->8---

The problem might be that the sections are not numbered in the TOC
either. But if you don't care about that, this is certainly simpler
than adding toc entries by hand.

-- 
Nick

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04 15:10     ` Eric S Fraga
@ 2013-06-04 19:56       ` Andreas Leha
  2013-06-05  1:00         ` Eric Abrahamsen
  2013-06-05  7:27         ` Eric S Fraga
  0 siblings, 2 replies; 12+ messages in thread
From: Andreas Leha @ 2013-06-04 19:56 UTC (permalink / raw)
  To: emacs-orgmode

Hi Eric,

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
> [...]
>
>>> There are workarounds but they involve using latex directly (to add
>>> entries to a TOC basically).
>>
>> I am aware of that.  Sorry for being unclear.  I would like to automate
>> exactly that.
>>
>> I use several LaTeX export classes and I would like that possibility
>> (TOC with unnumbered sections/subsections/...) in each of these classes.
>> Thus, I am searching for a (more) general approach, that I could 'switch on'
>> and have it insert the latex statement on its own.
>>
>> Best,
>> Andreas
>
> Ah, I see.  Well, you could do something along these lines (completely
> untested and likely to be wrong...):
>
> #+latex_header: \newcommand{\mysection}[1]{\section*{#1}\addcontentsline{toc}{section}{#1}}
>
> and similar for subsection, subsubsection, ...
>
> Then customise org-latex-classes and replace, for instance,
> \\section*{%s} by \\mysection{%s}.
>
> However, you'll probably need to put a bit more TeX in the
> addcontentsline bit if you want some proper formatting (have a look at
> latex.ltx [around line 5659 in my version of this file] to see how
> content lines are handled by default...).
>
> Not trivial but also not impossible!
>
> I would suggest you look at latex-specific fora for answers to the more
> general question of generating tables of contents for unnumbered
> headings as I can imagine that there are simpler solutions.
>

Thanks for these hints!  When I follow that route I'll have to do
more work I guess:
1. either I have to provide two versions of my org-latex-classes (one
   for numbered and one for un-numbered cases)
2. or I have to provide a filter or sth similar to replace sections
   with mysections, correct?

That's why I would prefer to follow Nick's suggestion.

Regards,
Andreas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04 19:01     ` Nick Dokos
@ 2013-06-04 20:10       ` Andreas Leha
  2013-06-04 20:54         ` Nick Dokos
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas Leha @ 2013-06-04 20:10 UTC (permalink / raw)
  To: emacs-orgmode

Hi Nick,

Nick Dokos <ndokos@gmail.com> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi Eric,
>>
>> thanks for your answer.
>>
>> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>>
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>
>>>> Hi all,
>>>>
>>>> How can I export to LaTeX with the combined effect of toc:t and num:nil?
>>>>
>>>> Setting num:nil results in an empty TOC.
>>>>
>>>> I guess, I am looking for a way to automatically add
>>>> #+begin_latex
>>>>   \addcontentsline{toc}{<the level>}{<the heading>}
>>>> #+end_latex
>>>> to the exported document.
>>>>
>>>> Regards,
>>>> Andreas
>>>
>>> Andreas,
>>>
>>> the problem is that setting num:nil tells org to use the second form of
>>> sectioning, as specified in org-latex-classes.  The unnumbered section
>>> headings do not generate TOC information so no TOC is available.  It's a
>>> latex issue, not org.
>>>
>>> There are workarounds but they involve using latex directly (to add
>>> entries to a TOC basically).
>>
>> I am aware of that.  Sorry for being unclear.  I would like to automate
>> exactly that.
>>
>> I use several LaTeX export classes and I would like that possibility
>> (TOC with unnumbered sections/subsections/...) in each of these classes.
>> Thus, I am searching for a (more) general approach, that I could 'switch on'
>> and have it insert the latex statement on its own.
>>
>
> Instead of adding toc entries, you can use latex to delete section
> numbers:
>
> #+LATEX_HEADER: \setcounter{secnumdepth}{0}
>
> * foo
> This is foo.
>
> ** subfoo1
> This is foo.1
> ** subfoo2
> This is foo.2
>
> * bar
> This is bar.
>
> The problem might be that the sections are not numbered in the TOC
> either. But if you don't care about that, this is certainly simpler
> than adding toc entries by hand.

Thanks for that!  That is really cool and having the entries in the TOC
un-numbered is exactly what I want!

As a follow-up, it would be nice if I could mix
that now again with num:1.  That way I could add a TOC with depth 1
(only sections) and have them un-numbered.

But num:1 add its own '\setcounter{secnumdepth}{1}' (why?) which by default
comes later than than the #+LATEX_HEADER definition:

--8<---------------cut here---------------start------------->8---
#+OPTIONS: num:1
#+LATEX_HEADER: \setcounter{secnumdepth}{0}

* foo
This is foo.

** subfoo1
This is foo.1
** subfoo2
This is foo.2

* bar
This is bar.
--8<---------------cut here---------------end--------------->8---

Regards,
Andreas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04 20:10       ` Andreas Leha
@ 2013-06-04 20:54         ` Nick Dokos
  2013-06-05  7:09           ` Andreas Leha
  0 siblings, 1 reply; 12+ messages in thread
From: Nick Dokos @ 2013-06-04 20:54 UTC (permalink / raw)
  To: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

>> Instead of adding toc entries, you can use latex to delete section
>> numbers:
>>
>> #+LATEX_HEADER: \setcounter{secnumdepth}{0}
>> ...
>>
>> The problem might be that the sections are not numbered in the TOC
>> either. But if you don't care about that, this is certainly simpler
>> than adding toc entries by hand.
>
> Thanks for that!  That is really cool and having the entries in the TOC
> un-numbered is exactly what I want!
>
> As a follow-up, it would be nice if I could mix
> that now again with num:1.  That way I could add a TOC with depth 1
> (only sections) and have them un-numbered.
>

There is a tocdepth counter that you can set similarly. Will that
do what you want?

--8<---------------cut here---------------start------------->8---
#+LATEX_HEADER: \setcounter{tocdepth}{1}
#+LATEX_HEADER: \setcounter{secnumdepth}{0}
--8<---------------cut here---------------end--------------->8---


> But num:1 add its own '\setcounter{secnumdepth}{1}' (why?) which by default
> comes later than than the #+LATEX_HEADER definition:
>
> #+OPTIONS: num:1
> #+LATEX_HEADER: \setcounter{secnumdepth}{0}
>


-- 
Nick

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04 19:56       ` Andreas Leha
@ 2013-06-05  1:00         ` Eric Abrahamsen
  2013-06-05  7:14           ` Andreas Leha
  2013-06-05  7:27         ` Eric S Fraga
  1 sibling, 1 reply; 12+ messages in thread
From: Eric Abrahamsen @ 2013-06-05  1:00 UTC (permalink / raw)
  To: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:

> Hi Eric,
>
> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>
>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>>
>> [...]
>>
>>>> There are workarounds but they involve using latex directly (to add
>>>> entries to a TOC basically).
>>>
>>> I am aware of that.  Sorry for being unclear.  I would like to automate
>>> exactly that.
>>>
>>> I use several LaTeX export classes and I would like that possibility
>>> (TOC with unnumbered sections/subsections/...) in each of these classes.
>>> Thus, I am searching for a (more) general approach, that I could 'switch on'
>>> and have it insert the latex statement on its own.
>>>
>>> Best,
>>> Andreas
>>
>> Ah, I see.  Well, you could do something along these lines (completely
>> untested and likely to be wrong...):
>>
>> #+latex_header: \newcommand{\mysection}[1]{\section*{#1}\addcontentsline{toc}{section}{#1}}
>>
>> and similar for subsection, subsubsection, ...
>>
>> Then customise org-latex-classes and replace, for instance,
>> \\section*{%s} by \\mysection{%s}.
>>
>> However, you'll probably need to put a bit more TeX in the
>> addcontentsline bit if you want some proper formatting (have a look at
>> latex.ltx [around line 5659 in my version of this file] to see how
>> content lines are handled by default...).
>>
>> Not trivial but also not impossible!
>>
>> I would suggest you look at latex-specific fora for answers to the more
>> general question of generating tables of contents for unnumbered
>> headings as I can imagine that there are simpler solutions.
>>
>
> Thanks for these hints!  When I follow that route I'll have to do
> more work I guess:
> 1. either I have to provide two versions of my org-latex-classes (one
>    for numbered and one for un-numbered cases)
> 2. or I have to provide a filter or sth similar to replace sections
>    with mysections, correct?

I've gone the filter route before, with pretty good success: checking
for the type of heading and adding toc statements. In my case I *wanted*
something more complicated, though, using tocloft and \addtocontents. If
you don't need all that then Nick's suggestion seems perfect.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04 20:54         ` Nick Dokos
@ 2013-06-05  7:09           ` Andreas Leha
  0 siblings, 0 replies; 12+ messages in thread
From: Andreas Leha @ 2013-06-05  7:09 UTC (permalink / raw)
  To: emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>>> Instead of adding toc entries, you can use latex to delete section
>>> numbers:
>>>
>>> #+LATEX_HEADER: \setcounter{secnumdepth}{0}
>>> ...
>>>
>>> The problem might be that the sections are not numbered in the TOC
>>> either. But if you don't care about that, this is certainly simpler
>>> than adding toc entries by hand.
>>
>> Thanks for that!  That is really cool and having the entries in the TOC
>> un-numbered is exactly what I want!
>>
>> As a follow-up, it would be nice if I could mix
>> that now again with num:1.  That way I could add a TOC with depth 1
>> (only sections) and have them un-numbered.
>>
>
> There is a tocdepth counter that you can set similarly. Will that
> do what you want?
>
> #+LATEX_HEADER: \setcounter{tocdepth}{1}
> #+LATEX_HEADER: \setcounter{secnumdepth}{0}
>
>

That does what I want.  Thanks a lot!

Best,
Andreas

PS: I will come back when I need a cross-backend-solution, that work for
odt as well....

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-05  1:00         ` Eric Abrahamsen
@ 2013-06-05  7:14           ` Andreas Leha
  0 siblings, 0 replies; 12+ messages in thread
From: Andreas Leha @ 2013-06-05  7:14 UTC (permalink / raw)
  To: emacs-orgmode

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>
>> Hi Eric,
>>
>> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>>
>>> Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:
>>>> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>>>
>>> [...]
>>>
>>>>> There are workarounds but they involve using latex directly (to add
>>>>> entries to a TOC basically).
>>>>
>>>> I am aware of that.  Sorry for being unclear.  I would like to automate
>>>> exactly that.
>>>>
>>>> I use several LaTeX export classes and I would like that possibility
>>>> (TOC with unnumbered sections/subsections/...) in each of these classes.
>>>> Thus, I am searching for a (more) general approach, that I could 'switch on'
>>>> and have it insert the latex statement on its own.
>>>>
>>>> Best,
>>>> Andreas
>>>
>>> Ah, I see.  Well, you could do something along these lines (completely
>>> untested and likely to be wrong...):
>>>
>>> #+latex_header: \newcommand{\mysection}[1]{\section*{#1}\addcontentsline{toc}{section}{#1}}
>>>
>>> and similar for subsection, subsubsection, ...
>>>
>>> Then customise org-latex-classes and replace, for instance,
>>> \\section*{%s} by \\mysection{%s}.
>>>
>>> However, you'll probably need to put a bit more TeX in the
>>> addcontentsline bit if you want some proper formatting (have a look at
>>> latex.ltx [around line 5659 in my version of this file] to see how
>>> content lines are handled by default...).
>>>
>>> Not trivial but also not impossible!
>>>
>>> I would suggest you look at latex-specific fora for answers to the more
>>> general question of generating tables of contents for unnumbered
>>> headings as I can imagine that there are simpler solutions.
>>>
>>
>> Thanks for these hints!  When I follow that route I'll have to do
>> more work I guess:
>> 1. either I have to provide two versions of my org-latex-classes (one
>>    for numbered and one for un-numbered cases)
>> 2. or I have to provide a filter or sth similar to replace sections
>>    with mysections, correct?
>
> I've gone the filter route before, with pretty good success: checking
> for the type of heading and adding toc statements. In my case I *wanted*
> something more complicated, though, using tocloft and \addtocontents. If
> you don't need all that then Nick's suggestion seems perfect.


The more I think about it, the more I get the impression, that it would
have been faster (even given my elisp 'skills') to write such a
filter than to raise that here.  And I might even need a similar and
more complicated TOC handling soon, so it would have been a good start.

Anyway, Nick's suggestion works for now.  As I said in the other post,
it works at least as long as I do not want odt as well...

Best,
Andreas

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: export to LaTeX with TOC but without numbers
  2013-06-04 19:56       ` Andreas Leha
  2013-06-05  1:00         ` Eric Abrahamsen
@ 2013-06-05  7:27         ` Eric S Fraga
  1 sibling, 0 replies; 12+ messages in thread
From: Eric S Fraga @ 2013-06-05  7:27 UTC (permalink / raw)
  To: Andreas Leha; +Cc: emacs-orgmode

Andreas Leha <andreas.leha@med.uni-goettingen.de> writes:


[...]

> That's why I would prefer to follow Nick's suggestion.

Yes, Nick's suggestion is straightforward and should work very well for
what you want.
-- 
: Eric S Fraga, GnuPG: 0xC89193D8FFFCF67D
: in Emacs 24.3.50.1 and Org release_8.0.3-193-g334581

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-06-05  8:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-04  7:34 export to LaTeX with TOC but without numbers Andreas Leha
2013-06-04 11:47 ` Eric S Fraga
2013-06-04 11:55   ` Andreas Leha
2013-06-04 15:10     ` Eric S Fraga
2013-06-04 19:56       ` Andreas Leha
2013-06-05  1:00         ` Eric Abrahamsen
2013-06-05  7:14           ` Andreas Leha
2013-06-05  7:27         ` Eric S Fraga
2013-06-04 19:01     ` Nick Dokos
2013-06-04 20:10       ` Andreas Leha
2013-06-04 20:54         ` Nick Dokos
2013-06-05  7:09           ` Andreas Leha

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.