GeneralWriting Author's Name in the TableofContents

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
tacio
Posts: 2
Joined: Fri Apr 18, 2008 11:50 pm

Writing Author's Name in the TableofContents

Post by tacio »

Please, Anybody knows how to Write the Author's Name in the TableofContents?

I was trying to do something like that is showed bellow...

\def\@chapter[#1]#2{%
\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}
\typeout{\@chapapp\space\thechapter.} %
\addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
%%% \addcontentsline{toc}{chapter}{\@author} (the author's name enter here, would be something like that?)
\else

\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10pt}}%
\addtocontents{lot}{\protect\addvspace{10pt}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}\@afterheading
\fi

Thanks in advance!

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Writing Author's Name in the TableofContents

Post by Stefan Kottwitz »

Hi tacio,

welcome to the LaTeX Community board!
Why not this way or similar. Try this example:

Code: Select all

\documentclass[a4paper,10pt]{report}
\title{Test}
\author{Anonymous}
\begin{document}
\makeatletter
\addtocontents{toc}{\protect\contentsline{chapter}{\@author}{}}
\makeatother
\maketitle
\tableofcontents
\chapter{Test}
\section{Section}
\end{document}
Stefan
tacio
Posts: 2
Joined: Fri Apr 18, 2008 11:50 pm

Re: Writing Author's Name in the TableofContents

Post by tacio »

It worked, thanks a lot!
Post Reply