Debian Codegraph @

texmf-dist/doc/latex/censor/censor.tex

raw
1 \documentclass{article}
2 \usepackage{verbatimbox,xcolor,mathtools}
3 \usepackage{censor}
4
5 \parindent 0in
6 \parskip 1em
7
8 \begin{document}
9
10 \vspace*{0in}
11 \begin{center}
12 \LARGE The \textsf{censor} Package\\
13 \small \rule{0in}{1em}Tools for Producing Redacted Documents\\
14 \large \rule{0in}{2em} Steven B. Segletes\\
15 [email protected]\\
16 \rule{0em}{2em}\censorversiondate\\
17 v\censorversionnumber
18 \end{center}
19
20 \section{Introduction}
21
22 The \textsf{censor} package allows a convenient redaction/censor
23 capability to be employed, for those who need to protect restricted
24 information, as well as for those who are forced to work in a less
25 efficient environment when dealing with restricted information.
26
27 Let us assume you have a document for internal use, containing some
28 restricted (\textit{i.e.}, private, sensitive, proprietary or
29 classified) information. To give a very short (fictitious) example:
30
31 {\addtolength{\leftskip}{2.3em}
32 RESTRICTED SOURCE: \hrulefill
33
34 \verb|The Liberty missile, with charge diameter (CD) of 80~mm, |\\
35 \verb|revealed a penetration capability of 1.30 1.19, and |\\
36 \verb|1.37~CD in three recent tests into armor steel.|
37
38 RESTRICTED OUTPUT: \hrulefill
39
40 The Liberty missile, with charge diameter (CD) of 80~mm, revealed a
41 penetration capability of 1.30 1.19, and 1.37~CD in three recent tests
42 into armor steel.
43
44 \hrulefill
45
46 }
47
48 Censor/redaction capabilities are desirable to sanitize the information.
49 This would accomplish two things: allow for wider distribution of the
50 output and/or allow a less sensitive output to be stored locally with
51 fewer storage controls.
52
53 There are two modes in which the censor package can be used: (i) when
54 the source (.tex file) remains restricted/secure; and (ii) when the source
55 (.tex file) is public/unsecure.
56
57 \clearpage
58 \section{Mode I: Restricted/Secure Source (.tex file)}
59
60 In this mode, you create the source in a restricted/secure environment,
61 but would like to produce output that can be more widely distributed, or
62 stored in a less restricted location. With the addition of
63 \verb|\usepackage{censor}| to your document preamble, the \verb|\censor|
64 command becomes accessible to block out key identifiers:
65
66 {\addtolength{\leftskip}{2.3em}
67 CENSORED RESTRICTED SOURCE: \hrulefill
68
69 \verb|The \censor{Liberty} missile, with charge diameter (CD) of|\\
70 \verb|\censor{80}~mm, revealed a penetration capability of 1.30|\\
71 \verb|1.19, and 1.37~CD in three recent tests into armor steel.|
72
73 CENSORED NO-LONGER-RESTRICTED OUTPUT: \hrulefill
74
75 The \censor{Liberty} missile, with charge diameter (CD) of
76 \censor{80}~mm, revealed a penetration capability of 1.30 1.19, and
77 1.37~CD in three recent tests into armor steel.
78
79 \hrulefill
80
81 }
82
83 The censored version of the output is (presumably) less sensitive in its
84 content, and my be stored in or distributed to a less sensitive
85 environment (\textit{e.g.}, as a hardcopy). The censored words are not part
86 of the output document (hardcopy or electronic), even though the space
87 allocated for the redaction is identical to the original word being
88 redacted.
89
90 The document may also be printed out in its restricted (uncensored)
91 form, merely with the addition of the \verb|\StopCensoring| command at
92 the beginning of the document:
93
94 {\addtolength{\leftskip}{2.3em}
95 UNCENSORED RESTRICTED SOURCE: \hrulefill
96
97 \verb|\StopCensoring|\\
98 \verb| |\\
99 \verb|The \censor{Liberty} missile, with charge diameter (CD) of|\\
100 \verb|\censor{80}~mm, revealed a penetration capability of 1.30,|\\
101 \verb|1.19, and 1.37~CD in three recent tests into armor steel.|
102
103 UNCENSORED RESTRICTED OUTPUT: \hrulefill
104
105 \StopCensoring
106
107 The \censor{Liberty} missile, with charge diameter (CD) of
108 \censor{80}~mm, revealed a penetration capability of 1.30, 1.19, and
109 1.37~CD in three recent tests into armor steel.
110
111 \hrulefill
112
113 }
114
115 As of version 3.0, the ability to censor ``boxed'' objects like images
116 and/or tabular environments is made possible with the \verb|\censorbox|
117 command. As an example, one could use the following source:
118
119 {\addtolength{\leftskip}{2.3em}
120 UNCENSORED RESTRICTED SOURCE: \hrulefill
121
122 \verb|The \censor{Liberty} missile, with charge diameter (CD) of|\\
123 \verb|\censor{80}~mm, revealed a penetration capability into armor|\\
124 \verb|steel, as detailed in Table 1.|\\
125 \verb||\\
126 \verb|\begin{table}[ht]|\\
127 \verb|\begin{center}|\\
128 \verb|\textbf{Table 1. \censor{Liberty} Missile Test Data}\\|\\
129 \verb|\censorbox{%|\\
130 \verb| \small\begin{tabular}{cc}|\\
131 \verb| Standoff & Penetration \\|\\
132 \verb| (CD) & (CD) \\|\\
133 \verb| \hline|\\
134 \verb| 5.0 & 1.30 \\|\\
135 \verb| 6.0 & 1.19 \\|\\
136 \verb| 6.8 & 1.37\\|\\
137 \verb| \end{tabular}%|\\
138 \verb|}|\\
139 \verb|\end{center}|\\
140 \verb|\end{table}|\\
141
142 \hrulefill
143
144 }
145
146 in order to turn, what would otherwise be the following restricted
147 output into a censored, unrestricted table.
148
149 {\addtolength{\leftskip}{2.3em}
150 UNCENSORED RESTRICTED OUTPUT: \hrulefill
151
152 The Liberty missile, with charge diameter (CD) of
153 80~mm, revealed a penetration capability into armor steel, as detailed
154 in Table 1.
155
156 \begin{table}[ht]
157 \begin{center}
158 \textbf{Table 1. Liberty Missile Test Data}\\
159 \small\begin{tabular}{cc}
160 Standoff & Penetration \\
161 (CD) & (CD) \\
162 \hline
163 5.0 & 1.30 \\
164 6.0 & 1.19 \\
165 6.8 & 1.37\\
166 \end{tabular}
167 \end{center}
168 \end{table}
169
170 \clearpage CENSORED UNRESTRICTED OUTPUT: \hrulefill
171
172 The \censor{Liberty} missile, with charge diameter (CD) of
173 \censor{80}~mm, revealed a penetration capability into armor steel, as
174 detailed in Table 1.
175
176 \begin{table}[ht]
177 \begin{center}
178 \textbf{Table 1. \censor{Liberty} Missile Test Data}\\
179 \censorbox{%
180 \small\begin{tabular}{cc}
181 Standoff & Penetration \\
182 (CD) & (CD) \\
183 \hline
184 5.0 & 1.30 \\
185 6.0 & 1.19 \\
186 6.8 & 1.37\\
187 \end{tabular}%
188 }
189 \end{center}
190 \end{table}
191 \par
192 \hrulefill
193
194 }
195
196
197 As of version 2.0, there is provided a block-censor
198 capability, for redacting larger blocks of text.
199 This new command is \verb|\blackout|, and is used in the form
200 \verb|\blackout{Block of text}|. This nice thing about this command
201 is that it can stretch across line, paragraph, and page boundaries
202 conveniently.
203 For example,
204
205 {\addtolength{\leftskip}{2.3em}
206 UNCENSORED RESTRICTED SOURCE: \hrulefill
207
208
209 \verb|\blackout{|\\
210 \verb|The Liberty missile, with charge diameter (CD) of 80~mm,|\\
211 \verb|revealed a penetration capability of 1.30, 1.19, and 1.37~CD|\\
212 \verb|in three recent tests into armor steel.}|\\
213 \verb| |\\
214 \verb|New paragraph.}|
215
216 CENSORED UNRESTRICTED OUTPUT: \hrulefill
217
218 \blackout{%
219 The Liberty missile, with charge diameter (CD) of
220 80~mm, revealed a penetration capability of 1.30, 1.19, and
221 1.37~CD in three recent tests into armor steel. xxx
222
223 New paragraph.
224 }
225
226 \hrulefill
227
228 }
229
230 Prior to V4.0, \verb|\blackout| did not conveniently work across
231 environment boundaries, such as math or tabular.
232 To blackout the whole tabular environment, one could use
233 the \verb|\censorbox| command as has been shown.
234 Presently, however, there is another option---to censor
235 cell-by-cell using a shorthand notation.
236
237 The \verb|\blackout| macro now allows uncensored content to be \textit{escaped}
238 from its argument by delimiting it between \verb+|...|+ bars (note: the
239 closing escape bar must be in the same grouping level).
240 Thus, the censoring directive {\ttfamily\detokenize
241 {\blackout{This |is a| test}}}
242 renders as \blackout{This |is a| test}.
243
244 This escaping of text becomes essential if one wishes to execute
245 environments within a \verb|\blackout| argument.
246 Unless the environment name is escaped, it will break the command,
247 since the environment name itself would be replaced with censoring
248 commands.
249 As of v4.2, tokens of catcode 4 (the \verb|&| token) are intercepted
250 and automatically passed through to the output stream, which can
251 be of use in censoring \verb|tabular| expressions.
252 Here shows how a partial and full censor could be accomplished, with
253 the use of appropriate text-escaping delimiters, instead of a
254 \verb|\censorbox|:
255
256 \begingroup
257 \begin{verbatim}
258 \blackout{
259 |\begin{tabular}{|c|c|}
260 \hline
261 Title 1 & Title 2 \\
262 \hline
263 a & |bbb\\
264 cc| & dd\\
265 \hline
266 \end{tabular}|
267 |\begin{tabular}{|c|c|}|
268 \hline
269 Title 1 & Title 2 \\
270 \hline
271 a & bbb \\
272 cc & dd\\
273 \hline
274 |\end{tabular}|
275 }
276 \end{verbatim}
277
278 \blackout{
279 |\begin{tabular}{|c|c|}
280 \hline
281 Title 1 & Title 2 \\
282 \hline
283 a & |bbb\\
284 cc| & dd\\
285 \hline
286 \end{tabular}|
287 |\begin{tabular}{|c|c|}|
288 \hline
289 Title 1 & Title 2 \\
290 \hline
291 a & bbb \\
292 cc & dd\\
293 \hline
294 |\end{tabular}|
295 }
296
297 \StopCensoring
298
299 For comparison, the uncensored tabulars are:
300
301 \blackout{
302 |\begin{tabular}{|c|c|}
303 \hline
304 Title 1 & Title 2 \\
305 \hline
306 |a| & |bbb|\\
307 |cc| & dd\\
308 \hline
309 \end{tabular}|
310 |\begin{tabular}{|c|c|}|
311 \hline
312 Title 1 & Title 2 \\
313 \hline
314 a&bbb\\
315 cc&dd\\
316 \hline
317 |\end{tabular}|
318 }
319
320 \endgroup
321
322
323 \noindent**v4.0 CHANGE**:
324 The restriction on \verb|\blackout| \textit{not} ending on glue
325 is no longer applicable.
326
327 Finally, the argument to \verb|\blackout| can, in limited situations,
328 process macros; However,
329 the macros are not expanded by default.
330 See section~\ref{S:A} for details on what is possible with respect to
331 the censoring of macro content with this package.
332
333
334 \section{Mode II: Public/Unsecure Source (.tex file)}
335
336 This mode is envisioned for users who must bear a large level of
337 inconvenience to work in a restricted/secure environment (generally
338 meaning in a location physically removed from one's desk). Its use is
339 envisioned to allow a large percentage of a document to be created in an
340 public/unsecure environment, with only the restricted details being
341 completed in a restricted/secure environment.
342
343 After including the \verb|\usepackage{censor}| command in the document
344 preamble, the \verb|\censor*| and \verb|\censorbox*| commands becomes
345 accessible. The way this author envisions its use is as follows:
346
347 {\addtolength{\leftskip}{2.3em}
348 CENSORED UNRESTRICTED SOURCE: \hrulefill
349
350 \verb|% KEYWORD IDENTIFIERS:|\\
351 \verb|\def\Missile{\censor*{7}}|\\
352 \verb|\def\Size{\censor*{2}}|\\
353 \verb|\def\TableOne{\censorbox*[\small]{26}{5}{3.5}}|\\
354 \verb||\\
355 \verb|The \Missile{} missile, with charge diameter (CD) of|\\
356 \verb|\Size~mm, revealed a penetration capability ranging from|\\
357 \verb|1.19--1.37~CD in three recent tests into armor steel, as|\\
358 \verb|detailed in Table 1.|\\
359 \verb||\\
360 \verb|\begin{table}[ht]|\\
361 \verb|\begin{center}|\\
362 \verb|\textbf{Table 1. \Missile{} Missile Test Data}\\|\\
363 \verb|\TableOne{}|\\
364 \verb|\end{center}|\\
365 \verb|\end{table}|\\
366
367 CENSORED UNRESTRICTED OUTPUT: \hrulefill
368
369 \def\Missile{\censor*{7}}
370 \def\Size{\censor*{2}}
371 \def\TableOne{\censorbox*[\small]{26}{5}{3.5}}
372
373 The {\Missile} missile, with charge diameter (CD) of {\Size}~mm, revealed a
374 penetration capability ranging from 1.19--1.37~CD in three recent tests
375 into armor steel, as detailed in Table 1.
376
377 \begin{table}[ht]
378 \begin{center}
379 \textbf{Table 1. {\Missile} Missile Test Data}\\
380 {\TableOne}
381 \end{center}
382 \end{table}
383
384 \hrulefill
385
386 }
387
388 In this way, the source (.tex file) contains no restricted information,
389 and may thus be prepared in an unrestricted environment. The argument
390 to the \verb|\censor*| command is a number representing the approximate
391 width of the redaction (in ex's). In the case of the \verb|\censorbox*|
392 command, it has three mandatory arguments and one optional argument
393 (note that the unstarred form of the \verb|\censorbox| command has not
394 three, but one, mandatory arguments). The mandatory arguments to
395 \verb|\censorbox*| are box width (in ex's), box height (in multiples of
396 \verb|\baselineskip|) and finally the depth below the baseline where the
397 bottom of the box should be (in multiples of \verb|\baselineskip|). The
398 optional argument can include commands that you want in force for the
399 \verb|\censorbox| command, most typically fontsize commands, which will
400 affect the size of the an ex and \verb|\baselineskip|.
401
402 Because the redaction width is only approximate, it is possible that the
403 censored and uncensored originals might have differing text
404 justification.
405 In the text, empty braces may be added after the
406 keyword identifier macros so as to produce the proper interaction
407 with the subsequent whitespace and punctuation.
408
409 Because the source (.tex) file contains no restricted information, the
410 use of \verb|\StopCensoring| cannot (in and of itself) produce the
411 restricted document. Rather it will produce the following:
412
413 {\addtolength{\leftskip}{2.3em}
414 UNCENSORED UNRESTRICTED OUTPUT: \hrulefill
415
416 \StopCensoring
417
418 \def\Missile{\censor*{7}}
419 \def\Size{\censor*{2}}
420 \def\TableOne{\censorbox*[\small]{26}{5}{3.5}}
421
422 The {\Missile} missile, with charge diameter (CD) of {\Size}~mm, revealed a
423 penetration capability ranging from 1.19--1.37~CD in three recent tests
424 into armor steel, as detailed in Table 1.
425
426 \begin{table}[ht]
427 \begin{center}
428 \textbf{Table 1. {\Missile} Missile Test Data}\\
429 {\TableOne}
430 \end{center}
431 \end{table}
432
433 \hrulefill
434
435 }
436
437 In order to produce the uncensored, restricted output, the unrestricted
438 source file must be moved into the restricted/secure environment and be
439 subject to a small amount of additional editing. Once in the restricted
440 environment, the source (.tex file) may be edited such that the censored
441 keyword identifiers are filled in with their restricted values and, in
442 the process, changing the \verb|\censor*| and \verb|\censorbox*|
443 commands to \verb|\censor| and \verb|\censorbox|, respectively. This
444 and the addition of the \verb|\StopCensoring| command to the file will
445 produce the uncensored, restricted result:
446
447 {\addtolength{\leftskip}{2.3em}
448 UNCENSORED NO-LONGER-UNRESTRICTED SOURCE: \hrulefill
449
450 \verb|\StopCensoring|\\
451 \verb|\def\Missile{\censor{Liberty}}|\\
452 \verb|\def\Size{\censor{80}}|\\
453 \verb|\def\TableOne{\censorbox{%|\\
454 \verb| \begin{tabular}{cc}|\\
455 \verb| Standoff & Penetration \\|\\
456 \verb| (CD) & (CD) \\|\\
457 \verb| \hline|\\
458 \verb| 5.0 & 1.30 \\|\\
459 \verb| 6.0 & 1.19 \\|\\
460 \verb| 6.8 & 1.37\\|\\
461 \verb| \end{tabular}%|\\
462 \verb|}}|\\
463 \verb||\\
464 \verb|The {\Missile} missile, with charge diameter (CD) of|\\
465 \verb|{\Size}~mm, revealed a penetration capability ranging|\\
466 \verb|from 1.19--1.37~CD in three recent tests into armor|\\
467 \verb|steel, as detailed in Table 1.|\\
468 \verb||\\
469 \verb|\begin{table}[ht]|\\
470 \verb|\begin{center}|\\
471 \verb|\textbf{Table 1. {\Missile} Missile Test Data}\\|\\
472 \verb|{\TableOne}|\\
473 \verb|\end{center}|\\
474 \verb|\end{table}|\\
475
476 UNCENSORED RESTRICTED OUTPUT: \hrulefill
477
478 \StopCensoring
479
480 \def\Missile{\censor{Liberty}}
481 \def\Size{\censor{80}}
482 \def\TableOne{\censorbox{%
483 \begin{tabular}{cc}
484 Standoff & Penetration \\
485 (CD) & (CD) \\
486 \hline
487 5.0 & 1.30 \\
488 6.0 & 1.19 \\
489 6.8 & 1.37\\
490 \end{tabular}%
491 }}
492
493 The {\Missile} missile, with charge diameter (CD) of
494 {\Size}~mm, revealed a penetration capability ranging
495 from 1.19--1.37~CD in three recent tests into armor
496 steel, as detailed in Table 1.
497
498 \begin{table}[ht]
499 \begin{center}
500 \textbf{Table 1. {\Missile} Missile Test Data}\\
501 {\TableOne}
502 \end{center}
503 \end{table}
504
505 \hrulefill
506
507 }
508
509 The only changes required of the document were at the very beginning,
510 among the keyword identifiers. The primary text of the source document
511 remained unaltered. Note also that the censored, unrestricted output
512 may also be obtained from the no-longer-unrestricted source by removing
513 the \verb|\StopCensoring| command at the beginning of the file.
514
515 It is not envisioned that the \verb|\blackout|
516 command, discussed in the prior section, is used in this mode, where
517 the source file is in an unsecure environment.
518
519 \section{Contiguous Blackout}
520
521 The author received some negative feedback concerning the appearance
522 resulting from the \verb|\blackout| command. Generally, people did not
523 like the fact that spaces were not blacked out.
524 To this end, the \verb|\xblackout| command is introduced in V3.10, which
525 \textit{cosmetically} blacks out the text more completely
526 (note, however, that underneath the more complete blackout are still
527 the word-length blackouts that otherwise compose \verb|\blackout|).
528
529 As of v4.2 of this package,
530 additional blacking-out provided by the \verb|\xblackout| macro
531 does not make use of any tunable parameters, but merely employs
532 the \verb|\fontdimen| parameters already provided by each font.
533 % is controlled
534 % by one resettable length which laps additional blacking atop the
535 % result of \verb|\blackout|.
536 %This length is defined in the macro \verb|\spacelap|, with
537 % a default value of \spacelap.
538
539 %During \verb|\xblackout|, a
540 % right- and left-lapped blacking of dimension \verb|\spacelap| is
541 % applied before and after each space character, respectively.
542
543 The blacking from \verb|\xblackout| is intended to be less ``choppy''
544 than that of \verb|\blackout|. However, it too has some drawbacks.
545 Importantly, because spaces are now subject to blackout, any
546 space that would otherwise be ignored by \verb|\ignorespaces| or
547 \verb|\ignorespacesafterend| will not be ignored during
548 the \verb|\xblackout|.
549 These will include bounding spaces in \verb|tabular| cells as well
550 as trailing spaces after the \verb|\end| of environments.
551
552 With these caveats,
553 it may still be found preferable to the \verb|\blackout| macro, as
554 shown in the example below.
555
556 {\addtolength{\leftskip}{2.3em}
557 UNCENSORED RESTRICTED SOURCE: \hrulefill
558
559
560 \verb|\|\textit{x}\verb|blackout{|\\
561 \verb|The Liberty missile, with charge diameter (CD) of 80~mm,|\\
562 \verb|revealed a penetration capability of 1.30, 1.19, and 1.37~CD|\\
563 \verb|in recent testing here. The tests were into armor steel.}|\\
564 \verb| |\\
565 \verb|New paragraph} with open text.|
566
567 UNCENSORED RESTRICTED OUTPUT: \hrulefill
568
569 {
570 The Liberty missile, with charge diameter (CD) of
571 80~mm, revealed a penetration capability of 1.30, 1.19, and
572 1.37~CD in recent testing here. The tests were into armor steel.
573
574 New paragraph} with open text.
575
576 CENSORED UNRESTRICTED OUTPUT (\verb|\blackout{}|): \hrulefill
577
578 \blackout{
579 The Liberty missile, with charge diameter (CD) of
580 80~mm, revealed a penetration capability of 1.30, 1.19, and
581 1.37~CD in recent testing here. The tests were into armor steel.
582
583 New paragraph} with open text.
584
585 CENSORED UNRESTRICTED OUTPUT (\verb|\xblackout{}|): \hrulefill
586
587 \xblackout{
588 The Liberty missile, with charge diameter (CD) of
589 80~mm, revealed a penetration capability of 1.30, 1.19, and
590 1.37~CD in recent testing here. The tests were into armor steel.
591
592 New paragraph} with open text.
593
594 \hrulefill
595
596 }
597
598 \section{Can I Censor Control Sequences?\label{S:A}}
599
600 In general, the \textsf{censor} package is designed to operate on
601 literal text.
602 This is especially true if you are using the \verb|\censor| macro, which
603 is designed for use on a single word, rather than extended text.
604 However, it is also clear that an extended text passage may contain
605 various macro markup, for example, italic phrases.
606
607 The \verb|\blackout| and \verb|\xblackout| macros can at least digest
608 control sequences in the input-text stream.
609 How the sequences are handled may require some user intervention.
610
611 Certain macro that are known to expand directly into typeset characters
612 are handled automatically.
613 These include \verb|\$|, \verb|\&|, \verb|\#|, \verb|\%|, \verb|\_|,
614 \verb|\o|, \verb|\O|, \verb|\oe|, \verb|\OE|, \verb|\aa|, \verb|\AA|,
615 \verb|\ae|, \verb|\AE|, \verb|\l|, and \verb|\L|.
616 Other macros, that are part of the \LaTeX{} accents, are likewise
617 handled seamlessly, including \verb|\`|, \verb|\=|, \verb|\'|,
618 \verb|\.|, \verb|\^|, \verb|\"|, \verb|\u|, \verb|\d|, \verb|\v|,
619 \verb|\b|, \verb|\H|, \verb|\t|, \verb|\~|, and \verb|\c|.
620
621 For macros outside of these special cases, the default behavior is
622 to echo the macro into the output stream in a literal
623 (unexpanded) form.
624
625 Consider the following line of \LaTeX{} code:
626
627 \verb|\blackout{This is \textit{italic text}}|\\
628 \blackout{|This is \textit{italic text}|\\This is \textit{italic text}}
629
630 With censoring disabled, it would normally render as in the 2nd line.
631 When enabled, it renders as the 3rd line.
632 The \verb|\textit| is still part of the blackout rendering, but the
633 \textit{input} to \verb|\textit| has been censored and the
634 censor rule does not change its presented shape under the influence
635 of \verb|\textit|.
636
637 Some macros, however, expand to literal text.
638 Because macros are, by default, carried literally into the output, they
639 will only expand into text \textit{after} the censoring has been
640 applied.
641 Consider the following line of \LaTeX{} code, in which the macro
642 \verb|\today| is not rendered until after censoring is complete:
643
644 \verb|\blackout{Today's date is \today.}|\\
645 \blackout{|Today's date is \today.|\\Today's date is \today.}
646
647 If the macro is expandable (and not all are), the \verb|\blackout|
648 and \verb|\xblackout| macros are set up to intercept callouts to
649 the primitive \verb|\expanded| and act upon them prior to censoring.
650 Therefore, with one small change to the above example, the problem
651 can be remedied:
652
653 \verb|\blackout{Today's date is \expanded{\today}.}|\\
654 \blackout{|Today's date is \expanded{\today}.|\\%
655 Today's date is \expanded{\today}.}
656
657 If a control sequence is not expandable, then there is, in general, no way to
658 censor its \textit{output}.\footnote{%
659 In some cases, such as
660 \texttt{\string\maketitle}, you can define
661 \texttt{\detokenize{\author{\censor{...}}}} in the preamble, to bring
662 about the effect, even if \texttt{\string\maketitle} falls within a
663 \texttt{\string\blackout} argument.
664 }
665 Therefore, you have two options: you can remove it (and its arguments)
666 from the blackout altogether, or else you can leave it
667 in the blackout, but ``escape'' its non-typeset arguments between $|$ escape
668 character delimiters.
669 In either case, however, the output of the unexpandable macro will be
670 visible to the reader, as in the example below, where the arguments to the
671 macro \verb|\ref| are escaped from the blackout.
672
673 %\settcEscapechar{|}
674 \verb+\blackout{In Section \ref|{S:A}|, we discuss censored macros}+\\
675 \StopCensoring
676 \blackout{In Section \ref|{S:A}|, we discuss censored macros}\\
677 \RestartCensoring
678 \blackout{In Section \ref|{S:A}|, we discuss censored macros}
679
680 \section{Can I Censor Math?}
681
682 As of v4.2, the package makes an attempt to facilitate the
683 censoring of mathematical expressions, when given as part of the
684 argument to \verb|\blackout| and \verb|\xblackout|.
685 Namely, tokens with catcodes 3, 7 and 8 (typically,
686 \verb|$|, \verb|^|, and \verb|_|) are intercepted and passed
687 through to the output stream without censoring
688 (Note: the same is true of catcode 4, the \verb|&| token, which can
689 be of use in censoring \verb|tabular| as well as
690 \verb|amsmath| expressions.)
691
692 Because macros are, likewise, passed through by default without
693 censoring, this means the expression
694 ``\verb|the equation $\frac{E}{m}=c^{2}$,|'' will be rendered under
695 \verb|\blackout| as \blackout{the equation $\frac{E}{m}=c^{2}$,}.
696 There are several points that \textbf{\textit{must}} be noted in
697 a case such as this. First, the arguments to super/sub-scripts
698 must be embraced, even if a single character in length.
699 Secondly, censored math scripts will not be reduced to script size, but
700 will be censored using the height and depth of the pre-defined
701 censor rule (this can
702 affect the vertical spacing of lines).
703 Finally, customary math spacing associated with operators,
704 punctuation, etc., may be lost, depending on the expression.
705
706 As of v4.2, \verb|\blackout| will, by default, automatically
707 detect and censor macros of math-mode Greek letters, such as
708 \verb|\alpha|, \verb|\beta|, etc.
709 If one, however, wishes to not waste compilation time searching
710 for such instances, one may disable the feature with the switch
711 \verb|\censormathgreekfalse|.
712
713
714 \section{Censor-Rule Marks}
715
716 The censor (blacking) mark is a \verb|\rule| which has a depth
717 \(-\)0.3ex (\textit{i.e.}, below the baseline), and a total height
718 of 2.1ex, by default.
719 The characteristics of that rule may be changed by setting
720 the following two lengths.
721
722 \itshape
723 \verb| \censorruledepth=|length\\
724 \verb| \censorruleheight=|length
725 \upshape
726
727 When using \verb|\blackout| and \verb|\xblackout|, periods are
728 now censored by default.
729 If, however, you wish the prior approach of not censoring periods,
730 you may redefine \verb|\censordot| to something else, for example,
731
732 \verb| \renewcommand\censordot{.}|
733
734 to make them visible in the censored document.
735
736 \section{Usage Summary}
737
738 The complete set of commands available to the \textsf{censor} package,
739 to bring about text redaction, are:\\
740 {~\\
741 \verb| \censor{|\it text\tt\}\\
742 \verb| \censor*{|\it width multiplier\tt\}\\
743 \verb| \censorbox[|\it pre-commands\tt]\{\it object box\tt\}\\
744 \verb| \censorbox*[|\it pre-commands\tt]\{\it width mult.\tt\}\{\it
745 height mult.\tt\}\{\it depth mult.\tt\}\\
746 \verb| \blackout{|\it extended text passage\tt\}\\
747 \verb| \xblackout{|\it extended text passage\tt\}\\
748 \verb| \StopCensoring|\\
749 \verb| \RestartCensoring|\\
750 \verb| \censorruledepth=|\it length\\
751 \verb| \censorruleheight=|length\\
752 %\verb| \renewcommand\spacelap{|\it length expression\tt\}\\
753 \verb| \renewcommand\censordot{|\it token or instruction\tt\}\\
754 \verb| \censormathgreektrue| \rm(default) or \verb|\censormathgreekfalse|\\
755 ~\\}
756 The star ({\tt*}) version of the commands is envisioned when the source
757 document is being created in an unsecure environment, whereas, the
758 unstarred version is when the document source may be created in a secure
759 environment.
760 In the star ({\tt*}) commands, width multipliers are given in ex's,
761 whereas height and depth multipliers are given in multiples of
762 \verb|\baselineskip|. The depth indicates the distance below the
763 baseline where the bottom of a boxed object is to be placed (this
764 command has a more direct effect for inline use, whereas use within
765 environments is often overridden by the environment). The use of
766 pre-commands will typically be fontsize commands, so that measurements
767 of ex's and \verb|\baselineskip| are done in a relevant fontsize.
768
769 Censoring may be dynamically turned off and on in a document with the
770 use of the \verb|\StopCensoring| and \verb|\RestartCensoring| commands,
771 respectively. The default is censoring `on.'
772
773 \subsection{\textit{Caveat Emptor}}
774
775 Here is some added information that users of the package should know.
776
777 \begin{itemize}
778
779 \item As of package version v4.4, censoring of unicode characters such as umlauts
780 is now supported in pdflatex (it had already been supported in lualatex and
781 xelatex).
782
783 \item As of package version v4.0, the token-cycling pseudo-environments of the
784 \textsf{tokcycle} package were used to process the tokens of
785 the \verb|\blackout| and \verb|\xblackout| macros.
786 While the syntax of these macros is unchanged, one has the additional
787 option of invoking them using the pseudo-environment syntax of
788 \textsf{tokcycle} as
789
790 \verb|\blackoutenv Text to blackout\endblackoutenv|:\\
791 \blackoutenv Text to blackout\endblackoutenv{} and\\
792 \verb|\xblackoutenv Text to blackout\endxblackoutenv|:\\
793 \xblackoutenv Text to blackout\endxblackoutenv.
794
795 \item Because \verb|\blackout| and \verb|\xblackout| use
796 tokcycle-package environments to perform their actions, the
797 macro \verb|\settcEscapechar| can be used to reset the escape
798 character to something other than $|$, in accordance with
799 the documented \textsf{tokcycle}-package commands.
800
801
802 \item It is preferable not to apply \verb|\censor| to whitespace, or text
803 justification could be adversely affected. If one wishes to censor a
804 multi-word phrase, such as ``Little Bo Peep,'' it is recommended to do
805 it as follows:\\
806 \verb| \xblackout{Little Bo Peep}|\\
807 If such a phrase is to be used repeatedly through a document,
808 it is most convenient to place it as a macro:\\
809 \verb| \newcommand\CenName{\xblackout{Little Bo Peep}}|\\
810 such that subsequent reference is done indirectly:\\
811 \verb| We examine the life of \CenName{} in this report,|\\
812 \verb| assured that \CenName{} line breaks.|\\
813 \newcommand\CenName{\xblackout{Little Bo Peep}}
814 \verb| |We examine the life of \CenName{} in this report, assured that
815 \CenName{} line breaks.
816
817 \item Censoring can still affect text justification, because
818 censored words are never hyphenated across line
819 boundaries, whereas the original text may have been.
820 For this reason, both \verb|\blackout| and \verb|\xblackout|
821 operate locally in \verb|\sloppy| mode, to minimize instances
822 of overfull \verb|\hbox|es.
823 (Note however, that effects of \verb|\sloppy| will take hold only
824 for blacked-out text that closes out a paragraph.)
825 If necessary, hyphenation points (\verb|\-|) or
826 \verb|\allowbreak| may be added to words subject to blackout
827 or xblackout, to facilitate manual hyphenation.
828
829 \item Users have asked for color support in the package.
830 I do not wish to hardwire color into the package---however,
831 if the \textsf{xcolor} package is loaded,
832 the following preamble definition will force censoring to be
833 in the selected color (in this example, red):
834
835 \verb| \def\censorcolor{red}|\\
836 \verb| \let\svcensorrule\censorrule|\\
837 \verb| \renewcommand\censorrule[1]{%|\\
838 \verb| \textcolor{\censorcolor}{\svcensorrule{#1}}}|
839
840 Let's see if it works:
841
842 {\let\svcensorrule\censorrule
843 \renewcommand\censorrule[1]{\textcolor{red}{\svcensorrule{#1}}}
844 \addtolength\leftskip{2em}
845 Is this blacked out text censored in red?\\
846 \blackout{Is this blacked out text censored in red?}\par}
847
848 This technique can be used at the user's discretion to provide color
849 censoring.
850 The value of \verb|\censorcolor| can be redefined on the fly to change
851 the color of the censoring.
852
853 \end{itemize}
854
855 \clearpage
856 \section{Source Code}
857
858 The source code for \textsf{censor} is included below:
859
860 \verbfilenobox[\small]{censor.sty}
861
862 \end{document}