我正在做需要填写空白的笔记,并想制作一个填写了空白的教师版本和一个未填写空白的学生版本。
我想要一个可以\fillin{ . . . }
换行并允许数学运算的命令。解决方案来自创建文档的填空版本,并可以打开或关闭空白适合于换行文本,但censor
不允许数学(或其他字体切换):
\documentclass{article}
\usepackage{censor}
\censorruledepth=-.2ex
\censorruleheight=.1ex
\begin{document}
\xblackout{this works fine this works fine this works fine this works fine this works fine this works fine this works fine this works fine this works fine this works fine }
\xblackout{this does not work $a+b$ this does not work $a+b$ this does not work $a+b$ this does not work $a+b$ this does not work $a+b$ this does not work $a+b$ this does not work $a+b$ this does not work $a+b$ this does not work $a+b$}
\end{document}
ulem
我尝试过的一个想法是使用uline
,但学生版的文字颜色为白色。这适用于数学模式,但文本换行失败:
\documentclass{article}
\usepackage{ulem,xcolor}
\newcommand{\fillin}[1]{\uline{\textcolor{white}{#1}}}
\begin{document}
\fillin{This allows math mode $a+b=c$, but the text-wrapping is broken This allows math mode $a+b=c$, but the text-wrapping is broken This allows math mode $a+b=c$, but the text-wrapping is broken}
\end{document}
答案1
ulem
和都soul
可以实现您的目标,尽管似乎后者更受欢迎。在以下示例中,文本仅出于说明目的而采用红色。将颜色更改为白色将“隐藏”文本。
代码
\documentclass{article}
\usepackage{ulem,xcolor}
\usepackage{soul}
\newcommand\ulemfill{\bgroup\color{red}\markoverwith % change red to white to hide text
{\textcolor{black}{\rule[-.6ex]{2pt}{.5pt}}}\ULon} % underline color for ulem
\setulcolor{black} % underline color for soul
\newcommand{\soulfill}[1]{\textcolor{red}{\ul{#1}}} % change red to white to hide text
\begin{document}
\ulemfill{This allows math mode $a+b=c$, but the text-wrapping is broken This allows math mode $a+b=c$, but the text-wrapping is broken This allows math mode $a+b=c$, but the text-wrapping is broken}
\vspace{20pt}
\soulfill{This allows math mode $a+b=c$, but the text-wrapping is broken This allows math mode $a+b=c$, but the text-wrapping is broken This allows math mode $a+b=c$, but the text-wrapping is broken}
\end{document}