summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/caption/caption-light.dtx
blob: c56734a4142d16fb2adf3b489cab1c1f51defd21 (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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
% \iffalse meta-comment
% 
% This is file `caption-light.dtx'.
% 
% Copyright (C) 2020 Axel Sommerfeldt (axel.sommerfeldt@f-m.fm)
% 
% --------------------------------------------------------------------------
% 
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
% 
% This work has the LPPL maintenance status "maintained".
% 
% This Current Maintainer of this work is Axel Sommerfeldt.
% 
% This work consists of the files
%   caption.ins, caption.dtx, caption-light.dtx, caption2.dtx, caption3.dtx,
%   caption-ams-smf.dtx, caption-beamer.dtx, caption-elsarticle.dtx,
%   caption-koma.dtx, caption-memoir.dtx, caption-ntg.dtx,
%   caption-thesis.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx,
% the derived files
%   caption.sty, caption-light.sty, caption2.sty, caption3.sty,
%   caption-ams-smf.sto, caption-beamer.sto, caption-elsarticle.sto,
%   caption-koma.sto, caption-memoir.sto, caption-ntg.sto,
%   caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty,
% and the user manuals
%   caption-deu.tex, caption-eng.tex, caption-rus.tex.
% 
% \fi
% \CheckSum{84}
%
% \iffalse
%<*driver>
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesFile{caption-light.drv}[2020/08/24 v1.0 Customizing captions (AR)]
\hbadness=9999 \newcount\hbadness \hfuzz=74pt % Make TeX shut up.
%\errorcontextlines=3
%
\documentclass{ltxdoc}
\setlength\parindent{0pt}
\setlength\parskip{\smallskipamount}
%
\newcommand\LineBreak{\linebreak[3]}
\newcommand\PageBreak{\pagebreak[3]}
\usepackage{ifpdf}
\ifpdf
  \usepackage{mathptmx,courier}
  \usepackage[scaled=0.90]{helvet}
  \addtolength\marginparwidth{15pt}
  \ifdim\paperheight=297mm % a4paper
    \renewcommand\LineBreak{\\}
    \renewcommand\PageBreak{\clearpage}
  \fi
\fi
%
\usepackage[bottom]{footmisc}
%
\PassOptionsToPackage{breaklinks=true}{hyperref}
\usepackage{hypdoc}
\ifpdf\usepackage{hypdestopt}\fi
\hypersetup{pdfkeywords={LaTeX, package, subcaption},pdfstartpage={},pdfstartview={}}
%
\usepackage{caption-light}[2020/08/23] % needs v1.0 or newer
%
\newcommand*\purerm[1]{{\upshape\mdseries\rmfamily #1}}
\newcommand*\puresf[1]{{\upshape\mdseries\sffamily #1}}
\newcommand*\purett[1]{{\upshape\mdseries\ttfamily #1}}
\let\package\puresf
\let\env\purett \let\opt\purett
%
\newcommand*\csmarg[1]{\texttt{\char`\{#1\char`\}}}
\newcommand*\csoarg[1]{\texttt{\char`\[#1\char`\]}}
\newcommand*\version[2][]{v$#2$}
%
\usepackage{marvosym}
\makeatletter
\newcommand*\INFO{\@ifstar{\@INFO{}}{\@INFO{\vbox to \ht\strutbox}}}
\newcommand*\@INFO[1]{\MARGINSYM{#1{\LARGE\Info}}}
\makeatother
%
\newcommand*\MARGINSYM[1]{\hskip 1sp \marginpar{\raggedleft\textcolor{blue}{{#1}}}}
\newcommand*\NEW[2]{\MARGINSYM{\vskip2pt\footnotesize#1\\#2}}
%
\begin{document}
  \DocInput{caption-light.dtx}
\end{document}
%</driver>
% \fi
%
% \let\subsectionautorefname\sectionautorefname
% \let\subsubsectionautorefname\sectionautorefname
%
% \def\thispackage{the \package{caption-light} package}
% \def\Thispackage{The \package{caption-light} package}
%
% \newcommand\NEWfeature{\NEW{New feature}}
% \newcommand\NEWdescription{\NEW{New description}}
%
% \makeatletter
% \def\Ref{\@ifstar{\@Ref\ref}{\@Ref\autoref}}
% \def\@Ref#1#2{#1{#2}: \textit{\nameref{#2}}}
% \makeatother
% \def\See#1{\nopagebreak{\small (See #1)}}
%
% \GetFileInfo{caption-light.drv}
% \let\docdate\filedate
% \let\docversion\fileversion
% \GetFileInfo{caption-light.sty}
%
% \title{\texorpdfstring{\Thispackage\thanks{%^^A
%          This package has version number \docversion.}}%^^A
%        {The caption-light package}}
% \author{Axel Sommerfeldt\\
%         \url{https://gitlab.com/axelsommerfeldt/caption}}
% \date{\docdate}
% \maketitle
% 
% \begin{abstract}
% \Thispackage\ offers (limited) customization of captions
% in floating environments such |figure| and |table|.
% \par\smallskip
% \textit{Please note:} Many document classes already have build-in options and
% commands for customizing captions.
% If these possibilities are sufficient for you, there is usually no need for
% you to use the \package{caption} package at all.
% And if you are just interested in using the command \cs{captionof}, loading
% of the very small \package{capt-of} package is usually sufficient.
% \end{abstract}
%
% \iffalse\clearpage\fi
% \setcounter{tocdepth}{2}
% \tableofcontents
%
% \clearpage
% \section{Loading the package}
%
% Load this package using
% \begin{quote}
%   |\usepackage|\oarg{options}|{caption-light}|
% \end{quote}
% or
% \begin{quote}
%   |\usepackage{caption-light}|\\
%   \ldots\\
%   |\captionsetup|\marg{options}
% \end{quote}
% As opposite to the \package{caption} package only a limited set of options is
% supported by \thispackage:
% |aboveskip=|\ldots,
% |belowskip=|\ldots,
% |font=|\ldots,
% |justification=|\ldots,
% |labelfont=|\ldots,
% |labelseparator=|\ldots,
% |position=|\ldots,
% |singlelinecheck=|\ldots,
% |skip=|\ldots, and
% |textfont=|\ldots
%
% See \package{caption} package documentation for the meaning and usage of
% these options.
%
% \section{Commands}
%
% This package offers |\caption|\-|setup|, |\set|\-|caption|\-|type|, and
% |\caption|\-|of| as well.
%
% \section{Why this package?}
%
% This package offers some advantages over the \package{caption} package:
% \begin{itemize}
% \item It does not depend on correct |\hsize| for "long" captions,
% just like the original definition included in |article|, |report|, and |book|.
% \item If the caption is typeset as "short" (centered), the content of
% the caption is evaluated only once,
% just like the original definition included in |article|, |report|, and |book|.
% \item It does not re-define |\caption| and floating environments,
% therefore avoiding incompatibilities.
% \item It does not patch any other packages, therefore avoiding
% incompatibilities.
% \end{itemize}
%
% In short it's a more compatible and less troublesome variant of the
% \package{caption} package, but (much) less powerful.
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \StopEventually{%^^A
% }
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \DoNotIndex{\\,\_,\ ,\@@par}
% \DoNotIndex{\@bsphack}
% \DoNotIndex{\@car,\@cdr,\@classoptionslist,\@cons,\@currext,\@currname}
% \DoNotIndex{\@ehc,\@ehd,\@empty,\@esphack,\@expandtwoargs}
% \DoNotIndex{\@for,\@firstofone,\@firstoftwo}
% \DoNotIndex{\@gobble,\@gobblefour,\@gobbletwo,\@hangfrom}
% \DoNotIndex{\@ifnextchar,\@ifpackagelater,\@ifpackageloaded}
% \DoNotIndex{\@ifstar,\@ifundefined,\@latex@error,\@namedef,\@nameuse}
% \DoNotIndex{\@onlypreamble,\@parboxrestore,\@plus,\@ptionlist}
% \DoNotIndex{\@removeelement,\@restorepar,\@secondoftwo,\@setpar}
% \DoNotIndex{\@tempa,\@tempboxa,\@tempdima,\@tempdimb,\@tempdimc,\@tempb,\@tempc}
% \DoNotIndex{\@testopt}
% \DoNotIndex{\@undefined,\@unprocessedoptions,\@unusedoptionlist}
% \DoNotIndex{\p@,\z@}
% \DoNotIndex{\active,\addtocounter,\addtolength,\advance,\aftergroup}
% \DoNotIndex{\baselineskip,\begin,\begingroup,\bfseries,\box}
% \DoNotIndex{\catcode,\centering,\changes,\csname,\def,\divide,\do,\downarrow}
% \DoNotIndex{\edef,\else,\empty,\end,\endcsname,\endgraf,\endgroup,\expandafter}
% \DoNotIndex{\fi,\footnotesize,\global}
% \DoNotIndex{\hangindent,\hbox,\hfil,\hsize,\hskip,\hspace,\hss}
% \DoNotIndex{\ifcase,\ifdim,\ifnum,\ifodd,\ifvoid,\ifvmode}
% \DoNotIndex{\ifx,\ignorespaces,\itshape}
% \DoNotIndex{\Large,\large,\leavevmode,\leftmargini,\leftskip,\let,\linewidth}
% \DoNotIndex{\llap,\long,\m@ne,\margin,\mdseries,\message}
% \DoNotIndex{\newcommand,\newdimen,\newlength,\newline,\newif,\newsavebox}
% \DoNotIndex{\next,\nobreak,\nobreakspace,\noexpand,\noindent,\numberline}
% \DoNotIndex{\normalcolor,\normalfont,\normalsize,\or,\par,\parbox,\parfillskip}
% \DoNotIndex{\parindent,\parskip,\prevdepth,\protect,\protected@edef,\protected@write}
% \DoNotIndex{\providecommand,\quad}
% \DoNotIndex{\raggedleft,\raggedright,\relax,\renewcommand,\RequirePackage}
% \DoNotIndex{\rightskip,\rmfamily}
% \DoNotIndex{\sbox,\scriptsize,\scshape,\setbox,\setlength,\sffamily,\slshape}
% \DoNotIndex{\small,\string,\space,\strut}
% \DoNotIndex{\textheight,\the,\toks@,\typeout,\ttfamily}
% \DoNotIndex{\unvbox,\uparrow,\upshape,\usebox,\usepackage}
% \DoNotIndex{\value,\vbox,\vsize,\vskip,\wd,\width,\z@skip}
% \DoNotIndex{\AtBeginDocument,\AtEndOfPackage,\CurrentOption,\DeclareOption}
% \DoNotIndex{\ExecuteOptions,\GenericWarning,\IfFileExists,\InputIfFileExists}
% \DoNotIndex{\NeedsTeXFormat,\MessageBreak}
% \DoNotIndex{\PackageError,\PackageInfo,\PackageWarning,\PackageWarningNoLine}
% \DoNotIndex{\PassOptionsToPackage,\ProcessOptions,\ProvidesPackage}
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \setlength{\parskip}{0pt plus 1pt}
% \changes{v1.0}{2020/08/24}{First version}
%
% \newcommand*\Note[2][Note]{\par{\small\emph{#1:} #2}}
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \clearpage
% \section{The implementation}
% \iffalse
%<*package>
% \fi
%
% \subsection{Identification}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{caption-light}[2020/08/24 v1.0 Customizing captions (AR)]
%    \end{macrocode}
%
% \section{Loading the kernel}
%
%    \begin{macrocode}
\RequirePackage{caption3}[2020/08/23] % needs v2.0 or newer
%    \end{macrocode}
%
% \section{Check against unknown document classes}
%
%    \begin{macrocode}
\caption@ifbool{documentclass}{}{%
  \caption@WarningNoLine{%
    Unknown document class (or package),\MessageBreak
    standard defaults will be used}}
%    \end{macrocode}
%
% \section{Check against incompatible packages}
%
%    \begin{macrocode}
\@ifpackageloaded{caption2}{%
  \caption@Error{%
    You can't use both, the (obsolete) caption2 *and*\MessageBreak
    the caption-light package}%
  \endinput
}{}
%    \end{macrocode}
%
% \section{Processing of options}
%
%    \begin{macrocode}
\caption@SetupOptions{caption-light}{\caption@setkeys{caption}{#2}}
\caption@ProcessOptions*{caption-light}
%    \end{macrocode}
%
% \section{\cs{@makecaption}}
%
% If the \package{caption} package is loaded, we abort processing this file.
%    \begin{macrocode}
\caption@ifdefined\caption@makecaption
  {\caption@Info{\noexpand\caption@makecaption is already defined}%
   \endinput}{}
%    \end{macrocode}
%
% \begin{macro}{\caption@makecaption}
%   |\@makecaption|\marg{label}\marg{text}\\
%   We do basically the same as the original code (from the standard
%   \LaTeX\ document classes), but take care of selected settings
%   offered by the \package{caption3} kernel.
%    \begin{macrocode}
\long\def\caption@makecaption#1#2{%
  \caption@iftop\caption@belowskip\caption@aboveskip
  \caption@labelseparator % defines \caption@iflabelfont and \caption@labelsep
  \caption@singlelinecheck
    {\sbox\@tempboxa{\caption@@makecaption{#1}{#2}}%
     \ifdim \wd\@tempboxa >\hsize}%
    {\iftrue}%
    \caption@@makecaption{#1}{#2}\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \caption@iftop\caption@aboveskip\caption@belowskip}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand\caption@@makecaption[2]{%
  \caption@applyfont
  {\captionlabelfont #1}%
  {\caption@iflabelfont\captionlabelfont
   \relax\caption@labelsep}%
  {\captiontextfont #2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makecaption}
%   Patch |\@makecaption|, so our definition will be used.
%    \begin{macrocode}
\let\@makecaption\caption@makecaption
%    \end{macrocode}
% \end{macro}
%
% \section{\cs{setcaptiontype}}
%
% We offer the options |type=| and |type*=|, too:
%    \begin{macrocode}
\caption@AtBeginDocument{%
%    \end{macrocode}
%    \begin{macrocode}
  \DeclareCaptionOption{type}{\setcaptiontype{#1}}%
  \DeclareCaptionOption{type*}{\setcaptiontype*{#1}}%
%    \end{macrocode}
%    \begin{macrocode}
}
%    \end{macrocode}
% \begin{macro}{\setcaptiontype}
%   |\setcaptiontype*|\marg{type}\\
%   For compatibility reasons we offer a starred variant as well,
%   but it does not differ from the non-starred variant here.
%    \begin{macrocode}
\newcommand*\setcaptiontype{%
  \caption@teststar{\def\@captype}{}{}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\captionof}
%   |\captionof*|\marg{type}\oarg{list-entry}\marg{text}\\
%   For compatibility reasons we offer a starred variant as well.
%    \begin{macrocode}
\caption@AtBeginDocument{%
  \def\captionof{\caption@teststar\caption@of{\caption*}\caption}}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*\caption@of[2]{\setcaptiontype*{#2}#1}
%    \end{macrocode}
% \end{macro}
%
% \iffalse
%</package>
% \fi
%
% \iffalse
% --------------------------------------------------------------------------- %
% \fi
%
% \Finale
%
\endinput