How do I use \cite in \DeclareRobustCommand? I'm using \DeclareRobustCommand to create two ways to highlight text using package soul. For example, this is what I have in the header of the document:

\definecolor{electricgreen}{rgb}{0.0, 1.0, 0.0}


When I use these commands like this, it works:

\hlyg{This is my text here} 

However, when I use these comands with \cite, it fails and throws the error below:

\hlyg{This is~\cite{someone} my text here} 

And this is the error that I get when I compile the document with Miktex 2.9:

Argument of \@citex has an extra }.
<inserted text> 
l.191 ...ct and limitations on larger scenarios. }

This is an MWE



\definecolor{electricgreen}{rgb}{0.0, 1.0, 0.0}



\noindent In order to outline the changes made to the document, the revised
sentences/words are highlighted in two colours:
\item \hly{Yellow} colour for reviewer 1's comments.
\item \hlyg{Green} colour for reviewer 2's comments. 

\\hly{Lorem Ipsum~\cite{lipsum} is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum}

Lorem Ipsum

  • 1
    Welcome to TeX.SX! Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass and ending with \end{document}.
    – Bobyandbob
    Dec 14 '17 at 18:36

You just need to brace \cite{someone}. There's no need to declare \hlyg and \hly as robust commands, unless you need them in sectional titles or captions.


\definecolor{electricgreen}{rgb}{0.0, 1.0, 0.0}



\hlyg{This is my text here}

\hlyg{This is~{\cite{someone}} my text here}


\bibitem{someone} A. Uthor, Title, Journal.



enter image description here


I found the answer in another post, but basically \cite needs to be wrapped into curly brackets:

\hlyg{This is{~\cite{someone}} my text here} 

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.