Hiding part of text leaving blank space

I have often done the same thing; in the education community here in the U.S., it's called a skeleton outline.

I prepare the note for myself, including all diagrams, solutions, comments, etc. I also include extra vertical spacing because my students are not able to write as small or as neatly as LaTeX. (It would sure make my job simpler if they could!)

Finally, to prepare the student version, I go back to the sections I want to hide from my students and wrap them with

\color{white}{ here's the hidden text }

It's low tech, but as long as I make any edits in the original, complete file, creating the student version only takes a minute or two.


Use this answer as a starting point...

Put the code that has to be hidden inside the environment \begin{master}...\end{master}.

When you want the students' version uncomment the line

%\studenttrue

Complete MWE

\documentclass{report}
\usepackage{xcolor,lipsum}

\newif\ifstudent

%\studenttrue

\makeatletter
\newenvironment{master}{%
  \ifstudent\def\@eqnnum{{\normalfont \color{white} (\theequation)}}\color{white}%
  \else\def\@eqnnum{{\normalfont \normalcolor (\theequation)}}\normalcolor%
  \fi}{}
\makeatother

\begin{document}
\lipsum[1]

\begin{master}
  \lipsum[1]
  \begin{equation}
    \omega
  \end{equation}
  \lipsum[1]
\end{master}

\lipsum[1]
\begin{equation}
  \omega
\end{equation}
\lipsum[1]
\end{document} 

Of course the answer is full of limitations...


In this answer, List of Underlining Packages - Pros and Cons, I modified censor to underline with the text still intact, allowing for line breaks, even breaking the underline for descending letters (but it doesn't handle hyphenation). Most importantly, I added a math underlining/censoring capability.

So I took that solution, and removed the stuff that places the text there, leaving just the underlining. Then by setting \censorruleheight=0ex, the underline is set to zero thickness and so it disappears. So you have \censor for a string of words on a single line, \blackout for a group of words across multiple lines, and \mblackout for math expressions.

This approach does allow for blankspace that spans not only multiple lines, but even page breaks!

\documentclass{article}
\usepackage{censor}
\usepackage{stackengine}
\usepackage{scalerel}
\censorruleheight=0ex
\makeatletter
\long\def\blackout#1{%
  \def~{-}%
  \protected@edef\save@arg{#1}%
  \expandafter\censor@Block\save@arg\stringend\let~\sv@tilde}
\let\sv@cenword\@cenword
\newcommand\m@cenword[1]{\ThisStyle{%
  \stackengine{\mcensorruledepth}{$\SavedStyle\phantom{#1}$}%
    {\rule{\widthof{$\SavedStyle#1$}}{\the\censorruleheight}}{U}{c}{F}{T}{L}}}
\newcommand\mblackout[2][\dp\strutbox]{%
  \let\@cenword\m@cenword%
  \def\mcensorruledepth{#1}%
  \blackout{{#2}}%
  \let\@cenword\sv@cenword%
}
\makeatother
\parskip 1em
\begin{document}
The \verb|\censor| command can blackout \censor{this text} which appears on a single line.

The  \verb|\blackout| command allows the censoring of text even if it crosses a line/page boundary.
To test this macro, let's see \blackout{if this block of text is truly blacked out} across a line boundary.

For total blanking, there should be no need for \verb|\xblackout|.

But here is math versions, not black out, then blacked out:
\[ y = A x^2 + Bx + C + D\]
\[ y = \mblackout{A x^2} + Bx + \mblackout{C} + D\]

\[ y = \frac{a^3 + b^2 + c}{d_3}  + \frac{a^3 + b^2 + c}{d_3}\]
\[ y = \mblackout{\frac{a^3 + b^2 + c}{d_3}}  + \frac{a^3 + b^2 + c}{d_3}\]
\end{document}

enter image description here