5

I am about to improve my lecture slides from last semester. Specifically, I would like to add a fill-in-the-blank option. I found this code suggestion (from here):

\documentclass{article}
\usepackage{censor}
\censorruledepth=-.2ex
\censorruleheight=.1ex
%\StopCensoring
\begin{document}
An the answer is \xblackout{forty two}.

The beginning six words of the Gettysburg Address are \blackout{Four score and seven years ago}.
\end{document}

I think that will be a very good method (Thank you Steven B. Segletes). However, I believe that a little bit of fine tuning could tremendously improve the learning experience of my students. So here is what I am looking for:

In the non-blackout version of my document (presentation), I would like the text (that is blacked out for the students) to appear in color (say blue).

I believe that this would allow my audience to follow my talks much better, since no effort is wasted on determining which parts (from the presentations) have to be manually copied and which not - an additional visual cue.

My thought is:

From the Censor Documentation I realize that I can use \StopCensoring and \RestartCensoring for switching between output options. How can I use the same switch to evoke colors. Something like:

\ifx{\RestartCensoring=True} 
\then{\renewcommand{\blackout}[][text=blue]{\blackout}} 
\else{Do noting} 
\fi

I am certain that the syntax of my if statement is incorrect, but since I am not sure how to implement this "little trick", this is all I got at the moment. Any help or totally different approaches are very welcome. Thanks guys!

  • 2
    Why not simply add \renewcommand\blackout[1]{\textcolor{red}{#1}} at the end of the preamble to compile your presentation without becoming entangled in conditionals? For the student version you only need add a % at the beginning of this line to restore the original \blackout command. – Fran Jan 5 '15 at 7:46
  • You can have a look at PAT. It uses the attribute mechanism from luatex (credit goes to Paul Isambert). – cjorssen Jan 5 '15 at 12:13
  • Thanks @Fran that seems to make more sense than my original suggestion. However, Steven B. Segletes provided a solution below that seems "more complete" in view of the Censor Package. – Raphael Jan 6 '15 at 2:24
  • Thanks @cjorssen , I appreciate the input, but Steven B. Segletes provided a smooth solution below. – Raphael Jan 6 '15 at 2:25
5

Perhaps something like this (EDITED to provide capability for \censorboxes as well):

\documentclass{article}
\usepackage{censor,xcolor}
\censorruledepth=-.2ex
\censorruleheight=.1ex
\makeatletter
\renewcommand\StopCensoring{%
           \def\censor##1{\textcolor{blue}{##1}}%
           \def\censorbox##1{\bgroup\color{blue}\un@censorbox{##1}\egroup}%
           \let\xblackout\blackout%
}
  \renewcommand\censor@box[2][]{\fboxsep=0pt\fbox{\color{white}%
                      #1\setbox0\hbox{#2}%
                      \rule[-\the\dp0]{\the\wd0}{\the\ht0+\the\dp0}}}
\makeatother
\begin{document}
And the answer is \censor{forty two}.
\StopCensoring

And the answer is \censor{forty two}.
\RestartCensoring

The beginning six words of the Gettysburg Address are \blackout{Four score and seven years ago}.
\StopCensoring

The beginning six words of the Gettysburg Address are \blackout{Four score and seven years ago}.
\RestartCensoring

The tabular answer is 
\censorbox{\begin{tabular}{|c|c|}\hline a & b\\ \hline\end{tabular}}
\StopCensoring

The tabular answer is 
\censorbox{\begin{tabular}{|c|c|}\hline a & b\\ \hline\end{tabular}}
\end{document}

enter image description here

  • Thank you Steven! This solution works perfectly. I am using different "Output Options" (Presentation, Presentation With Note Slides, Handout, Beamerarticle). For my Presentations, I placed the \StopCensoring command in the preamble, and now it automatically produces the blue text. In the handout and article, it leaves the blanks (since it is the censored version). – Raphael Jan 6 '15 at 2:19
  • Can I mark this as "The Solution" so that other users know that the original question has been answered (to the satisfaction of the questioner)? – Raphael Jan 6 '15 at 2:31
  • @Raphael To mark a preferred answer as the "accepted" solution, you click on the check mark in the left column next to that answer. After considering all the given answers, you should try to make a point to accept the best answer for any given question that you ask on this forum. (if you later change your mind, you can even unaccept an answer and accept another, though this is somewhat rare). – Steven B. Segletes Jan 6 '15 at 2:51
  • @Seven B. Segletes Your solution works great and I already updated all my presentations. It seems that the students really like/love it. Thanks – Raphael Jan 18 '15 at 23:03
  • 1
    Steven B. Selgetes Thanks for your response and all the work you do. I would like to make sure that you know that all my comments here are not complaints or anything like that. In fact, it is amazing what your tools (and all the other LaTeX tools) allow me to do. Sometimes I just try to find the silver bullet (to avoid extra/double work), although it is already a "high value solution". However, thank you for all your work and efforts. If you find an "ultimate solution", I will be happy to know. But also, I am already happy with what I can do so far. THANKS so much! – Raphael Jan 20 '15 at 20:25
1

You can simply redefine \blackout and \xblackout. (We suppose that color or xcolor package is loaded).

\def\xblackout{\textcolor{blue}}  \let\blackout=\xblackout
  • Thanks for tip @wipet. I decided to go with Steven B. Segletes code suggestion, since it allows me evoke other commands provided by the censor package. But thanks anyways. – Raphael Jan 6 '15 at 2:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.