我的问题涉及: 不同颜色的删除线出现在字母后面,而不是字母上面,只不过我使用的是 beamer 而不是 article。因此,那里提供的解决方案不知何故不起作用。我手头上的例子是:
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
\documentclass[t, 10 pt, mathserif]{beamer}
\usepackage{xparse,soul}
\makeatletter
\NewDocumentCommand{\sotwo}{O{red}O{black}+m}
{%
\begingroup
\setulcolor{#1}%
\setul{-.5ex}{.4pt}%
\def\SOUL@uleverysyllable{%
\rlap{%
\color{#2}\the\SOUL@syllable
\SOUL@setkern\SOUL@charkern}%
\SOUL@ulunderline{%
\phantom{\the\SOUL@syllable}}%
}%
\ul{#3}%
\endgroup
}
\makeatother
\begin{document}
Hello \sotwo{Welt} World!
\sotwo[green]{Here is a long sentence that will span across a number of lines to force a linebreak}
\sotwo[green][blue]{Here is a long sentence that will span across a number of lines to force a linebreak}
Here is a long sentence that will span across a number of lines to force a linebreak
\end{document}
任何想法都将不胜感激!谢谢!
答案1
在这种情况下,对代码进行简单的更改即可:在 的定义中\setulcolor{#1}%
简单地用 替换。\color{#1}%
\sotwo
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
\documentclass[t, 10pt]{beamer}
\usepackage{xparse,soul}
\makeatletter
\NewDocumentCommand{\sotwo}{O{red}O{black}+m}
{%
\begingroup
\color{#1}%
\setul{-.5ex}{.4pt}%
\def\SOUL@uleverysyllable{%
\rlap{%
\color{#2}\the\SOUL@syllable
\SOUL@setkern\SOUL@charkern}%
\SOUL@ulunderline{%
\phantom{\the\SOUL@syllable}}%
}%
\ul{#3}%
\endgroup
}
\makeatother
\begin{document}
Hello \sotwo{Welt} World!
\sotwo[green]{Here is a long sentence that will span across a number
of lines to force a linebreak}
\sotwo[green][blue]{Here is a long sentence that will span across a
number of lines to force a linebreak}
Here is a long sentence that will span across a number of lines to
force a linebreak
\end{document}
答案2
您也可以从为什么投影机里的灵魂着色不可见:
\makeatletter
\newcommand\SoulColor{%
\let\set@color\beamerorig@set@color
\let\reset@color\beamerorig@reset@color}
\makeatother
\SoulColor
得出的结果是:
代码:
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
\documentclass[t, 10 pt, mathserif]{beamer}
\usepackage{xparse,soul}
% https://tex.stackexchange.com/questions/41683/why-is-it-that-coloring-in-soul-in-beamer-is-not-visible
\makeatletter
\newcommand\SoulColor{%
\let\set@color\beamerorig@set@color
\let\reset@color\beamerorig@reset@color}
\SoulColor
\NewDocumentCommand{\sotwo}{O{red}O{black}+m}
{%
\begingroup
\setulcolor{#1}%
\setul{-.5ex}{.4pt}%
\def\SOUL@uleverysyllable{%
\rlap{%
\color{#2}\the\SOUL@syllable
\SOUL@setkern\SOUL@charkern}%
\SOUL@ulunderline{%
\phantom{\the\SOUL@syllable}}%
}%
\ul{#3}%
\endgroup
}
\makeatother
\begin{document}
Hello \sotwo{Welt} World!
\sotwo[green]{Here is a long sentence that will span across a number of lines to force a linebreak}
\sotwo[green][blue]{Here is a long sentence that will span across a number of lines to force a linebreak}
Here is a long sentence that will span across a number of lines to force a linebreak
\end{document}