Debian Codegraph @

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

raw
1 \def\fileversion{v1.0a -- (c) 2001 by Hans-Christoph Wirth}
2 \def\filedate{2005/06/15}
3 % \iffalse
4 % File `formular.dtx'. See below for Copyright.
5 %
6 %<*driver>
7 \documentclass{ltxdoc}
8 \CheckSum{639}
9 \CodelineIndex
10 \RecordChanges
11 \usepackage{formular}
12 \title{The \textsf{formular} Package.\thanks{This file has version
13 number \fileversion, dated \filedate.}}
14 \date{\filedate}
15 \author{Hans-Christoph Wirth\\[email protected]}
16 \begin{document}
17 \setlength{\parindent}{0pt}
18 \setlength{\parskip}{0.3\baselineskip}
19 \maketitle
20 \DocInput{formular.dtx}
21 \end{document}
22 %</driver>
23 %
24 % \fi
25 % \parindent 0pt
26 % \begin{quote}\itshape
27 % This package provides some commands useful for typesetting
28 % fields in formulars which are intended to be filled either manually
29 % or using \TeX.
30 % \end{quote}
31 %
32 %%
33 %\begin{verbatim}
34 %% Copyright 2001 Hans-Christoph Wirth ([email protected])
35 %%
36 %% This program/package may be distributed and/or modified under the
37 %% conditions of the LaTeX Project Public License, either version 1.2
38 %% of this license or (at your option) any later version.
39 %% The latest version of this license is available at
40 %% http://www.latex-project.org/lppl.txt
41 %% and version 1.2 or later is part of all distributions of LaTeX
42 %% version 1999/12/01 or later.
43 %%
44 %% The quintessence of LPPL is:
45 %% - Distribute the package only in its full contents
46 %% - If you modify any files, rename them before
47 %%
48 %% This program/package consists of the files
49 %% formular.ins (driver file)
50 %% formular.dtx (source and documentation)
51 %% formular.sty (actual style file, generated)
52 %% formular.dvi (documentation, generated)
53 %\end{verbatim}
54 %%
55 % \section{Examples}
56 %
57 % When typesetting forms there often arises the need for defining
58 % fields which consists of one or more lines where the customer can
59 % write something down manually. To support a unique appearance of
60 % those fields we contribute some commands which define general
61 % fields.
62 %
63 % \subsection{One-line Fields}
64 %
65 % The following piece of code declares and uses a simple
66 % one-line field |namef|:
67 % \begin{quote}\begin{verbatim}
68 %\newFRMfield{namef}{15mm}
69 %
70 %This is \useFRMfield{namef}[John]
71 % and \useFRMfield{namef}.
72 % \end{verbatim}\end{quote}
73 %
74 % The output is the following:
75 % \begin{quote}
76 %\newFRMfield{namef}{15mm}
77 %This is \useFRMfield{namef}[John]
78 % and \useFRMfield{namef}.
79 % \end{quote}
80 %
81 % More complicated fields may have a description and a default content.
82 %
83 % \begin{quote}\begin{verbatim}
84 %\newFRMfield{namef}{15mm}[Name][nobody]
85 %
86 %This is \useFRMfield{namef}[John]
87 % and \useFRMfield{namef}
88 % and \useFRMfield{namef}[]
89 % and \useFRMfield{namef}[Fred Long Name]
90 % \end{verbatim}\end{quote}
91 %
92 % Notice that the field growths with the content:
93 % \begin{quote}
94 %\newFRMfield{namef}{15mm}[Name][nobody]
95 %\renewFRMfield{namef}{15mm}[Name][nobody]
96 %This is \useFRMfield{namef}[John]
97 % and \useFRMfield{namef}
98 % and \useFRMfield{namef}[]
99 % and \useFRMfield{namef}[Fred Long Name]
100 % \end{quote}
101 %
102 % \subsection{Different Styles}
103 %
104 % Each class of fields can have its own font style. Additionally
105 % there is a \emph{ruled} style implemented. In the
106 % following we declare two one-line fields with different appearance:
107 %
108 % \begin{quote}\begin{verbatim}
109 %\newFRMfield{placef}{40mm}[Place]
110 %
111 %\setFRMfontfamily{cmr}
112 %\setFRMfontshape{it}
113 %\setFRMfontsize{12}
114 %\setFRMruledstyle
115 %\newFRMfield{sigf}{30mm}[Signature]
116 %
117 %\useFRMfield{placef}[Sometown], \useFRMfield{sigf}[U. N. Known]
118 % \end{verbatim}\end{quote}
119 %
120 % \begin{quote}
121 %\newFRMfield{placef}{40mm}[Place]
122 %\setFRMfontfamily{cmr}
123 %\setFRMfontshape{it}
124 %\setFRMfontsize{12}
125 %\setFRMruledstyle
126 %\newFRMfield{sigf}{30mm}[Signature]
127 %
128 %\useFRMfield{placef}[Sometown], \useFRMfield{sigf}[U. N. Known]
129 % \end{quote}
130 %
131 % \subsection{Multi-line Environments}
132 %
133 % The following piece of code declares and uses two multi-line
134 % environments. Notice that there are two styles: The description of the
135 % field may appear on a separate line or not. Each environment has a
136 % description and a minimal number of lines.
137 %
138 % \begin{quote}\begin{verbatim}
139 %\setFRMbreakstyle
140 %\newFRMenvironment{env1}{Foobar}{2}
141 %\setFRMinlinestyle
142 %\newFRMenvironment{env2}{Barfoo}{3}
143 %
144 %\begin{env1} This is break style \end{env1}
145 %\begin{env2} This is inline style \end{env2}
146 % \end{verbatim}\end{quote}
147 %
148 %\setFRMbreakstyle
149 %\newFRMenvironment{env1}{Foobar}{2}
150 %\setFRMinlinestyle
151 %\newFRMenvironment{env2}{Barfoo}{3}
152 %
153 %\begin{env1} This is break style \end{env1}
154 %\begin{env2} This is inline style \end{env2}
155 %
156 % \subsection{Containers}
157 % \label{sec:example:container}
158 % A container is a collection of fields. The container specifies
159 % which fields belong to it, and where the fields are to be printed.
160 % The following piece of code declares a container which contains three
161 % fields.
162 % \begin{quote}\begin{verbatim}
163 %\newFRMcontainer{Grades}
164 % {\setFRMruledstyle
165 % \newFRMfield{Ma}{30mm}[][////]
166 % \newFRMfield{Ph}{30mm}[][////]
167 % \newFRMfield{En}{30mm}[english grade][////]
168 % }{%
169 % \parbox[t]{0.45\linewidth}{\baselineskip18pt
170 % Maths \dotfill\ \useFRMfield{Ma}\newline
171 % Physics \dotfill\ \useFRMfield{Ph}}\hfill
172 % \parbox[t]{0.45\linewidth}{%
173 % English \dotfill\ \useFRMfield{En}}%
174 % }
175 %\begin{Grades}
176 % \setMa{excellent}
177 % \setPh{very good}
178 %\end{Grades}
179 % \end{verbatim}\end{quote}
180 %
181 %\newFRMcontainer{Grades}
182 % {\setFRMruledstyle
183 % \newFRMfield{Ma}{30mm}[][////]
184 % \newFRMfield{Ph}{30mm}[][////]
185 % \newFRMfield{En}{30mm}[english grade][////]
186 % }{%
187 % \parbox[t]{0.45\linewidth}{\baselineskip18pt
188 % Maths \dotfill\ \useFRMfield{Ma}\newline
189 % Physics \dotfill\ \useFRMfield{Ph}}\hfill
190 % \parbox[t]{0.45\linewidth}{%
191 % English \dotfill\ \useFRMfield{En}}%
192 % }
193 %\begin{Grades}
194 % \setMa{excellent}
195 % \setPh{very good}
196 %\end{Grades}
197 %
198 % \section{Command Description}
199 %
200 % \subsection{Style Parameters}
201 %
202 % The commands explained in this section select the general appearance
203 % of the fields. A call to a command affects all fields which are
204 % declared subsequently (within the same scope).
205 %
206 % \bigskip
207 % \DescribeMacro{\setFRMrulewidth}
208 % The command
209 % \begin{quote}|\setFRMrulewidth|\marg{dimen}\end{quote}
210 % sets the thickness of the underlining rules to \meta{dimen}
211 % (default: 0.1pt). The instruction |\setFRMrulewidth{0pt}| makes
212 % rules disappear.
213 %
214 % \DescribeMacro{\setFRMrulesep}
215 % The command
216 % \begin{quote}|\setFRMrulesep|\marg{dimen}\end{quote}
217 % sets the vertical distance between the font baseline and the
218 % underlining rules (default: 2pt).
219 %
220 % \DescribeMacro{\setFRMmargin}
221 % The command
222 % \begin{quote}|\setFRMmargin|\marg{dimen}\end{quote}
223 % sets the horizontal indentation of the content of multi-line
224 % |FRMenvironment|s (default: 5pt).
225 %
226 % \DescribeMacro{\setFRMbaselineskip}
227 % The command
228 % \begin{quote}|\setFRMbaselineskip|\marg{dimen}\end{quote}
229 % sets the baselineskip of the content of multi-line
230 % |FRMenvironment|s (default: 18pt).
231 %
232 % \DescribeMacro{\setFRMfontencoding}
233 % \DescribeMacro{\setFRMfontsize}
234 % \DescribeMacro{\setFRMfontfamily}
235 % \DescribeMacro{\setFRMfontseries}
236 % \DescribeMacro{\setFRMfontshape}
237 % The |\setFRMfont|\ldots{} commands select the font used for the content, and
238 % the corresponding |\setFRMdfont|\ldots{} commands select the font
239 % of the description of one-line fields. For a description of the
240 % meaning of the parameters we refer to command |\usefont| in standard
241 % \LaTeX2e{} documentation. Notice that |\setFRMfontsize| has only
242 % one parameter, since the baselineskip is selected with a separate
243 % command.
244 %
245 % \bigskip
246 % All above commands can be supplied with an optional parameter
247 % specifying a (already declared) field. This enables to change the
248 % appearance of fields after declaration. The following example
249 % illustrates this:
250 % \begin{quote}\begin{verbatim}
251 %\newFRMfield{foo}{3cm}
252 %\setFRMfontsize[foo]{20pt}
253 % \end{verbatim}\end{quote}
254 %
255 % To this end, there are some more commands which have only effect when this
256 % optional parameter is supplied:
257 %
258 % \DescribeMacro{\setFRMcontent}
259 % \DescribeMacro{\setFRMdescription}
260 % \DescribeMacro{\setFRMwidth}
261 % The commands \begin{quote}|\setFRMcontent|\oarg{field}\marg{content}\newline
262 % |\setFRMdescription|\oarg{field}\marg{content}\end{quote} set the
263 % (default) content and the description of the field, while
264 % \begin{quote}|\setFRMwidth|\oarg{field}\marg{width}\end{quote}
265 % changes the (minimal) width.
266 %
267 % \subsection{One-line Fields}
268 % A |FRMfield| consists of three ingredients:
269 %
270 % \begin{enumerate}
271 % \item The \emph{content} of the field. This is a (maybe empty)
272 % one-line string.
273 % \item A \emph{horizontal rule}. The length of the rule is at least
274 % the minimal width of the field, but it grows with the content or the
275 % description. It is guaranteed that the rule exceeds the content at
276 % least by the amount which is set with |\setFRMmargin|.
277 % \item The \emph{description}. This is a (maybe empty) one-line
278 % string printed below the rule.
279 % \end{enumerate}
280 %
281 % \bigskip\DescribeMacro{\newFRMfield}
282 % A |FRMfield| must be declared as follows:
283 % \begin{quote}
284 % |\newFRMfield|\marg{field id}\marg{width}\newline
285 % |\newFRMfield|\marg{field
286 % id}\marg{width}\oarg{description}\newline
287 % |\newFRMfield|\marg{field
288 % id}\marg{width}\oarg{description}\oarg{default content}
289 % \end{quote}
290 % The field is associated with the style setting which is valid at
291 % this moment.
292 %
293 % \DescribeMacro{\useFRMfield}
294 % When a field is declared, it can be used with the command
295 % \begin{quote}
296 % |\useFRMfield|\marg{name}\newline
297 % |\useFRMfield|\marg{name}\oarg{content}
298 % \end{quote}
299 % If the \meta{content} is not supplied to |\useFRMfield|, then the
300 % \meta{default content} is printed.
301 %
302 % \bigskip\DescribeMacro{\renewFRMfield}
303 % The macro |\renewFRMfield| is nearly the same as |\newFRMfield|,
304 % but it changes an existing field rather than defining a new one.
305 %
306 % \bigskip
307 % \DescribeMacro{\setFRMruledstyle}
308 % \DescribeMacro{\setFRMplainstyle}
309 % Besides the style parameters discussed above, the user has the
310 % additional choice between the following two styles: With
311 % \begin{quote}|\setFRMplainstyle|\end{quote}
312 % the content is underlined by a single rule. With
313 % \begin{quote}|\setFRMruledstyle|\end{quote}
314 % the content is printed over a field of rules. The height of the
315 % ruled field adjusts automatically to the current font size.
316 %
317 % \subsection{Multi-line Environments}
318 % A |FRMenvironment| consists of three ingredients:
319 %
320 % \begin{enumerate}
321 % \item The \emph{content} of the field. This is a (possibly empty)
322 % text.
323 % \item A collection of \emph{rules} which underline the content.
324 % \item The \emph{description}. This is a one-line string printed at
325 % the beginning of the environment.
326 % \end{enumerate}
327 %
328 % \bigskip\DescribeMacro{\newFRMenvironment}
329 % A |FRMenvironment| must be declared as follows:
330 %
331 % \begin{quote}
332 % |\newFRMenvironment|\marg{envid}\marg{description}\marg{default lines}
333 % \end{quote}
334 %
335 % As one may expect, the current style settings are associated with
336 % the environment from this point on. The |FRMenvironment| is used in
337 % the following way:
338 %
339 % \begin{quote}
340 % |\begin|\marg{envid} \meta{content} |\end|\marg{envid}\newline
341 % |\begin|\marg{envid}\oarg{lines} \meta{content} |\end|\marg{envid}
342 % \end{quote}
343 %
344 % This will print a |FRMenvironment| with description
345 % \meta{description} and content \meta{content}. The environment
346 % extends to at least \meta{default lines} many lines (or to
347 % \meta{lines} lines, if the optional argument is supplied). If the
348 % \meta{content} does not fit into this space, the environment is
349 % further extended and a warning is issued.
350 %
351 % \DescribeMacro{\setFRMbaselineskip}
352 % The baselineskip of the content can be adjusted with
353 % \begin{quote}|\setFRMbaselineskip|\marg{dimen}\end{quote}
354 %
355 % \DescribeMacro{\setFRMmargin}
356 % The indentation of the content can be adjusted with
357 % \begin{quote}|\setFRMmargin|\marg{dimen}\end{quote}
358 % It defaults to 5pt.
359 %
360 % \DescribeMacro{\setFRMbreakstyle}
361 % \DescribeMacro{\setFRMinlinestyle}
362 % There are two styles implemented:
363 % The content may start in the same line as the description
364 % (|\setFRMinlinestyle|), or the description may appear on its own
365 % line (|\setFRMbreakstyle|). Notice that in |break| style, the
366 % description's line is not counted within the line range.
367 %
368 % \subsection{Containers}
369 %
370 % A |FRMcontainer| is a simple way to collect several |FRMfield|s into
371 % one logical unit. The container defines the set of fields, their
372 % default content, and how to print the individual fields. This
373 % definition can go to the preamble of the document.
374 %
375 % The content of the container will usually consist solely of commands
376 % which set the field's content. So the user must not care about the
377 % actual typesetting of the fields.
378 %
379 % \DescribeMacro{\newFRMcontainer}
380 % The command
381 % \begin{quote}|\newFRMcontainer|\marg{cid}\marg{init code}\marg{apply
382 % code}\end{quote}
383 % defines a new container \meta{cid}. The container will be used
384 % afterwards like a environment
385 % \begin{quote}|\begin|\marg{cid} \meta{container
386 % content} |\end|\marg{cid}\end{quote}
387 %
388 % The \meta{init code} may contain any code needed for setup of the
389 % container. In particular, one may employ at this point:
390 % \begin{itemize}
391 % \item All style setting commands |\setFRM|\ldots{} of this package
392 %
393 % Notice that the container always initializes the
394 % settings to the situtation which was valid when the call to
395 % |\newFRMcontainer| happens. This ensures that multiple calls to the
396 % same container always appear in the same style.
397 % \item The command |\newFRMfield| to declare local fields.
398 % \end{itemize}
399 %
400 % \DescribeMacro{\set...}
401 % Within the \meta{init code} of a container, a call to
402 % |\newFRMfield|\marg{field} defines one more command, namely
403 % |\set|\meta{field}. The command
404 % \begin{quote}|\set|\meta{field}\marg{content}\end{quote}
405 % is a convenient shortcut for
406 % \begin{quote}|\setFRMcontent|\oarg{field}\marg{content}\end{quote}
407 % It may be used in the content of the container to define the content
408 % of the individual fields. (See example in
409 % Section~\ref{sec:example:container}.)
410 %
411 % \StopEventually{}
412 %
413 % \section{The Implementation}
414 % \begin{macrocode}
415 \NeedsTeXFormat{LaTeX2e}
416 \ProvidesPackage{formular}[\filedate \space \fileversion]
417
418 \RequirePackage{xspace}
419 \def\FRM@err{\PackageError{formular}}
420 \def\FRM@warn{\PackageWarning{formular}}
421
422 \newlength\frm@margin
423 \newlength\frm@baselineskip
424 \newbox\frm@namebx
425 \newbox\frm@contbx
426 \newcount\frm@cnt
427 \newcount\frm@lbound
428 \newif\iffrm@breakstyle
429 \newif\iffrm@ruledstyle
430 % \end{macrocode}
431
432 % \subsection{Global defaults}
433 % The current and global settings are stored internally in |\frm@...|.
434 % The settings of individual field \meta{f} is stored in
435 % |\frm@|\meta{f}|@...|.
436 %
437 % Auxiliary macros to define the |\setFRM|\ldots{} commands. Those
438 % commands, when called with optional argument containing a field id,
439 % must check whether the field is declared and then modify its settings.
440 % \begin{macrocode}
441 \newcommand{\FRM@generatesetcommand}[1]{%
442 \expandafter
443 \newcommand\expandafter{\csname setFRM#1\endcsname}[2][]{%
444 \ifx##1\relax\relax
445 \expandafter\def\csname frm@#1\endcsname{##2}\else
446 \@ifundefined{frm@##1@content}
447 {\FRM@err{FRMfield `##1' not declared.}}{%
448 \expandafter\def\csname frm@##1@#1\endcsname{##2}}\fi
449 }
450 }
451 % \end{macrocode}
452 % This is for the handling of |\setFRM...style| commands. The call\newline
453 % |\FRM@generatesetstylecommand|\marg{a}\marg{b}\marg{c}\newline
454 % generates |\setFRM|\meta{a}|style| which itself will let
455 % |\iffrm@|\meta{b}|style| to be |\if|\meta{c}. For individual
456 % fields, the |\if...| are stored in one macro only.
457 % \begin{macrocode}
458 \newcommand{\FRM@generatesetstylecommand}[3]{%
459 \expandafter
460 \newcommand\expandafter{\csname setFRM#1style\endcsname}[1][]{%
461 \ifx##1\relax\relax
462 \csname frm@#2style#3\endcsname \else
463 \@ifundefined{frm@##1@content}
464 {\FRM@err{FRMfield `##1' not declared.}}{%
465 \expandafter\let\csname iffrm@##1@#2style\expandafter
466 \endcsname \csname if#3\endcsname }\fi
467 }
468 }
469 % \end{macrocode}
470 % This is for the handling of |\setFRM...| counters and lengths.
471 % Since we do not want to waste registers, we store the contents of
472 % registers in macros (rather than in registers) for the individual fields.
473 % \begin{macrocode}
474 \newcommand{\FRM@generatesetlengthcommand}[1]{%
475 \expandafter
476 \newcommand\expandafter{\csname setFRM#1\endcsname}[2][]{%
477 \ifx##1\relax\relax
478 \csname frm@#1\endcsname=##2\relax \else
479 \@ifundefined{frm@##1@content}
480 {\FRM@err{FRMfield `##1' not declared.}}{%
481 \expandafter\def\csname frm@##1@#1\endcsname{##2}}\fi
482 }
483 }
484 % \end{macrocode}
485
486 % The first two commands generated have no effect if called without
487 % the optional parameter.
488 % \begin{macrocode}
489 \FRM@generatesetcommand{content}
490 \FRM@generatesetcommand{description}
491 % \end{macrocode}
492 % Thickness of all rules
493 % \begin{macrocode}
494 \FRM@generatesetcommand{rulewidth}
495 \setFRMrulewidth{0.1pt}
496 % \end{macrocode}
497 % Vertical distance between baseline and an underlining rule
498 % \begin{macrocode}
499 \FRM@generatesetcommand{rulesep}
500 \setFRMrulesep{2pt}
501 % \end{macrocode}
502
503 % \subsection{Defaults for one-line environments}
504 % Style of a one-line environment
505 % \begin{macrocode}
506 \FRM@generatesetstylecommand{plain}{ruled}{false}
507 \FRM@generatesetstylecommand{ruled}{ruled}{true}
508 % \end{macrocode}
509 % Default width of fields (not user accessible)
510 % \begin{macrocode}
511 \def\frm@width{0pt}
512 % \end{macrocode}
513
514 % \subsection{Defaults for multi-line environments}
515 % Indentation of the content of a multi-line environment
516 % \begin{macrocode}
517 \FRM@generatesetlengthcommand{margin}
518 \setFRMmargin{5pt}
519 % \end{macrocode}
520 % |\baselineskip| within a multi-line environment
521 % \begin{macrocode}
522 \FRM@generatesetlengthcommand{baselineskip}
523 \setFRMbaselineskip{18pt}
524 % \end{macrocode}
525 % Style of a multi-line environment
526 % \begin{macrocode}
527 \FRM@generatesetstylecommand{break}{break}{true}
528 \FRM@generatesetstylecommand{inline}{break}{false}
529 % \end{macrocode}
530 % Default number of lines (not user accessible)
531 % \begin{macrocode}
532 \frm@lbound=0
533 % \end{macrocode}
534
535 % \subsection{Font selection for the fields}
536 % Font shape of the content of all fields
537 % \begin{macrocode}
538 \FRM@generatesetcommand{fontencoding}
539 \FRM@generatesetcommand{fontsize}
540 \FRM@generatesetcommand{fontfamily}
541 \FRM@generatesetcommand{fontseries}
542 \FRM@generatesetcommand{fontshape}
543 \setFRMfontencoding{T1}
544 \setFRMfontsize{10}
545 \setFRMfontfamily{cmtt}
546 \setFRMfontseries{m}
547 \setFRMfontshape{n}
548 % \end{macrocode}
549
550 % Font shape of the description of one-line fields
551 % \begin{macrocode}
552 \FRM@generatesetcommand{dfontencoding}
553 \FRM@generatesetcommand{dfontsize}
554 \FRM@generatesetcommand{dfontfamily}
555 \FRM@generatesetcommand{dfontseries}
556 \FRM@generatesetcommand{dfontshape}
557 \setFRMdfontencoding{T1}
558 \setFRMdfontsize{6}
559 \setFRMdfontfamily{cmss}
560 \setFRMdfontseries{m}
561 \setFRMdfontshape{n}
562 % \end{macrocode}
563
564 % \subsection{Auxiliary Macros for saving and restoring the settings}
565 %
566 % Store the current settings for a individual field. All \TeX{}
567 % registers are also stored in macros.
568 % \begin{macrocode}
569 \newcommand{\FRM@storeappearance}[1]{%
570 \expandafter\let\csname frm@#1@content\endcsname \frm@content
571 \expandafter\let\csname frm@#1@description\endcsname \frm@description
572 \expandafter\let\csname iffrm@#1@breakstyle\endcsname \iffrm@breakstyle
573 \expandafter\let\csname iffrm@#1@ruledstyle\endcsname \iffrm@ruledstyle
574 \expandafter\let\csname frm@#1@width\endcsname \frm@width
575 \expandafter\let\csname frm@#1@rulewidth\endcsname \frm@rulewidth
576 \expandafter\let\csname frm@#1@rulesep\endcsname \frm@rulesep
577 \expandafter\edef\csname frm@#1@lbound\endcsname{\the\frm@lbound}
578 \expandafter\edef\csname frm@#1@baselineskip\endcsname{\the\frm@baselineskip}
579 \expandafter\edef\csname frm@#1@margin\endcsname{\the\frm@margin}
580 \expandafter\let\csname frm@#1@fontfamily\endcsname \frm@fontfamily
581 \expandafter\let\csname frm@#1@fontseries\endcsname \frm@fontseries
582 \expandafter\let\csname frm@#1@fontsize\endcsname \frm@fontsize
583 \expandafter\let\csname frm@#1@fontshape\endcsname \frm@fontshape
584 \expandafter\let\csname frm@#1@fontencoding\endcsname \frm@fontencoding
585 \expandafter\let\csname frm@#1@dfontfamily\endcsname \frm@dfontfamily
586 \expandafter\let\csname frm@#1@dfontseries\endcsname \frm@dfontseries
587 \expandafter\let\csname frm@#1@dfontsize\endcsname \frm@dfontsize
588 \expandafter\let\csname frm@#1@dfontshape\endcsname \frm@dfontshape
589 \expandafter\let\csname frm@#1@dfontencoding\endcsname \frm@dfontencoding
590 }
591 % \end{macrocode}
592 % Load the current settings from a individual field. All \TeX{}
593 % registers which were stored in macros are retransformed into registers.
594 % \begin{macrocode}
595 \newcommand{\FRM@restoreappearance}[1]{%
596 \expandafter\let\expandafter\frm@content
597 \csname frm@#1@content\endcsname
598 \expandafter\let\expandafter\frm@description
599 \csname frm@#1@description\endcsname
600 \expandafter\let\expandafter\iffrm@breakstyle
601 \csname iffrm@#1@breakstyle\endcsname
602 \expandafter\let\expandafter \iffrm@ruledstyle
603 \csname iffrm@#1@ruledstyle\endcsname
604 %
605 \expandafter\let\expandafter\frm@width
606 \csname frm@#1@width\endcsname
607 \expandafter\let\expandafter\frm@rulewidth
608 \csname frm@#1@rulewidth\endcsname
609 \expandafter\let\expandafter\frm@rulesep
610 \csname frm@#1@rulesep\endcsname
611 %
612 \expandafter
613 \frm@lbound\expandafter=\csname frm@#1@lbound\endcsname
614 \expandafter
615 \frm@baselineskip=\csname frm@#1@baselineskip\endcsname
616 \expandafter
617 \frm@margin=\csname frm@#1@margin\endcsname
618 %
619 \expandafter\let\expandafter\frm@fontencoding
620 \csname frm@#1@fontencoding\endcsname
621 \expandafter\let\expandafter\frm@fontseries
622 \csname frm@#1@fontseries\endcsname
623 \expandafter\let\expandafter\frm@fontshape
624 \csname frm@#1@fontshape\endcsname
625 \expandafter\let\expandafter\frm@fontsize
626 \csname frm@#1@fontsize\endcsname
627 \expandafter\let\expandafter\frm@fontfamily
628 \csname frm@#1@fontfamily\endcsname
629 %
630 \expandafter\let\expandafter\frm@dfontencoding
631 \csname frm@#1@dfontencoding\endcsname
632 \expandafter\let\expandafter\frm@dfontseries
633 \csname frm@#1@dfontseries\endcsname
634 \expandafter\let\expandafter\frm@dfontshape
635 \csname frm@#1@dfontshape\endcsname
636 \expandafter\let\expandafter\frm@dfontsize
637 \csname frm@#1@dfontsize\endcsname
638 \expandafter\let\expandafter\frm@dfontfamily
639 \csname frm@#1@dfontfamily\endcsname
640 }
641 % \end{macrocode}
642
643 % Shorthands for actually switching to the font settings
644 % \begin{macrocode}
645 \newcommand{\FRM@selectfont}{%
646 \fontsize{\frm@fontsize}{\the\frm@baselineskip}%
647 \usefont{\frm@fontencoding}{\frm@fontfamily}
648 {\frm@fontseries}{\frm@fontshape}%
649 }
650 \newcommand{\FRM@selectdfont}{%
651 \fontsize{\frm@dfontsize}{\the\frm@baselineskip}%
652 \usefont{\frm@dfontencoding}{\frm@dfontfamily}
653 {\frm@dfontseries}{\frm@dfontshape}%
654 }
655 % \end{macrocode}
656
657 % \subsection{One-line fields}
658 % \begin{macro}{\newFRMfield}
659 % Parameter list:\newline
660 % |#1| field id\newline
661 % |#2| minimum field width\newline
662 % |#3| description (optional)\newline
663 % |#4| default content (optional)
664 % \begin{macrocode}
665 \newcommand{\newFRMfield}[1]{%
666 \@ifundefined{frm@#1@content}
667 {\new@FRMfield{#1}}{\FRM@err{cannot
668 \string\new... existing field `#1'}}
669 }
670 \newcommand{\renewFRMfield}[1]{%
671 \@ifundefined{frm@#1@content}
672 {\FRM@err{cannot \string\renew... undeclared
673 field `#1'}}{\new@FRMfield{#1}}
674 }
675 % \end{macrocode}
676 % \end{macro}
677 % \begin{macro}{\new@FRMfield}
678 % We first must fiddle around with the two optional parameters. Then
679 % we set the default values (if any) and store all settings of the
680 % individual field.
681 % \begin{macrocode}
682 \def\new@FRMfield#1#2{%
683 \@ifnextchar[%]
684 {\new@FRMfield@{#1}{#2}}{\new@FRMfield@@{#1}{#2}[][]}}
685 \def\new@FRMfield@#1#2[#3]{%
686 \@ifnextchar[%]
687 {\new@FRMfield@@{#1}{#2}[#3]}{\new@FRMfield@@{#1}{#2}[#3][]}}
688 \def\new@FRMfield@@#1#2[#3][#4]{%
689 \def\frm@width{#2}
690 \def\frm@description{#3}
691 \def\frm@content{#4}
692 \FRM@storeappearance{#1}
693 \new@FRMcontainerhook{#1}
694 }
695 % \end{macrocode}
696 % \end{macro}
697
698 % The hook is used by |\newFRMcontainer| to define the |\set...|
699 % shortcut afterwards.
700 % \begin{macrocode}
701 \let\new@FRMcontainerhook\@gobble
702 \def\new@FRMfieldspecials#1{%
703 \expandafter\def\csname set#1\endcsname##1{\setFRMcontent[#1]{##1}}
704 % \expandafter\def\csname use#1\endcsname{\useFRMfield{#1}\relax}
705 }
706 % \end{macrocode}
707
708 % \begin{macro}{\useFRMfield}
709 % Parameter list:\newline
710 % |#1| field id\newline
711 % |#2| field content (optional)
712 % \begin{macrocode}
713 \newcommand{\useFRMfield}[1]{%
714 \@ifundefined{frm@#1@content}
715 {\FRM@err{FRMfield `#1' is not declared.}}
716 {\use@FRMfield{#1}}
717 }
718 \def\use@FRMfield#1{%
719 \@ifnextchar[%]
720 {\use@FRMfield@{#1}}
721 {\use@FRMfield@{#1}[\csname frm@#1@content\endcsname]\xspace}
722 }
723 % \end{macrocode}
724 % This macro does the actual typesetting job. We must open a group to
725 % keep changes to the current settings (via |\FRM@restore...|) locally.
726 % \begin{macrocode}
727 \def\use@FRMfield@#1[#2]{\begingroup
728 \FRM@restoreappearance{#1}%
729 \setbox\frm@contbx=\hbox{%
730 \FRM@selectfont
731 \kern\frm@margin #2\kern\frm@margin}%
732 \dp\frm@contbx0pt\relax
733 % \end{macrocode}
734 % The baseline of the final field is the baseline of the content and
735 % has depth extending to the underlining rule.
736 % This makes alignment of more than one field on the
737 % same line less complex.
738 % \begin{macrocode}
739 \leavevmode
740 \vtop to \frm@rulesep{%
741 \halign{\hfil##\hfil\cr
742 % \end{macrocode}
743 % Enclose |\usebox| in braces. This circumvents a bug(?) in
744 % \texttt{pdftex.def} v0.03k of standard \texttt{graphicx} and
745 % \texttt{color} packages: Compiling with \emph{pdflatex} would
746 % break here.
747 % \changes{v1.0a}{2005/06/15}{Circumvent problem with pdflatex and graphicx/color.sty}
748 % \begin{macrocode}
749 {\usebox{\frm@contbx}}\cr
750 \noalign{\kern\frm@rulesep
751 \iffrm@ruledstyle
752 \dimen0=\frm@fontsize pt\dimen2=0pt\relax
753 \loop
754 \kern-2pt\advance\dimen2 by 2pt%
755 \hrule height\frm@rulewidth \kern-\frm@rulewidth
756 \advance\dimen0 by-2pt%
757 \ifnum\dimen0>0%
758 \repeat
759 \kern\dimen2\relax
760 \fi
761 \hrule height\frm@rulewidth depth0pt \kern2pt}%
762 \FRM@selectdfont \frm@description\cr
763 \vrule width \frm@width height 0pt\cr}\vss
764 }\endgroup
765 }
766 % \end{macrocode}
767 % \end{macro}
768
769 % \subsection{Multi-line fields}
770 % \begin{macro}{\newFRMenvironment}
771 % Parameter list:\newline
772 % |#1| environment id\newline
773 % |#2| description\newline
774 % |#3| number of lines
775 % \begin{macrocode}
776 \newcommand{\newFRMenvironment}[3]{%
777 \def\frm@description{#2}%
778 \frm@lbound=#3\relax
779 \FRM@storeappearance{env@#1}%
780 \newenvironment{#1}{%
781 \FRM@restoreappearance{env@#1}%
782 \@ifnextchar[%]
783 {\FRM@openenvironment}
784 {\FRM@openenvironment[\the\frm@lbound]}%
785 }{%
786 \FRM@closeenvironment%
787 }%
788 }
789 % \end{macrocode}
790 % Define the |\begin{}| part of the |FRMenvironment|.
791 % \begin{macrocode}
792 \def\FRM@openenvironment[#1]{%
793 \frm@lbound=#1\relax
794 % \end{macrocode}
795 % Set the description of the environment. If the current style is a
796 % |break| style, then extend the box to |\hsize|.
797 % The top line gets a ``strut'' of height |\frm@baselineskip| minus
798 % |\frm@rulesep|. The lowest line will have depth |\frm@rulesep|.
799 % Hence multiple environments fit smoothly to each other.
800 % \begin{macrocode}
801 \setbox\frm@namebx\hbox
802 \iffrm@breakstyle to\hsize\fi
803 {\frm@description\enspace
804 \skip0=\frm@baselineskip \advance\skip0-\frm@rulesep
805 \vrule width0pt height \skip0\hfil}%
806 % \end{macrocode}
807 % Start the box containing the body.
808 % \begin{macrocode}
809 \setbox\frm@contbx=\vtop\bgroup
810 \advance\hsize-2\frm@margin
811 % \end{macrocode}
812 % Leave out the horizontal space needed for the description. If the
813 % description extends the whole line, allow for a line break after this.
814 % \begin{macrocode}
815 \hskip-\frm@margin
816 \hskip\wd\frm@namebx
817 \hskip-\frm@margin\penalty0\relax
818 \hskip2\frm@margin
819 \FRM@selectfont
820 }
821 % \end{macrocode}
822 % Define the |\end{}| part of the environment.
823 % \begin{macrocode}
824 \newcommand{\FRM@closeenvironment}{%
825 % \end{macrocode}
826 % Close the content box and count the number of lines below the
827 % baseline. Set the box with depth zero.
828 % \begin{macrocode}
829 \par\egroup
830 \frm@cnt=\dp\frm@contbx
831 \dimen0=\frm@baselineskip
832 \divide\frm@cnt\dimen0\relax
833 \leavevmode\rlap{\dp\frm@contbx0pt \kern\frm@margin \usebox\frm@contbx}%
834 % \end{macrocode}
835 % Now set the rules box. It must be shifted down, since the rules
836 % should be below the actual baseline.
837 % \begin{macrocode}
838 \raise-\frm@rulesep\vtop{%
839 % \end{macrocode}
840 % The first line contains the description and a rule (if it does not
841 % extend the whole line). The description is shifted back to be
842 % aligned with the baseline.
843 % \begin{macrocode}
844 \hbox to\hsize{%
845 \dp\frm@namebx0pt%
846 \raise\frm@rulesep\hbox{\usebox{\frm@namebx}}\leaders \hrule
847 height \frm@rulewidth \hfill}
848 % \end{macrocode}
849 % If there is no |break| style, then the first line contains already
850 % one rule and the line bound must be decreased by one.
851 % \begin{macrocode}
852 \iffrm@breakstyle\else \advance\frm@lbound-1\fi\relax
853 % \end{macrocode}
854 % If the bound on the number of lines is exceeded then issue a
855 % warning.
856 % \begin{macrocode}
857 \ifnum\frm@cnt>\frm@lbound\relax
858 \@tempcnta\frm@cnt \advance\@tempcnta-\frm@lbound\relax
859 \FRM@warn{Line bound in FRMenvironment exceeded by
860 \the\@tempcnta\space line(s)}
861 \else \frm@cnt\frm@lbound \fi
862 % \end{macrocode}
863 % In each case, |\frm@cnt| contains the number of remaining rules.
864 % Plot them now. The depth of the final box is determined by the
865 % lowest rule.
866 % \begin{macrocode}
867 \loop
868 \ifnum\frm@cnt>0\relax
869 \advance\frm@cnt-1\relax
870 \kern\frm@baselineskip \kern-\frm@rulewidth
871 \hrule height \frm@rulewidth\relax
872 \repeat
873 }%
874 }
875 % \end{macrocode}
876 % \end{macro}
877
878 % \subsection{Containers}
879 %
880 % \begin{macro}{\newFRMcontainer}
881 % Parameter list:\newline
882 % |#1| container id\newline
883 % |#2| init code\newline
884 % |#3| apply code\par
885 % We store the current settings for restore at the beginning of the
886 % init code. Moreover, we use the hook to let |\newFRMfield| also
887 % define the |\set...| shortcut afterwards.
888 % \begin{macrocode}
889 \long\def\newFRMcontainer#1#2#3{%
890 \FRM@storeappearance{con@#1}%
891 \newenvironment{#1}{%
892 \let\new@FRMcontainerhook=\new@FRMfieldspecials
893 \FRM@restoreappearance{con@#1}#2}{#3}
894 }
895 % \end{macrocode}
896 % \end{macro}
897
898 % Seems to be a convention:
899 % \begin{macrocode}
900 \endinput
901 % \end{macrocode}
902 %
903 % \Finale \PrintIndex \PrintChanges