I am using soul package and \hl to highlight text in my Latex. However, it does not work when there is a linebreak or a new paragraph. I have a whole page to highlight. Is it possible to make \hl include the linebreaks? How to do it?
Asked
Active
Viewed 321 times
0
Pankaj Singh
- 107
- 3
-
1no, soul can't do that. If you want to do heavy highlighting use lualatex and the lua-ul package. – Ulrike Fischer Jun 21 '22 at 14:32
-
See https://tex.stackexchange.com/questions/5959/cool-text-highlighting-in-latex for some background (pun intended...). And if you indeed want to highlight the full page then you could also change the page color (see https://tex.stackexchange.com/questions/25137/how-to-change-the-background-color-only-for-the-current-page). – Marijn Jun 21 '22 at 18:34
1 Answers
0
\hl does not work properly with line breaks in LaTeX. However, there is a workaround to highlight text that spans across multiple lines. You can use the \colorbox command from the xcolor package to create a colored box around the text. Here is an example:
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\colorbox{yellow}{%
\parbox{\linewidth}{%
This is some text that spans across multiple lines, and it is being highlighted in yellow using the \textbackslash colorbox command from the xcolor package.
}}
\end{document}
This code will highlight the text in a yellow box that spans across multiple lines. You can change the color of the box by replacing "yellow" with any other color name or code.
Pankaj Singh
- 107
- 3