Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

My document is organized as following:

\title[Some title]
\section[Section 1]
\section[Section 2]

etc.

When I use \completecontents command to print a ToC, I only get the section titles (which are numbered) and not the titles (\title entries). Is there a way to tell ConTeXt to print \title entries into ToC? Ideally, I prefer a table of contents that looks something like this:

Some Title

  1. Section 1 xx 2. Section 2 yy

Another Title

  1. Section in second title zz
share|improve this question
    
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. –  doncherry Jun 26 '12 at 12:49
    
Thanks. It was my first attempt in posting a question and I didn't know that. Now, I know. –  Hooman Jun 26 '12 at 13:29
    
No worries, you'll soon get used to the format of tex.sx, which is a bit different from normal forums. We'll gladly help you along the way. (I don't know any ConTeXt, so I can't help you with your question, unfortunately.) –  doncherry Jun 26 '12 at 13:42
add comment

1 Answer

Here is a complete compileable example of what you want.

\setuphead[title][
    incrementnumber=yes, % keep an internal title counter+list
    number=no]  % don't display the counter

% Manually specify the composition of the section and subsection numbers
\setuphead[section][sectionsegments=section]
\setuphead[subsection][sectionsegments=section:subsection]   

% Redefine the toc list to include titles
\definecombinedlist[content][title, section]

\starttext
    % Place the toc
    \placecontent

    % Place some sections to see what their numbers look like.
    \title{T1}
      \section{S1}
        \subsection{Sb1.1}
        \subsection{Sb1.2}
      \section{S2}
        \subsection{Sb2.1}

    \title{T1}
      \section{S1}
        \subsection{Sb1.1}
\stoptext

I got the sectionsegments key from phg. For examples on styling the ToC, see the ConTeXt Garden wiki article on the table of contents, section Modifying the default ToC.

share|improve this answer
    
Thank you @Esteis for the providing the solution. It achieves almost what I had in mind with a small caveat: since \title now has a number, the sections inherit this number and show up as 1.1, 1.2, etc. Since, this is a lab book that I am writing, I prefer to have just the section numbers and do not append the \title numbers to them. I am fairly new to the world of ConTeXt, but I am pretty sure one can setup the sections using \setuphead so that the sections do not inherit the chapter or title numbers. I just don't know how. Thanks again. –  Hooman Jun 27 '12 at 15:34
    
Thanks @Caramdir for editing the answer. As much I tried the "Add Comment" button was showing up under the original answer. That's why I started a new answer. Is there a way to delete my answer now that it shows up as a comment? –  Hooman Jun 27 '12 at 17:02
    
@Hooman: It already is. Please register so that you won't lose your login again (and thus keep being able to comment). –  Caramdir Jun 27 '12 at 17:06
    
Thank you very much @Esteis. –  Hooman Jul 3 '12 at 14:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.