summaryrefslogtreecommitdiff
path: root/macros/inrstex/inrsdoc/genins.tex
blob: cf08172235044a55a3ef39f5afbe489584bf3a76 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
%-*-tex-*-
% Copyright Michael J. Ferguson, INRS-Telecommunications
% All rights reserved. 

% ========= Syntactic Compability Forms ============
% Each of these has a token list that is inserted before each
% particular insert ... and in a group. 
% in \begin... \end.. pairs
\newtoks\everytopinsert
\newtoks\everymidinsert
\newtoks\everypageinsert
\def\begintopinsert{\begingroup\the\everytopinsert\topinsert}
\def\beginmidinsert{\begingroup\the\everymidinsert\midinsert}
\def\beginpageinsert{\begingroup\the\everypageinsert\pageinsert}

\def\e@ndinsert{\endinsert\endgroup}

\let\endtopinsert = \e@ndinsert
\let\endmidinsert = \e@ndinsert
\let\endpageinsert = \e@ndinsert

% ============= Figure, Table, etc inserts ==========

% Assumptions 
%   The form is described by three letters, eg "fig" or "tbl"
%   If the list file exists, the page info is written. 
%   \writelistfile must be defined 
%   \autonumber, \autoreference, \ref, \quietref, \veryraggedright
%   If autonumbering is on, then 
%      \silent, \autofignum ..
%   An "fig" form and "tbl" form are defined. These need 
%        \figurelabel, and \tablelabel respectively. These are
%        usually defined in the \englishversion and \versionfrancaise
%   The insert forms use \beginmidinsert ... \endmidinsert. 


%  Defaults  --- to be set. 
%    \captiontextfraction  ... inrsdef.tex 
%    \captionskip  ... inrsdef.tex 
%    \topcaptiontrue or \topcaptionfalse  ... inrsdef.tex 
%    \figurelabel  or \figlabel  ... english.tex or francais.tex 
%    \tablelabel   or \tbllabel  ... english.tex or francais.tex 
%    \captionnumfont ... inrsfont.tex
%    \captiontitlefont ... inrsfont.tex
%    \captionbodyfont ... inrsfont.tex
%    \captionbodyon <off> ... inrsdef.tex


% This is a general form for an  insert with a caption, under it 
% if \topcaptionfalse and over it if \topcaptiontrue
% The particular form is identified with a (usually) three letter sequence
% such as "fig" or "tbl". There can be an associated list file for 
% automatic generation of the page list for the items. 
% The basic form is a non-floating type, enclosed in $$ ... $$ to give
% correct spacing. This can be put in an insert to make it float. 
% Full page forms require \vfill above and/or below for top, bottom, or center.

% The caption box measures its size and centers the text if it is short 
% or puts it in a \vbox which is \captiontextfraction of the \hsize 
% if it is not. 
% The \captionskip is the spacing between the caption and the actual 
% item in the text. This may be a table or figure or ....

% \let\captionnumfont = \bf
% \let\captiontextfont = \relax % defaults to "outside font" 
% \def\captiontextfraction{0.8} 

\def\captionbox#1#2{\setbox0=\hbox{{\captionnumfont #1}\quad #2}
                \ifdim 1\wd0 < \captiontextfraction\hsize
                    \centerline{\unhbox0}
                \else
                    \centerline{\vbox{\hsize=\captiontextfraction\hsize
                                      \veryraggedright
                                      \setbox0=\hbox{{\captionnumfont #1}\quad}
                                      \hangindent=1\wd0 \hangafter=1
                                      \noindent\unhbox0 
                                        \captiontitlefont #2}}%
                \fi}

% A caption is assumed to have both a <title> that will appear in the 
% list, if any and a <caption body> that will appear only when the caption is
% printed. The default is to have \captionbody ... "active" and to turn it
% off when making lists. 
% This is done with two commands \captionbodyon and \captionbodyoff 
% associated with a <caption body> is a <caption body font>

\def\captionbodyon{\def\captionbody##1{\captionbodyfont ##1}}
\def\captionbodyoff{\def\captionbody##1{}}


%  \rect <hor dimen>  by <vert dimen>}  A centered rectangular box to act 
% as a place holder if there is a figure to be pasted in later. 
\def\r@ect{\centerline{\vbox{\hrule
                          \hbox{\vrule height \the\dimen2
                                \hskip \dimen0
                                \vrule height \the\dimen2}
                          \hrule
                         }}}
\def\rect #1by{\dimen0 #1\afterassignment\r@ect \dimen2}

% ======= This is the general insert form =======
% #1 is the name of the insert form, #2 is the tag or number, #3 is the title
% #4 is the actual insert form value ... ie figure or table or ...

% This is the glue specification between the caption and the body of the 
% insert

\newskip\captionskip  %\captionskip=2ex

% This is a switch that controls whether the caption is above or below the
% the body of the insert

\newif\iftopcaption  %\topcaptionfalse % defaulted 

% This is the general form of the insert --- it requires both \autonumber
% and \autoreference to work. By selectively turning on/off these
% switches, multipart figures are possible. 

\def\geninsertform #1#2#3#4{
                    \ifautonumber 
                        \silent{\expandafter\csname auto#1num\endcsname{#2}}\relax
                        \edef\i@nsnum{\csname:@#2\endcsname}\else
                        \edef\i@nsnum{#2}\fi 
                        {\def\captionbody##1{}\edef\t@out{\noexpand\writelistfile
                {#1}{\csname #1tocout\endcsname}{\i@nsnum}{#3}}\t@out}\relax
                   $$\vbox{\normalbaselines
                   \iftopcaption
                         \captionbox{\csname #1label\endcsname\i@nsnum}{#3}
                         \vskip \captionskip
                         \centerline{\vbox{#4}}
                     \else
                         \centerline{\vbox{#4}}
                         \vskip \captionskip
                         \captionbox{\csname #1label\endcsname\i@nsnum}{#3}
                     \fi
                    \vss}$$}


%  ==========  Special Cases ============
%  These define simple forms for standard midinserts. It uses 
%  \beginmidinsert ... \endmidinsert for consistency

% For Figures 
\def\figureform #1#2#3{\geninsertform {fig}{#1}{#2}{#3}}
\def\figlabel{\figurelabel }
\def\figureinsert #1#2#3{\beginmidinsert 
                         \figureform{#1}{#2}{#3} 
                         \endmidinsert }

%\def\figtocout{\string\figtoc} % actually set in inrsdef.tex 


% For Tables 
\def\tableform #1#2#3{\geninsertform {tbl}{#1}{#2}{#3}}
\def\tbllabel{\tablelabel }
\def\tableinsert #1#2#3{\beginmidinsert 
                         \tableform{#1}{#2}{#3} 
                         \endmidinsert }
%\def\tbltocout{\string\tbltoc} % actually set in inrsdef.tex 


% Comment ---- \endinsert in Plain has a pre and post \bigskip 
% This should probably be removed and the spacing always controlled by 
% the $$ ... $$. Instead, if the \everymidinsert form were used it 
% would be possible to remove it with \everymidinsert = {\let\bigskip=\relax