Text FormattingError message from "\addcontentsline" command

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
insinoori
Posts: 3
Joined: Sun Nov 06, 2011 8:17 pm

Error message from "\addcontentsline" command

Post by insinoori »

My code,

Code: Select all

\documentclass[12pt,a4paper]{article}
\usepackage[ascii]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}

\title{Literature Review}
\author{Riku Raisanen}
\maketitle

\newpage
\tableofcontents
\newpage

\part*{Introduction}
\addcontentsline{toc}{part*}{Introduction}
text

\part{1}
text

\end{document}
is giving me the error message,
"Something's wrong--perhaps a missing \item. \contentsline {part}{I\hspace {1em}1}{3}"
for line 2 when I LaTex it more than once. I'm guessing it's a conflict between the ToC and the "\addcontentsline" command.
Thanks
Last edited by insinoori on Sun Nov 06, 2011 9:52 pm, edited 2 times 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.

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

Error message from "\addcontentsline" command

Post by Stefan Kottwitz »

Use part instead of part* with \addcontentsline:

Code: Select all

\addcontentsline{toc}{part}{Introduction}
Stefan
LaTeX.org admin
insinoori
Posts: 3
Joined: Sun Nov 06, 2011 8:17 pm

Re: Error message from "\addcontentsline" command

Post by insinoori »

I would like to keep the "Introduction" heading without a number.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Error message from "\addcontentsline" command

Post by localghost »

insinoori wrote:I would like to keep the "Introduction" heading without a number.
I don't think that you tested Stefan's proposal. Otherwise you wouldn't say this. It works as desired.
insinoori
Posts: 3
Joined: Sun Nov 06, 2011 8:17 pm

Re: Error message from "\addcontentsline" command

Post by insinoori »

You're right, sorry, it does work. Thank you very much.
Post Reply