2

I need my chapter names displayed as uppercase in my TOC. I am quite new to Latex and I am not comfortable using patches or macros as explained in this solution Uppercase sections and subsections on ToC and this solution Upper case chapter titles Tocstyle?.

Therefore, I would like to ask if there is a simpler way to make chapter titles uppercase in the TOC, maybe using the tocloft package?

I have also picked up that the hyperref package causes some problems. Please note that I do use this package in my main document and I have also loaded it in my very simple MWE (although not used it specifically).

The MWE:

\documentclass[a4paper,11pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc} %help make sfdefault arial
\usepackage{hyperref}
\usepackage[auto]{chappg} %want to have page numbering per section this also works on equation numbering
\pagenumbering{bychapter}
\usepackage[titles]{tocloft}

\begin{document}

\tableofcontents \addtocontents{toc}

\chapter{First chapter} \section{first section}

\clearpage

\chapter{Second chapter}

\end{document}

enter image description here

Edit: After trying the solution by @fran, I realized my initial question was incomplete. I also need to make the references and the appendix headings uppercase in the TOC. It seems like the reverse was achieved here with Printing the bibliography heading in uppercase but showing it as sentence case in the ToC but my document gives an error for the apacite environment. I have included an updated MWE below:

\documentclass[a4paper,11pt,oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc} %help make sfdefault arial
\usepackage{hyperref}
\usepackage[auto]{chappg} %want to have page numbering per section this also works on equation numbering
\pagenumbering{bychapter}
\usepackage[titles]{tocloft}
\usepackage[titletoc]{appendix} %want to display "appendix" before A,B,C etc. Use [title]

\usepackage[maxcitenames=2, maxbibnames=99, backend=biber, citestyle=authoryear, bibstyle=authoryear, sorting=nyt, %sort by name title year natbib=true, giveninits=true, hyperref ]{biblatex} % CustomBib

\begin{filecontents}{\jobname.bib} @book{2000_adams_prob, title={Urban stormwater management planning with analytical probabilistic models}, author={Adams, Barry J}, year={2000}, publisher={John Wiley and Sons, Inc., New York, NY (US)} } \end{filecontents}

\addbibresource{\jobname.bib}

\begin{document} \pagenumbering{roman} \tableofcontents \newpage \pagenumbering{bychapter}

\chapter[CHAPS CHAPTER 2]{First chapter} \section{first section}

\clearpage

\chapter[CHAPS CHAPTER 2]{Second chapter} blabla bla \citep{2000_adams_prob}

\cleardoublepage \printbibliography[heading=bibnumbered, title={References}]

\newpage \begin{appendices} \addtocontents{toc}{\cftpagenumbersoff{chapter}} %don't want to show the appendix page number in the Toc \chapter[CHAPS FIRST APPENDIX]{First appendix}

\end{appendices}

\end{document}

enter image description here

JamesT
  • 3,169
Karien
  • 75
  • 6
  • Hopefully tocloft will soon be updated to cater for this. – Peter Wilson May 17 '20 at 16:44
  • \chapter[TRY THIS]{Try this} – Fran May 18 '20 at 06:30
  • Thanks @Fran , Giving it a go - I see that I will need to have another work around for the References and the Appendixes (will update my MWE to include a Appendix and a Referance), I will give it another day or two to see if there are some other ingenious answers, otherwise I might read -up on patching a bit. – Karien May 18 '20 at 08:53

1 Answers1

2

Like this?

mwe

\documentclass[oneside]{book}
 % small page, just for the screenshot
\usepackage[paperwidth=12cm,paperheight=9cm,margin=1cm,tmargin=-2cm]{geometry}

\usepackage{lipsum}
\usepackage[colorlinks]{hyperref}
\usepackage[auto]{chappg} %want to have page numbering per section this also works on equation numbering
\usepackage[titletoc]{appendix} %want to display "appendix" before A,B,C etc. Use [title]
\renewcommand\appendixtocname{APPENDICES}
\usepackage[style=authoryear, natbib=true ]{biblatex} 

\begin{filecontents}{\jobname.bib}
@book{2000adams,
  title={Urban stormwater management planning with analytical probabilistic models},
  author={Adams, Barry J},
  year={2000},
  publisher={John Wiley and Sons, Inc., New York, NY (US)}}
\end{filecontents}
\addbibresource{\jobname.bib}
\def\mychapter#1{\chapter[\MakeUppercase{#1}]{#1}}
\pdfstringdefDisableCommands{\let\MakeUppercase\relax}
\defbibheading{xxx}[References]{\chapter*{References}
\addcontentsline{toc}{chapter}{REFERENCES}
\markboth{REFERENCES (twoside header)}{REFERENCES (oneside header)}}
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\mychapter{First chapter}
\section{first section}\lipsum[1][1-2]
\mychapter{Second chapter}\lipsum[2][1-2] \citep{2000adams}. \lipsum[3][1] 
\printbibliography[heading=xxx]
% \newpage More bib ....\newpage Even more bib ... % just to test headers 
\appendix\addappheadtotoc
\mychapter{First appendix} \lipsum[3][1-5]
\end{document}
Fran
  • 80,769
  • Thanks for the reply an all the trouble @Fran ,Seems like I will need a bit of coding after all. So, basically you propose a new chapter style \mychapter, that change entries in the ToC to uppercase without affecting the document style, for the references we will use the \defbibheading command to force the chapter style. Last question, I need the word “Appendix” before my Appendix number, that is why I have specified the \begin{appendices} , \end{appendices} environment with \usepackage[titletoc]{appendix} , any idea how to capitalize the word “Appendix” in the ToC as well – Karien May 19 '20 at 11:20