How to highlight paragraph (linebreak preserving) as well as itemize, tabular etc.?

5,005

Concerning your question about \hl support for \cite: while \hl{text\cite{book}} gives an error, it works if you additionally group the \cite command by curly braces.

\documentclass{article}
\usepackage{soul}
\begin{document}
\hl{text{\cite{texbook}}}
\begin{thebibliography}{Knuth86]}
\bibitem[Knuth86]{texbook} D.E. Knuth, The TeXbook, 1986
\end{thebibliography}
\end{document}

gives

highlighted \cite

Share:
5,005

Related videos on Youtube

math
Author by

math

Updated on August 01, 2022

Comments

  • math
    math over 1 year

    I want to highlight changes which are introduced by myself in the pdf document. So far the soul package is very neat but it does throw errors when I want to highlight not only paragraphs but also some itemize environments, and I don't want to highlight the items separately. Also the \cite{...} command is not supported by \hl. I recently posted a slightly different question: Change text background within paragraph (with automatic linebreaks)

    BTW: What I liked most over other approaches like pdfcomments etc. is that the \hl command from soul has a very exact and clear output, no icons, no clicking etc. involved. Together with todonotes it's very good and almost all I need.

    • math
      math over 12 years
      Clumsy me: when this is a single paragraph I could clearly use \colorbox. Even with \cite commands inside. When its a phrase without \cite commands inside a paragraph I can use \hl from soul package. The only problem left is when I have a phrase with \cite commands, \hl will not work :(
  • Filipe Correia
    Filipe Correia over 10 years
    I had instead to use \hl{text\mbox{\cite{texbook}}} for it to work for me, otherwise I got "Reconstruction failed" errors.
  • math
    math about 10 years
    Is there a way to automate this encapsulation into curly braces? I though of a custom macro \newcommand{\mycite}[1]{{\cite{#1}}}.. and then maybe \soulregister{\mycite}{1}?