Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Highlight \& cite problem

4,743 views
Skip to first unread message

Dieter Britz

unread,
Apr 11, 2008, 7:05:17 AM4/11/08
to
I want to highlight some text, including a citation. Here is what I am
trying in mini-form:

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

Herbert Voss

unread,
Apr 11, 2008, 7:10:19 AM4/11/08
to
Dieter Britz schrieb:

> I want to highlight some text, including a citation. Here is what I am
> trying in mini-form:
>
> \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}}.

\hl{Highlighting, with the cite. Citing Romberg again

\protect\cite{Romb1955}}.

Herbert

Lars Madsen

unread,
Apr 11, 2008, 7:19:54 AM4/11/08
to

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

Ulrike Fischer

unread,
Apr 11, 2008, 7:32:09 AM4/11/08
to

\mbox{\cite{Romb1955}}}.

\def\test{\cite{Romb1955}}
\hl{Highlighting, with the cite. Citing Romberg again \test}.

--
Ulrike Fischer

Dieter Britz

unread,
Apr 11, 2008, 8:29:15 AM4/11/08
to
Ulrike Fischer wrote:

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.

Dieter Britz

unread,
Apr 11, 2008, 8:51:05 AM4/11/08
to
Dieter Britz wrote:

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?

Ulrike Fischer

unread,
Apr 11, 2008, 9:07:35 AM4/11/08
to

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

Dieter Britz

unread,
Apr 11, 2008, 10:20:43 AM4/11/08
to
Ulrike Fischer wrote:

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 -?

Ulrike Fischer

unread,
Apr 11, 2008, 10:25:45 AM4/11/08
to
Am Fri, 11 Apr 2008 16:20:43 +0200 schrieb Dieter Britz:

> 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

Dieter Britz

unread,
Apr 14, 2008, 5:05:48 AM4/14/08
to
Ulrike Fischer wrote:

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?

Ulrike Fischer

unread,
Apr 14, 2008, 5:15:06 AM4/14/08
to

\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

Dieter Britz

unread,
Apr 14, 2008, 6:28:55 AM4/14/08
to
Ulrike Fischer wrote:

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.

0 new messages