\addcontentsline 的参数有一个额外的 }

\addcontentsline 的参数有一个额外的 }

我显然在使用该命令时遇到了麻烦\addcontentsline

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

这是失败的代码:

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

我正在使用article课程文档:

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

这个命令有什么问题?它需要额外的包吗?我在 Ubuntu 16.04 上使用 TeXmaker,使用 PDFLaTeX 编译文档。

我是hyperref这样使用的:

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

而且还\addcontentsline不够精致。
以下是 MWE:http://pastebin.com/raw/nnqXJkHh

平均能量损失

\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} 

答案1

错误是\markboth{Problematic}--\markboth需要两个参数而不只是一个。因此,要么使用 ,\markboth{Problematic}{Problematic}要么使用\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} 

相关内容