summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/secret.sty
blob: 65361e6d301fd7f237513b4eaf113be118e2e48b (plain)
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
%Date: Fri, 24 Nov 89 13:44:13 EST
%From: Denys Duchier <duchier-denys@YALE.ARPA>
%Subject: Re: secret.sty?
%Keywords: LaTeX, secret.sty
%
%>   Does anyone out there have an option file for report.sty (call
%>   it secret.sty?) which does the following (for use in LaTeXing
%>   classified reports):
%>
%>   (1)  all paragraphs must begin with a (U), (C), or (S) which
%>   denotes unclassified, confidential, and secret, respectively.
%>
%>   (2)  if a paragraph continues on the next page, the (U), (C),
%>   and (S) has to be inserted into the first line of the continuing
%>   paragraph on the next page.
%
%I don't think requirement (2) can be satisfied as stated because when
%TeX exercises its page breaking algorithm, paragraphs have already
%been formatted and broken into individual lines, each one put in its
%own box and appended to the vertical list: you can't insert (S) at the
%top of the next page and have TeX reconsider line breaks.
%
%However, it is possible to come close: instead of putting the labels
%in the running text, we can let them hang out in the margin. The code
%below appears to work on the example I tried; put it in file
%secret.sty and use \documentstyle[secret]{article} or something like
%it at the top of your document.
%
%If you type \unclassified (resp. \confidential or \secret) the
%subsequent paragraphs will begin with (U) (resp. (C) or (S)) hanging
%out in the margin. \nosecret turns off this behaviour. You can also
%use them as environments.
%
%%--Denys
%Organization: Computer Science, Yale University, New Haven, CT 06520-2158
%%% File: secret.sty

\def\@markright#1#2#3#4{\gdef\@themark{{#1}{#4}{#3}}}
\def\@markextra#1#2#3#4{\gdef\@themark{{#1}{#2}{#4}}}
\def\@markboth#1#2#3#4#5{\gdef\@themark{{#4}{#5}{#3}}}

\def\@leftmark#1#2#3{#1}
\def\@rightmark#1#2#3{#2}
\def\@extramark#1#2#3{#3}

\def\markboth#1#2{{\let\protect\noexpand
  \let\label\relax \let\index\relax
  \expandafter\@markboth\@themark
  {#1}{#2}\mark{\@themark}}\if@nobreak\ifvmode\nobreak\fi\fi}

\def\markextra#1{{\let\protect\noexpand
  \let\label\relax \let\index\relax
  \expandafter\@markextra\@themark
  {#1}\mark{\@themark}}\if@nobreak\ifvmode\nobreak\fi\fi}

\def\extrabotmark{\expandafter\@extramark\botmark}
\def\extrafirstmark{\expandafter\@extramark\firstmark}

\def\@themark{{}{}{}}

\newdimen\@tempdimc

\output{\@tempdimc = \dp255
  \ifnum\outputpenalty <-\@M\@specialoutput\else
  \@makecol\@opcol\@floatplacement\@startcolumn
  \@whilesw\if@fcolmade \fi{\@opcol\@startcolumn}\fi
  \global\vsize\ifnum\outputpenalty >-\@Miv \@colroom
                  \else \maxdimen\fi
  \edef\@tempa{\extrabotmark}\ifx\@tempa\empty\else
    \llap{\@tempa\hskip\labelsep}\advance\@tempdimc
    -\prevdepth \advance\@tempdimc -\baselineskip
    \kern\@tempdimc\fi}

\def\@secret#1{\everypar{\markextra{}\llap{#1\hskip\parindent\hskip\labelsep}\markextra{#1}}}

\def\unclassified{\@secret{(U)}}
\def\confidential{\@secret{(C)}}
\def\secret{\@secret{(S)}}

\def\nosecret{\markextra{}\everypar{}}

\let\@extraenddocument\enddocument
\def\enddocument{\nosecret\@extraenddocument}

%--Denys