TransWikia.com

add an item in table of contents with no page number and hyperlink

TeX - LaTeX Asked on March 31, 2021

I wanted to add a separate line saying "CHAPTER" in toc, but I don’t want it to have a page number and to link anywhere. My current code is:

documentclass[12pt]{report}

usepackage[titles]{tocloft}
usepackage{hyperref}

begin{document}

tableofcontents

cftaddtitleline{toc}{chapter}{CHAPTERS}{}

chapter{Some chapter}
section{Some section 1}

chapter{Some chapter 2}
section{Some section 2}

end{document}

In this way, there is no page number, but "CHAPTERS" is still clickable. How could I remove the hyperlink?

One Answer

Use addtocontents instead of cftaddtitleline.

% titlelineprob.tex  SE 564030
documentclass[12pt]{report}

usepackage[titles]{tocloft}
usepackage{hyperref}

begin{document}

tableofcontents

%cftaddtitleline{toc}{chapter}{CHAPTERS}{}
addtocontents{toc}{textbf{CHAPTERS}par}

chapter{Some chapter}
section{Some section 1}

chapter{Some chapter 2}
section{Some section 2}

end{document}

Correct answer by Peter Wilson on March 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP