\documentclass[oneside,9pt]{memoir}
\usepackage{soul}
\usepackage{cancel}
\usepackage{ulem}
\usepackage{lipsum}
\usepackage{xcolor}
\makeatletter
\def\SOUL@hlpreamble{%
\setul{\dp\strutbox}{\dimexpr\ht\strutbox+\dp\strutbox\relax}%
%\setul{}{2em}
\let\SOUL@stcolor\SOUL@hlcolor
\SOUL@stpreamble
}
\makeatother
\newcommand{\highlight}[2]{\sethlcolor{#1}\hl{#2}}
\newcommand{\myQuote}[4]{{\textsuperscript{\tiny\sffamily\bfseries\textcolor{#2}{ #3$\langle$}}}\textcolor{#2}{\highlight{#1}{#4}}}
\newcommand{\Ben}[1]{\myQuote{gray}{blue}{Ben}{#1}} % Ben Franklin
\newcommand{\cancelMe}[1]{\xcancel{\textit{\tiny #1}}}
\begin{document}
% https://www.keepinspiring.me/benjamin-franklin-quotes/
\Ben{``If you are active and prosperous, or young, or in good health, it may be easier for you to augment your means than to diminish your wants. But if you are wise, you will do both at the same time, young or \cancelMe{old}, rich or poor, sick or well; and if you are wise, you will do both in such a way as to augment the general happiness of society.''}
\vspace{0.5in}
\Ben{``If you are active and prosperous, or young, or in good health, it may be easier for you to augment your means than to diminish your wants. But if you are wise, you will do both at the same time, young or''} \cancelMe{old}, \Ben{``rich or poor, sick or well; and if you are wise, you will do both in such a way as to augment the general happiness of society.''}
\end{document}
当我尝试将 放入宏cancelMe
中时,出现“extra {”错误\Ben
。我猜这是“soul”及其hl
宏的嵌套问题???
理想情况下,我希望小文本在同一行垂直居中。
我希望第一个输出中相应的“旧”被划掉。这会引发错误。
答案1
用括号括起来\cancelMe{old}
。包\highlight
中的命令soul
会逐个遍历引号标记并分别处理它们。这样,\cancelMe
会不带参数执行。用括号括起来时,\cancelMe
会与其参数一起移动。
\documentclass[oneside,9pt]{memoir}
\usepackage{soul}
\usepackage{cancel}
\usepackage{ulem}
\usepackage{lipsum}
\usepackage{xcolor}
\makeatletter
\def\SOUL@hlpreamble{%
\setul{\dp\strutbox}{\dimexpr\ht\strutbox+\dp\strutbox\relax}%
%\setul{}{2em}
\let\SOUL@stcolor\SOUL@hlcolor
\SOUL@stpreamble
}
\makeatother
\newcommand{\highlight}[2]{\sethlcolor{#1}\hl{#2}}
\newcommand{\myQuote}[4]{{\textsuperscript{\tiny\sffamily\bfseries\textcolor{#2}{ #3$\langle$}}}\textcolor{#2}{\highlight{#1}{#4}}}
\newcommand{\Ben}[1]{\myQuote{gray}{blue}{Ben}{#1}} % Ben Franklin
\newcommand{\cancelMe}[1]{\xcancel{\textit{\tiny #1}}}
\begin{document}
% https://www.keepinspiring.me/benjamin-franklin-quotes/
\Ben{``If you are active and prosperous, or young, or in good health, it may be easier for you to augment your means than to diminish your wants. But if you are wise, you will do both at the same time, young or {\cancelMe{old}}, rich or poor, sick or well; and if you are wise, you will do both in such a way as to augment the general happiness of society.''}
\end{document}