2

I have used

\documentclass{article}
\usepackage{soul}
\usepackage[normalem]{ulem}
\begin{document}
\hl{\mbox{\sout{This is my text which I want to highlight and strike through. The text does not go to the next line, instead it goes beyond the page.}}}
\end{document}

But the sentence is not broken down in output pages. It goes beyond the page. How to fix it?

enter image description here

YatShan
  • 155

1 Answers1

4

Easiest would be to use soulpos:

%! TEX program = pdflatex
\documentclass{article}
%\usepackage{soul}
\usepackage{soulpos}
\usepackage{xcolor}

\ulposdef{\hlst}{% \rlap{\textcolor{yellow}{\rule[-.75ex]{\ulwidth}{2.5ex}}}% \rule[.45ex]{\ulwidth}{.1ex}% }

\begin{document} \pagenumbering{gobble}

\textbf{New hlst macro:}

\hlst{This is my text which I want to highlight and strike through. The text goes to the next line instead of going beyond the page.}

\textbf{hl:}

\hl{This is my text which I want to highlight and strike through. The text goes to the next line instead of going beyond the page.}

\textbf{st:}

\st{This is my text which I want to highlight and strike through. The text goes to the next line instead of going beyond the page.}

\end{document}

Output:

output


Another alternative is to use lua-ul see Can't underline highlighted text (soul) for an example.

user202729
  • 7,143