Debian Codegraph @

texmf-dist/source/latex/secretx/secretx.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (c) 2019-2024 by Keith F. Prussing <[email protected]>
4 %
5 % This work may be distributed and/or modified under the conditions of
6 % the LaTeX Project Public License, either version 1.3c of this license
7 % or (at your option) any later version. The latest version of this
8 % license is in
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.3c or later is part of all distributions of LaTeX
13 % version 2005/12/01 or later.
14 %
15 % This work has the LPPL maintenance status `maintained'.
16 %
17 % The Current Maintainer of this work is Keith F. Prussing.
18 %
19 % \fi
20 %
21 % \iffalse
22 %<*driver>
23 \ProvidesFile{\jobname.dtx}
24 %</driver>
25 %<package>\NeedsTeXFormat{LaTeX2e}[2003/12/01]
26 %<package>\ProvidesPackage{secretx}
27 %<package>[2024/03/07 v0.10.9 Classification marking macros]
28 %
29 %<*driver>
30 \documentclass{ltxdoc}
31 \usepackage{hypdoc}
32 \usepackage{secretx}
33 \fancyhead[L,C,R]{}
34 \fancyfoot[C]{}
35 \fancyfoot[R]{\thepage}
36 \EnableCrossrefs
37 \CodelineIndex
38 \RecordChanges
39 \usepackage{hologo}
40 \usepackage{listings}
41 \usepackage{mwe}
42 \newtcolorbox{notice}{colback=red!5!white,colframe=red!75!black,%
43 fonttitle=\bfseries,title={Notice}}
44 \setcounter{IndexColumns}{2}
45 \IndexPrologue{\section{Index}}
46 \GlossaryPrologue{\section{Change History}}
47 \usepackage[style=ieee]{biblatex}
48 \addbibresource{secretx.bib}
49 \usepackage{cleveref}
50 % Command for <barg>
51 \newcommand\barg[1]{{\ttfamily<}\meta{#1}{\ttfamily>}}
52 \tcbuselibrary{listings}
53 \begin{document}
54 \DocInput{\jobname.dtx}
55 \end{document}
56 %</driver>
57 % \fi
58 %
59 % \CheckSum{305}
60 %
61 % \CharacterTable
62 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
63 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
64 % Digits \0\1\2\3\4\5\6\7\8\9
65 % Exclamation \! Double quote \" Hash (number) \#
66 % Dollar \$ Percent \% Ampersand \&
67 % Acute accent \' Left paren \( Right paren \)
68 % Asterisk \* Plus \+ Comma \,
69 % Minus \- Point \. Solidus \/
70 % Colon \: Semicolon \; Less than \<
71 % Equals \= Greater than \> Question mark \?
72 % Commercial at \@ Left bracket \[ Backslash \\
73 % Right bracket \] Circumflex \^ Underscore \_
74 % Grave accent \` Left brace \{ Vertical bar \|
75 % Right brace \} Tilde \~}
76 %
77 % \changes{v0.5}{2019/04/24}{Initial version}
78 % \changes{v0.6}{2019/04/27}{Implementation reorganization}
79 % \changes{v0.7}{2019/04/27}{Correctly roll over marking level}
80 % \changes{v0.8}{2019/05/03}{Consolidate macros}
81 % \changes{v0.8.5}{2019/05/11}{Add explicit environments}
82 % \changes{v0.8.6}{2019/05/11}{Make all new commands robust}
83 % \changes{v0.9.0}{2020/09/16}{Provide manual heading override}
84 % \changes{v0.10}{2021/03/13}{Move development to trunk branch}
85 % \GetFileInfo{\jobname.sty}
86 %
87 %^^A Package macros
88 % \DoNotIndex{\begin, \end, \newenvironment, \newrobustcmd, \renewcommand}
89 % \DoNotIndex{\csdef, \csuse, \ifcsdef, \if, \else, \fi, \everypar}
90 % \DoNotIndex{\iftoggle, \ifnum, \toggletrue, \togglefalse, \thepage}
91 % \DoNotIndex{\newcounter, \newtoggle, \setcounter, \stepcounter}
92 % \DoNotIndex{\PackageError, \RequirePackage, \PackageWarning, \llap}
93 % \DoNotIndex{\box, \setbox}
94 % \DoNotIndex{\protect, \makebox, \parindent, \PushPostHook, \aftergroup}
95 % \DoNotIndex{\bgroup, \egroup, \@ifclassloaded, \centering, \kern}
96 % \DoNotIndex{\hfill, \null, \edef, \vspace, \setlist, \Large, \bfseries}
97 % \DoNotIndex{\space, \@ifpackageloaded, \fancyfoot, \fancyhead}
98 % \DoNotIndex{\fancypagestyle, \fbox, \ifcsempty, \ifdefstring}
99 % \DoNotIndex{\ifnumgreater, \IfValueTF, \lastbox, \leavevmode}
100 % \DoNotIndex{\leftmargin, \MessageBreak, \NewDocumentCommand}
101 % \DoNotIndex{\NewTColorBox, \PushPreHook, \tcbset, \tcbtitle}
102 % \DoNotIndex{\textwidth, \value, \usebeamerfont}
103 %^^A Other package macros
104 % \DoNotIndex{\AtBeginShipout}
105 % \DoNotIndex{\lhead, \chead, \rhead, \lfoot, \cfoot, \rfoot, \fancyhf}
106 % \DoNotIndex{\headerrulewidth, \pagestyle, \thispagestyle}
107 % \DoNotIndex{\zref, \zref@extract, \zlabel, \defbeamertemplate}
108 % \DoNotIndex{\BODY, \NewEnviron, \userbeamerfont, \setbeamerfont}
109 % \DoNotIndex{\ifdefempty, \DeclareStringOption, \ProcessKeyvalOptions}
110 % \DoNotIndex{\AtBeginEnvironment, \AtEndEnvironment}
111 %^^A Package specific to ignore
112 % \DoNotIndex{\thesecretx@doclevel, \thesecretx@pagelevel, \reset}
113 % \DoNotIndex{\thesecretx@markcount, \thesecretx@currentlevel, \curcnt}
114 %^^A Writing to the aux file macros
115 % \DoNotIndex{\@auxout, \immediate, \\, \AtEndDocument, \write, \string}
116 % \DoNotIndex{\space}
117 %
118 % \title{
119 % Classification Marking Macros for \LaTeX{} \thanks{This document
120 % corresponds to \textsf{\jobname}~\fileversion, % dated~\filedate.}
121 % }
122 %
123 % \author{Keith F. Prussing \\ \texttt{[email protected]}}
124 %
125 % \maketitle
126 % \tableofcontents
127 % \thispagestyle{secretx}
128 %
129 % \begin{abstract}
130 % This package provides a set of \LaTeX{} macros for marking paragraphs
131 % in a document with a leading string and modifying the header and the
132 % footer of each page. This is the spiritual successor to
133 % \textsf{secret.sty} but adds the feature of marking the header and the
134 % footer correctly.
135 % \end{abstract}
136 %
137 % \section{Introduction}
138 %
139 % A core component of reporting sensitive information is properly
140 % marking sections of a document with appropriate labels. This package
141 % aims to provide tools for helping mark a document correctly.
142 %
143 % \section{Usage}
144 % \changes{v0.7.1}{2019/04/28}{Expand usage documentation}
145 %
146 % To install the package, simply run the provided |secretx.ins| file
147 % through your preferred \LaTeX{} engine. Then, copy the resultant
148 % |.sty| file to a location where \LaTeX{} can find it. To generate
149 % the documentation, run this file (|secretx.dtx|) through \LaTeX{}
150 % twice. The second time is only to make sure the references and index
151 % are typeset correctly. If you have \hologo{LuaLaTeX}, you could also
152 % run |l3build install| to install into your local texmf tree and
153 % |l3build doc| to get a quick version of the documentation.
154 %
155 % \Cref{app:example} provides an example document and \textsf{beamer}
156 % presentation showing the usage of the package. The raw source is also
157 % provided in the \textsf{doc} directory with this reference. To see
158 % the typeset result, simply run the example files through \LaTeX{}.
159 %
160 % \subsection{Marking Management}
161 %
162 % The basic concept behind marking each page is setting a ``level'' for
163 % each paragraph. The highest level paragraph on any given page sets
164 % the overall level of the page in a standard document. Before use, the
165 % user must specify every desired marking level along with paragraph and
166 % header markings. The header and footer markings are set with a
167 % \textsf{fancyhdr} |\pagestyle| which is activated by default for
168 % non-\textsf{beamer} documents.
169 %
170 % To apply headers and footers to \textsf{beamer} slides, use
171 % \begin{lstlisting}[gobble=2, basicstyle=\ttfamily\small]
172 % \usebeamertemplate{headline}[secretx]
173 % \usebeamertemplate{footline}[secretx]
174 % \end{lstlisting}
175 % or simply use |\getheading| in your custom \textsf{headline} and
176 % \textsf{footline}. Additionally, the \textsf{headline} and
177 % \textsf{footline} themes accept an optional argument. If this matches
178 % the string ``title'', the overall document banner is typeset instead
179 % of the individual page banner.
180 %
181 % \DescribeMacro{\setmarking}
182 % \DescribeMacro{\setheading}
183 % To register a paragraph marking, use
184 % |\setmarking|\marg{level}\marg{marking}. Likewise, to register a
185 % heading use |\setheading|\marg{level}\marg{heading}. These marcos
186 % register a \marg{marking} or \marg{heading} at the specified
187 % \marg{level}. The user is responsible for making sure the marker and
188 % heading for given level are consistent. Providing a level more than
189 % once will simply overwrite the previous definition with no warning.
190 %
191 % \DescribeMacro{\addmarking}
192 % |\addmarking|\marg{level}\marg{marking}\marg{heading} will set the
193 % marking and heading at the given level. This is simply a convenience
194 % wrapper around |\setmarking| and |\setheading|.
195 %
196 % \DescribeMacro{\getmarking}
197 % \DescribeMacro{\getheading}
198 % \changes{v0.8.4}{2019/05/11}{Use current level as default marking}
199 % Once a level has been registered, retrieving the marking or heading is
200 % done with |\getmarking|\oarg{level} or |\getheading|\oarg{level}
201 % respectively. The argument defaults to the current paragraph or page
202 % level as appropriate. These macros check that the given \oarg{level}
203 % has a defined marking and heading. If not, these will raise an error.
204 % These return the expanded string given to |\setmarking| and
205 % |\setheading|.
206 %
207 % \DescribeMacro{\pagelevel}
208 % \DescribeMacro{\doclevel}
209 % These provide access to the current page and document levels. These
210 % are read only and are provided to reveal the current state for the
211 % user instead of having to work with the package internals.
212 %
213 % \DescribeMacro{\pagestyle\{secretx\}}
214 % \changes{v0.10}{2022/03/11}{Define fancyhdr page style}
215 % This pagestyle places the appropriate header and footer page marking
216 % in the center of the header and footer. It changes no other parts of
217 % the header or footer. This is loaded by default; however, it is
218 % ultimately the users responsibility to ensure this is loaded at the
219 % appropriate time or that other header/footer customizations do not
220 % overwrite the center portion of either the header or footer. If you
221 % need to have a highly customized header or footer, simply add
222 % |\getheading| to the appropriate portion of your header or footer.
223 %
224 % \subsection{Document Marking}
225 %
226 % \DescribeMacro{\marking}
227 % Marking a paragraph is done by specifying the numeric level with which
228 % to mark using |\marking|\marg{level}\{\ldots\}. This macro takes care
229 % of marking the paragraph with the appropriate marker and updating the
230 % page and document levels. The page and document levels are only
231 % updated if the given marking is higher than the current level.
232 %
233 % \DescribeEnv{marking block}
234 % Collecting large bodies of text into a macro is not ideal. Instead,
235 % we would like to use an environment. To this end, this package
236 % provides the |marking block| environment. The syntax is analogous to
237 % the |\marking| macro in that it takes a \marg{level}. For example:
238 % \begin{lstlisting}[gobble=2, basicstyle=\ttfamily\small]
239 % \begin{marking block}{1}
240 % \ldots
241 % \end{marking block}
242 % \end{lstlisting}
243 %
244 %
245 % \DescribeEnv{marking box}
246 % \changes{v0.11}{2024/02/28}{Add marking box environment}
247 % Graphical or tabular content can be wrapped in a |tcolorbox| to
248 % indicate the marking level of the entire content. The |marking box|
249 % environment will wrap the item in a colored box and place the heading
250 % in the upper left and lower right corners of the box in the same color
251 % as the box. The environment accepts the following options:
252 %
253 % \begin{enumerate}
254 % \item \marg{level}: The level of the marking
255 % \item \barg{top sep}: The additional separation above the content
256 % \item \barg{bottom sep}: The additional separation below the content
257 % \item \oarg{options}: Additional options passed to |tcolorbox|
258 % \end{enumerate}
259 %
260 % Under the hood, this is a |tcolorbox| customized with the |secretx|
261 % style.
262 %
263 % \iffalse
264 %<*driver>
265 % \fi
266 \begin{tcblisting}{listing outside text}
267 \setheading{1}{Marking}
268 \begin{marking box}{1}
269 \includegraphics%
270 [width=\textwidth]%
271 {example-image-a}
272 \end{marking box}
273 \end{tcblisting}
274 % \iffalse
275 %</driver>
276 % \fi
277 %
278 % For convenience, we provide definitions to set common levels. The
279 % styles and colors listed are used with |marking box| and may be
280 % customized as described in the documentation for |tcolorbox|. These
281 % are:
282 %
283 % \DescribeMacro{\unclassified}
284 % \DescribeEnv{unclassified block}
285 % \DescribeEnv{unclassified box}
286 % \DescribeMacro{unclassified style}
287 % \DescribeMacro{unclassified/color}
288 % Mark unclassified.
289 % \begin{itemize}
290 % \item Level: 1
291 % \item Marking: \getmarking[1]
292 % \item Heading: \getheading[1]
293 % \end{itemize}
294 %
295 % \DescribeMacro{\fouo}
296 % \DescribeEnv{fouo block}
297 % Mark for official use only.
298 % \begin{notice}
299 % The FOUO marking is deprecated. This will be removed in version 0.11.
300 % \end{notice}
301 % \begin{itemize}
302 % \item Level: 2
303 % \item Marking: \getmarking[2]
304 % \item Heading: \getheading[2]
305 % \end{itemize}
306 %
307 % \DescribeMacro{\confidential}
308 % \DescribeEnv{confidential block}
309 % \DescribeEnv{confidential box}
310 % \DescribeMacro{confidential style}
311 % \DescribeMacro{confidential/color}
312 % Mark confidential.
313 % \begin{itemize}
314 % \item Level: 5
315 % \item Marking: \getmarking[5]
316 % \item Heading: \getheading[5]
317 % \end{itemize}
318 %
319 % \DescribeMacro{\secret}
320 % \DescribeEnv{secret block}
321 % \DescribeEnv{secret box}
322 % \DescribeMacro{secret style}
323 % \DescribeMacro{secret/color}
324 % Mark secret.
325 % \begin{itemize}
326 % \item Level: 10
327 % \item Marking: \getmarking[10]
328 % \item Heading: \getheading[10]
329 % \end{itemize}
330 %
331 % \DescribeMacro{\secretnoforn}
332 % \DescribeEnv{secretnoforn block}
333 % \DescribeEnv{secretnoforn box}
334 % \DescribeMacro{secretnoforn style}
335 % \DescribeMacro{secretnoforn/color}
336 % Mark secret no foreign.
337 % \begin{itemize}
338 % \item Level: 15
339 % \item Marking: \getmarking[15]
340 % \item Heading: \getheading[15]
341 % \end{itemize}
342 %
343 % \DescribeMacro{\topsecret}
344 % \DescribeEnv{topsecret block}
345 % \DescribeEnv{topsecret box}
346 % \DescribeMacro{topsecret style}
347 % \DescribeMacro{topsecret/color}
348 % Mark top secret.
349 % \begin{itemize}
350 % \item Level: 25
351 % \item Marking: \getmarking[25]
352 % \item Heading: \getheading[25]
353 % \end{itemize}
354 %
355 % \subsection{Overriding the Default Page Marking}
356 %
357 % \begin{notice}
358 % Version 0.11 will change the meaning of this option as the internal
359 % logic is still buggy. After 0.11, |heading| will \emph{enable} the
360 % adaptive marking.
361 % \end{notice}
362 %
363 % \DescribeMacro{heading}
364 % \changes{v0.10}{2022/03/10}{Allow default behavior of header}
365 % Although this package attempts to automate away many of the underlying
366 % details of marking a document, it cannot always succeed. Since it is
367 % the final responsibility of the document author to ensure appropriate
368 % overall markings, the |heading| argument to the package provides
369 % a manual override to the package determined page marking per the
370 % alternate marking advice in \cite{noauthor_marking_2021}. This
371 % option can be given alone or assigned as a string |heading=<text>|.
372 % If a string is given, the text is typeset in the header and footer
373 % verbatim. If the text is not given, the highest header marking of the
374 % document will be used for the header and footer. The header and
375 % footers will be the same on all pages in the document.
376 %
377 % If possible, we would appreciate any representative examples of usages
378 % that fails to get marked correctly reported to the
379 % \href{https://github.com/kprussing/secretx/issues}{issue tracker}.
380 % However, due to the intended use of this package, we understand if
381 % this is not practical.
382 %
383 % \DescribeMacro{\setlevel}
384 % \changes{v0.10}{2021/08/17}{Add setlevel command}
385 % This macro explicitly sets the level of a page without marking a
386 % particular item. The focus of this is more for a class like
387 % \textsf{beamer} where the slide may be composed solely of images
388 % that are themselves marked but are unknown to \LaTeX{}, or floating
389 % environment such as |figure| or |table|. This lets the user
390 % explicitly state the classification of the proper page or scope.
391 %
392 % \subsection{Additional Statements}
393 %
394 % \DescribeMacro{\distribution}
395 % A distribution statement is a common need for documentation. Using
396 % |\distribution| \marg{level}\marg{reason}\marg{date of
397 % determination}\marg{controlling DoD office} will place the appropriate
398 % distribution statement following DoDI 5230.24\cite{dodi_5230.24}.
399 % Here \marg{level} is the letter version of the statement (A, B, C, D,
400 % etc.).
401 %
402 % \DescribeMacro{\exportcontrol}
403 % This macro places the export control warning in a framed box at the
404 % current location in accordance with DoDI 5230.24\cite{dodi_5230.24}.
405 % The default is to typeset the box at 90\% of the |\textwidth|. Using
406 % |\exportcontrol|\oarg{width} typesets the control statement in a box
407 % of the given \oarg{width}.
408 %
409 % \section{Tips and Tricks}
410 %
411 % A few items must be kept in mind while using this package.
412 % Specifically, this package makes use of \textsf{everyhook} to
413 % manipulate the |\everypar| hook. As noted
414 % online\footnote{\url{https://tex.stackexchange.com/q/263744/61112}},
415 % \LaTeX{} makes extensive use of |\everypar| in many unexpected places.
416 % From a practical point of view, the following sections point out best
417 % practices.
418 %
419 % \subsection{Do Not Span Sections}
420 %
421 % A marking environment should not span a sectioning command. If the
422 % document contains:
423 %
424 % \begin{lstlisting}[gobble=2, basicstyle=\ttfamily\small]
425 % \begin{unclassified block}
426 % \lipsum[1]
427 %
428 % \chapter{The Next Chapter}
429 %
430 % \lipsum[2]
431 % \end{unclassified block}
432 % \end{lstlisting}
433 %
434 % the marking will be placed in the margin next to the chapter and not
435 % associated with the chapter text. Instead, use
436 %
437 % \begin{lstlisting}[gobble=2, basicstyle=\ttfamily\small]
438 % \unclassified{\lipsum[1]}
439 %
440 % \chapter{\getmarking[1]\setlevel{1} The Next Chapter}
441 %
442 % \unclassified{\lipsum[2]}
443 % \end{lstlisting}
444 %
445 % This will set the level, correctly associate the marking with the
446 % chapter title, and place it in the table of contents. To silence the
447 % warning from \textsf{hyperref}, place the macros in the \TeX{} portion
448 % of |\texorpdfstring|.
449 %
450 % \subsection{Do Not Wrap Floats}
451 %
452 % Similar to sectioning commands, placing floating environments within a
453 % marking block has negative consequences. When the floating
454 % environment is placed, it will have the marking in the margin.
455 % Instead, explicitly set the level within the floating environment and
456 % get the marking for the caption.
457 %
458 % \begin{lstlisting}[gobble=2, basicstyle=\ttfamily\small]
459 % \end{unclassified block}
460 %
461 % \begin{figure}
462 % \begin{secret box}
463 % \includegraphics{example-image-16x10}
464 % \end{secret box}
465 % \caption{\getmarking[1] Different level caption.}
466 % \end{figure}
467 %
468 % \begin{unclassified block}
469 % \end{lstlisting}
470 %
471 % \subsection{Marking Front Matter Titles}
472 %
473 % Markings can be added to the table of contents, list of figures, and
474 % list of tables titles using |\preto| from \textsf{etoolbox} (which is
475 % loaded by this package).
476 %
477 % \begin{lstlisting}[gobble=2, basicstyle=\ttfamily\small]
478 % \AtBeginDocument{%
479 % \preto\contentsname{\setlevel{1}\getmarking[1] }
480 % \preto\listfigurename{\setlevel{1}\getmarking[1] }
481 % \preto\listtablename{\setlevel{1}\getmarking[1] }
482 % }
483 % \end{lstlisting}
484 %
485 % \subsection{Marking List of Acronyms from \textsf{Acro}}
486 %
487 % The list of acronyms can be placed in a marking environment by
488 % redefining the template according to example
489 % 8\footnote{acro.example.texsx-505891} from the \textsf{acro}
490 % documentation.
491 %
492 % \begin{lstlisting}[gobble=2, basicstyle=\ttfamily\small]
493 % \RenewAcroTemplate[list]{description}{%
494 % \acroheading
495 % \acropreamble
496 % \begin{unclassified block}
497 % \begin{description}
498 % \acronymsmapF{
499 % \item[%
500 % \acrowrite{short}
501 % ]
502 % \acrowrite{list}%
503 % }
504 % {\item \AcroRerun}
505 % \end{description}
506 % \end{unclassified block}
507 % }
508 %
509 % \prinacronyms[name={\getmarking[1] \acrotranslate{list-name}}]
510 % \end{lstlisting}
511 %
512 % \subsection{Adjusting Boxed Environments}
513 %
514 % As mentioned, the |marking box| environment relies on |tcolorbox| with
515 % the custom |secretx| style. You may change the defaults using
516 % |\tcbset|. The following sets all marked box titles to be bold and to
517 % use a dark green to mark unclassified boxed content.
518 %
519 % \begin{lstlisting}[gobble=2, basicstyle=\ttfamily\small]
520 % \tcbset{secretx/.append style={fonttitle=\bfseries},
521 % unclassified/color/.default=green!50!black,
522 % }
523 % \end{lstlisting}
524 %
525 % \StopEventually{
526 % \printbibliography[heading=bibnumbered]
527 % \PrintChanges{}
528 % \PrintIndex{}
529 % }
530 %
531 % \section{Implementation}
532 %
533 % \iffalse
534 %<*package>
535 % \fi
536 %
537 % The basic logic is to define markings with increasing levels of
538 % sensitivity. We track these along with paired line markings and page
539 % markings in internal arrays.
540 %
541 % \subsection{Required Packages}
542 %
543 % For this package, we will need to modify the shipout, work with
544 % counters, control sequences, complex labels, and we will, obviously,
545 % need to modify the headers and footers. We add all of the packages in
546 % one location to keep things organized.
547 %
548 % \begin{macrocode}
549 \RequirePackage{atbegshi}
550 \RequirePackage{etoolbox}
551 \RequirePackage[excludeor]{everyhook}
552 \RequirePackage{environ}
553 \@ifclassloaded{beamer}{}{%
554 \RequirePackage{fancyhdr}%
555 }
556 \RequirePackage{kvoptions}
557 \RequirePackage{zref-user}
558 \RequirePackage{zref-abspage}
559 \@ifpackageloaded{tcolorbox}{}{%
560 \RequirePackage{tcolorbox}
561 }
562 % \end{macrocode}
563 % |Tcolorbox| moved the |\NewTColorBox| macro from the |xparse| library
564 % in version 5.1.0. We need to include it for older versions.
565 % \changes{v0.11}{2024/06/04}{Conditionally load xparse |tcolorbox| library}
566 % \begin{macrocode}
567 \@ifpackagelater{tcolorbox}{2022/06/22}{}{\tcbuselibrary{xparse}}
568 % \end{macrocode}
569 %
570 % \subsection{Package Options}
571 %
572 % \begin{macro}{\secretx@heading}
573 % This optional key-value pair is used to induce a manual override of
574 % page-level headings. All pages will be marked with the indicated
575 % heading if this option is specified.
576 % \begin{macrocode}
577 \DeclareStringOption{heading}[default]
578 \ProcessKeyvalOptions*
579 % \end{macrocode}
580 % \end{macro}
581 %
582 % \subsection{Package Counters}
583 %
584 % Define the package counters and toggle.
585 %
586 % \begin{macro}{secretx@pagelevel}
587 % A counter to store the marking level of the highest current page.
588 % \begin{macrocode}
589 \newcounter{secretx@pagelevel}
590 % \end{macrocode}
591 % \end{macro}
592 %
593 % \begin{macro}{secretx@doclevel}
594 % A counter to store the highest marking level of the current document.
595 % We also write out the document marking level to the auxiliary file for
596 % use on the second pass when creating the cover page.
597 % \begin{macrocode}
598 \newcounter{secretx@doclevel}
599 \AtEndDocument{%
600 \immediate\write\@auxout{%
601 \string\setcounter{secretx@doclevel}{\thesecretx@doclevel}%
602 }
603 }
604 % \end{macrocode}
605 % \end{macro}
606 %
607 % \begin{macro}{secretx@currentlevel}
608 % A counter to maintain the marking level of the current scope.
609 % \begin{macrocode}
610 \newcounter{secretx@currentlevel}
611 % \end{macrocode}
612 % \end{macro}
613 %
614 % \begin{macro}{secretx@markcount}
615 % A counter for the classification environment.
616 % \begin{macrocode}
617 \newcounter{secretx@markcount}
618 % \end{macrocode}
619 % \end{macro}
620 %
621 % \subsection{Marking and Heading Management}
622 %
623 % These are the user facing macros for establishing the markings and
624 % headings. These automate away the tasks of storing the information at
625 % increasing levels and validating the levels when getting a marking or
626 % heading from the internal storage. When setting the marking or
627 % heading, we simply overwrite any previous value. It is up to the user
628 % to ensure the markings and headings are set at consistent levels. For
629 % this, we also provide a utility macro for setting both simultaneously.
630 %
631 % \begin{macro}{\setmarking}
632 % Set a marking level by defining the level and a line marking (e.g. (U)
633 % for unclassified, (S) for secret, etc.). This will overwrite a
634 % previously defined marking at the same level.
635 % \begin{macrocode}
636 \newrobustcmd{\setmarking}[2]{\csdef{secretx@marking#1}{#2}}
637 % \end{macrocode}
638 % \end{macro}
639 %
640 % \begin{macro}{\getmarking}
641 % Get a line marking from the marking storage.
642 % \begin{macrocode}
643 \newrobustcmd{\getmarking}[1][\thesecretx@currentlevel]{%
644 \ifcsdef{secretx@marking#1}{%
645 \csuse{secretx@marking#1}%
646 }{%
647 \PackageWarning{secretx}{%
648 Marking ##1 level was not previously defined. Is it a typo
649 or did you simply forget to define it?%
650 }
651 }
652 }
653 % \end{macrocode}
654 % \end{macro}
655 %
656 % \begin{macro}{\setheading}
657 % Set the heading level by defining the level and the heading (e.g.
658 % UNCLASSIFIED, SECRET, etc.). This will overwrite a previously defined
659 % marking at the given level.
660 % \begin{macrocode}
661 \newrobustcmd{\setheading}[2]{\csdef{secretx@heading#1}{#2}}
662 % \end{macrocode}
663 % \end{macro}
664 %
665 % \begin{macro}{\getheading}
666 % \changes{v0.11}{2023/05/23}{Get specific heading when given level}
667 % Get the heading on the page. Use the current page level unless the
668 % |heading| option was specified. If it was, always use it.
669 % \begin{macrocode}
670 \NewDocumentCommand{\getheading}{ o }{%
671 \IfValueTF{#1}{%
672 \ifcsdef{secretx@heading#1}{%
673 \csuse{secretx@heading#1}%
674 }{%
675 \PackageError{secretx}{Undefined heading level}{%
676 Marking ##1 level was not previously defined. Is it a
677 typo or did you simply forget to define it?%
678 }%
679 }%
680 }{%
681 \ifdefempty{\secretx@heading}{%
682 \csuse{secretx@heading\thesecretx@pagelevel}%
683 }{%
684 \ifdefstring{\secretx@heading}{default}{%
685 % \end{macrocode}
686 %^^A This should not be possible because the level was checked when
687 %^^A getting the marking.
688 % \begin{macrocode}
689 \csuse{secretx@heading\doclevel}%
690 }{%
691 \csuse{secretx@heading}%
692 }%
693 }
694 }%
695 }
696 % \end{macrocode}
697 % \end{macro}
698 %
699 % \begin{macro}{\addmarking}
700 % A helper macro to set a marking's level, section marking, and header
701 % marking.
702 % \begin{macrocode}
703 \newrobustcmd{\addmarking}[3]{%
704 \setmarking{#1}{#2}%
705 \setheading{#1}{#3}%
706 }
707 % \end{macrocode}
708 % \end{macro}
709 %
710 % \begin{macro}{\pagelevel}
711 % \begin{macro}{\doclevel}
712 % User facing macros to get the current page and document marking level.
713 % \begin{macrocode}
714 \newrobustcmd{\pagelevel}[0]{\thesecretx@pagelevel}
715 \newrobustcmd{\doclevel}[0]{\thesecretx@doclevel}
716 % \end{macrocode}
717 % \end{macro}
718 % \end{macro}
719 %
720 % \subsection{Low Level Macros}
721 %
722 % Some low level macros for managing the marking level state.
723 %
724 % \begin{macro}{\secretx@updatelevel}
725 % A macro to update the page and document levels. We only update if the
726 % given level is higher than the current level. We do this for both the
727 % page and the document.
728 % \begin{macrocode}
729 \newrobustcmd{\secretx@updatelevel}[1]{%
730 \ifnum#1 > \thesecretx@pagelevel%
731 \setcounter{secretx@pagelevel}{#1}%
732 \fi%
733 \ifnum#1 > \thesecretx@doclevel%
734 \setcounter{secretx@doclevel}{#1}%
735 \fi%
736 }
737 % \end{macrocode}
738 % \end{macro}
739 %
740 % \subsection{Marking Utilities}
741 %
742 % We provide a macro for marking the document. These will handle the
743 % lower level details of getting the line markings and adjusting the
744 % details to set the headings. Each one starts by incrementing the
745 % marking count to track the count of the current environment, creates a
746 % label, sets the marking for each paragraph, and inserts the content.
747 % At the end, it sets an ending label.
748 %
749 % \begin{macro}{\marking}
750 % \changes{v0.8.1}{2019/05/10}{Remove nested marking restriction}
751 % \changes{v0.8.2}{2019/05/10}{Resolve multiply defined labels}
752 %
753 % The workhorse macro to actually set the headings and paragraph
754 % markings. We begin by incrementing the current marking count and
755 % storing it for later use.
756 % \begin{macrocode}
757 \newrobustcmd{\marking}[2]{%
758 \stepcounter{secretx@markcount}%
759 \edef\curcnt{\thesecretx@markcount}%
760 % \end{macrocode}
761 % Next, in order to correctly reset the level in the case of a nested
762 % marking, we need to wrap everything up in a group and use
763 % |\aftergroup|. But, it appears like we need to wrap the counter
764 % setting in a macro.
765 % \begin{macrocode}
766 \edef\reset{%
767 \setcounter{secretx@currentlevel}{\thesecretx@currentlevel}%
768 }%
769 \bgroup%
770 \aftergroup\reset%
771 % \end{macrocode}
772 % Now step the environment counter to track the current environment.
773 % \begin{macrocode}
774 \zlabel{secretx@mark-begin-\curcnt}%
775 \secretx@updatelevel{#1}%
776 \setcounter{secretx@currentlevel}{#1}%
777 #2%
778 % \end{macrocode}
779 % We finish by marking the ending and releasing the lock.
780 % \begin{macrocode}
781 \egroup%
782 \zlabel{secretx@mark-end-\curcnt}%
783 }
784 % \end{macrocode}
785 % \end{macro}
786 %
787 % \begin{environment}{marking block}
788 % We also provide an environment for marking large bodies of text with a
789 % common marking.
790 % \begin{macrocode}
791 \NewEnviron{marking block}[1]{\marking{#1}{\BODY}}
792 % \end{macrocode}
793 % \end{environment}
794 %
795 % \subsection{Boxed Environment Marking}
796 %
797 % Define a style for creating a color box with level markings in the
798 % upper left end lower right.
799 % \begin{macrocode}
800 \tcbset{%
801 secretx/.style n args={3}{%
802 % Basic shape
803 sharp corners,%
804 boxrule=1pt,%
805 boxsep=1pt,%
806 % The heading
807 title={\getheading[#1]},%
808 % Place the heading in the upper left and lower right
809 detach title,
810 before upper={\tcbtitle\hfill\null\\[#2]},%
811 after upper={\leavevmode\\[#3]\null\hfill\tcbtitle},%
812 % Make the background transparent
813 standard jigsaw,%
814 opacityback=0.0,%
815 % Set the default color of the heading and the frame
816 secretx/color,
817 },
818 secretx/.prefix code={\setlevel{#1}},
819 % Set the default color of the heading and the frame
820 secretx/color/.default=black,
821 secretx/color/.style={/tcb/colframe=#1,,
822 /tcb/coltitle=#1},
823 }
824 % \end{macrocode}
825 %
826 % \begin{macro}{marking box}
827 % Define a new color box that passes the appropriate options to
828 % |secretx| style.
829 % \begin{macrocode}
830 \NewTColorBox{marking box}{m D<>{0pt} D<>{0pt} !O{} }{%
831 secretx={#1}{#2}{#3},%
832 % Additional options
833 #4%
834 }
835 % \end{macrocode}
836 % \end{macro}
837 %
838 % \subsection{Specific Markings}
839 %
840 % Now we define specific markings for the known classification levels.
841 % For each, we define an environment and a macro.
842 %
843 % An empty default marking.
844 % \begin{macrocode}
845 \addmarking{0}{}{}
846 % \end{macrocode}
847 %
848 % \begin{macro}{\unclassified}
849 % \begin{environment}{unclassified block}
850 % Unclassified markings.
851 % \begin{macrocode}
852 \addmarking{1}{(U)}{Unclassified}
853 \newrobustcmd{\unclassified}[1]{\marking{1}{#1}}
854 \NewEnviron{unclassified block}{\unclassified{\BODY}}
855 \tcbset{unclassified/.style 2 args={secretx={1}{#1}{#2},
856 unclassified/color},
857 unclassified/color/.forward to=/tcb/secretx/color}
858 \NewTColorBox{unclassified box}{D<>{0pt} D<>{0pt} !O{}
859 }{unclassified={#1}{#2}, #3}
860 % \end{macrocode}
861 % \end{environment}
862 % \end{macro}
863 %
864 % \begin{macro}{\fouo}
865 % \begin{environment}{fouo block}
866 % \changes{v0.9.1}{2019/09/19}{Fix capitalization}
867 % For official use only markings.
868 % \begin{macrocode}
869 \addmarking{2}{(U//FOUO)}{Unclassified//For Official Use Only}
870 \newrobustcmd{\fouo}[1]{%
871 \PackageWarning{secretx}{%
872 Deprecation warning: Marking FOUO is not correct.\MessageBreak%
873 Define and use a CUI level instead.\MessageBreak%
874 This level will be removed in v0.11.\MessageBreak%
875 }%
876 \marking{2}{#1}%
877 }
878 \NewEnviron{fouo block}{\fouo{\BODY}}
879 % \end{macrocode}
880 % \end{environment}
881 % \end{macro}
882 %
883 % \begin{macro}{\confidential}
884 % \begin{environment}{confidential block}
885 % Confidential markings.
886 % \begin{macrocode}
887 \addmarking{5}{(C)}{Confidential}
888 \newrobustcmd{\confidential}[1]{\marking{5}{#1}}
889 \NewEnviron{confidential block}{\confidential{\BODY}}
890 \tcbset{confidential/.style 2 args={secretx={5}{#1}{#2},
891 confidential/color},
892 confidential/color/.forward to=/tcb/secretx/color}
893 \NewTColorBox{confidential box}{D<>{0pt} D<>{0pt} !O{}
894 }{confidential={#1}{#2}, #3}
895 % \end{macrocode}
896 % \end{environment}
897 % \end{macro}
898 %
899 % \begin{macro}{\secret}
900 % \begin{environment}{secret block}
901 % Secret markings.
902 % \begin{macrocode}
903 \addmarking{10}{(S)}{Secret}
904 \newrobustcmd{\secret}[1]{\marking{10}{#1}}
905 \NewEnviron{secret block}{\secret{\BODY}}
906 \tcbset{secret/.style 2 args={secretx={10}{#1}{#2},
907 confidential/color},
908 secret/color/.forward to=/tcb/secretx/color}
909 \NewTColorBox{secret box}{D<>{0pt} D<>{0pt} !O{}
910 }{secret={#1}{#2}, #3}
911 % \end{macrocode}
912 % \end{environment}
913 % \end{macro}
914 %
915 % \begin{macro}{\secretnoforn}
916 % \begin{environment}{secretnoforn block}
917 % Secret no forn markings.
918 % \begin{macrocode}
919 \addmarking{15}{(S//NF)}{Secret//No Forn}
920 \newrobustcmd{\secretnoforn}[1]{\marking{15}{#1}}
921 \NewEnviron{secretnoforn block}{\secretnoforn{\BODY}}
922 \tcbset{secretnoforn/.style 2 args={secretx={15}{#1}{#2},
923 secretnoforn/color},
924 secretnoforn/color/.forward to=/tcb/secretx/color}
925 \NewTColorBox{secretnoforn box}{D<>{0pt} D<>{0pt} !O{}
926 }{secretnoforn={#1}{#2}, #3}
927 % \end{macrocode}
928 % \end{environment}
929 % \end{macro}
930 %
931 % \begin{macro}{\topsecret}
932 % \begin{environment}{topsecret block}
933 % Top secret markings.
934 % \begin{macrocode}
935 \addmarking{25}{(TS)}{Top Secret}
936 \newrobustcmd{\topsecret}[1]{\marking{25}{#1}}
937 \NewEnviron{topsecret block}{\topsecret{\BODY}}
938 \tcbset{topsecret/.style 2 args={secretx={25}{#1}{#2},
939 topsecret/color},
940 topsecret/color/.forward to=/tcb/secretx/color}
941 \NewTColorBox{topsecret box}{D<>{0pt} D<>{0pt} !O{}
942 }{topsecret={#1}{#2}, #3}
943 % \end{macrocode}
944 % \end{environment}
945 % \end{macro}
946 %
947 % \subsection{Overriding the Default Page Marking}
948 %
949 % \begin{macro}{\setlevel}
950 % This macro provides a user interface to explicitly set the page level.
951 % It is targeted as \textsf{beamer} frames that are predominantly
952 % explicitly marked.
953 % \begin{macrocode}
954 \newrobustcmd{\setlevel}[1]{%
955 \secretx@updatelevel{#1}%
956 }
957 % \end{macrocode}
958 % \end{macro}
959 %
960 % \subsection{Deprecated Macros}
961 %
962 % \begin{notice}
963 % These macros will be removed in v0.11.
964 % \end{notice}
965 % These macros are deprecated and are preserved for temporary backwards
966 % compatibility. They will be removed in the future.
967 %
968 % \begin{macrocode}
969 \newrobustcmd{\UCL}[1]{%
970 \PackageWarning{secretx}{Macro deprecated! Use
971 \protect\unclassified\space instead}%
972 \unclassified{#1}%
973 }
974 \newrobustcmd{\CNF}[1]{%
975 \PackageWarning{secretx}{Macro deprecated! Use
976 \\protect\confidential\space instead}%
977 \confidential{#1}%
978 }
979 \newrobustcmd{\SEC}[1]{%
980 \PackageWarning{secretx}{Macro deprecated! Use
981 \\protect\secret\space instead}%
982 \secret{#1}%
983 }
984 \newrobustcmd{\SNF}[1]{%
985 \PackageWarning{secretx}{Macro deprecated! Use
986 \\protect\secretnoforn\space instead}%
987 \secretnoforn{#1}%
988 }
989 \newrobustcmd{\TS}[1]{%
990 \PackageWarning{secretx}{Macro deprecated! Use
991 \\protect\topsecret\space instead}%
992 \topsecret{#1}%
993 }
994 % \end{macrocode}
995 %
996 % \subsection{Formatting Details}
997 %
998 % Now we move on to specific formatting details. The header and footer
999 % are determined by the marking level of the current page, but only for
1000 % article style documents and not beamer slides. For beamer, we need to
1001 % provide a headline and footline template. We can use our macros to
1002 % set them once. We only specify the center header and footer and leave
1003 % the left and right marks up to the user.
1004 %
1005 % For \textsf{beamer}, simply use
1006 % \begin{lstlisting}[gobble=2, basicstyle=\ttfamily\small]
1007 % \usebeamertemplate{headline}[secretx]
1008 % \usebeamertemplate{footline}[secretx]
1009 % \end{lstlisting}
1010 % to get a centered marking on the header and footer. To customize your
1011 % headline and footline, simply add |\getheading| to your template.
1012 % See~\cref{app:beamer} for a simple example.
1013 %
1014 % \changes{v0.8.4}{2019/05/11}{Provide beamer head/footline}
1015 % \changes{v0.8.7}{2019/10/17}{Adjust beamer header/footer to keep size}
1016 % \changes{v0.11}{2024/06/20}{Allow selecting the document level for header/footer}
1017 % \begin{macrocode}
1018 \@ifclassloaded{beamer}{%
1019 \defbeamertemplate*{headline}{secretx}[1][]{%
1020 \begin{beamercolorbox}[ht=5ex]{headline}
1021 \usebeamerfont{secretx}\hfill%
1022 \ifstrequal{#1}{title}{\getheading[\doclevel]}{\getheading}%
1023 \hfill\null%
1024 \end{beamercolorbox}
1025 }
1026 \defbeamertemplate*{footline}{secretx}[1][]{%
1027 \begin{beamercolorbox}[ht=6ex]{footline}
1028 \usebeamerfont{secretx}\hfill%
1029 \ifstrequal{#1}{title}{\getheading[\doclevel]}{\getheading}%
1030 \hfill\null\vspace{3pt}%
1031 \end{beamercolorbox}
1032 }
1033 \setbeamerfont{secretx}{size=\Large,%
1034 series=\bfseries,%
1035 parent=structure}
1036 }{%
1037 \fancypagestyle{secretx}{%
1038 \fancyhead[C]{\getheading}
1039 \fancyfoot[C]{\getheading}
1040 }
1041 \pagestyle{secretx}
1042 }
1043 % \end{macrocode}
1044 %
1045 % \changes{v0.7.2}{2019/05/03}{Use everyhook to mark paragraphs}
1046 % \changes{v0.8.3}{2019/05/10}{Use PushPostHook for everypar}
1047 % \changes{v0.10}{2022/11/22}{Do not overhang the margin}
1048 % \changes{v0.11}{2023/05/22}{Aim for the margin using everyhook's
1049 % recommended method.}
1050 % We also place the marking before every paragraph based on the current
1051 % marking level.
1052 % \begin{macrocode}
1053 \PushPreHook{par}{%
1054 \ifcsempty{secretx@marking\thesecretx@currentlevel}%
1055 {}{\setbox0=\lastbox\llap{\getmarking{}%
1056 \hspace{5pt}%
1057 \hspace{\secretx@listmargin}}%
1058 \box0}%
1059 }
1060 % \end{macrocode}
1061 %
1062 % And now we need to deal with resetting the page levels correctly.
1063 % Each marking has been placed between begin and end labels. We can
1064 % check the last label when a page ships out to see if the begin is on
1065 % the same page. If it is not, we need to preserve the page level on
1066 % the next page. Otherwise, we need to reset the page to empty.
1067 %
1068 % \begin{macrocode}
1069 \AtBeginShipout{%
1070 \ifnum\zref@extract{secretx@mark-begin-\thesecretx@markcount}{abspage}
1071 =\zref@extract{secretx@mark-end-\thesecretx@markcount}{abspage}
1072 \setcounter{secretx@pagelevel}{0}%
1073 \else%
1074 \setcounter{secretx@pagelevel}{\thesecretx@currentlevel}%
1075 \fi%
1076 }
1077 % \end{macrocode}
1078 %
1079 % \begin{macro}{secretx@listlevel}
1080 % \changes{v0.11}{2023/05/22}{Add list counter for margins}
1081 % This counter is used to determine the nesting of the list level. It
1082 % will be used to determine if the current paragraph is within a noted
1083 % list environment to return the correct padding. We hook into each
1084 % known list environment\footnote{This could be done with \LaTeX3 using
1085 % \href{https://tex.stackexchange.com/a/638275/61112}{AddToHook}, but
1086 % that is a \href{https://tex.stackexchange.com/q/602066/61112}{recent
1087 % addition}.}.
1088 % \begin{macrocode}
1089 \newcounter{secretx@listlevel}
1090 \setcounter{secretx@listlevel}{0}
1091 \AtBeginEnvironment{itemize}{\addtocounter{secretx@listlevel}{1}}
1092 \AtEndEnvironment{itemize}{\addtocounter{secretx@listlevel}{-1}}
1093 \AtBeginEnvironment{enumerate}{\addtocounter{secretx@listlevel}{1}}
1094 \AtEndEnvironment{enumerate}{\addtocounter{secretx@listlevel}{-1}}
1095 \AtBeginEnvironment{description}{\addtocounter{secretx@listlevel}{1}}
1096 \AtEndEnvironment{description}{\addtocounter{secretx@listlevel}{-1}}
1097 % \end{macrocode}
1098 % \end{macro}
1099 %
1100 % \begin{macro}{secretx@listmargin}
1101 % \changes{v0.11}{2023/05/22}{Define margin macro for markings lists}
1102 % This defines an additional offset for list environments to make sure
1103 % the marking does not overhang the label.
1104 % \begin{macrocode}
1105 \newrobustcmd\secretx@listmargin[0]{%
1106 \ifnumgreater{\value{secretx@listlevel}}{0}{\leftmargin}{0pt}
1107 }
1108 % \end{macrocode}
1109 % \end{macro}
1110 %
1111 % \subsection{Additional Statements}
1112 % \changes{v0.10}{2021/03/14}{Add distribution statements}
1113 %
1114 % \begin{macro}{\distribution}
1115 % Define the wrapper for directing to the proper distribution statement.
1116 % \begin{macrocode}
1117 \newrobustcmd\distribution[4]{%
1118 DISTRIBUTION STATEMENT #1. \csuse{secretx@distro@#1}{#2}{#3}{#4}%
1119 }
1120 % \end{macrocode}
1121 % The individual statements from Table 5 in \cite{dodi_5230.24}.
1122 % \begin{macrocode}
1123 \newrobustcmd\secretx@distro@A[3]{%
1124 Approved for public release: distribution unlimited.
1125 }
1126 \newrobustcmd\secretx@distro@B[3]{%
1127 Distribution authorized to U.S. Government agencies #1 #2. Other
1128 requests for this document shall be referred to #3.
1129 }
1130 \newrobustcmd\secretx@distro@C[3]{%
1131 Distribution authorized to U.S. Government agencies and their
1132 contractors #1 #2. Other requests for this document shall be
1133 referred to #3.
1134 }
1135 \newrobustcmd\secretx@distro@D[3]{%
1136 Distribution authorized to Department of Defense and U.S. DoD
1137 contractors only #1 #2. Other requests for this document shall be
1138 referred to #3.
1139 }
1140 \newrobustcmd\secretx@distro@E[3]{%
1141 Distribution authorized to DoD Components only #1 #2. Other requests
1142 for this document shall be referred to #3.
1143 }
1144 \newrobustcmd\secretx@distro@F[3]{%
1145 Further dissemination only as directed by #3 #2 or higher DoD
1146 authority.
1147 }
1148 % \end{macrocode}
1149 % \end{macro}
1150 %
1151 % \begin{macro}{\exportcontrol}
1152 % \changes{v0.10}{2021/03/14}{Add export control statement}
1153 %
1154 % Typeset the export control statement in a framed box.
1155 % \begin{macrocode}
1156 \newrobustcmd\exportcontrol[1][0.9\textwidth]{
1157 \fbox{%
1158 \begin{minipage}{#1}%
1159 WARNING - This document contains technical data whose export
1160 is restricted by the Arms Export Control Act (Title 22,
1161 U.S.C., Sec 2751, et seq.) or the Export Administration Act
1162 of 1979 (Title 50, U.S.C., App. 2401 et seq.), as amended.
1163 Violations of these export laws are subject to severe
1164 criminal penalties. Disseminate in accordance with
1165 provisions of DoD Directive 5230.25.
1166 \end{minipage}%
1167 }%
1168 }
1169 % \end{macrocode}
1170 % \end{macro}
1171 %
1172 % \iffalse
1173 %</package>
1174 % \fi
1175 %
1176 % \appendix
1177 %
1178 % \section{\label{app:example} Examples}
1179 %
1180 % This is the code demonstrating the use of \textsf{secretx}. The
1181 % source is in the \textsf{doc/latex/secretx} directory. Simply run the
1182 % code through \LaTeX{} to see the typeset examples.
1183 %
1184 % \subsection{\label{app:document} Example Document}
1185 % \changes{v0.8.4}{2019/05/11}{Move example article to appendix}
1186 %
1187 % \begin{lstlisting}[basicstyle=\ttfamily\small]
1188 % \iffalse
1189 %<*document>
1190 % \fi
1191 \documentclass{article}
1192 \usepackage{secretx}
1193 \title{\unclassified{An example document with markings}}
1194 \author{Keith F. Prussing}
1195 \date{\today}
1196
1197 % Show the page and document level in the header.
1198 \fancyhead[L]{Document --- \doclevel}
1199 \fancyhead[R]{Page --- \pagelevel}
1200 \fancyfoot[L]{\thepage}
1201 % Remove the header line.
1202 \renewcommand{\headrulewidth}{0pt}
1203 % Redefine headers and markings to avoid unnecessary alarm.
1204 \addmarking{1}{(1)}{Trivial}
1205 \addmarking{5}{(5)}{Sensitive}
1206 \addmarking{10}{(10)}{Important}
1207 \addmarking{25}{(25)}{Very Important}
1208
1209 \usepackage{mwe}
1210 \usepackage[colorlinks]{hyperref}
1211 \begin{document}
1212 \maketitle
1213 \thispagestyle{secretx}
1214 \tableofcontents
1215 \listoffigures
1216
1217 \begin{abstract}
1218 \unclassified{%
1219 This is an example document showing the usage of the
1220 \textsf{secretx} package. The markings in the following are purely
1221 for demonstration purpose. All of the material is
1222 unclassified.\footnote{\unclassified{%
1223 This document may have been typeset with the markings adjusted
1224 to prevent unnecessary alarm. To see the real markings, simply
1225 remove the redefinitions as described in
1226 \href{file://secretx.pdf}{secretx.pdf} and rerun through
1227 \LaTeX{}.
1228 }
1229 }
1230 }
1231 \end{abstract}
1232
1233 \unclassified{\lipsum[1]}\par
1234 \unclassified{\lipsum[2]}\par
1235 \unclassified{\lipsum[3]}\par
1236 \confidential{\lipsum[4]}\par
1237 \unclassified{\lipsum[5]}\par
1238 \unclassified{\lipsum[6]}\par
1239 \topsecret{\lipsum[7]}\par
1240 \secret{\lipsum[8]}\par
1241 \section{\setlevel{1}\getmarking[1] A New Section}
1242 \unclassified{\lipsum[9]\par\secret{\lipsum[9]\par}\lipsum[9]}\par
1243 \unclassified{\lipsum[10]}\par
1244 \unclassified{\lipsum[11]}\par
1245 \unclassified{\lipsum[12]}\par
1246 \unclassified{\lipsum[13]}\par
1247 \unclassified{\lipsum[14]}\par
1248 \unclassified{\lipsum[15]}\par
1249
1250 % Demonstrate marking a figure.
1251 \begin{figure}
1252 \centering
1253 \begin{secret box}
1254 \includegraphics{example-image-16x10}%
1255 \end{secret box}
1256 \caption{\setlevel{1}\getmarking[1]%
1257 An example image with a classification on the caption.
1258 }
1259 \end{figure}
1260
1261 % Use as an environment
1262 \begin{unclassified block}
1263 \lipsum[16-20]
1264 \end{unclassified block}
1265
1266 \begin{secret block}
1267 \section{A Section within a Block}
1268
1269 Notice how the marking gets placed in the margin and not correctly
1270 with the section title? It is not properly reflected in the table
1271 of contents. Additionally, Fig. \ref{fig:bad-figure} places the
1272 markings in the margin and not with the image or the caption.
1273
1274 \lipsum[21]\par
1275 \unclassified{\lipsum[22]}\par
1276 \lipsum[23]\par
1277 \begin{figure}
1278 \includegraphics{example-image-16x10}
1279 \unclassified{\caption{A short caption}}
1280 \label{fig:bad-figure}
1281 \end{figure}
1282 \end{secret block}
1283
1284 \begin{itemize}
1285 \item \unclassified{The first unclassified item}
1286 \item \confidential{The second item is a higher marking}
1287 \item \unclassified{The third is back to unclassified}
1288 \end{itemize}
1289
1290 \unclassified{\lipsum[1]\par}
1291
1292 \begin{enumerate}
1293 \item \confidential{First enumerated item}
1294 \item \unclassified{A second enumerated item}
1295 \item \unclassified{And a final enumerated item}
1296 \end{enumerate}
1297
1298 \begin{description}
1299 \item[One] \unclassified{First description item}
1300 \item[Two] \unclassified{A second description item}
1301 \item[Three] \confidential{And a final description item}
1302 \end{description}
1303 \end{document}
1304 % \iffalse
1305 %</document>
1306 % \fi
1307 % \end{lstlisting}
1308 %
1309 % \subsection{\label{app:beamer} Beamer Slides}
1310 % \changes{v0.8.4}{2019/05/11}{Add beamer example}
1311 %
1312 % \begin{lstlisting}[basicstyle=\ttfamily\small]
1313 % \iffalse
1314 %<*slides>
1315 % \fi
1316 \documentclass{beamer}
1317
1318 \usepackage{secretx}
1319
1320 \begin{document}
1321 \begin{frame}
1322 \frametitle{\unclassified{An example}}
1323 \begin{itemize}
1324 \item \unclassified{An unclassified item}
1325 \end{itemize}
1326 \end{frame}
1327
1328 \begin{frame}
1329 \frametitle{\unclassified{A slide with secret information}}
1330 \begin{itemize}
1331 \item \secret{A secret item}
1332 \end{itemize}
1333 \end{frame}
1334 \end{document}
1335 % \iffalse
1336 %</slides>
1337 % \fi
1338 % \end{lstlisting}
1339 %
1340 % \Finale{}
1341 %
1342 % \iffalse
1343 %<*bibliography>
1344 @manual{dodi_5230.24,
1345 title = {{Distribution} {Statements} on {Technical} {Documents}},
1346 editor = {Frank Kendall},
1347 type = {{DoD} {Instruction}},
1348 number = 5230.24,
1349 year = 2018,
1350 month = 10,
1351 day = 15,
1352 organization = {{Department} of {Defense}},
1353 location = {Washington, DC},
1354 url = {https://www.esd.whs.mil/Portals/54/Documents/DD/issuances/dodi/523024p.pdf},
1355 urldate = {2021-03-13}
1356 }
1357
1358 @misc{noauthor_marking_2021,
1359 title = {Marking {Classified} {Information} {Job} {Aid}},
1360 url = {https://www.cdse.edu/Portals/124/Documents/jobaids/information/Marking_Classified_Information.pdf?ver=K6RVqlnVuvTyO5lI2yF23g%3d%3d},
1361 urldate = {2022-11-28},
1362 publisher = {Center for Development of Security Excellence},
1363 month = jul,
1364 year = {2021},
1365 }
1366 %</bibliography>
1367 % \fi
1368 %
1369 \endinput