\documentclass[12pt]{article}
\usepackage{color,soul}
\begin{document}
\title{Title here}
\author{}
\date{}
\maketitle
A line of normal text.
\hl{Highlighting, without the cite.}. Citing Romberg \cite{Romb1955}.
\hl{Highlighting, with the cite. Citing Romberg again \cite{Romb1955}}.
\begin{thebibliography}{1}
\bibitem{Romb1955}
W.~Romberg, Kong. Norske Vid. Selsk. Forh. 28 (1955) 30.
\end{thebibliography}
\end{document}
Result:
! Argument of \@citex has an extra }.
<inserted text>
\par
l.11 ...ite. Citing Romberg again \cite{Romb1955}}
.
?
The first citation line works fine, if I remove the second.
How do I get a citation into a highlighted area?
--
Dieter Britz (britz<at>chem.au.dk)
\hl{Highlighting, with the cite. Citing Romberg again
\protect\cite{Romb1955}}.
Herbert
we already tried that, it does not color the background of the citation
--
/daleif (remove RTFSIGNATURE from email address)
LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html
\mbox{\cite{Romb1955}}}.
\def\test{\cite{Romb1955}}
\hl{Highlighting, with the cite. Citing Romberg again \test}.
--
Ulrike Fischer
Thank you. I just printed this out for future reference and put it
away into my filing cabinet, and saw that you already answered this
question almost exactly 2 years ago, on the German TeX group. The
reason I mention this is that there was a complication, due to
the fact that in the actual document, I use the package cite, and
this causes problems. This could happen to others. Your solution then
was
newbox\citebox
\sbox\citebox{\cite{Romb1955}}%
...
\hl{some text and {\usebox\citebox}}
Sorry to repeat the question (how quickly one forgets), and thanks
for the help.
I wrote this too soon. In fact, I have three places where I have this
problem. So I tried it with two in the mini-example:
\documentclass[12pt]{article}
\usepackage{color,soul}
\usepackage{cite}
\begin{document}
\title{Title here}
\author{}
\date{}
\maketitle
\newbox\citebox1% First box
\sbox\citebox1{\cite{Romb1955}}
\newbox\citebox2% 2nd box
\sbox\citebox2{\cite{Romb1955}}
A line of normal text.
\hl{highlighted text with citation {\usebox\citebox1} and
{\usebox\citebox2}}
\begin{thebibliography}{1}
\bibitem{Romb1955}
W.~Romberg, Kong. Norske Vid. Selsk. Forh. 28 (1955) 30.
\end{thebibliography}
\end{document}
This produces a strange listing of the two citations at the top
of the output, and where the citations are supposed to be in the form
[1] and [1] again, they appear simply as numbers without the square
brackets.
What do I do now?
Don't use numbers in command names:
\newbox\citeboxa% First box
\sbox\citeboxa{\cite{Romb1955}}
\newbox\citeboxb% 2nd box
\sbox\citeboxb{\cite{Romb1955}}
--
Ulrike Fischer
OK, did that. A new problem now appears (sorry!). I now have four
of these, and they appear as [1]...[4] in the list. All other
references appear in the order of their appearance, as they should,
but not these; they come first. I tried putting the citebox things
just before where they are invoked, but they still come first in the
list. Can I prevent this?
You might regard this as a non-problem, because eventually, I will
remove the highlighting, and I can then get rid of the citeboxes. But
just out of interest -?
> OK, did that. A new problem now appears (sorry!). I now have four
> of these, and they appear as [1]...[4] in the list. All other
> references appear in the order of their appearance, as they should,
> but not these; they come first. I tried putting the citebox things
> just before where they are invoked, but they still come first in the
> list. Can I prevent this?
I don't understand what you mean. Make a minimal example.
--
Ulrike Fischer
I found out that it isnot the highlighting itself, but the use of
citeboxes. Here is the new miniexample:
\documentclass[12pt]{article}
\usepackage{color,soul}
\usepackage{cite}
\begin{document}
\title{Title here}
\author{}
\date{}
\maketitle
\newbox\citebox
\sbox\citebox{\cite{Romb1955}}
A line of normal text, including a citation that should come first in the
list
of references \cite{Peac1955} since this is the first citation in this
paper,
and given the bst used here. Next we have a \hl{highlighted text with
another
citation {\usebox\citebox}}, which should be next in the list. But their
order
is reversed.
\begin{thebibliography}{1}
\bibitem{Romb1955}
W.~Romberg, Kong. Norske Vid. Selsk. Forh. 28 (1955) 30.
\bibitem{Peac1955}
D.~W. Peaceman, H.~H. Rachford, J. Soc. Ind. Appl. Math. 3 (1955) 28.
\end{thebibliography}
\end{document}
Of course, at first I had no bbl file but drew on my bibtex data files.
Without using citeboxes, Peac1955 becomes [1] as it should and
Romb1955 becomes [2]. But the use of citeboxes makes the latter [1].
If I add more citations via citeboxes, they all come in a group
before the others, using \cite{..}.
Can this be prevented?
\cite{Peax1955} is obviously not the first citation in this paper. You
used \cite{Romb1955} first. So move the \sbox-command.
> \begin{thebibliography}{1}
>
> \bibitem{Romb1955}
> W.~Romberg, Kong. Norske Vid. Selsk. Forh. 28 (1955) 30.
>
> \bibitem{Peac1955}
> D.~W. Peaceman, H.~H. Rachford, J. Soc. Ind. Appl. Math. 3 (1955) 28.
>
> \end{thebibliography}
And if you add the bibiography manually then the order of the \cite
doesn't count anyway.
--
Ulrike Fischer
I tried moving the sbox, of course, but it doesn't make a difference.
I was afraid you'd mention the bibliography, so here is how I do it
here, which you can't use because you don't have that Bibtex file,
and probably not the bst either.
\documentclass[12pt]{article}
\usepackage{color,soul}
\usepackage{cite}
\begin{document}
\title{Title here}
\author{}
\date{}
\maketitle
A line of normal text, including a citation that should come first in the
list
of references \cite{Peac1955} since this is the first citation in this
paper,
\newbox\citebox
\sbox\citebox{\cite{Romb1955}}
and given the bst used here. Next we have a \hl{highlighted text with
another
citation {\usebox\citebox}}, which should be next in the list. But their
order
is reversed.
\bibliography{/home/db/latex/bib/numerical}%
\bibliographystyle{/home/db/latex/styfiles/jec}%
\end{document}
The result is a bbl file as I posted before, and in the text, the first
reference, to Peaceman \& Rachford, becomes [2] etc. Iow, moving the
sbox is not the answer.