2

I'm an amateur user of LaTeX and I'm writing my PhD thesis using a template that I found in: PhDtemplateLATEX

Looking inside Classes/CUEDthesisPSnPDF.cls, I found that it uses fancyhdr for the customization of headers and footers. Specifically:

\pagestyle{fancy} 
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter. #1 }}{}}    
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}   
\fancyhf{}    
\fancyhead[RO]{\bfseries\rightmark}    
\fancyhead[LE]{\bfseries\leftmark}    
\fancyfoot[C]{\thepage}    
\renewcommand{\headrulewidth}{0.5pt}    
\renewcommand{\footrulewidth}{0pt}    
\addtolength{\headheight}{0.5pt}    
\fancypagestyle{plain}{    
  \fancyhead{}    
  \renewcommand{\headrulewidth}{0pt}    
}

I have changed it, because I wanted the headers and footers with "small caps" style and "scriptsize" size.

The problem appears in the header of the frontmatter (the footer is ok), I mean: the table of contents, the list of figures and the list of tables. In this case, the header appears with bolded capitals, and I would want the same format of the rest of the document.

I've tried to change it introducing the "markboth" command in the following way:

\frontmatter    
\setcounter{secnumdepth}{3} % organisational level that receives a numbers    
\setcounter{tocdepth}{3}    % print table of contents for level 3    

\tableofcontents            % print the table of contents    
\markboth{\sc {\scriptsize \contentsname}}{\sc {\scriptsize \contentsname}}    

\listoffigures  % print list of figures    
\markboth{\sc {\scriptsize \listfigurename}}{\sc {\scriptsize \listfigurename}}

\listoftables  % print list of tables    
\markboth{\sc {\scriptsize \listtablename}}{\sc {\scriptsize \listtablename}}

... and it works, if the list has two pages. If the list has more than two pages, the last two pages have the desired format, but the rest of pages have the original format. For example, if the table of contents has six pages, the first page has no header (that's ok), pages 2-4 have the original format, and pages 5-6 have the desired format. This occurs with the table of contents and the list of figures (with the list of tables I haven't problems yet, because, for now, it has only two pages).

So... what can I do?

I will appreciate any help. Thanks.

--------------------------------------EDIT----------------------------------------

Ok, I've tried the suggestion of @Johannes_B and my document has improved, but the problem is not completely solved.

Specifically, I've modified (using package etoolbox):

