3

I get the error

! Argument of \@item has an extra }. <inserted text> \par l.135 \emph{class} \bfcode{C}} 

when translating a LaTeX file generated by Sphinx documentation system.

I've managed to reduce it to the following self-contained example:

\documentclass{article} \usepackage{hyperref} \newcommand{\pysigline}[1]{\item[#1]\nopagebreak} \newenvironment{fulllineitems}{ \begin{list}{}{\labelwidth \leftmargin \labelsep 0pt \rightmargin 0pt \topsep -\parskip \partopsep \parskip \itemsep -\parsep} }{\end{list}} \begin{document} \begin{fulllineitems} \pysigline{\phantomsection\label{index:project0class_c}\item[] template \textless{}typename T\textgreater{} \emph{class} \bfcode{C}} Test class. \end{fulllineitems} \end{document} 

As you can see the '{' and '}' are balanced.

What does this error mean and how can I fix it?

8
  • 2
    Can you post some sort of minimal, compile-able example? For instance, there's no way for us to know (right now) that the \item is indeed inside some sort of list environment (where it would cause an error outside of one). Commented Sep 15, 2014 at 15:32
  • 3
    impossible to be sure without working example but I wpould gues that \pysigline puts its argument in an optional argument so use \pysigline{{...}} to hide the [] Commented Sep 15, 2014 at 15:34
  • You should work a little and try to reduce the code to the minimal necessary to reproduce your error. Then post it here. Commented Sep 15, 2014 at 15:44
  • @SeanAllred OK, now I've reduced it to a self-contained example. Commented Sep 15, 2014 at 16:00
  • 1
    @SeanAllred answer added I was constrained yesterday:-) chat.stackexchange.com/transcript/message/17694997#17694997 Commented Sep 16, 2014 at 11:08

1 Answer 1

7

A LaTeX optional argument ends at the first ] (unless it is inside a {} group. It does not match [ ] (unless you use the declarations provided by xparse) so in

... \item[...\foo[] ...] zzz 

the argument of \item is not ...\foo[] ... but ...\foo[ and things go wrong.

\pysigline puts its argument in an optional argument so use

\pysigline{{...}} 

to hide the []

Or better (if you have access to the definition in your real case) fix the definition to add the extra {} in all cases:

\newcommand{\pysigline}[1]{\item[{#1}]\nopagebreak} % % 

now a stray ] in the argument to \pysigline is protected from terminating the optional argument of the inner \item

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.