📄 caption2.dtx.svn-base
字号:
% This macro will also define a new caption style, but a one which is based on the% actual set caption style. Therefore you can't set a caption style made with this% command with \cs{captionstyle} -- we check this to avoid an endless recursion.% \begin{macrocode}\newcommand*\dummycaptionstyle[2]{% \defcaptionstyle{#1}{% \expandafter\ifx\csname caption@@\caption@style\expandafter\endcsname% \csname caption@@#1\endcsname \PackageError{caption2}{You can't use the caption style `#1' directy}{% The caption style `#1' is only a dummy and does not really exists.% \MessageBreak You have to redefine it (with \protect\renewcaptionstyle) before you can select\MessageBreak it with \protect\captionstyle. \space\caption@eh}% \else #2\usecaptionstyle\caption@style \fi}}% \end{macrocode}% \end{macro}%% \begin{macro}{\captionstyle}% \cs{captionstyle} sets the actual caption style. It includes a check if the given caption% style is defined or not.% \begin{macrocode}\newcommand*\captionstyle[1]{% \expandafter\ifx\csname caption@@#1\endcsname\relax \PackageError{caption2}{Undefined caption style `#1'}{\caption@eh}% \else \def\caption@style{#1}% \fi}% \end{macrocode}% \end{macro}%% \begin{macro}{style `normal'}% \begin{macro}{style `center'}% \begin{macro}{style `centerlast'}% \begin{macro}{style `flushleft'}% \begin{macro}{style `flushright'}% \begin{macro}{style `hang'}% \begin{macro}{style `indent'}% The predefined caption styles `normal', `center', `flushleft', `flushright', `centerlast',% `hang', `hang+X', and `indent'. Because they are quite similar they all are based on the macro% \cs{caption@make}.% \begin{macrocode}\newcaptionstyle{normal}{\caption@make{normal}}\newcaptionstyle{center}{\caption@make{center}}\newcaptionstyle{centerlast}{\caption@make{centerlast}}\newcaptionstyle{flushleft}{\caption@make{flushleft}}\newcaptionstyle{flushright}{\caption@make{flushright}}\newcaptionstyle{hang}{\caption@make{hang}}\newcaptionstyle{hang+center}{\caption@make{hang@center}}\newcaptionstyle{hang+centerlast}{\caption@make{hang@centerlast}}\newcaptionstyle{hang+flushleft}{\caption@make{hang@flushleft}}\newcaptionstyle{indent}{\caption@make{indent}}% \end{macrocode}% \end{macro}% \end{macro}% \end{macro}% \end{macro}% \end{macro}% \end{macro}% \end{macro}%% \begin{macro}{\caption@makecaption}% Our predefined caption styles. \cs{caption@makecaption} takes the style% name as parameter, it does the common stuff and calls a macro% (build out of the style name) to do the uncommon stuff if neccessary.% \changes{v2.1}{26 Feb 02}{Renamed from \cs{caption@make} to \cs{caption@makecaption}}% \changes{v2.1b}{16 Apr 04}{We offer and use \cs{caption@make}, again}% \changes{v2.1c}{10 May 04}{Bugfix: Extra \cs{par} added}% \begin{macrocode}\newcommand*\caption@makecaption[1]{% \usecaptionmargin% \ifcaptionlabel \def\caption@label{% {\captionlabelfont\captionlabel\captionlabeldelim}\captionlabelsep}% \else \let\caption@label\@empty \fi% \captionfont \onelinecaption {\caption@label\captiontext}% {\parbox[b]\captionlinewidth{\strut\@nameuse{caption@@@#1}\par}\par}}\newcommand*\caption@make{\caption@makecaption}% \end{macrocode}% \end{macro}%% \changes{v2.1}{26 Feb 02}{Removed all extra parboxes from caption styles}% \changes{v2.1a}{12 Nov 03}{\ldots and put the parbox into \cs{caption@makecaption} instead}%% \begin{macro}{\caption@@@normal}% The `normal' caption style. Just typeset caption (label \& text) as paragraph.% \begin{macrocode}\newcommand*\caption@@@normal{% \caption@label\captiontext}% \end{macrocode}% \end{macro}%% \begin{macro}{\caption@@@center}% The `center' caption style. Typeset the caption centered within a parbox.% \begin{macrocode}\newcommand*\caption@@@center{% \centering\caption@label\captiontext}%% \end{macrocode}% \end{macro}%% \begin{macro}{\caption@@@centerlast}% The `centerlast' caption style.% The idea how to do this was taken from Br\"uggemann-Klein\cite{Anne},% it is also mentioned in Kopka\cite[p227]{Kopka-E}.% \begin{macrocode}\newcommand*\caption@centerlast{% \advance\leftskip by 0pt plus 1fil% \advance\rightskip by 0pt plus -1fil% \parfillskip0pt plus 2fil\relax}%\newcommand*\caption@@@centerlast{% \caption@centerlast\caption@label\captiontext}% \end{macrocode}% \end{macro}%% \begin{macro}{\caption@@@flushleft}% The `flushleft' caption style. Typeset the caption raggedright within a parbox.% \begin{macrocode}\newcommand*\caption@@@flushleft{% \raggedright\caption@label\captiontext}%% \end{macrocode}% \end{macro}%% \begin{macro}{\caption@@@flushright}% The `flushright' caption style. Typeset the caption raggedleft within a parbox.% \begin{macrocode}\newcommand*\caption@@@flushright{% \raggedleft\caption@label\captiontext}%% \end{macrocode}% \end{macro}%% \begin{macro}{\caption@@@hang}% \begin{macro}{\caption@hangplus}% The `hang' caption style.% This code was taken from \LaTeXcomp\cite[p155]{A-W:GMS94} and modified.% \begin{macrocode}\newcommand*\caption@@@hang{% \sbox\@tempboxa{\caption@label}% \hangindent\wd\@tempboxa\noindent \usebox\@tempboxa\caption@hangplus\captiontext}%\newcommand*\caption@hangplus{}% \end{macrocode}% \end{macro}% \end{macro}%% \begin{macro}{\caption@@@hang@center}% The `hang+flushleft' caption style.% \begin{macrocode}\newcommand*\caption@@@hang@center{% \let\caption@hangplus\centering\caption@@@hang}% \end{macrocode}% \end{macro}%% \begin{macro}{\caption@@@hang@centerlast}% The `hang+flushleft' caption style.% \begin{macrocode}\newcommand*\caption@@@hang@centerlast{% \let\caption@hangplus\caption@centerlast\caption@@@hang}% \end{macrocode}% \end{macro}%% \begin{macro}{\caption@@@hang@flushleft}% The `hang+flushleft' caption style.% \begin{macrocode}\newcommand*\caption@@@hang@flushleft{% \let\caption@hangplus\raggedright\caption@@@hang}% \end{macrocode}% \end{macro}%% \begin{macro}{\caption@@@indent}% The `indent' caption style. Is is quite like the `hang' style but the% indention is given as \cs{captionindent}.% \begin{macrocode}\newcommand*\caption@@@indent{% \hangindent\captionindent\noindent \caption@label\captiontext}% \end{macrocode}% \end{macro}%% \subsection{Options}%% \begin{macro}{normal}% \begin{macro}{center}% \begin{macro}{centerlast,anne}% \begin{macro}{flushleft}% \begin{macro}{flushright}% \begin{macro}{hang,isu}% \begin{macro}{indent}% These options will set the caption style.% (`normal' is the default one.)%% The options `anne' and `isu' are for% backward compatibility only.% \begin{macrocode}\DeclareOption{normal}{\captionstyle{normal}}\DeclareOption{center}{\captionstyle{center}}\DeclareOption{centerlast}{\captionstyle{centerlast}}\DeclareOption{flushleft}{\captionstyle{flushleft}}\DeclareOption{flushright}{\captionstyle{flushright}}\DeclareOption{anne}{\ExecuteOptions{centerlast}}\DeclareOption{hang}{\captionstyle{hang}}\DeclareOption{hang+center}{\captionstyle{hang+center}}\DeclareOption{hang+centerlast}{\captionstyle{hang+centerlast}}\DeclareOption{hang+flushleft}{\captionstyle{hang+flushleft}}\DeclareOption{isu}{\ExecuteOptions{hang}}\DeclareOption{indent}{\captionstyle{indent}}% \end{macrocode}% \end{macro}% \end{macro}% \end{macro}% \end{macro}% \end{macro}% \end{macro}% \end{macro}%% \begin{macro}{scriptsize}% \begin{macro}{footnotesize}% \begin{macro}{small}% \begin{macro}{normalsize}% \begin{macro}{large,Large}% These options will set the caption size. We use \cs{g@addto@macro} so more that one% option can be set.% \begin{macrocode}\DeclareOption{scriptsize}{\g@addto@macro\captionsize\scriptsize}\DeclareOption{footnotesize}{\g@addto@macro\captionsize\footnotesize}\DeclareOption{small}{\g@addto@macro\captionsize\small}\DeclareOption{normalsize}{\g@addto@macro\captionsize\normalsize}\DeclareOption{large}{\g@addto@macro\captionsize\large}\DeclareOption{Large}{\g@addto@macro\captionsize\Large}% \end{macrocode}% \end{macro}% \end{macro}% \end{macro}% \end{macro}% \end{macro}%% \begin{macro}{up,it,sl,sc}% \begin{macro}{md,bf}% \begin{macro}{rm,sf,tt}% These options will set the caption label.% \begin{macrocode}\DeclareOption{up}{\g@addto@macro\captionlabelfont\upshape}\DeclareOption{it}{\g@addto@macro\captionlabelfont\itshape}\DeclareOption{sl}{\g@addto@macro\captionlabelfont\slshape}\DeclareOption{sc}{\g@addto@macro\captionlabelfont\scshape}\DeclareOption{md}{\g@addto@macro\captionlabelfont\mdseries}\DeclareOption{bf}{\g@addto@macro\captionlabelfont\bfseries}\DeclareOption{rm}{\g@addto@macro\captionlabelfont\rmfamily}\DeclareOption{sf}{\g@addto@macro\captionlabelfont\sffamily}\DeclareOption{tt}{\g@addto@macro\captionlabelfont\ttfamily}% \end{macrocode}% \end{macro}% \end{macro}% \end{macro}%% \begin{macro}{oneline}% \begin{macro}{nooneline}% These options will set the `oneline' flag.% (`oneline' is the default.)% \begin{macrocode}\DeclareOption{oneline}{\onelinecaptionstrue}\DeclareOption{nooneline}{\onelinecaptionsfalse}% \end{macrocode}% \end{macro}% \end{macro}%% \begin{macro}{\caption@package}% A helper macro, a value of 1 within parameter \#2 will activate the support% of the package given in parameter \#1, a value of 0 will deactivate it.% \begin{macrocode}\newcommand*\caption@package[1]{\@namedef{caption@pkt@#1}}% \end{macrocode}% \end{macro}%% \begin{macro}{float}% \begin{macro}{longtable}% \begin{macro}{subfigure}% \changes{v2.1}{19 Feb 02}{New options for interaction with other packages}% These options will enable or suppress the support of the packages% \textsf{float}, \textsf{longtable}, and \textsf{subfigure}.% \begin{macrocode}\DeclareOption{float}{\caption@twozerofalse\caption@package{float}{1}}\DeclareOption{longtable}{\caption@twozerofalse\caption@package{longtable}{1}}\DeclareOption{subfigure}{\caption@twozerofalse\caption@package{subfigure}{1}}% \end{macrocode}% \end{macro}% \end{macro}% \end{macro}%% \begin{macro}{none}% \begin{macro}{all}% These options will enable or suppress the support of all the above packages.% \begin{macrocode}\DeclareOption{none}{\caption@twozerofalse \caption@package{float}{0}\caption@package{longtable}{0}% \caption@package{subfigure}{0}}\DeclareOption{all}{\ExecuteOptions{float,longtable,subfigure}}% \end{macrocode}% \end{macro}% \end{macro}%% \begin{macro}{ruled}% \begin{macro}{boxed}% The option `ruled' introduced in \textsf{caption} v1.2 is obsolete now, but% we will still support it. The option `boxed' was introduced in version 2.0% and is obsolete now, too.% \begin{macrocode}\newif\ifcaption@ruled\DeclareOption{ruled}{\caption@ruledtrue}\DeclareOption{boxed}{}% \end{macrocode}% \end{macro}% \end{macro}%% \begin{macro}{ignoreLTcapwidth}% This option will make the caption code ignore the setting of \cs{LTcapwidth}% and use the setting of \cs{setcaptionmargin} or \cs{setcaptionwidth} instead.% \begin{macrocode}\DeclareOption{ignoreLTcapwidth}{\ignoreLTcapwidthtrue}% \end{macrocode}% \end{macro}%% \begin{macro}{debug}% This option will put additional debug information in the log file.% \begin{macrocode}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -