2

Is it possible to create table of content, that is based on new command appearance, like this:

\mycomm{Circles and squares} %title of 1st chapter
\mycomm{Triangles and rectangles} %title of 2nd chapter

Every chapter has a title with some style (applied by mycomm). Can I use appearance of this style for creating table of contents? And can I apply some completely new style to table of contents? I think about table of content as a set of paragraphs (every entry is a paragraph = name of chapter + filler + page number). Possible?

Here is a minimal document:

\documentclass{book}   
\newcommand{\mycomm}[1]
{
\newpage
\vspace{55 mm}
\textbf{\huge{#1}}
\vspace{35 mm}
}     
\begin{document}              
\mycomm{Circles and squares} %title of 1st chapter

bla bla
\mycomm{Triangles and rectangles} %title of 2nd chapter

bla bla
\end{document}

What have to be added to \mycomm to create table of content that will be based on this style? How to control the look of the table of content? I wish to set new command '\mycommtwo' and use it to style every entry in table of content, sometimes I wish to use different command, something like:

\newcommand{\mycommtwo}[1]
{
\textbf{\huge{#1}}
}     
\newcommand{\mycommtwotwo}[1]
{
\textbf{\large{#1}}
}

I wish to control also fillers between name of element in table of content and page number and space between them. I know how to do it in InDesign, but I wish to switch to LaTeX just for fun

5
  • Yes, this is possible. There are packages for this or you can do it manually. It would be better if you would give the definition of \mycomm together with what you're trying to achieve in terms of the look for your ToC, since a mere "Yes" answers your question. Do so by constructing a minimal working example (MWE) that starts with \documentclass and ends with \end{document}.
    – Werner
    Oct 2, 2013 at 2:58
  • Check Memoir manual. Oct 2, 2013 at 3:20
  • Adding content to the ToC is done using \addtocontents{<toc>}{<stuff>} or \addcontentsline{<toc>}{<type>}{<stuff>}, but you have to be careful of what you write. Do you want the ToC entries to be set in same format, \textbf{\huge ...}? The question "How to control [the] look of [the] Table of Contents?" is just too broad...
    – Werner
    Oct 2, 2013 at 6:01
  • Forget about easy styling the ToC in LaTeX, it doesn't work like InDesign, sadly:) You can change ToC, read memman.pdf Oct 2, 2013 at 16:16
  • 1
    It looks like you've got two separate accounts, which means you cannot edit your original post or leave comments. The StackExchange staff can merge them together for you.
    – Werner
    Oct 2, 2013 at 16:21

1 Answer 1

1

I think for you it is most suitable to redefine \@makechapterhead (and his friend \@makeschapterhead if needed). What you actually did, is to write sectioning commands from scratch, and you don't need to do it in the sitaution you described. The default of these macros can be found in the source code of the class you are using, which again can be found on your machine (or on CTAN). Use this as a basis for your redefinition, i.e.

\makeatletter
\renewcommand{\@makechapterhead}[1]{...}
\makeatother

Then, you don't have to worry about chapter headings not making it into the TOC. The comments to your post rightly state that you can manipulate the TOC with the macros \addtocontents and \addcontentsline. But this is exactly what \chapter, respectively \@chapter is doing.

The TOC can be easily styled with the canonic packages tocloft or titletoc. For the dotted leaders you need something like:

\usepackage{titletoc}
\titlecontents{chapter}[0pt]{\addvspace{1pc}}%
{\bfseries\thecontentslabel\hspace{.5em}\large}{}%
{\titlerule*[.5pc]{.}\contentspage}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .