1

I'm having trouble apparently with the \addcontentsline command:

! Argument of \addcontentsline has an extra }.
<inserted text>
\par
l.157 \addcontentsline
{toc}{section}{Introduction}

Here's the code that fails:

\section*{Introduction}
\markboth{Introduction}{Introduction}
\addcontentsline{toc}{section}{Introduction}
\vspace*{-2.4mm}

I'm using an article class document:

\documentclass[a4paper,12pt,twoside]{article}

What's wrong with this command? Does it need an extra package? I am using TeXmaker on Ubuntu 16.04, compiling the document with PDFLaTeX.

I'm using hyperref like this:

\usepackage[
 unicode=true,
 bookmarks=true,
 bookmarksnumbered=true,
 bookmarksopen=true,
 bookmarksopenlevel=1,
 breaklinks=false,
 pdfborder={0 0 1},
 backref=false,
 colorlinks=false
 ]
 {hyperref}

And the \addcontentsline is not refined.
Here is a MWE: http://pastebin.com/raw/nnqXJkHh

MWE

\documentclass[a4paper,12pt,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage[frenchb]{babel}
\addto\extrasfrench{
\providecommand{\og}{\leavevmode\flqq~}\providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}
}

\usepackage[showframe=false,headheight=-1mm, top=2cm, bottom=2.4cm, left=2.4cm, right=2cm, footskip=20pt]{geometry}

\setlength\parindent{0pt}

\usepackage{lmodern}
\usepackage{atbegshi}


\usepackage[absolute,overlay]{textpos}
  \setlength{\TPHorizModule}{1mm}
  \setlength{\TPVertModule}{1mm}


\widowpenalty=9999
\clubpenalty=9996

\usepackage{aeguill}
\usepackage{eurosym}
\usepackage{gensymb}

\usepackage{caption}
\captionsetup{justification=centering}
\usepackage{subcaption}

\usepackage{multicol}
\usepackage{vwcol}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{natbib}

\usepackage{enumitem}
\usepackage{floatrow}
\usepackage{calc} % To calculate width for \FBwidth
\usepackage{amssymb}
\usepackage{multirow}
\usepackage[normalem]{ulem}

\floatsetup{ 
  heightadjust=object,
  valign=t
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% en-têtes et pieds de pages :
\usepackage{fancyhdr}
\pagestyle{fancy}
\setlength\headheight{26pt} %% just to make warning go away. Adjust the value after looking into the warning.
%\rhead{{\color{blue}\rule{1cm}{1cm}}}
\fancyhf{} % clear head and foot !
\fancyhead[LO,RE]{\footnotesize{\itshape{\nouppercase{\textcolor{gray}{\leftmark}}}}}
\fancyhead[RO,LE]{\includegraphics[width=3.2cm]{logo.png}}
\fancyfoot[C]{\textcolor{gray}{\thepage}}

\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\headrule}{{\color{red}%
\hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%\usepackage{textcomp} % <-------------- problem with def of : \mencl \t
\usepackage{color}
\usepackage{tocvsec2}
\usepackage{tikz}
\usepackage{pstricks}
\usepackage{graphicx}
\usepackage{type1cm}
\usepackage{eso-pic}
\usepackage{tocloft}


\usepackage[hyphens]{url}
\usepackage[
 unicode=true,
 bookmarks=true,
 bookmarksnumbered=true,
 bookmarksopen=true,
 bookmarksopenlevel=1,
 breaklinks=false,
 pdfborder={0 0 1},
 backref=false,
 colorlinks=false
 ]
 {hyperref}

\hypersetup{
 pdftitle={Title},
 pdfauthor={Author},
 pdfkeywords={key1, key2, key3},
 colorlinks=false,
 linkbordercolor={0 0.8 0.2},
 linktoc=section
 }

\linespread{1}

\usepackage{rotating}
\usepackage{watermark}


\raggedbottom
\usepackage[bottom]{footmisc}


\captionsetup[figure]{textfont={it}}
\captionsetup[subfigure]{textfont=it,singlelinecheck=off,justification=raggedright}
\usepackage{titling}
\setlength{\droptitle}{-18mm}   % This is your set screw

\graphicspath{{images/}}

\pdfobjcompresslevel=0
\usepackage{authblk}

\makeatletter
\newcommand{\thickhline}{%
    \noalign {\ifnum 0=`}\fi \hrule height 1pt
    \futurelet \reserved@a \@xhline
}
\newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}
\makeatother
\setcounter{tocdepth}{3}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\thispagestyle{empty}
\pagenumbering{gobble} 
\renewcommand{\tablename}{Tab}
%\setlength{\droptitle}{-24mm}

\title{Title}

\author{\normalsize{Author} \\
    \texttt{
        \scriptsize{
            \href{mailto:[email protected]}{[email protected]}
        }
    }
}

\date{\small{july 2016}}

\maketitle

\tableofcontents

\listoffigures 

\listoftables 


%\newpage{}
\clearpage
\pagenumbering{arabic} 
\setcounter{page}{1}
\pagestyle{fancy}

\vspace*{-17.2mm}

\newpage{}
\section*{Introduction}
\markboth{Introduction}{Introduction}
\addcontentsline{toc}{section}{Introduction}
\vspace*{-2.4mm}

text


\newpage{}
\section*{Problematic}
\markboth{Problematic}
\addcontentsline{toc}{section}{Problematc}
\vspace*{-2.4mm}


text
\end{document} 
8
  • Have you refined \addcontentsline? Or are you using hyperref? That's most likely the cause of your problem. From that fragment we can't say much, however
    – user31729
    Jul 25, 2016 at 15:25
  • No, the command is not refined. I use hyperref, yes. See update for options.
    – s.k
    Jul 25, 2016 at 15:46
  • That's not compilable and as such not useful. Again: Don't post such fragments but the real code (i.e. the document!)
    – user31729
    Jul 25, 2016 at 15:46
  • Ok, MWE added. Thanks. (I do need hyperref package to insert mails, url, and so on. This worked on an old version of texlive/texmaker I had.)
    – s.k
    Jul 25, 2016 at 16:00
  • You added the MWE in pastebin, but not here :-(
    – user31729
    Jul 25, 2016 at 16:02

1 Answer 1

2

The error is \markboth{Problematic} -- \markboth requires two arguments not just one. So either use \markboth{Problematic}{Problematic} or \markboth{Problematic}{}.

\documentclass[a4paper,12pt,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage[frenchb]{babel}

\addto\extrasfrench{
\providecommand{\og}{\leavevmode\flqq~}\providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}
}

\usepackage[showframe=false,headheight=-1mm, top=2cm, bottom=2.4cm, left=2.4cm, right=2cm, footskip=20pt]{geometry}

\setlength\parindent{0pt}

\usepackage{lmodern}
\usepackage{atbegshi}


\usepackage[absolute,overlay]{textpos}
  \setlength{\TPHorizModule}{1mm}
  \setlength{\TPVertModule}{1mm}


\widowpenalty=9999
\clubpenalty=9996

\usepackage{aeguill}
\usepackage{eurosym}

    \usepackage{gensymb}

    \usepackage{caption}
    \captionsetup{justification=centering}
    \usepackage{subcaption}

    \usepackage{multicol}
    \usepackage{vwcol}
    \usepackage{array}
    \usepackage{pdflscape}
    \usepackage{natbib}

    \usepackage{enumitem}
    \usepackage{floatrow}
    \usepackage{calc} % To calculate width for \FBwidth
    \usepackage{amssymb}
    \usepackage{multirow}
    \usepackage[normalem]{ulem}

    \floatsetup{ 
      heightadjust=object,
      valign=t
    }

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% en-têtes et pieds de pages :
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \setlength\headheight{26pt} %% just to make warning go away. Adjust the value after looking into the warning.
    %\rhead{{\color{blue}\rule{1cm}{1cm}}}
    \fancyhf{} % clear head and foot !
    \fancyhead[LO,RE]{\footnotesize{\itshape{\nouppercase{\textcolor{gray}{\leftmark}}}}}
    \fancyhead[RO,LE]{\includegraphics[width=3.2cm]{ente}}
    \fancyfoot[C]{\textcolor{gray}{\thepage}}

    \renewcommand{\headrulewidth}{0.4pt}
    \renewcommand{\headrule}{{\color{red}%
    \hrule width\headwidth height\headrulewidth \vskip-\headrulewidth}}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %\usepackage{textcomp} % <-------------- problem with def of : \mencl \t
    \usepackage{color}
    \usepackage{tocvsec2}
    \usepackage{tikz}
    \usepackage{pstricks}
    \usepackage{graphicx}
    \usepackage{type1cm}
    \usepackage{eso-pic}
    \usepackage{tocloft}


    \usepackage{rotating}
    \usepackage{watermark}


    \raggedbottom
    \usepackage[bottom]{footmisc}


    \captionsetup[figure]{textfont={it}}
    \captionsetup[subfigure]{textfont=it,singlelinecheck=off,justification=raggedright}
    \usepackage{titling}
    \setlength{\droptitle}{-18mm}   % This is your set screw

    \graphicspath{{images/}}

    \pdfobjcompresslevel=0
    \usepackage{authblk}


    \usepackage[hyphens]{url}
    \usepackage[
     unicode=true,
     bookmarks=true,
     bookmarksnumbered=true,
     bookmarksopen=true,
     bookmarksopenlevel=1,
     breaklinks=false,
     pdfborder={0 0 1},
     backref=false,
     colorlinks=false
     ]
     {hyperref}

    \hypersetup{
     pdftitle={Title},
     pdfauthor={Author},
     pdfkeywords={key1, key2, key3},
     colorlinks=false,
     linkbordercolor={0 0.8 0.2},
     linktoc=section
     }

    \linespread{1}


    \makeatletter
    \newcommand{\thickhline}{%
        \noalign {\ifnum 0=`}\fi \hrule height 1pt
        \futurelet \reserved@a \@xhline
    }
    \newcolumntype{"}{@{\hskip\tabcolsep\vrule width 1pt\hskip\tabcolsep}}
    \makeatother
    \setcounter{tocdepth}{3}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \begin{document}
    \thispagestyle{empty}
    \pagenumbering{gobble} 
    \renewcommand{\tablename}{Tab}
    %\setlength{\droptitle}{-24mm}

    \title{Title}

    \author{\normalsize{Author} \\
        \texttt{
            \scriptsize{
                \href{mailto:[email protected]}{[email protected]}
            }
        }
    }

    \date{\small{july 2016}}

    \maketitle

    \tableofcontents

    \listoffigures 

    \listoftables 


    %\newpage{}
    \clearpage
    \pagenumbering{arabic} 
    \setcounter{page}{1}
    \pagestyle{fancy}

    \vspace*{-17.2mm}

    \newpage{}
    \section*{Introduction}
    \markboth{Introduction}{Introduction}
    \addcontentsline{toc}{section}{Introduction}
    \vspace*{-2.4mm}

    text


    \newpage{}
    \section*{Problematic}
    \markboth{Problematic}{Problematic}
    \addcontentsline{toc}{section}{Problematc}
    \vspace*{-2.4mm}


    text
    \end{document} 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .