"Black marker" effect in the text (sanitization used to hide passwords in code example)

There also is the Steven B. Se­gletes's censor package (documentation).

You can use \censor{blurg} to censor short pieces of text.

Long paragraphs can be blacked out with \blackout{foo\par bar}.

Censoring can be turned off via \StopCensoring.

\documentclass{article}
\usepackage{censor}

\begin{document}
When shall we \censor{three meet again}, in thunder, lightning or in rain?

Hi \blackout{Hello

Goodbye} Bye

\StopCensoring
When shall we \censor{three meet again}, in thunder, lightning or in rain?
\end{document}

enter image description here


Depending on whether you want to mark only short strings of text you could do something like this:

\documentclass{article}
\usepackage{calc}
\newif\ifmarksecrets % declare new switch
\marksecretstrue %comment or use \marksecretsfalse to display normal text
\newcommand{\secret}[1]{
   \ifmarksecrets % Show black rule
      \rule{\widthof{#1}}{\heightof{#1}}
   \else % Just display text
      #1
   \fi   
   }

\begin{document}
Foo foo foo \secret{VERY SECRET BAR} foo foo foo.
\end{document}

For larger boxes, TikZ can be used to draw anything anywhere on the page, but I'm in a bit of a hurry so I can't provide an example now.

Tags:

Fonts