Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using package soul to highlight text, for example with \hl{some text}. It works nicely in general, but when the text contains other macros, soul simply skips it. For example:

\usepackage{soul}
\newcommand{\removed}[1]{\st{#1}}
...
\removed{Some articles by \cite{someauthor2013} support this view.}

turns out in the pdf as Some articles by, cutting the macro and all the subsequent text. The same happens with \st and all the other highlighting macros.

Any fix to make the removed macro more robust, possibly without changing the input text?

Thanks!

SOLUTION: The following code solves the problem nicely.

\usepackage[normalem]{ulem}
\newcommand\reduline{\bgroup\markoverwith{\textcolor{red}{\rule[0.5ex]{2pt}{0.4pt}}}\ULon}
\newcommand{\removed}[1]{\reduline{#1}}
...
\removed{This text by \cite{someauthor2013} will be rendered with a red line on it.}
share|improve this question
    
Read the documentation of soul. Section 2.1 and 2.2. You should also not ignore the log-file: your code should give errors. –  Ulrike Fischer Jan 9 '13 at 14:18
    
query - where does \textcolor come from - when I try a small example it fails - presumably it comes from another package? –  JPH Jul 29 '13 at 18:05
add comment

1 Answer 1

up vote 1 down vote accepted

Edit:

OK, It seems you are not using soul properly -- \package{soul} is clearly wrong. Make it \usepackage{soul}. Having said that the following code works. (This technique of adding {} may not work always. Refer to soul documentation sections 2.1 and 2.2):

\documentclass{article}
\usepackage{soul}
\newcommand{\removed}[1]{\st{#1}}


\begin{document}
\removed{Some articles by {\cite{Ferrero:1997}} support this view.}
\begin{thebibliography}{}

\bibitem[Ferrero, 1997]{Ferrero:1997}
Fererro, X.Y., 1997. text of teh rest of the reference.

\bibitem[Doe, 1999]{Doe:1999}
Doe, J., 1999. another reference

\end{thebibliography}
\end{document}

enter image description here

Earlier answer:

Enclose \cite{someauthor2013} inside an additional set of {} and for this case it works:

\documentclass{article}
\usepackage{soul}


\begin{document}
\hl{Some articles by {\cite{Ferrero:1997}} and {\cite{Doe:1999}} support this view.}


\begin{thebibliography}{}

\bibitem[Ferrero, 1997]{Ferrero:1997}
Fererro, X.Y., 1997. text of teh rest of the reference.

\bibitem[Doe, 1999]{Doe:1999}
Doe, J., 1999. another reference

\end{thebibliography}
\end{document}

enter image description here

With ulem, things look some what easier:

\documentclass{article}
\usepackage[normalem]{ulem}
\newcommand{\removed}[1]{\sout{#1}}


\begin{document}
\removed{Some articles by \cite{Ferrero:1997} support this view.}
\begin{thebibliography}{}

\bibitem[Ferrero, 1997]{Ferrero:1997}
Fererro, X.Y., 1997. text of teh rest of the reference.

\bibitem[Doe, 1999]{Doe:1999}
Doe, J., 1999. another reference

\end{thebibliography}
\end{document}
share|improve this answer
    
Thanks! If I wrap the macro with {}, I get black squares and not text :-/ –  Mulone Jan 9 '13 at 14:57
    
@Mulone Where is your code that gives this behavior? Please post it to your question starting from \begin{document} and ending at \end{document. –  Harish Kumar Jan 9 '13 at 15:00
    
Ok. I've updated the question. –  Mulone Jan 9 '13 at 15:03
    
Thanks. It might be some issue with my natbib set up, which is quite complex. Any more robust alternative to soul to simply strikeout some text? –  Mulone Jan 9 '13 at 15:12
    
@Mulone I suggest the use of ulem. Check out the ulem part in the answer. –  Harish Kumar Jan 9 '13 at 15:13
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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