Page Layout ⇒ Custom Entry in ToC
Custom Entry in ToC
I would like to enter a custom entry to the ToC of my document, with "TEXT" instead of the page number.
I need to have a special entry in my ToC, where the last appendix is actually added. I need to have the special entry in my ToC even though there is no actual extra appendix in the text. And at the end of the row of dots instead of a page number, I need to have the string "TEXT" at the end. How do I do that?
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Re: Custom Entry in ToC
I have not yet received a response to my inquiry about how to modify the page number of an entry in the table of contents.
How do I change the page number for a forced Appendix entry in the table of contents?
- Stefan Kottwitz
- Site Admin
- Posts: 10330
- Joined: Mon Mar 10, 2008 9:44 pm
Re: Custom Entry in ToC
Re: Custom Entry in ToC
I still don't have an answer.
How do I use either of the \addcontents to change the page number to "TEXT" in the toc?
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Custom Entry in ToC
Just click on the commands in Stefan's reply and you will get a synopsis of their usage. Furthermore every good LaTeX introduction should explain them.LavaTyper wrote:[…] How do I use either of the \addcontents to change the page number to "TEXT" in the toc?
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Custom Entry in ToC
Re: Custom Entry in ToC
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Custom Entry in ToC
Stefan already pushed you down a road, you never told us whats holding you back. But to help you we need more information (MWE).
Best regards
Johannes
Custom Entry in ToC
So, how do I modify this script?
Code: Select all
\documentclass[12pt]{book}
\usepackage[dotinlabels]{titletoc}
\usepackage[indentafter,newlinetospace]{titlesec}
\usepackage{ifthen}
\renewcommand{\contentsname}{TABLE OF CONTENTS}
\renewcommand{\listtablename}{LIST OF TABLES}
\renewcommand{\appendixname}{Appendix}
% Format the Chapter in the TOC
\titlecontents{chapter}[0in]{\ifthenelse{\equal{\thecontentslabel}{1}}{
\vspace{1.3\baselineskip}Chapter\\ \normalsize}{
\normalsize\vspace{.2\baselineskip}}}
{\contentspush{\thecontentslabel.~}}
{}
{\titlerule*[.3em]{.}\thecontentspage}
{}
\titlecontents{section}[.3in]{}
{\contentspush{\thecontentslabel.~}}{}
{\titlerule*[.3em]{.}\thecontentspage}{}
% Format the Appendix in the TOC
\renewcommand{\appendixname}{Appendix}
\let\oldAppendix\appendix
\renewcommand{\appendix}{
\oldAppendix
\addtocontents{toc}{\protect \setcounter{tocdepth}{0} \par}
\titlecontents{chapter}[0in]{\normalsize\vspace{.2\baselineskip}}
{\contentspush{Appendix~\thecontentslabel.~}}{}
{\titlerule*[.3em]{.}\thecontentspage}{}
}
\linespread{2}
\title{An example with TEXT for a Page Number}
\author{Lava Typer}
\begin{document}
\maketitle
\tableofcontents
\listoftables
\chapter{First Chapter}
\section{First Section}
Here is a table. I have many tables in my project.
\begin{table}[h]
\caption{\label{table:mycaption}Caption goes here}
\begin{tabular}{lcr}
left & center & right \\
\end{tabular}
\end{table}
\section{Second Section of new chapter}
Content
\appendix
\chapter{First Appendix}
\section{Greetings}
I have multiple appendices...
\chapter{Second Appendix}
Here is another appendix.
\section{What I need from LaTeX-Community}
\textbf{After Appendix B in the actual Table of Contents page listing... \\
I need ``Appendix C," dots, and a string of text (say, ``TEXT") instead of a page number.}
But I want the document to end at Appendix B...and not actually have a physical ``Appendix C" in the \LaTeX file.
How do I do that?
\end{document}