summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/plates/plates.sty
blob: b54c3a78769a0f2e3dd8be60a8f2d64ae2ce6d33 (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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
%PACKAGE plates
%    For placement of special float enviornment `plates'.  Allows
%    user to put plate floats in document as if they were figure, but
%    the plates are all gathered and printed at the specified location.
%    Designed to be helpful when including color figures at the back of
%    a document.  Optionally, the `figures' option can be supplied and then
%    the plates will just be printed in the document.
%
%NEW ENVIORNMENT
%\begin{plate}
%%just use like figure enviornment
%\end{plate}
%
%NEW COMMANDS
%\ProcessPlates - at point of issue the plates are gathered together and printed.
%\listofplates - prints the list of plates just like \listoffigures
%\setplatename - sets the name of the float enviornment - default `plates'
%
%OPTIONS
%figures - treats plates like regular floats.  Plates are printed inside the document
%            and \autoref{} will now use Figure instead of Plate in referencing.
%            \listofplates & \ProcessPlates has no effect
%memoir - if using memoir class creates an added appendix page where \ProcessPlates is issued.
%onefloatperpage - only allows one float per page, after each float \cleardoublepage is issued.
%   otherwise default is to gather floats together but will print as many as will fit to a page
%   as well as printing on both sides of a two sided document. *Probably should fix this
%   or make an option to turn off both sides.    
%
%
%This Package includes code from the Memoir class and uses
%the endplate package, a modification of endfloat.
%
%Anthony A. Tanbakuchi
%Mar.19.2002
%
%
\NeedsTeXFormat{LaTeX2e} \ProvidesPackage{plates}[2002/03/18 v0.1 FigSize sizes graphics for graphicx package]
\RequirePackage{ifthen}[1994/06/01]

\newcounter{optfigures}
\newcounter{optmemoir}
\newcounter{optonefloatperpage}
    %Option to process all plates as figures (ie --- the package is disables, plate enviornments act like figures.)
    \DeclareOption{figures}{\setcounter{optfigures}{1}}
    \DeclareOption{memoir}{\setcounter{optmemoir}{1}}
        \DeclareOption{onefloatperpage}{\setcounter{optonefloatperpage}{1}}
    \ProcessOptions\relax

%The real setplatename definition comes later... this is just to ensure that 
%when figures option is used setplatename is still valid.
\newcommand{\setplatename}[1]{}

\ifthenelse{\value{optfigures} = 0}{%
%
%COMMANDS for the new float env & list of are from memoir.  
%If memoir is not in use then define the commands
\makeatletter
\@ifundefined{newlistof}{%TRUE TEXT
%*******************************************************************
%%***************COPIED from MEMOIR CLASS***************************
%*******************************************************************
\newcounter{newflo@tctr}
  \setcounter{newflo@tctr}{1}
\newcommand{\newfloat}[4][\@empty]{%
  \@namedef{ftype@#2}{\value{newflo@tctr}}
  \addtocounter{newflo@tctr}{\value{newflo@tctr}}
  \@ifundefined{c@#2}{% counter is not defined
    \ifx \@empty#1\relax
      \newcounter{#2}
    \else
      \newcounter{#2}[#1]
      \expandafter\edef\csname the#2\endcsname{%
        \expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}}
    \fi}{}
  \setcounter{#2}{0}

  \@namedef{ext@#2}{#3}  % file extension
  \@ifundefined{c@#3depth}{\newcounter{#3depth}}{}
  \setcounter{#3depth}{1}

  \@namedef{fps@#2}{tbp}                     % position
  \@namedef{fnum@#2}{#4~\@nameuse{the#2}}    % caption naming
  \@namedef{fleg#2}{#4}                      % legend naming
  \@namedef{flegtoc#2}##1{}                  % legend name in ToC

  \newenvironment{#2}{\@float{#2}}{\end@float}
  \newenvironment{#2*}{\@dblfloat{#2}}{\end@dblfloat}
} % end \newfloat

\newcommand{\newlistentry}[4][\@empty]{%
  \@ifundefined{c@#2}{%    check & set the counter
    \ifx \@empty#1\relax
      \newcounter{#2}
    \else
      \newcounter{#2}[#1]%
      \expandafter\edef\csname the#2\endcsname{%
        \expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}}
    \fi}{}
  \setcounter{#2}{0}

  \@namedef{l@#2}##1##2{%
    \ifnum \@nameuse{c@#3depth} > #4\relax
      \vskip \@nameuse{cftbefore#2skip}
      {\leftskip \@nameuse{cft#2indent}\relax
       \rightskip \@tocrmarg
       \parfillskip -\rightskip
       \parindent \@nameuse{cft#2indent}\relax\@afterindenttrue
       \interlinepenalty\@M
       \leavevmode
       \@tempdima \@nameuse{cft#2numwidth}\relax
       \expandafter\let\expandafter\@cftbsnum\csname cft#2presnum\endcsname
       \expandafter\let\expandafter\@cftasnum\csname cft#2aftersnum\endcsname
       \expandafter\let\expandafter\@cftasnumb\csname cft#2aftersnumb\endcsname
       \advance\leftskip\@tempdima \null\nobreak\hskip -\leftskip
       {\@nameuse{cft#2font}##1}\nobreak
       \@nameuse{cft#2fillnum}{##2}}
    \fi
  }  % end of \l@#2

  \expandafter\newlength\csname cftbefore#2skip\endcsname
    \setlength{\@nameuse{cftbefore#2skip}}{\z@ \@plus .2\p@}
  \expandafter\newlength\csname cft#2indent\endcsname
  \expandafter\newlength\csname cft#2numwidth\endcsname
  \ifcase #4\relax  % 0   (level 1)
    \setlength{\@nameuse{cft#2indent}}{0em}
    \setlength{\@nameuse{cft#2numwidth}}{2.3em}
  \or               % 1   (level 2)
    \setlength{\@nameuse{cft#2indent}}{2.3em}
    \setlength{\@nameuse{cft#2numwidth}}{3.2em}
  \or               % 2   (level 3)
    \setlength{\@nameuse{cft#2indent}}{5.5em}
    \setlength{\@nameuse{cft#2numwidth}}{4.1em}
  \or               % 3   (level 4)
    \setlength{\@nameuse{cft#2indent}}{8.5em}
    \setlength{\@nameuse{cft#2numwidth}}{5.0em}
  \else             % anything else
    \setlength{\@nameuse{cft#2indent}}{10.5em}
    \setlength{\@nameuse{cft#2numwidth}}{6.0em}
  \fi
  \@namedef{cft#2font}{\normalfont}
  \@namedef{cft#2presnum}{}
  \@namedef{cft#2aftersnum}{}
  \@namedef{cft#2aftersnumb}{}
  \@namedef{cft#2dotsep}{\cftdotsep}
  \@namedef{cft#2leader}{\normalfont\cftdotfill{\@nameuse{cft#2dotsep}}}
  \@namedef{cft#2pagefont}{\normalfont}
  \@namedef{cft#2afterpnum}{}
  \@namedef{toclevel@#2}{#4}
  \@namedef{cft#2fillnum}##1{%
    {\@nameuse{cft#2leader}}\nobreak
    \hb@xt@\@pnumwidth{\hfil\@nameuse{cft#2pagefont}##1}\@nameuse{cft#2afterpnum}\par}
} % end \newlistentry

\newcommand{\newsubfloat}[1]{%
  \newlistentry[#1]{sub#1}{\@nameuse{ext@#1}}{1}
  \@namedef{ext@sub#1}{\csname ext@#1\endcsname}
  \@namedef{thesub#1}{(\alph{sub#1})}
  \@namedef{@thesub#1}{{\subcaplabelfont\@nameuse{thesub#1}}\space}
  \@namedef{p@sub#1}{\csname the#1\endcsname}
  \@namedef{@makesub#1caption}{\@makesubfigurecaption}
}

\newcommand{\newfixedcaption}[3][\caption]{%
  \newcommand{#2}{\def\@captype{#3}#1}}
\newcommand{\renewfixedcaption}[3][\caption]{%
  \renewcommand{#2}{\def\@captype{#3}#1}}
\newcommand{\providefixedcaption}[3][\caption]{%
  \providecommand{#2}{\def\@captype{#3}#1}}

\newcommand{\newlistof}[3]{%
  \@namedef{ext@#2}{#2}
  \@ifundefined{c@#2depth}{\newcounter{#2depth}}{}
  \setcounter{#2depth}{1}

  \@namedef{#2mark}{%
    \@mkboth{#3}{#3}}

  \@namedef{#1}{\@ifstar{\@nameuse{@star#2}}{\@nameuse{@plain#2}}}
  \@namedef{@star#2}{%
    \ensureonecol
    \par
    \begingroup
%%%      \parindent\z@ \parskip\cftparskip
      \@nameuse{@#2maketitle}
      \@starttoc{#2}%
    \endgroup
    \restorefromonecol}

  \@namedef{@plain#2}{%
    \ensureonecol
    \par
    \begingroup
%%%      \parindent\z@ \parskip\cftparskip
      \@nameuse{@#2maketitle}
      \phantomsection
      \addcontentsline{toc}{chapter}{#3}
      \@starttoc{#2}%
    \endgroup
    \restorefromonecol}

  \@namedef{@#2maketitle}{%
    \@nameuse{#2headstart}
   {\parindent\z@ \parskip\cftparskip
    \interlinepenalty\@M
    \@nameuse{print#2title}{#3}%
    \@nameuse{#2mark}%
    \thispagestyle{chapter}%
    \@nameuse{after#2title}
   }
    \@afterheading}

  \@namedef{#2headstart}{\chapterheadstart}
  \@namedef {after#2title}{\afterchaptertitle}
    \@namedef{print#2title}##1{\printchaptertitle{##1}}
} % end \newlistof
%*******************************************************************
%%***********END*COPIED from MEMOIR CLASS***************************
%*******************************************************************
}{%FALSE TEXT -- nothing needed
}

%
%Plates Commands
\newcommand{\platename}{Plate}%
\newcommand{\platenames}{{\platename}s}%
\renewcommand{\setplatename}[1]{\renewcommand{\platename}{#1}}

\newcommand{\listplatename}{List of \platenames}%
\newlistof{listofplates}{plt}{\listplatename}%
\newfloat{plate}{plt}{\platename}%
\newfixedcaption{\fpltcaption}{plt}%
\newlistentry{plate}{plt}{0}%
\newsubfloat{plate}%
\renewcommand{\theplate}{\Roman{plate}}%
%
%Make sure plate pages don't have seciton headers
%%kuchicomment
%\makepagestyle{floatcomp}%
%% \headwidth has already been defined for the companion style
%\makeheadrule{floatcomp}{\headwidth}%
%{\ifonlyfloats{0pt}{\normalrulethickness}}%
%\makeheadposition{floatcomp}{flushright}{flushleft}{}{}%
%\makepsmarks{floatcomp}{\companionpshook}%
%\makeevenhead{floatcomp}{\ifonlyfloats{}{\normalfont\bfseries\thepage}}%
%{}{\ifonlyfloats{}{\normalfont\bfseries\leftmark}}%
%\makeoddhead{floatcomp}{\ifonlyfloats{}{\normalfont\bfseries\rightmark}}%
%{}{\ifonlyfloats{}{\normalfont\bfseries\thepage}}%
%\makeevenfoot{floatcomp}{}{\ifonlyfloats{\thepage}{}}{}%
%\makeoddfoot{floatcomp}{}{\ifonlyfloats{\thepage}{}}{}%
%
%Ensure proper autoref for subplates
\newcommand{\subplateautorefname}{\mbox{\platename}}%
%
\RequirePackage[nolists,noheads,nomarkers]{endplate}[2002/03/18]%
%
%Set up what is to happen when \ProcessPlates is issued
%
%Command to print out the plates at given location
\newcommand{\ProcessPlates}{\processdelayedfloats}%

    %If option MEMOIR is supplied then add an appendix page to front of plates
\ifthenelse{\value{optmemoir} = 1}{%
\renewcommand{\ProcessPlates}{%
\AtBeginPlates{\renewcommand{\appendixpagename}{\platenames}%
\renewcommand{\appendixname}{\platenames}%
\renewcommand{\appendixtocname}{\platenames}%
\appendixpage%
\clearforchapter}%
\processdelayedfloats}
}{}
%
%Allow multiple floats per page
\renewcommand{\efloatseparator}{}
%Option for one float per page
\ifthenelse{\value{optonefloatperpage} = 1}{%
\renewcommand{\efloatseparator}{\cleardoublepage}}{}
%
}{%OPTION FIGURES is being used, so we just make the plate enviornment a figure enviornment
\newenvironment{plate}{\begin{figure}}{\end{figure}}%
%ProcessPlates command now does nothing!%
\newcommand{\ProcessPlates}{}%
%\listofplates now does nothing
\newcommand{\listofplates}{}

}


\endinput