General\addtocontents and \contentsline issue

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
saimike
Posts: 20
Joined: Wed Apr 11, 2012 10:44 pm

\addtocontents and \contentsline issue

Post by saimike »

I'm trying to add the word "APPENDICES" between my Bibliography and Appendices, but without a page number.

When I try to use this:

Code: Select all

\addtocontents{toc}{\contentsline{chapter}{APPENDICES}{}}
I get a lot of errors. What am I doing wrong here?
Last edited by Stefan Kottwitz on Mon Apr 30, 2012 11:19 pm, edited 1 time in total.

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

\addtocontents and \contentsline issue

Post by Stefan Kottwitz »

Hi,

that code line is correct, with standard classes and no interfering packages.
saimike wrote:I get a lot of errors. What am I doing wrong here?
Perhaps tell us at least the first error message.

Stefan
LaTeX.org admin
saimike
Posts: 20
Joined: Wed Apr 11, 2012 10:44 pm

\addtocontents and \contentsline issue

Post by saimike »

Stefan,

I have 98 errors, so here are the first few. The log file is 70kb, pretty big to attach I'd imagine.
! Missing \endcsname inserted.
<to be read again>
\noindent
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Argument of \@secondoftwo has an extra }.
<inserted text>
\par
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
! Paragraph ended before \@secondoftwo was complete.
<to be read again>
\par
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

! Argument of \@newcommand has an extra }.
<inserted text>
\par
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
\fi \hangafter \def \noindent
! Paragraph ended before \@newcommand was complete.
<to be read again>
\par
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

! Argument of \@xargdef has an extra }.
<inserted text>
\par
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
0]\hangafter \def \noindent
! Paragraph ended before \@xargdef was complete.
<to be read again>
\par
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

! Missing \endcsname inserted.
<to be read again>
\noindent
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

The control sequence marked <to be read again> should
not appear between \csname and \endcsname.

! Argument of \@secondoftwo has an extra }.
<inserted text>
\par
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.

Runaway argument?
! Paragraph ended before \@secondoftwo was complete.
<to be read again>
\par
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.

! Illegal parameter number in definition of \reserved@a.
<to be read again>
\hangafter
l.62 ...toc}{\contentsline{chapter}{APPENDICES}{}}

You meant to type ## instead of #, right?
Or maybe a } was forgotten somewhere earlier, and things
are all screwed up? I'm going to assume that you meant ##.
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

\addtocontents and \contentsline issue

Post by Juanjo »

I think you just want something like

Code: Select all

\addcontentsline{toc}{chapter}{APPENDICES}
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Post Reply