1

{\color } can do that, but only for the color of text. I would want the same for the background. I have looked across many solutions, but they either can not go across environments (e.g. colorbox) or create new paragraphs (e.g. framed).

I just want to highlight arbitrary regions of text, without any other modification to them.

EDIT: An example for gigi:

\documentclass{article}

\usepackage{color,soul}
\sethlcolor{red}
\begin{document}


text \hl{
\begin{itemize}
        \item text
\end{itemize}
} text

\end{document}

It produces:

$ pdflatex a.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./a.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/color.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def))
(/usr/share/texlive/texmf-dist/tex/latex/soul/soul.sty) (./a.aux)
(/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
)

! LaTeX Error: Environment {itemize} undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.12 }
       text
?

1 Answer 1

1

The soul package can do this:

\documentclass{article}

\usepackage{color,soul}
\sethlcolor{red}
\begin{document}


text \hl{text} text

\end{document}
3
  • Wrapping itemize with hl caused LaTeX Error: Environment {itemize} undefined.
    – arataj
    Jun 21, 2019 at 14:30
  • @arataj Can you add a document to your question that shows the problem?
    – gigi
    Jun 21, 2019 at 14:31
  • I added an example.
    – arataj
    Jun 24, 2019 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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