Debian Codegraph @

texmf-dist/source/latex/caption/caption-memoir.dtx

raw
1 % \iffalse meta-comment
2 %
3 % This is file `caption-memoir.dtx'.
4 %
5 % Copyright (C) 2011-2023 Axel Sommerfeldt ([email protected])
6 %
7 % --------------------------------------------------------------------------
8 %
9 % This work may be distributed and/or modified under the
10 % conditions of the LaTeX Project Public License, either version 1.3
11 % of this license or (at your option) any later version.
12 % The latest version of this license is in
13 % http://www.latex-project.org/lppl.txt
14 % and version 1.3 or later is part of all distributions of LaTeX
15 % version 2003/12/01 or later.
16 %
17 % This work has the LPPL maintenance status "maintained".
18 %
19 % This Current Maintainer of this work is Axel Sommerfeldt.
20 %
21 % This work consists of the files
22 % caption.ins, caption.dtx, caption-light.dtx, caption2.dtx, caption3.dtx,
23 % caption-ams-smf.dtx, caption-beamer.dtx, caption-elsarticle.dtx,
24 % caption-koma.dtx, caption-memoir.dtx, caption-ntg.dtx,
25 % caption-thesis.dtx, bicaption.dtx, ltcaption.dtx, subcaption.dtx,
26 % the derived files
27 % caption.sty, caption-light.sty, caption2.sty, caption3.sty,
28 % caption-ams-smf.sto, caption-beamer.sto, caption-elsarticle.sto,
29 % caption-koma.sto, caption-memoir.sto, caption-ntg.sto,
30 % caption-thesis.sto, bicaption.sty, ltcaption.sty, subcaption.sty.
31 %
32 % \fi
33 %
34 % \CheckSum{90}
35 %
36 % \iffalse
37 %<*driver>
38 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
39 \ProvidesFile{caption-memoir.drv}[2023/07/10 v2.2 Implementation of the caption-memoir package]
40 %\errorcontextlines=3
41 %
42 \documentclass{captiondoc}
43 \hypersetup{pdfkeywords={LaTeX, package, caption-memoir}}
44 %
45 \begin{document}
46 \DocInput{caption-memoir.dtx}
47 \end{document}
48 %</driver>
49 % \fi
50 %
51 % \GetFileInfo{caption-memoir.drv}
52 % \let\docdate\filedate
53 % \let\docversion\fileversion
54 % \GetFileInfo{caption-memoir.sto}
55 %
56 % \title{\texorpdfstring
57 % {The adaption of the \pkg{caption} package to the \cls{memoir} document class\thanks{%^^A
58 % This adaption has version number \docversion.}}%^^A
59 % {The adaption of the caption package to the memoir document class}}
60 % \author{Axel Sommerfeldt\\
61 % \url{https://gitlab.com/axelsommerfeldt/caption}}
62 % \date{\docdate}
63 % \maketitle
64 %
65 % \begin{abstract}
66 % This package adapts the \pkg{caption} package to the \cls{memoir} document class.
67 % \end{abstract}
68 %
69 % \section*{User manual}
70 %
71 % This document is describing the code implementation only.
72 % The user documentation can be found in
73 % \nopagebreak\begin{quote}
74 % \begin{tabular}{ll}
75 % \href{http://mirror.ctan.org/macros/latex/contrib/caption/caption.pdf}%
76 % {\texttt{caption.pdf}} & The caption package documentation \\
77 % \end{tabular}
78 % \end{quote}
79 %
80 % \StopEventually{}
81 % \iffalse
82 % \clearpage
83 % \tableofcontents
84 % \fi
85 %
86 % \iffalse
87 % --------------------------------------------------------------------------- %
88 % \fi
89 %
90 % \DoNotIndex{\\,\_,\ ,\@@par}
91 % \DoNotIndex{\@bsphack}
92 % \DoNotIndex{\@car,\@cdr,\@classoptionslist,\@cons,\@currext,\@currname}
93 % \DoNotIndex{\@ehc,\@ehd,\@empty,\@esphack,\@expandtwoargs}
94 % \DoNotIndex{\@for,\@firstofone,\@firstoftwo}
95 % \DoNotIndex{\@gobble,\@gobblefour,\@gobbletwo,\@hangfrom}
96 % \DoNotIndex{\if@minipage,\@ifnextchar,\@ifpackagelater,\@ifpackageloaded}
97 % \DoNotIndex{\@ifstar,\@ifundefined,\@latex@error,\@minipagefalse,\@minipagetrue}
98 % \DoNotIndex{\@namedef,\@nameuse}
99 % \DoNotIndex{\@onlypreamble,\@parboxrestore,\@plus,\@ptionlist}
100 % \DoNotIndex{\@removeelement,\@restorepar,\@secondoftwo,\@setminipage,\@setpar}
101 % \DoNotIndex{\@tempa,\@tempboxa,\@tempdima,\@tempdimb,\@tempdimc,\@tempb,\@tempc}
102 % \DoNotIndex{\@testopt}
103 % \DoNotIndex{\@undefined,\@unprocessedoptions,\@unusedoptionlist}
104 % \DoNotIndex{\p@,\z@}
105 % \DoNotIndex{\active,\addtocounter,\addtolength,\advance,\aftergroup}
106 % \DoNotIndex{\baselineskip,\begin,\begingroup,\bfseries,\box}
107 % \DoNotIndex{\catcode,\centering,\changes,\csname,\def,\divide,\do,\downarrow}
108 % \DoNotIndex{\edef,\else,\empty,\end,\endcsname,\endgraf,\endgroup,\expandafter}
109 % \DoNotIndex{\fi,\footnotesize,\global}
110 % \DoNotIndex{\hangindent,\hbox,\hfil,\hsize,\hskip,\hspace,\hss}
111 % \DoNotIndex{\ifcase,\ifdim,\ifnum,\ifodd,\ifvoid,\ifvmode}
112 % \DoNotIndex{\ifx,\ignorespaces,\itshape}
113 % \DoNotIndex{\kernel@ifnextchar}
114 % \DoNotIndex{\Large,\large,\leavevmode,\leftmargini,\leftskip,\let,\linewidth}
115 % \DoNotIndex{\llap,\long,\m@ne,\margin,\mdseries,\message}
116 % \DoNotIndex{\newcommand,\newdimen,\newlength,\newline,\newif,\newsavebox}
117 % \DoNotIndex{\next,\nobreak,\nobreakspace,\noexpand,\noindent,\numberline}
118 % \DoNotIndex{\normalcolor,\normalfont,\normalsize,\or,\par,\parbox,\parfillskip}
119 % \DoNotIndex{\parindent,\parskip,\prevdepth,\protect,\protected@edef,\protected@write}
120 % \DoNotIndex{\providecommand,\quad}
121 % \DoNotIndex{\raggedleft,\raggedright,\relax,\renewcommand,\RequirePackage}
122 % \DoNotIndex{\rightskip,\rmfamily}
123 % \DoNotIndex{\sbox,\scriptsize,\scshape,\setbox,\setlength,\sffamily,\slshape}
124 % \DoNotIndex{\small,\string,\space,\strut}
125 % \DoNotIndex{\textheight,\the,\toks@,\typeout,\ttfamily}
126 % \DoNotIndex{\unvbox,\uparrow,\upshape,\usebox,\usepackage}
127 % \DoNotIndex{\value,\vbox,\vsize,\vskip,\wd,\width,\z@skip}
128 % \DoNotIndex{\AtBeginDocument,\AtEndOfPackage,\CurrentOption,\DeclareOption}
129 % \DoNotIndex{\ExecuteOptions,\GenericWarning,\IfFileExists,\InputIfFileExists}
130 % \DoNotIndex{\NeedsTeXFormat,\MessageBreak}
131 % \DoNotIndex{\PackageError,\PackageInfo,\PackageWarning,\PackageWarningNoLine}
132 % \DoNotIndex{\PassOptionsToPackage,\ProcessOptions,\ProvidesPackage}
133 %
134 % \iffalse
135 % --------------------------------------------------------------------------- %
136 % \fi
137 %
138 % \setlength{\parskip}{0pt plus 1pt}
139 % \newcommand*\Note[2][Note]{\par{\small\emph{#1:} #2}\par}
140 %
141 % \changes{v1.4a}{2011/10/21}{\cls{memoir} class support added}
142 % \changes{v2.0}{2020/07/27}{\cls{memoir} class support adapted to \pkg{caption3}~\version{2.0}}
143 %
144 % \iffalse
145 % --------------------------------------------------------------------------- %
146 % \fi
147 %
148 % \clearpage
149 %
150 % \iffalse
151 %<*package>
152 % \fi
153 %
154 % \section{Identification}
155 %
156 % \begin{macrocode}
157 \NeedsTeXFormat{LaTeX2e}[1994/12/01]
158 \ProvidesFile{caption-memoir.sto}[2023/09/08 v2.2c Adaption of the caption package to the memoir document class (AR)]
159 % \end{macrocode}
160 %
161 % \section{Adaptions already included in the caption package}
162 %
163 % The following adaptions to the \cls{memoir} document class are already included in the \pkg{caption} package:
164 % \begin{itemize}
165 % \item \cs{@caption} expands \cs{memcaptioninfo}
166 % \item \cs{caption@prepareanchor} expands \cs{M@gettitle}
167 % \item \cs{caption@refstepcounter} expands \cs{donemaincaptiontrue}
168 % \item All sub-caption counters will be reset at |\@mem|\-|reset|\-|sub|\-|counter|,
169 % even if they weren't defined by the \cls{memoir} document class itself.
170 % As work-around this command will be patched to protect the counters
171 % defined by |\Declare|\-|Caption|\-|Sub|\-|Type|.
172 % \end{itemize}
173 %
174 % \section{Single-line-check}
175 %
176 % \begin{macro}{\pagenote}
177 % \changes{v1.4a}{2011/10/21}{Re-definition of \cs{pagenote} added}
178 % We re-define \cs{pagenote} here so it won't disturb the single-line-check.
179 % \begin{macrocode}
180 \providecommand*\AtCaptionSingleLineCheck{\g@addto@macro\caption@prepareslc} % for caption v3.5
181 \AtCaptionSingleLineCheck{%
182 \let\pagenote\caption@gobble}
183 % \end{macrocode}
184 % \end{macro}
185 %
186 % \section{Label separator}
187 %
188 % The `default' caption label separator maps to \cs{@contdelim}.
189 % \begin{macrocode}
190 \DeclareCaptionLabelSeparator{@contdelim}{\@contdelim}
191 \SetCaptionDefault{labelseparator}{@contdelim}
192 % \end{macrocode}
193 %
194 % \begin{macro}{\captiondelim}
195 % \changes{v2.1}{2020/10/10}{Re-definition of \cs{captiondelim} added}
196 % We re-define |\caption|\-|delim| so it will set the \pkg{caption3} label separator setting, too.
197 % \begin{macrocode}
198 \let\caption@memoir@delim\captiondelim
199 \renewcommand\captiondelim{%
200 \captionsetup{labelsep=@contdelim}%
201 \caption@memoir@delim}
202 % \end{macrocode}
203 % \end{macro}
204 %
205 % \changes{v2.0a}{2020/10/10}{Re-definition of label separator `gobble' added}
206 % If |\fnum@figure| (or |\fnum@table| or\ldots) ends with |\@gobble|, the `:' part of the caption
207 % label separator will be suppressed when a standard document class (\cls{article}, \cls{report},
208 % or \cls{book}) will be used, leaving the following space character intact.
209 % This is different when using the \cls{memoir} document class, in this case the complete
210 % label separator will be suppressed. For this reason we re-define the pre-defined caption label
211 % separator `gobble' to emulate this behaviour.
212 %
213 % \begin{macrocode}
214 \DeclareCaptionLabelSeparator{gobble}{}
215 % \end{macrocode}
216 %
217 % \section{Fonts}
218 %
219 % The `default' caption fonts map to \cs{@contnfont} or \cs{conttfont}.
220 % \begin{macrocode}
221 \DeclareCaptionFont{@contnfont}{\@contnfont}
222 \SetCaptionDefault{labelfont}{@contnfont}
223 % \end{macrocode}
224 % \begin{macrocode}
225 \DeclareCaptionFont{@conttfont}{\@conttfont}
226 \SetCaptionDefault{textfont}{@conttfont}
227 % \end{macrocode}
228 %
229 % \begin{macro}{\captionnamefont}
230 % \changes{v2.1}{2020/10/10}{Re-definition of \cs{captionnamefont} added}
231 % We re-define |\caption|\-|delim| so it will set the \pkg{caption3} label separator setting, too.
232 % \begin{macrocode}
233 \let\caption@memoir@namefont\captionnamefont
234 \renewcommand\captionnamefont{%
235 \captionsetup{labelfont=@contnfont}%
236 \caption@memoir@namefont}
237 % \end{macrocode}
238 % \end{macro}
239 %
240 % \begin{macro}{\captiontitlefont}
241 % \changes{v2.1}{2020/10/10}{Re-definition of \cs{captiontitlefont} added}
242 % We re-define |\caption|\-|delim| so it will set the \pkg{caption3} label separator setting, too.
243 % \begin{macrocode}
244 \let\caption@memoir@titlefont\captiontitlefont
245 \renewcommand\captiontitlefont{%
246 \captionsetup{textfont=@conttfont}%
247 \caption@memoir@titlefont}
248 % \end{macrocode}
249 % \end{macro}
250 %
251 % \section{Vertical spaces before and after captions}
252 %
253 % The \cls{memoir} document classes uses |\above|\-|caption|\-|skip| and |\below|\-|caption|\-|skip|
254 % different than the standard document classes and the \pkg{caption} package:
255 % They always typeset |\above|\-|caption|\-|skip| before the caption and
256 % |\below|\-|caption|\-|skip| after the captions. Both are preset to |0.5\one|\-|line|\-|skip|.
257 %
258 % For this reason we have to set the |\below|\-|caption|\-|skip| to |0pt| if the \pkg{caption}
259 % package is used, so no extra vertical space will be created.
260 %
261 % \begin{macrocode}
262 \AtCaptionPackage{%
263 \setlength\belowcaptionskip{0pt}}
264 % \end{macrocode}
265 %
266 % Furthermore we adapt the `auto' positioning algorithm to match the one implemented
267 % in the \cls{memoir} document class.
268 % (Note: This needs at least \pkg{caption3} \version{2.3}.)
269 %
270 % \begin{macrocode}
271 \@ifundefined{DeclareCaptionAutoPosition}{}{%
272 \DeclareCaptionAutoPosition{%
273 \ifvmode
274 \ifdim\prevdepth>-99\p@#2\else#1\fi
275 \else
276 #2%
277 \fi}}%
278 % \end{macrocode}
279 %
280 % \section{Side captions}
281 %
282 % \begin{macro}{\endsidecaption}
283 % \changes{v2.2c}{2023/09/08}{This re-definition added}
284 % The \env{sidecaption} environment uses |\ref|\-|step|\-|counter| (if \pkg{hyperref} is not loaded)
285 % or |\H@ref|\-|step|\-|counter| plus |\hyper@make|\-|current| (if \pkg{hyperref} is loaded).
286 % We need to patch it so |\caption@ref|\-|step|\-|counter| is used instead to get a proper hyperlink reference.
287 % Since the definition could be overwritten by |memhfixc.sty|, we need to define it using |\At|\-|Begin|\-|Document|.
288 % \begin{macrocode}
289 \AtBeginDocument{\renewcommand*\endsidecaption{%
290 \m@mscapend@fbox
291 \caption@refstepcounter\@captype
292 \m@mscaplabel
293 \csname m@mscapcheckside\endcsname %<--- added 2012/08/19
294 \begin{lrbox}{\m@mscap@capbox}%
295 \begin{minipage}[c]{\sidecapwidth}%
296 \sidecapstyle
297 \@caption\@captype[\m@mscap@fortoc]{\m@mscap@forcap}
298 \end{minipage}%
299 \end{lrbox}%
300 \m@mscapopboxes}}
301 % \end{macrocode}
302 % \end{macro}
303 %
304 % \section{TODO}
305 %
306 % \begin{macrocode}
307 % TODO: \captionstyle
308 % TODO: \captionwidth, \changecaptionwidth, \normalcaptionwidth
309 % TODO: \hangcaption, \indentcaption, \normalcaption
310 % TODO: \precaption, \postcaption, \midbicaption
311 % TODO: \captiontitlefinal
312 % TODO: \contcaption
313 % TODO: \newfixedcaption, \renewfixedcaption, \providefixedcaption
314 %
315 % \end{macrocode}
316 %
317 % \iffalse
318 %</package>
319 % \fi
320 %
321 % \iffalse
322 % --------------------------------------------------------------------------- %
323 % \fi
324 %
325 % \clearpage
326 % \Finale
327 %
328 \endinput
329