keyfunc.sh.in: Export key label and owner as options to key generators.
[distorted-keys] / keeper-cards.tex
1 %%% -*-latex-*-
2 %%%
3 %%% Typeset cards for keeper secrets.
4 %%%
5 %%% (c) 2012 Mark Wooding
6 %%%
7
8 %%%----- Licensing notice ---------------------------------------------------
9 %%%
10 %%% This file is part of the distorted.org.uk key management suite.
11 %%%
12 %%% distorted-keys is free software; you can redistribute it and/or modify
13 %%% it under the terms of the GNU General Public License as published by
14 %%% the Free Software Foundation; either version 2 of the License, or
15 %%% (at your option) any later version.
16 %%%
17 %%% distorted-keys is distributed in the hope that it will be useful,
18 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
19 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 %%% GNU General Public License for more details.
21 %%%
22 %%% You should have received a copy of the GNU General Public License
23 %%% along with distorted-keys; if not, write to the Free Software Foundation,
24 %%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26 \documentclass[a4paper, landscape, 12pt]{article}
27 \usepackage[utf8]{inputenc}
28 \usepackage[T1]{fontenc}
29 %%\usepackage[palatino, helvetica, courier, maths = cmr]{mdwfonts}
30 \usepackage{graphicx}
31
32 %% Report errors with enough context that we can debug them.
33 \errorcontextlines=999
34
35 %% Basic layout for the cards. We use the paragraph filling machinery, but
36 %% don't actually need most of the trimmings.
37 \parindent=0pt
38 \parfillskip=0pt
39 \pagestyle{empty}
40
41 %% Page layout: try to use most of the page. The document class will already
42 %% have set up the paper size, but we do the rest here.
43 \hoffset=-1in \voffset=-1in
44 \oddsidemargin=20mm
45 \textwidth=\paperwidth \advance\textwidth by -2\oddsidemargin
46 \topmargin=20mm
47 \headheight=0pt \headsep=0pt
48 \textheight=\paperheight \advance\textheight by -2\topmargin
49 \AtBeginDocument{\special{papersize=\the\paperwidth,\the\paperheight}}
50
51 %% Parameters for the cards and guide rules.
52 \newdimen\cardwd \cardwd=82mm
53 \newdimen\cardht \cardht=49mm
54 \newdimen\guidelen \guidelen=10mm
55 \newdimen\rulewd \rulewd=0.6pt
56
57 %% Typesetting the secret as text. The macro \snarf TOKEN T0 T1 ... T7
58 %% gathers T0 T1 ... T7 into a single argument and passes them to TOKEN, as
59 %% long as T0 is not \relax. We use this to process the secret text in a
60 %% continuation-passing style.
61 \def\snarf#1#2{%
62 \ifx#2\relax\let\next\empty%
63 \else\def\next{\snarfdo#1#2}%
64 \fi%
65 \next%
66 }
67 \def\snarfdo#1#2#3#4#5#6#7#8#9{#1{#2#3#4#5#6#7#8#9}}
68
69 %% Print the left and right halves of the line, with a separator. Use boxes
70 %% for the lines so that TeX will work out the width of the enclosing vbox
71 %% for us. The basic usage is \line TEXT \relax ... \relax, with eight
72 %% \relax tokens: this is enough to complete both \snarf calls.
73 \def\line{\snarf\lineleft}
74 \def\lineleft#1{\hbox\bgroup#1 \snarf\lineright}
75 \def\lineright#1{#1\egroup\line}
76
77 %% Typeset a card containing a secret. Usage is \card{INDEX}{SECRET}.
78 \def\card#1#2{%
79 %%
80 %% Make sure we're setting a paragraph.
81 \leavevmode%
82 %%
83 %% Initial material: a stretchy space on the left.
84 \hbox{}\nobreak\hfil%
85 %%
86 %% An alignment for the guide markers surrounding the actual card.
87 \vbox{\halign{&##\cr%
88 %%
89 %% Top left guides.
90 \vrule width \guidelen height \rulewd depth 0pt%
91 \vrule width \rulewd depth 0pt height \guidelen%
92 &%
93 %%
94 %% Top centre gap.
95 \hfil%
96 &%
97 %%
98 %% Top right guides.
99 \vrule width \rulewd depth 0pt height \guidelen%
100 \vrule width \guidelen height \rulewd depth 0pt%
101 \cr%
102 %%
103 %% Left gap.
104 &%
105 %%
106 %% The actual card.
107 \vbox to \cardht{%
108 %%
109 %% We actually do more or less sensible typesetting. TeX will set the
110 %% box width from the hsize, and we should leave a small margin all
111 %% around.
112 \parfillskip=0pt plus 1fil%
113 \leftskip=1em \rightskip=1em%
114 \hsize=\cardwd%
115 %%
116 %% The heading.
117 \hrule height 0pt \prevdepth = 0pt%
118 \medskip%
119 {\large\bfseries\textsf{\keeper} secret #1/\total}%
120 %%
121 %% The QR-code and the text of the secret.
122 \vfil%
123 $%
124 \vcenter{\hbox{\includegraphics[scale = 2.4]{#1.eps}}}%
125 \hfil%
126 \vcenter{\ttfamily%
127 \line#2%
128 \relax\relax\relax\relax\relax\relax\relax\relax%
129 }%
130 $%
131 %%
132 %% And we're done.
133 \vfil%
134 }%
135 &%
136 %%
137 %% Right gap.
138 \cr%
139 %%
140 %% Bottom left guides.
141 \vrule width \guidelen depth \rulewd height 0pt%
142 \vrule width \rulewd depth \guidelen height 0pt%
143 &%
144 %% Bottom centre gap.
145 \hfil%
146 &%
147 %% Bottom right guides.
148 \vrule width \rulewd depth \guidelen height 0pt%
149 \vrule width \guidelen depth \rulewd height 0pt%
150 \cr%
151 %%
152 %% Leave a small vertical space at the bottom to separate lines of cards.
153 \strut \cr%
154 }}%
155 %%
156 %% End material: a stretchy space to match the one at the start, and then
157 %% allow a break.
158 \nobreak\hfil\hbox{}%
159 \penalty0%
160 }
161
162 %%%----- That's all, folks --------------------------------------------------