⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 caption2.dtx.svn-base

📁 moses开源的机器翻译系统
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
\DeclareOption{debug}{\caption@debugtrue}%    \end{macrocode}% \end{macro}%% That's it! Now set the default values and start processing the options.% (If \cs{caption@twozero} is set to true (default) we will emulate the package% load algorithm of \textsf{caption} v2.0: If the package is already loaded% patch it, otherwise do nothing.)% \changes{v2.1}{19 Feb 02}{\cs{ProcessOptions} changed to \cs{ProcessOptions*}}%    \begin{macrocode}\newif\ifcaption@debug\newif\ifcaption@twozero\normalcaptionparams\ExecuteOptions{none,normal}\caption@twozerotrue\ProcessOptions*\ifcaption@twozero  \PackageInfo{caption2}{Running in caption2 v2.0 compatibility mode}\fi%    \end{macrocode}%% \subsection{More declarations}%% \begin{macro}{\captionof}% \begin{macro}{\captionof*}% \cs{captionof} resp.\ \cs{captionof*} will just set \cs{@captype} and do the normal% \cs{caption} resp.\ \cs{caption*}, so we can also typeset captions outside floating% environments.% \changes{v2.1}{19 Feb 02}{New commands \cs{captionof} and \cs{captionof*}}%    \begin{macrocode}\def\captionof{\@ifstar{\caption@of{\caption*}}{\caption@of\caption}}\newcommand*\caption@of[2]{\def\@captype{#2}#1}%    \end{macrocode}% \end{macro}% \end{macro}%% \begin{macro}{\abovecaptionskip}% \begin{macro}{\belowcaptionskip}% Not all document classes define \cs{abovecaptionskip} and \cs{belowcaptionskip}% (like \textsf{ucthesis}), so we do it here if not already done.% \changes{v2.1}{19 Feb 02}{\cs{abovecaptionskip} and \cs{belowcaptionskip} will be defined if neccessary}%    \begin{macrocode}\@ifundefined{abovecaptionskip}{%  \newlength\abovecaptionskip\setlength\abovecaptionskip{10\p@}}{}\@ifundefined{belowcaptionskip}{%  \newlength\belowcaptionskip\setlength\belowcaptionskip{0\p@}}{}%    \end{macrocode}% \end{macro}% \end{macro}%% \begin{macro}{\captionlinewidth}% \changes{v2.1}{26 Feb 02}{Renamed from \cs{realcaptionwidth} to \cs{captionlinewidth}}% \changes{v2.1a}{12 Nov 03}{We offer \cs{realcaptionwidth}, again}% \begin{macro}{\captionlabel}% \begin{macro}{\captiontext}% These values are only set and used within the caption code itself.% \cs{captionlinewidth} will be set to the given vertical space for the caption,% normally this is \cs{linewidth}. (This value was called \cs{realcaptionwidth}% within \thispackage\ \mbox{2.0}, so we will offer this, too.)%% \cs{captionlabel} and \cs{captiontext} will be set to the caption label% resp.\ the caption text.% (Because \cs{captionlabel} and \cs{captiontext} will be locally defined with% \cs{def} we do not need to define them here.)%    \begin{macrocode}\newdimen\captionlinewidth\newdimen\realcaptionwidth%    \end{macrocode}% \end{macro}% \end{macro}% \end{macro}%% \begin{macro}{\usecaptionmargin}% A helper macro for caption style authors:% It calculates \cs{leftskip} and \cs{rightskip} out of% \cs{captionlinewidth} and \cs{captionmargin} resp.\ \cs{captionwidth}.% Also \cs{captionlinewidth} will be corrected to the appropriate value.%    \begin{macrocode}\newcommand*\usecaptionmargin{%  \ifcaptionwidth    \leftskip\captionlinewidth    \advance\leftskip by -\captionwidth    \divide\leftskip by 2    \rightskip\leftskip    \captionlinewidth\captionwidth  \else    \leftskip\captionmargin    \rightskip\captionmargin    \advance\captionlinewidth by -2\captionmargin  \fi  \realcaptionwidth\captionlinewidth}%    \end{macrocode}% \end{macro}%% \begin{macro}{\onelinecaption}% This macro definition helps setting captions the \LaTeX\ base classes way:% If \cs{ifonelinecaptions} is set and the 1st argument fits within \cs{captionlinewidth},% we typeset it centered -- otherway we typeset the 2nd argument.% (We use the savebox \cs{@tempboxa} as helper for this.)%    \begin{macrocode}\newcommand\onelinecaption[1]{%  \let\next\@firstofone  \ifonelinecaptions    \sbox\@tempboxa{#1}%    \ifdim\wd\@tempboxa >\captionlinewidth    \else      \def\next{{\centering\usebox\@tempboxa\par}\@gobble}%    \fi  \fi\next}%    \end{macrocode}% \end{macro}%% \begin{macro}{\usecaptionstyle}% First we check if we are inside a caption -- if \cs{captiontext} is undefined we are not.% If we are we call the appropriate caption definition.%% \changes{v2.1b}{16 Apr 04}{Missing percent added (and extra space removed)}%    \begin{macrocode}\newcommand*\usecaptionstyle[1]{%  \@ifundefined{captiontext}{%    \PackageError{caption2}{You can't use \protect#1      in normal text}{The usage of \protect#1 is only      allowed inside code declared with\MessageBreak \protect\defcaptionstyle,      \protect\newcaptionstyle \space or \protect\renewcaptionstyle.      \space\caption@eh}  }{%    \@ifundefined{caption@@#1}%      {\PackageError{caption2}{Caption style `#1' undefined}{\caption@eh}}%      {\@nameuse{caption@@#1}}%  }}%    \end{macrocode}% \end{macro}%% \begin{macro}{\@makecaption}% This is the heart of the \thispackage\ package -- the redefinition of the% core caption code. It was taken from the \LaTeXe\ standard classes and modified.% It's very easy -- apart from using \cs{abovecaptionskip} and \cs{belowcaptionskip}% we just set \cs{captionlinewidth}, \cs{captionlabel} and \cs{captiontext}% to its appropriate values and using the code of the actual caption style via% \cs{usecaptionstyle}.%    \begin{macrocode}\renewcommand\@makecaption[2]{%  \vskip\abovecaptionskip  \captionlinewidth\hsize  \realcaptionwidth\hsize  \def\captionlabel{#1}%  \def\captiontext{#2}%  \usecaptionstyle\caption@style  \vskip\belowcaptionskip}%    \end{macrocode}% \end{macro}%% \subsection{Support of other packages}%% \begin{macro}{\caption@package}% This macro will execute the code needed to support the package% named within argument \#1. The parameter \#2 is the command% which shows if the package is loaded -- it is defined, it is% already loaded, otherwise not. The parameter \#3 contains code% which will be executed if no support is required -- this is for% cleanup purposes. The final parameter \#4 contains the code itself.% \changes{v2.1c}{9 May 04}{Compatibility warning removed}%    \begin{macrocode}\renewcommand*\caption@package[3]{%  \if1\@nameuse{caption@pkt@#1}%    \@ifundefined{#2}%      {\let\next\AtBeginDocument}%      {\let\next\@firstofone}%  \else\ifcaption@twozero    \@ifundefined{#2}%      {#3\let\next\@gobble}%      {\let\next\@firstofone}%  \else    #3\let\next\@gobble  \fi\fi  \expandafter\let\csname caption@pkt@#1\endcsname\undefined  \ifcaption@debug    \ifx\next\@gobble\PackageInfo{caption2}{#1 => gobble}%    \else\ifx\next\@firstofone\PackageInfo{caption2}{#1 => firstofone}%    \else\ifx\next\AtBeginDocument\PackageInfo{caption2}{#1 => AtBeginDocument}%    \fi\fi\fi  \fi  \next}%    \end{macrocode}% \end{macro}%% \subsubsection{Support of the \puresf{float} package}%%    \begin{macrocode}\caption@package{float}{floatc@plain}{}{%  \ifx\floatc@plain\relax    \PackageWarning{caption2}{%      Option `float' was set but there is no float package loaded}  \else    \PackageInfo{caption2}{float package v1.2 (or newer) detected}%    \end{macrocode}%% \begin{macro}{\caption@floatc}% First we define a helper macro to typeset the caption via \cs{usecaptionstyle},% the 1st parameter is the caption style name,% the 2nd and 3rd are the caption label and text.%% \textsf{caption2} has the goal not to modify the output just by% loading it (without options), therefore we have to be tricky here to% support \cs{@fs@cfont} which is in fact the same as our \cs{captionlabelfont}.% So we test if a \cs{captionlabelfont} has been set by the user -- if not% \cs{@fs@cfont} will be used, otherwise \cs{captionlabelfont}.%% \changes{v2.1b}{19 Mar 04}{\cs{realcaptionwidth}$=$\cs{hsize} was missing here}%    \begin{macrocode}    \newcommand\caption@floatc[3]{%      \ifx\captionlabelfont\@empty        \let\captionlabelfont\@fs@cfont      \fi      \captionlinewidth\hsize      \realcaptionwidth\hsize      \def\captionlabel{#2}%      \def\captiontext{#3}%      \usecaptionstyle{#1}}%    \end{macrocode}% \end{macro}%% \begin{macro}{\floatc@plain}% Now we can redefine the caption code of the \textsf{float} package.% Here we redefine \cs{floatc@plain} to use our caption code, so% \texttt{plain} and \texttt{boxed} float types will use the actual% caption style set by the user.%    \begin{macrocode}    \renewcommand*\floatc@plain{\caption@floatc{\caption@style}}%    \end{macrocode}% \end{macro}%% \begin{macro}{\floatc@ruled}% The support of the \texttt{ruled} float type is a little% more complex. First we define a caption style `ruled' so the end-user% can change this caption style afterwards. If the (obsolete) option% `ruled' is set, we define it in a \textsf{caption} v1.x compatible way,% otherwise we define it in a \textsf{float} compatible way.%% Then we redefine \cs{floatc@ruled} so the caption style `ruled' will% be used.%    \begin{macrocode}    \ifcaption@ruled      \dummycaptionstyle{ruled}{\onelinecaptionsfalse\setcaptionmargin{\z@}}%    \else      \newcaptionstyle{ruled}{%        \ifcaptionlabel          {\@fs@cfont\captionlabel}\space%        \fi\captiontext\par}%    \fi%    \renewcommand*\floatc@ruled{\caption@floatc{ruled}}%    \end{macrocode}% \end{macro}%% \begin{macro}{\caption@of}% Typesetting captions outside floats is not so easy with redefined floats,% because% \begin{itemize}% \item The caption code of the \textsf{float} package needs not only% \cs{@captype} defined, but \cs{@fs@capt} (the command which will typeset the% caption itself) either.% \item The caption is only saved within a \cs{vbox}, so the \textsf{float}% package can typeset the caption later at it's float style specific place% (that means at top or at the bottom of the float).% \end{itemize}%% Here is the new code: First we check if it's a restyled float by checking if% \cs{fst@<floattype>} is defined. If yes, we use this command (it will define% \cs{@fs@capt}).% Then we execute \cs{@float@setevery}, if it exists (that means we are% dealing with the \textsf{float} package 1.3 or newer here).% Now comes the basic trick:% We redefine the caption typesetting command \cs{@fs@capt}, so it will close% the \cs{vbox}, typeset the caption outside the vbox and finally start the% group again so the original \cs{@fs@capt} is happy with closing the group.%%    \begin{macrocode}    \renewcommand*\caption@of[2]{\def\@captype{#2}%      \@ifundefined{fst@#2}{}{%        \@nameuse{fst@#2}%        \@ifundefined{@float@setevery}{}{\@float@setevery{#2}}%        \let\caption@fs@capt\@fs@capt        \let\@fs@capt\caption@of@float}%      #1}%    \end{macrocode}%%    \begin{macrocode}    \newcommand\caption@of@float[2]{\egroup      \vskip\abovecaptionskip      \normalsize\caption@fs@capt{#1}{#2}%      \vskip\belowcaptionskip      \bgroup}%%    \end{macrocode}% \end{macro}%%    \begin{macrocode}  \fi}%    \end{macrocode}%% \subsubsection{Support of the \puresf{longtable} package}%%    \begin{macrocode}\caption@package{longtable}{LT@makecaption}{}{%  \ifx\LT@makecaption\relax    \PackageWarning{caption2}{%      Option `longtable' was set but there is no longtable package loaded}  \else    \PackageInfo{caption2}{longtable package v3.15 (or newer) detected}%    \end{macrocode}%% \begin{macro}{\LT@makecaption}% David Carlisle was so kind to introduce a macro called% \cs{LT@makecaption} in version 3.15 of the \textsf{longtable}% package which typeset the caption and can be easily redefined.%% This is the original definition:% \begin{quote}% |\def\LT@makecaption#1#2#3{%|\\% |  \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%|\\% |    |$\langle$\textit{typeset} |#1{#2: }#3| \textit{as caption}$\rangle$\\% |    \endgraf\vskip\baselineskip}%|\\% |  \hss}}}|% \end{quote}%% So we do here:% First we define a new (dummy) caption style `longtable',% than we redefine \cs{LT@makecaption} so this style will be used.% (Remember: |#1| is |\@gobble| in star form of |\caption|,% and |\@firstofone| otherwise.)%    \begin{macrocode}    \dummycaptionstyle{longtable}{}%

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -