LaTeX forum ⇒ GeneralPage Headers in TOC, LOF, LOT

LaTeX specific issues not fitting into one of the other forums of this category.
tennesseepaul
Posts: 7
Joined: Fri Apr 10, 2009 12:16 am

Page Headers in TOC, LOF, LOT

Postby tennesseepaul » Sat Apr 11, 2009 2:19 am

Hello. This might be a lot to ask in one post but here it goes...

How does one generate a TOC which contains the word "CHAPTER" without a page number just before the list of chapters. Example:
ACKNOWLEDGEMENT . . . . . . . . . . . . . . . . . . iii
LIST OF TABLES. . . . . . . . . . . . . . . . . . . vii
LIST OF FIGURES . . . . . . . . . . . . . . . . . . ix
CHAPTER
1. INTRODUCTION. . . . . . . . . . . . . . . . . . 1

And from here the TOC goes to the second page which needs a header with the word "CHAPTER" left justified and "Page" right justified.

Similarly, the LOF and LOT needs headers (FIGURE and Page, TABLE and Page) on the second and following pages while long figure or table titles have hangning indents if more than one line.

I am using a modified class file based on the Report class. All I've found to date is "\addcontentsline{toc}{xchapter}{CHAPTER}" but this doesn't build the headers on the next page and it generates a page number after the "CHAPTER" word.

Any help would be greatly appreciated.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9232
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Apr 11, 2009 2:40 am

Hi,

concerning headers have a look at the fancyhdr package and its documentation.
Instead of \addcontentsline you could use \addtocontents.

Stefan
Site admin

tennesseepaul
Posts: 7
Joined: Fri Apr 10, 2009 12:16 am

Postby tennesseepaul » Sat Apr 11, 2009 3:11 am

Stefan,

Thank you. I will read through the Fancy Header documentation.

I've tried the \addtocontents{toc}{CHAPTER} option but I receive errors. Where would this line be added?
  1. \tableofcontents
  2. \listoftables
  3. \listoffigures
  4. \addtocontents{toc}{CHAPTER}
  5. \newpage
  6. \clearpage
  7. \pagenumbering{arabic}
  8.  
  9. \include{Introduction}


Returns:

  1. main.tex(5): Error: ! LaTeX Error: Something's wrong--perhaps a missing \item.
  2. main.tex(5): Error: ! LaTeX Error: Something's wrong--perhaps a missing \item.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9232
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Apr 11, 2009 3:35 am

Inserting a protected paragraph break should fix it:
  1. \addtocontents{toc}{CHAPTER\protect\par}

Stefan
Site admin

tennesseepaul
Posts: 7
Joined: Fri Apr 10, 2009 12:16 am

Postby tennesseepaul » Sat Apr 11, 2009 8:15 pm

Thank you. That got it in there. But now it is indented. Is there a command which removes the indentation?

Thank you for all your help.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9232
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Sat Apr 11, 2009 8:20 pm

Here's no indentation:
  1. \documentclass[a4paper,10pt]{report}
  2. \begin{document}
  3. \tableofcontents
  4. \addtocontents{toc}{CHAPTER\protect\par}
  5. \chapter{Test}
  6. \section{Section}
  7. \end{document}

How's your code?

Stefan
Site admin

tennesseepaul
Posts: 7
Joined: Fri Apr 10, 2009 12:16 am

Postby tennesseepaul » Sat Apr 11, 2009 8:46 pm

Thank you. I actually ended up using
  1. \addtocontents{toc}{\noindent CHAPTER\protect\par}


This has been very helpful.

Do you know how to make the real long entries in LOF and LOT single space and hanging indent when they wrap to next line?

My LOF Code from my class file. I can't seem to get it. I'm so new at all of this I'm probably doing it all wrong to begin with:

  1. %% ----------------------------
  2. %% LIST OF FIGURES (LOF)
  3. %% ----------------------------
  4. \def\listoffigures{ %
  5. \chapter*{\listfigurename} %
  6. \vspace{-\baselineskip} %
  7. \vspace{-0.27in} %
  8. FIGURE\nobreak\hfill{Page}\par %
  9.  
  10. \begin{singlespace} % I added this line
  11. \hangindent=1.5em % this one
  12. \hangafter=1 % and this one
  13. \addcontentsline{toc}{xchapter}{\listfigurename} %
  14. \end{singlespace} % and then closed it with this.
  15. % but it did nothing.
  16. \@starttoc{lof}} %
  17.  
  18. \def\l@figure{\@dottedtocline{0}{1em}{1.6em}} %
  19.  
  20. \def\l@figure#1#2{ %
  21. {\leftskip 1em\relax \rightskip \@tocrmarg \parfillskip -\rightskip
  22. \parindent 1em\relax\@afterindenttrue %
  23. \interlinepenalty\@M %
  24. \leavevmode %
  25. \@tempdima 1.6em\relax %
  26. \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
  27. {#1}\nobreak %
  28. \leaders\hbox{$\m@th \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}%
  29. \hfill\nobreak %
  30. \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #2}%
  31. \par}}

tennesseepaul
Posts: 7
Joined: Fri Apr 10, 2009 12:16 am

Postby tennesseepaul » Sat Apr 11, 2009 10:02 pm

Wow. Just got it using this:
  1. %% ----------------------------
  2. %% LIST OF FIGURES (LOF)
  3. %% ----------------------------
  4. %
  5. \def\listoffigures{ %
  6. \chapter*{\listfigurename} %
  7. \vspace{-\baselineskip}
  8. \vspace{-0.27in} %% adjustment
  9. FIGURE\nobreak\hfill{Page}\par %
  10.  
  11. \addcontentsline{toc}{xchapter}{\listfigurename} %
  12.  
  13. \@starttoc{lof}}
  14.  
  15. \def\l@figure{\@dottedtocline{0}{1em}{1.6em}} %%%%%%%%%%%%%%% ADJUSTABLE! %%%%%%%%%%%%%%%%%
  16.  
  17.  
  18. \def\l@figure#1#2
  19. {
  20. \begin{singlespace}
  21. \hangindent=1.5em
  22. \hangafter=1
  23. {
  24. \leftskip 1em\relax \rightskip \@tocrmarg \parfillskip -\rightskip
  25. \parindent 1em\relax\@afterindenttrue
  26. \interlinepenalty\@M
  27. \leavevmode
  28. \@tempdima 1.6em\relax
  29. \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
  30. {#1}\nobreak
  31. \leaders\hbox{$\m@th \mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}%
  32. \hfill\nobreak
  33. \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #2}%
  34. \par
  35. }
  36. \end{singlespace}
  37. }


Return to “General”

Who is online

Users browsing this forum: No registered users and 11 guests