Page Layout ⇒ Adding a heading to the table of contents
Adding a heading to the table of contents
Hi,
I need to add a heading to the TOC as the image below:
Thanks
I need to add a heading to the TOC as the image below:
Thanks
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
Adding a heading to the table of contents
Hi nadaa,
you can use this:
Stefan
you can use this:
Code: Select all
\usepackage{afterpage}
\newcommand*{\headline}{%
\hbox to \linewidth{\underline{Title}\hfill\underline{Page}}
\bigskip\afterpage{\headline}}
\addtocontents{toc}{\protect\headline}
LaTeX.org admin
Adding a heading to the table of contents
Perfect!. Thank you so much, Stefan.Stefan Kottwitz wrote:Hi nadaa,
you can use this:
StefanCode: Select all
\usepackage{afterpage} \newcommand*{\headline}{% \hbox to \linewidth{\underline{Title}\hfill\underline{Page}} \bigskip\afterpage{\headline}} \addtocontents{toc}{\protect\headline}
There is a problem, this is repeated on all the pages, and multiple empty pages were created!?
I still need to set the font size for "Table of Content" to be 16px and centered.
chapter font size within the TOC to be 14px bold and section 12px bold.
How can I do that?
I use a report class doc.
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
Adding a heading to the table of contents
Please post a minimal but compilable example of your code. It takes too much time to imagine and create some code, that may be similar to what you wrote, or not... no way to test without your code.
Stefan
Stefan
LaTeX.org admin
Adding a heading to the table of contents
Hi Stefan. I am working on a large document (thesis). My question is about formatting table of content. What shall I show?Stefan Kottwitz wrote:Please post a minimal but compilable example of your code. It takes too much time to imagine and create some code, that may be similar to what you wrote, or not... no way to test without your code.
Stefan
The previous solution you gave works, but the heading was copied to the whole doc, besides, it adds multiple empty pages?!
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
Adding a heading to the table of contents
Then use it this way:
Stefan
Code: Select all
\usepackage{afterpage}
\newif\iftoc
\newcommand*{\headline}{%
\hbox to \linewidth{\normalfont\underline{Title}\hfill\underline{Page}}
\bigskip\afterpage{\iftoc\headline\fi}}
\addtocontents{toc}{\protect\headline}
...
\begin{document}
...
{\toctrue\tableofcontents}
LaTeX.org admin
Adding a heading to the table of contents
Thanks, I tried it, but the same.Stefan Kottwitz wrote:Then use it this way:
StefanCode: Select all
\usepackage{afterpage} \newif\iftoc \newcommand*{\headline}{% \hbox to \linewidth{\normalfont\underline{Title}\hfill\underline{Page}} \bigskip\afterpage{\iftoc\headline\fi}} \addtocontents{toc}{\protect\headline} ... \begin{document} ... {\toctrue\tableofcontents}
When I delete \toctrue, the heading appears on the first page of TOC only, not on the rest of TOC pages!
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
Adding a heading to the table of contents
Are you sure that you did not omit the braces? They are required, they keep the change local. Eithernadaa wrote:Thanks, I tried it, but the same.
{\toctrue\tableofcontents}
or
\toctrue
\tableofcontents
\tocfalse
should work.
Stefan
LaTeX.org admin
Adding a heading to the table of contents
Yes, it works. I forgot the brackets.Stefan Kottwitz wrote:Are you sure that you did not omit the braces? They are required, they keep the change local. Eithernadaa wrote:Thanks, I tried it, but the same.
{\toctrue\tableofcontents}
or
\toctrue
\tableofcontents
\tocfalse
should work.
Stefan
Thank you

How I can learn all these stuff. I have been using Latex for a while, but I can't solve problems without asking!. Any suggestion?.
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
Adding a heading to the table of contents
Knowing all stuff is not so important. A key is, to know where to look for (documentation), work with source code of packages, just try fixing things. There are good ways to know, such as why and how to build a
minimal working example - once one understood that, he easily tracks down problems and either fixes them himself with the hacked-down code piece, or post the small code sample to a LaTeX forum such as here. Once a problem can be reproduced and tested, it's usually easy to fix for very experienced people, even without knowing details before.
Experience comes over time. You can simply ask about any LaTeX problem here, that's the purpose of the forum. Once we talked about it and posted a fix, other people have a good chance to find it via google. So, asking questions helps other people too. Reading answers then also adds knowledge over time. Often solutions are quick hacks that show how to manually fix things.
Stefan

Experience comes over time. You can simply ask about any LaTeX problem here, that's the purpose of the forum. Once we talked about it and posted a fix, other people have a good chance to find it via google. So, asking questions helps other people too. Reading answers then also adds knowledge over time. Often solutions are quick hacks that show how to manually fix things.

Stefan
LaTeX.org admin