我为 QED 命令引入了颜色,但颜色对后面的文本有副作用。我希望颜色仅限于符号。
\documentclass[a4paper,12pt]{article}
\usepackage{xcolor}
\ExplSyntaxOn
\definecolor{dblue}{RGB}{0,0,139}
\colorlet{celestk}{dblue}
\NewDocumentCommand{\wvQed}{O{celestk}o}
{
\IfNoValueTF{#2}{\color{#1}}{\color[#1]{#2}}
\hfill\nabla
}
\ExplSyntaxOff
\begin{document}
Tantra is an Expansion Device. \wvQed
The word appears in the hymns of the Rigveda such as in 10.71
\end{document}
答案1
expl3
除了省去注释行尾的麻烦之外,语法在这里对您没有多大帮助。虽然这很方便,但我不会为此更改类别代码。
您需要$
编译它。您需要一个组来限制颜色变化的影响。
\documentclass[a4paper,12pt]{article}
\usepackage{xcolor}
\definecolor{dblue}{RGB}{0,0,139}
\colorlet{celestk}{dblue}
\NewDocumentCommand{\wvQed}{O{celestk}o}
{%
\begingroup
\IfNoValueTF{#2}{\color{#1}}{\color[#1]{#2}}%
\hfill$\nabla$%
\endgroup
}
\begin{document}
Tantra is an Expansion Device. \wvQed
The word appears in the hymns of the Rigveda such as in 10.71
\end{document}