1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
\documentclass{article}
\usepackage{censor}
\parindent 0in
\parskip 1em
\begin{document}
\vspace*{0in}
\begin{center}
\LARGE The \textsf{censor} Package\\
\small \rule{0in}{1em}Tools for Producing Redacted Documents\\
\large \rule{0in}{2em} Steven B. Segletes\\
steven.b.segletes.civ@mail.mil\\
\rule{0em}{2em}2012/09/10\\
v2.10
\end{center}
\section{Introduction}
The \textsf{censor} package allows a convenient redaction/censor
capability to be employed, for those who need to protect restricted
information, as well as for those who are forced to work in a more
inefficient environment when dealing with restricted information.
Let us assume you have a document for internal use, containing some
restricted (\textit{i.e.}, private, sensitive, proprietary or
classified) information. To give a very short (fictitious) example:
{\addtolength{\leftskip}{2.3em}
RESTRICTED SOURCE: \hrulefill
\verb|The Liberty missile, with charge diameter (CD) of 80~mm, |\\
\verb|revealed a penetration capability of 1.30 1.19, and |\\
\verb|1.37~CD in three recent tests into armor steel.|
RESTRICTED OUTPUT: \hrulefill
The Liberty missile, with charge diameter (CD) of 80~mm, revealed a
penetration capability of 1.30 1.19, and 1.37~CD in three recent tests
into armor steel.
\hrulefill
}
Censor/redaction capabilities are desirable to sanitize the information.
This would accomplish two things: allow for wider distribution of the
output and/or allow a less sensitive output to be stored locally with
fewer storage controls.
There are two modes in which the censor package can be used: (i) when
the source (.tex file) remains restricted/secure; and (ii) when the source
(.tex file) is public/unsecure.
\clearpage
\section{Mode I: Restricted/Secure Source (.tex file)}
In this mode, you create the source in a restricted/secure environment,
but would like to produce output that can be more widely distributed, or
stored in a less restricted location. With the addition of
\verb|\usepackage{censor}| to your document preamble, the \verb|\censor|
command becomes accessible to block out key identifiers:
{\addtolength{\leftskip}{2.3em}
CENSORED RESTRICTED SOURCE: \hrulefill
\verb|The \censor{Liberty} missile, with charge diameter (CD) of|\\
\verb|\censor{80}~mm, revealed a penetration capability of 1.30|\\
\verb|1.19, and 1.37~CD in three recent tests into armor steel.|
CENSORED NO-LONGER-RESTRICTED OUTPUT: \hrulefill
The \censor{Liberty} missile, with charge diameter (CD) of
\censor{80}~mm, revealed a penetration capability of 1.30 1.19, and
1.37~CD in three recent tests into armor steel.
\hrulefill
}
The censored version of the output is (presumably) less sensitive in its
content, and my be stored in or distributed to a less sensitive
environment (\textit{e.g.}, as a hardcopy). The censored words are not part
of the output document (hardcopy or electronic), even though the space
allocated for the redaction is identical to the original word being
redacted.
The document may also be printed out in its restricted (uncensored)
form, merely with the addition of the \verb|\StopCensoring| command at
the beginning of the document:
{\addtolength{\leftskip}{2.3em}
UNCENSORED RESTRICTED SOURCE: \hrulefill
\verb|\StopCensoring|\\
\verb| |\\
\verb|The \censor{Liberty} missile, with charge diameter (CD) of|\\
\verb|\censor{80}~mm, revealed a penetration capability of 1.30,|\\
\verb|1.19, and 1.37~CD in three recent tests into armor steel.|
UNCENSORED RESTRICTED OUTPUT: \hrulefill
\StopCensoring
The \censor{Liberty} missile, with charge diameter (CD) of
\censor{80}~mm, revealed a penetration capability of 1.30, 1.19, and
1.37~CD in three recent tests into armor steel.
\hrulefill
Additionally, as of version 2.0, there is provided a block-censor
capability, for redacting larger blocks of text. This new command
is \verb|\blackout|, and is used in the form
\verb|\blackout{Block of text}|. This nice thing about this command is
that it can stretch across line boundaries conveniently (and across
paragraph boundaries, a little less conveniently). For example,
}\RestartCensoring
{\addtolength{\leftskip}{2.3em}
UNCENSORED RESTRICTED SOURCE: \hrulefill
\verb|\blackout{|\\
\verb|The Liberty missile, with charge diameter (CD) of 80~mm,|\\
\verb|revealed a penetration capability of 1.30, 1.19, and 1.37~CD|\\
\verb|in three recent tests into armor steel.}|
CENSORED UNRESTRICTED OUTPUT: \hrulefill
\blackout{%
The Liberty missile, with charge diameter (CD) of
80~mm, revealed a penetration capability of 1.30, 1.19, and
1.37~CD in three recent tests into armor steel.}
\hrulefill
There are several caveats regarding the use of \verb|\blackout|. First,
its argument cannot, without help, extend across paragraph boundaries.
The help needed by \textsf{censor} is to insert the token \verb|\bpar|
on your blank lines that would normally constitute paragraph boundaries,
as shown in the example below:
\verb|\blackout{|\\
\verb|First paragraph to censor.|\\
\verb| \bpar|\\
\verb|Second paragraph to censor.}|\\
\vspace{-0.7em}%
will appear as
\blackout{
First paragraph to censor.
\bpar
Second paragraph to censor.}
Secondly, the argument cannot end on so-called ``glue,'' such as a space
or a carriage return. The following examples are, thus, bad forms of
the \verb|\blackout| command:
\verb|\blackout{Ends in space. Bad form }|
\verb|\blackout{Ends in carriage return. Bad form|\\
\verb|}|
Thirdly, periods are not censored (as of version 2.1). This is done
because it is necessary to preserve the period-space combination that
signifies end-of-sentence. In this way, {\LaTeX} can preserve spacing
in the redacted version that is identical to the unredacted version.
Fourthly, \verb|\blackout| does not work across environment boundaries,
such as math or tabular mode. You can blackout text in the table, cell
by cell; But you cannot blackout the whole tabular environment.
Finally, the argument to \verb|\blackout| can employ tokens; However,
the tokens are expanded into one large blackout, regardless of whether
the expanded token contains spaces. Thus
\verb|\blackout{\today}|
becomes \blackout{\today}, in spite of the fact that \verb|\today|,
given at the moment by \today, constains spaces.
}\RestartCensoring
\clearpage
\section{Mode II: Public/Unsecure Source (.tex file)}
This mode is envisioned for users who must bear a large level of
inconvenience to work in a restricted/secure environment (generally
meaning in a location physically removed from one's desk). Its use is
envisioned to allow a large percentage of a document to be created in an
public/unsecure environment, with only the restricted details being
completed in a restricted/secure environment.
After including the \verb|\usepackage{censor}| command in the document
preamble, the \verb|\censor*| command becomes accessible. The way this
author envisions its use is as follows:
{\addtolength{\leftskip}{2.3em}
CENSORED UNRESTRICTED SOURCE: \hrulefill
\verb|% KEYWORD IDENTIFIERS:|\\
\verb|\def\Missile{\censor*{7}}|\\
\verb|\def\Size{\censor*{2}}|\\
\verb| |\\
\verb|The {\Missile} missile, with charge diameter (CD) of|\\
\verb|{\Size}~mm, revealed a penetration capability of 1.30 1.19,|\\
\verb|and 1.37~CD in three recent tests into armor steel.|
CENSORED UNRESTRICTED OUTPUT: \hrulefill
\def\Missile{\censor*{7}}
\def\Size{\censor*{2}}
The {\Missile} missile, with charge diameter (CD) of {\Size}~mm, revealed a
penetration capability of 1.30 1.19, and 1.37~CD in three recent tests
into armor steel.
\hrulefill
}
In this way, the source (.tex file) contains no restricted information,
and may thus be prepared in an unrestricted environment. The argument
to the \verb|\censor*| command is a number representing the approximate
width of the redaction (in ex's). Because the redaction width is only
approximate, it is possible that the censored and uncensored originals
might have differing text justification. In the text, the curly braces
are placed around the keyword identifiers so as to produce the proper
interaction with the surrounding whitespace and punctuation.
Because the source (.tex) file contains no restricted information, the
use of \verb|\StopCensoring| cannot (in and of itself) produce the
restricted document. Rather it will produce the following:\clearpage
{\addtolength{\leftskip}{2.3em}
UNCENSORED UNRESTRICTED OUTPUT: \hrulefill
\StopCensoring
\def\Missile{\censor*{7}}
\def\Size{\censor*{2}}
The {\Missile} missile, with charge diameter (CD) of {\Size}~mm, revealed a
penetration capability of 1.30 1.19, and 1.37~CD in three recent tests
into armor steel.
\hrulefill
}\RestartCensoring
In order to produce the uncensored, restricted output, the unrestricted
source file must be moved into the restricted/secure environment and be
subject to a small amount of additional editing. Once in the restricted
environment, the source (.tex file) may be edited such that the censored
keyword identifiers are filled in with their restricted values, changing
the \verb|\censor*| commands to \verb|\censor| commands, in the process.
This and the addition of the \verb|\StopCensoring| command to the file
will produce the uncensored, restricted result:
{\addtolength{\leftskip}{2.3em}
UNCENSORED NO-LONGER-UNRESTRICTED SOURCE: \hrulefill
\verb|\StopCensoring|\\
\verb|% KEYWORD IDENTIFIERS:|\\
\verb|\def\Missile{\censor{Liberty}}}|\\
\verb|\def\Size{\censor{80}}|\\
\verb| |\\
\verb|The {\Missile} missile, with charge diameter (CD) of|\\
\verb|{\Size}~mm, revealed a penetration capability of 1.30 1.19,|\\
\verb|and 1.37~CD in three recent tests into armor steel.|
UNCENSORED RESTRICTED OUTPUT: \hrulefill
\StopCensoring
\def\Missile{\censor{Liberty}}
\def\Size{\censor{80}}
The {\Missile} missile, with charge diameter (CD) of {\Size}~mm, revealed a
penetration capability of 1.30 1.19, and 1.37~CD in three recent tests
into armor steel.
\hrulefill
}
The only changes required of the document were at the very beginning,
among the keyword identifiers. The primary text of the source document
remained unaltered. Note also that the censored, unrestricted output
may also be obtained from the no-longer-unrestricted source by removing
the \verb|\StopCensoring| command at the beginning of the file.
It is not envisioned that the \verb|\blackout| command, discussed in the
prior section, is used in this mode, where the source file is in an
unsecure environment.
\clearpage
\section{Miscellany}
Censoring may be dynamically turned on and off in a document with the
use of the \verb|\StopCensoring| and \verb|\RestartCensoring| commands.
In addition to these two commands, the \verb|\censor|, \verb|\censor*|.
and \verb|\blackout| commands constitute the totality of commands
available in the \textsf{censor} package.
It is preferable not to apply \verb|\censor| to whitespace, or text
justification could be adversely affected. If one wished to censor a
multi-word phrase, such as ``Little Bo Peep,'' it is recommended to do
it as follows:\\
\verb| \blackout{Little Bo Peep}|\\
If such a phrase is to be used repeatedly through a document,
it is most convenient to place it as a keyword identifier:\\
\verb| \def\Name{\blackout{Little Bo Peep}}|\\
such that subsequent reference is done indirectly:\\
\verb| We examine the life of {\Name} in this report|
The source code for \textsf{censor} is so short as to be included below:
\verb|\ProvidesPackage{censor}|\\
\verb|[2012/09/06 v2.10|\\
\verb| Provides capability for redaction of sensitive information]|\\
\verb||\\
\verb|\usepackage{pbox}|\\
\verb|\usepackage{ifnextok}|\\
\verb||\\
\verb|\newcommand\censor{\@ifstar{\@cenlen}{\@cenword}}|\\
\verb| \newcommand\@cenlen[1]{\protect\rule[-.3ex]{#1 ex}{2.1ex}}|\\
\verb| \newcommand\@cenword[1]{%|\\
\verb| \protect\rule[-.3ex]{\widthofpbox{#1}}{2.1ex}}|\\
\verb||\\
\verb|\newcommand\un@censor{\@ifstar{\un@cenlen}{\un@cenword}}|\\
\verb| \newcommand\un@cenlen[1]{\protect\underline{\hspace{#1 ex}}}|\\
\verb| \newcommand\un@cenword[1]{#1}|\\
\verb||\\
\verb|\newcommand\StopCensoring{\let\censor\un@censor}|\\
\verb|\newcommand\RestartCensoring{%|\\
\verb| \renewcommand\censor{\@ifstar{\@cenlen}{\@cenword}}}|\\
\verb||\\
\verb|\def\stringend{$}|\\
\verb|\def\blackout#1{\censor@Block#1\stringend}|\\
\verb|\def\censor@Block{\IfNextToken\stringend{\@gobble}%|\\
\verb| {\IfNextToken\@sptoken{ \bl@t{\censor@Block}}%|\\
\verb| {\bl@t{\censor@Block}}}}|\\
\verb||\\
\verb|\def\bl@t#1#2{\if\bpar#2\par\else\if.#2#2\else\censor{#2}\fi\fi#1}|\\
\verb|\def\bpar{_}|\\
\verb||\\
\verb|\endinput|\\
\end{document}
|