我一直试图删除宏定义的彩色文本,但似乎不支持换行。我有一个命令 bt 来输入蓝色文本,我想用红色笔划删除部分文本(命令 rs)。以下是我的问题的 MCVE。
\documentclass{article}
\usepackage{ulem,xcolor}
\newcommand{\bt}[1]{\textcolor{blue}{#1}} % bt: blue text
\newcommand{\rt}[1]{\textcolor{red}{#1}} % rt: red text
\newcommand{\rs}[1]{\rt{\sout{#1}}} % rs: red stroke
\textwidth=12cm % Forcing linebreak at 12cm
\usepackage[T1]{fontenc}
\begin{document}
\bt{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
sodales massa ac dapibus dignissim. Phasellus ac pretium urna.
Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis
tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}
\rs{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
sodales massa ac dapibus dignissim. Phasellus ac pretium urna.
Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis
tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}
\rs{\bt{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
sodales massa ac dapibus dignissim. Phasellus ac pretium urna.
Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis
tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}}
\end{document}
此代码产生以下输出。它确实用红色描边删除了文本,但是,这会破坏段落的换行。
我也尝试过这个soul
包并使用了expandafter
技巧(来自这个关联),但它对我不起作用。
答案1
沒有soul
問題。
\documentclass{article}
\usepackage{soul,xcolor}
\newcommand{\bt}[1]{\textcolor{blue}{#1}} % bt: blue text
\newcommand{\rt}[1]{\textcolor{red}{#1}} % rt: red text
\newcommand{\rs}[1]{\setstcolor{red}\st{#1}} % rs: red stroke
\textwidth=12cm % Forcing linebreak at 12cm
\usepackage[T1]{fontenc}
\begin{document}
\bt{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
sodales massa ac dapibus dignissim. Phasellus ac pretium urna.
Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis
tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}
\rs{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
sodales massa ac dapibus dignissim. Phasellus ac pretium urna.
Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis
tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}
\textcolor{blue}{\rs{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin
sodales massa ac dapibus dignissim. Phasellus ac pretium urna.
Mauris tincidunt molestie sapien vel mattis. Vestibulum aculis
tincidunt posuere. In interdum blandit diam, id tempus elit ullamcorper iaculis.}}
\end{document}