# Fill in the blank: text wrapping & math mode

I am making notes with blanks to fill in and would like to produce an instructor version with blanks filled in and a student version with blanks unfilled.

I would like a \fillin{ . . . } command that wraps text and allows math. The solution from Create fill-in-the-blank version of a document with ability to toggle blanks on and off works well for wrapping text, but censor does not allow math (or other font switching):

\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}


One idea I tried was to use ulem's uline, but color text white for the student version. This works for math mode, but text-wrapping fails:

\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}


Both ulem and soul can achieve what you're after, although it seems that the latter is slightly preferred. In the following examples, texts are colored red only for illustration purposes. Changing the color to white will "hide" the texts.

# Code

\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}


# Output

• With this approach, however, students can still select the "white" texts and copied them into a text editor to see the hidden materials, if they have access to a PDF version of the document. – Herr K. Nov 27 '13 at 7:26
• that's an interesting point. A solution that didn't allow that would be nice, but I'm tending toward handouts. – Chris Chudzicki Nov 27 '13 at 14:19
• I changed the code to \newcommand{\soulfill}[1]{\color{red}{\ul{#1}}\color{black}} in order to change the text back to black after the underlining is done. – Chris Chudzicki Nov 27 '13 at 14:53
• @mrc: sorry it was meant to be \textcolor, not \color. So \newcommand{\soulfill}[1]{\textcolor{red}{\ul{#1}}} should confine the coloring to just the underlined texts. – Herr K. Nov 27 '13 at 16:58