\frontmatter
\patchcmd{\tableofcontents}{%
  {\MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
}{
{\scriptsize {\sc \contentsname}}{\scriptsize {\sc \contentsname}}%
}
{}{}

\patchcmd{\listoffigures}{%
  {\MakeUppercase\listfigurename}{\MakeUppercase\listfigurename}%
}{
{\scriptsize {\sc \listfigurename}}{\scriptsize {\sc \listfigurename}}%
}
{}{}

\patchcmd{\listoftables}{%
  {\MakeUppercase\listtablename}{\MakeUppercase\listtablename}%
}{
{\scriptsize {\sc \listtablename}}{\scriptsize {\sc \listtablename}}%
}
{}{}

\setcounter{secnumdepth}{3} % organisational level that receives a numbers
\setcounter{tocdepth}{3}    % print table of contents for level 3

\tableofcontents
\listoffigures
\listoftables

In the case of the table of contents, the header appears exactly as I want it: In scriptsize and small caps, so this is a great improvement. But, in the case of the list of figures and the list of tables, I have no changes: The headers are still in normal size and bolded capitals.

Any suggestions? Thanks.

Johannes_B
  • 24,235
  • 10
  • 93
  • 248
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Oct 07 '14 at 13:20
  • Possibly related: \addtocontents at end of document not getting written to .toc file? -- that was when I was trying to get various page styles attached to front matter lists. – Mike Renfro Oct 07 '14 at 13:23
  • Christian, I don't know how to do what you are asking for, sorry. I mean, I don't know how to gather all the information distributed in the main file.tex and the class file. But, in the link of the template, there is a compilable example (with chapters and so on), that could be helpful. – Red Langosta Oct 07 '14 at 14:06
  • Mike, I will read carefully your link, but I need some time to understand it. Thank you anyway. – Red Langosta Oct 07 '14 at 14:09
  • Does this help? http://tex.stackexchange.com/questions/185310/how-do-i-format-the-header-text-of-the-table-of-contents – musarithmia Oct 07 '14 at 15:49
  • I've tried the solution posted in Andrew’s link. My document looks better now, but the problem it is not completely solved. I've added before the frontmatter: \let\oldmarkboth\markboth \newcommand\scsriptmarkboth[2]{% \oldmarkboth{\sc {\scriptsize {#1}}}{\sc {\scriptsize {#2}}}% } \let\markboth\scsriptmarkboth And added \let\markboth\oldmarkboth after the frontmatter. Now the headers are in scriptsize and are not bolded, so this has improved. But the letters remain capitalized. I would like a header that shows “Contents” (with small caps) and not “CONTENTS”. \MakeLowercase doesn’t work. – Red Langosta Oct 08 '14 at 14:29
  • I just stumbled over this question. The site you are lining states that the template is superseeded by another one. Which one are you using? – Johannes_B Oct 15 '14 at 17:01
  • I looked at both templates, and by a first glance, the newer is better (by far). – Johannes_B Oct 15 '14 at 17:14
  • I'm using "the old style" template. I got the template by a coworker, and I didn't know that there was an improved version. At this point, I've modified so much the original template, so it would be ardous to make the same modifications to the new version. – Red Langosta Oct 16 '14 at 11:58
  • Nearly the same was done by me in Text color of toc and bibliography in the page header,. Please have a look, you should be able to adapt this to your own code quite easily. The keyword is patchcmd. – Johannes_B Oct 27 '14 at 18:35
  • Thank you for your help, Johannes_B. I've done what you explain in the link. Speciffically: \patchcmd{\tableofcontents}{% {\MakeUppercase\contentsname}{\MakeUppercase\contentsname}% }{ {\scriptsize {\sc \contentsname}}{\scriptsize {\sc \contentsname}}% } {}{} And it works! ... but only for the table of contents. If I repeat the same with \listoffigures and \listoftables it doesn't work. But, with every step, we are getting closer to the solution. – Red Langosta Oct 28 '14 at 14:48
  • Hint: you can make someone aware by putting a @-sign in front. @redlangosta. Please add (by editing) the above information to the question, this way it gets pushed to the top of the main page and it gets the attention of the helpers – Johannes_B Nov 01 '14 at 11:34
  • did you replace the instances of contentsname with the according listfigurename etc? – Johannes_B Nov 01 '14 at 11:37
  • @Johannes_B, thank you for the @ point, I'm new here and I didn't know it. Excuse me but, what is the question you want me to edit? and what information do I have to add? (Sorry, but I didn't undertand you). And yes, I've replaced the contentsname by lisfigurename and listtablename and it doesn't work. Speciffically: \patchcmd{\listoffigures}{% {\MakeUppercase\listfigurename}{\MakeUppercase\listfigurename}% }{ {\scriptsize {\sc \listfigurename}}{\scriptsize {\sc \listfigurename}}% } {}{} I don't know what to do. – Red Langosta Nov 02 '14 at 13:35
  • As you may notice, code highlighting is a pain in comments. It would be better if you edit the information you gave in the comments right into your initial question (on the top of this page). Scrolling down you see your user name, on the left is the button to edit. – Johannes_B Nov 02 '14 at 13:37
  • Please also read the very first comment by @christian again. – Johannes_B Nov 02 '14 at 13:43
  • @Johannes_B , I didn't know if it was ok to edit the question, modifying what I wrote at the beginning. I noticed that writing code in the comments was horrible, but I didn't know how to do it better. I've edited it as you suggest. Thanks. – Red Langosta Nov 02 '14 at 19:43

2 Answers2

2

After a bit of Sherlock Holmes deduction power the whole thing comes down a a very basic example and a very straight forward solution. The template file uses package tocbibind to print the \listofs and bibliography to the table of contents. tocbibind provides a hook that we can redefine without patching any stuff.

I defined a new macro to define the appearance called \listheaderfont. It is red now just to demonstrate. This has a huge advantage, all instances use this macro, so changing this changes the document in a more consistent way.

\documentclass{book}
\usepackage{tocbibind}
\usepackage{xcolor}
%defining the apperance of the listheaders
\newcommand{\listheaderfont}{\scriptsize\normalfont\scshape\color{red}}
\renewcommand{\tocetcmark}[1]{
\markboth{\listheaderfont #1}{\listheaderfont #1}}
\usepackage{pgffor}
\begin{document}

\tableofcontents
\listoffigures
\listoftables

\begin{table}\foreach \n in {1,...,70} {\caption{}}
\end{table}
\begin{figure}\foreach \n in {1,...,70} {\caption{}}
\end{figure}

\nocite{aristotle:physics}
\bibliographystyle{plain}
\bibliography{biblatex-examples}
\clearpage Look at the header
\end{document}

We can do this for the standard classes as well, again using a helper macro. This time, no handy package provides a hook we can use. We have to patch the stuff by hand.

\documentclass{book}
%defining the apperance of the listheaders
\newcommand{\listheaderfont}{\scriptsize\normalfont\scshape\color{red}}

\usepackage{etoolbox}
\usepackage{xcolor}
\patchcmd{\tableofcontents}{%
    {\MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
}{
    {\listheaderfont \contentsname}{\listheaderfont \contentsname}%
}
{}{}

\patchcmd{\listoffigures}{%
    {\MakeUppercase\listfigurename}{\MakeUppercase\listfigurename}%
}{
    {\listheaderfont \listfigurename}{\listheaderfont \listfigurename}%
}
{}{}

\patchcmd{\listoftables}{%
    {\MakeUppercase\listtablename}{\MakeUppercase\listtablename}%
}{
    {\listheaderfont \listtablename}{\listheaderfont \listtablename}%
}
{}{}
\usepackage{pgffor}
\begin{document}

\tableofcontents
\listoffigures
\listoftables

\begin{table}\foreach \n in {1,...,70} {\caption{}}
\end{table}
\begin{figure}\foreach \n in {1,...,70} {\caption{}}
\end{figure}


\end{document}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
  • I'm so sorry, but I'm stupid. The class I provided is not exactly the same class I'm using, but a modified version (I haven't realized till now). The class that I'm actually using is: <http://openwetware.org/wiki/LaTeX_template_for_PhD_thesis. If I use your MWE with Classes/CUEDthesisPSnPDF.cls it works, but If I use your MWE with Latex/Classes/PhDthesisPSnPDF.cls (the class that I'm using) it doesn't work: the header of table of contents is ok, but the header of list of figures and tables are in normal size and bolded capitals. Sorry again and thanks for your patience. – Red Langosta Nov 04 '14 at 11:29
  • I've modified the information of the question with the real template. – Red Langosta Nov 04 '14 at 11:35
  • Please see the updated answer. – Johannes_B Nov 04 '14 at 14:38
  • Ok, using the first solution of your answer (the one that uses tocbibind), the headers of list of figures and tables are correctly modified, but the header of the table of contents has no changes; The second solution (the one that uses etoolbox) modifies the header of the table of contents, but it doesn't change the header of the list of figures/talbes. So, I've combined both solutions: I've used the first solution, adding etoolbox package and the patchmd code related to the table of contents... And the problem is solved! All the headers looks as I want. Thank you very very much. – Red Langosta Nov 04 '14 at 18:46
  • Please compile the first example as it is, is the header of the toc red as well? The template uses the option notoc to not print the toc to the toc (which is a good idea) and hence doens't take control over it. I didn't test this case, sorry. I think, the package should take over. – Johannes_B Nov 05 '14 at 15:51
  • yes, if I compile the first example, all the headers are correctly changed (and all are in red). But, in my document .tex, if I make the modifications of the first example, only the headers of the list of figures and tables are changed. But, as I told you, if I combine both examples, the problem is solved. – Red Langosta Nov 07 '14 at 10:15
2

A simple solution not involving any additional packages is the following: Simply redefine \contentsname or \listtablename so that it contains a \lowercase command.

To get the standard names while preserving lowercase headers, use the following definitions:

\renewcommand\contentsname{C\lowercase{ontents}}
\renewcommand\listtablename{L\lowercase{ist of} T\lowercase{ables}}

When passed to the small-caps command, the lowercase characters will be respected.

Ariel
  • 1,002