在 Latex 中突出显示和删除文本

在 Latex 中突出显示和删除文本

我用过

\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}

但是句子在输出页面中没有分解。它超出了页面范围。如何修复?

在此处输入图片描述

答案1

最简单的方法是使用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}

输出:

输出


另一种方法是lua-ul使用无法为突出显示的文本添加下划线(灵魂)举个例子。

相关内容