Monday, March 5, 2012

Highlighting text in LaTeX - changing hl colors too

Please Make A Note: How to highlight text in LaTeX
Utilize the "soul" package.  (Side note, I think the "color" package should be loaded for this to work as well. The class I am using for my thesis already has it loaded, and I saw this somewhere, so just in case.)

\usepackage{soul}

Then use the following command to highlight text:

\hl{text to be highlighted}

Screenshots:



Although, it seems you cannot highlight citations using this command.  There is probably a way to do this.

Update: 3-9-12

You can use the \hl command around text options such as \textit and \textbf.  To use different colors to highlight I found this neat command here:

http://tex.stackexchange.com/questions/5959/cool-text-highlighting-in-latex

\newcommand{\hlc}[2][yellow]{ {\sethlcolor{#1} \hl{#2}} }

which is to go into the preamble.  The command is then:


\hlc[green]{Text goes here.}


Screenshot:


6 comments:

  1. This is interesting, but it would be much more useful to be able to highlight references and citations. Did you find a way to do this?

    ReplyDelete
  2. yes, do you know how to highlight all text, references and citations? Thank you very much... please help

    ReplyDelete
  3. Hi, sorry, I have not yet found a way to do this. Honestly, I haven't looked much, but I will keep it in mind and try to get an answer.

    ReplyDelete
  4. Ok, after a quick search, I found that if you put an extra set of brackets around the \cite{}, then the highlighting should work!!

    So for example,

    \hl{{\cite{citation}}}

    It should work for other citation types too, \citeyear, etc.

    http://tex.stackexchange.com/questions/20021/how-to-highlight-paragraph-linebreak-preserving-as-well-as-itemize-tabular-et

    I'll make a separate post about this as well.

    ReplyDelete