Page LayoutCustom Entry in ToC

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Custom Entry in ToC

Post by LavaTyper »

Greetings,

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?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Re: Custom Entry in ToC

Post by LavaTyper »

GREETINGS AGAIN!
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?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10330
Joined: Mon Mar 10, 2008 9:44 pm

Custom Entry in ToC

Post by Stefan Kottwitz »

You could use \addtocontents or \addcontentsline.

Stefan
LaTeX.org admin
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Re: Custom Entry in ToC

Post by LavaTyper »

Well, can you show me how?
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Re: Custom Entry in ToC

Post by LavaTyper »

[2 weeks later]


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?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Custom Entry in ToC

Post by localghost »

LavaTyper wrote:[…] How do I use either of the \addcontents to change the page number to "TEXT" in the 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.


Thorsten
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Re: Custom Entry in ToC

Post by LavaTyper »

I did that, and I didn't see anything in any of the comprehensive documentation that said how to replace the actual page number with "TEXT."
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Re: Custom Entry in ToC

Post by LavaTyper »

Guys I need help on this soon. I am trying to write my dissertation and I NEED to have this done in order to get my degree. Can't you guys write some example code?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Custom Entry in ToC

Post by Johannes_B »

If you are stuck doing something, ask for help by providing a minimal working example!

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
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Custom Entry in ToC

Post by LavaTyper »

I can't do that because I have no idea how to get it to work. I already went down the road twice and it lead to a dead end.

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}
Post Reply