4

A new defined command (see below) works on my windows with MiKTeX 2.9 and on a Mac with MacTeX. On another windows (running in a Mac) with an absolute fresh installed MiKTeX and on the same Mac in Mac OS with MacTeX the command doesn't work.

We are using absolutely the same files. The scrartcl class is used in there.

The command:

\newcommand{\mysection}[1]{%
    \refstepcounter{section}%
    \sectionmark{#1}%
    \addcontentsline{toc}{section}{\numberline{\thesection}#1}%
}

The Error Message on the failing distributions (when the command is called):

Argument of \XKV@d@fine@k@y has an extra }.
<inserted text> 
                \par 
l.6 \mysection{Die rationalen Zahlen $\Qe_0^+$}

Update

I updated all my Packages via MiKTeX update manager and get the error now, too. I created a MWE. Interesting is that it works with class article, but not with scrartcl:

\documentclass{scrartcl}

\newcommand{\mysection}[1]{%
    \refstepcounter{section}%
    \sectionmark{#1}%
    \addcontentsline{toc}{section}{\numberline{\thesection}#1}%
}

\begin{document}
\tableofcontents
\mysection{test}
\end{document}

The error message is:

Argument of \reserved@a has an extra }.
<inserted text> 
                \par 
l.11 \mysection{test}
  • 1
    You are not using absolutly the same files. So check carefully the log for differences. – Ulrike Fischer Sep 18 '14 at 14:04
  • 2
    The error message is from xkeyval (which had some updates this year) but the code you show is not obviously using that) please always post a complete small document that demonstrates the error, not just a fragment – David Carlisle Sep 18 '14 at 14:13
  • with the new MWE I get (texlive 2014) ! Argument of \reserved@a has an extra }. what error do you see with miktex – David Carlisle Sep 18 '14 at 20:55
  • @David Carlisle: I added the Error message in the question. – Rafael Wörner Sep 18 '14 at 20:57
  • yes that's what I get so whatever it is it's an unrelated error to the one you put in the initial question (which was about xkeyval package) – David Carlisle Sep 18 '14 at 20:58
6

Add

\listfiles

to your document and compare the package versions listed on the two machines. Update any packages that are out of sync (xkeyval most likely given the error message).

The MWE you added shows a missing \protect

\documentclass{scrartcl}

\newcommand{\mysection}[1]{%
    \refstepcounter{section}%
   \sectionmark{#1}%
    \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}%
}

\begin{document}
\tableofcontents


\mysection{test}
\end{document}
  • I made an update now for my packages via miktex update manager. Now I get the same error message. So the next question is, what is wrong with the code. – Rafael Wörner Sep 18 '14 at 20:44
  • I created a MWE in my original question above. – Rafael Wörner Sep 18 '14 at 20:50
  • Ok, good to know. Is it possible to describe in a few words, why it is neccessary here? – Rafael Wörner Sep 18 '14 at 21:15
  • 2
    @RafaelWörner \protect is always needed in arguments that are written to external commands except for "robust" commands that are defined to add \protect automatically – David Carlisle Sep 18 '14 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.