diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/ncctools/nccfloats.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/ncctools/nccfloats.dtx | 326 |
1 files changed, 238 insertions, 88 deletions
diff --git a/Master/texmf-dist/source/latex/ncctools/nccfloats.dtx b/Master/texmf-dist/source/latex/ncctools/nccfloats.dtx index b23f6debe6c..bcf55b5e2e4 100644 --- a/Master/texmf-dist/source/latex/ncctools/nccfloats.dtx +++ b/Master/texmf-dist/source/latex/ncctools/nccfloats.dtx @@ -1,17 +1,21 @@ % \iffalse %% -%% File: nccfloats.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% File: nccfloats.dtx Copyright (C) 2002--2006 by Alexander I. Rozhenko %% %<package>\NeedsTeXFormat{LaTeX2e} %<package>\ProvidesPackage{nccfloats} -%<package> [2004/12/05 v1.1 More Float Management (NCC)] +%<package> [2006/01/07 v1.2 More Float Management (NCC)] % % \changes{v1.00}{2002/03/23}{This version is uploaded to CTAN} % \changes{v1.01}{2002/05/17}{Handling of side floats improved} % \changes{v1.1}{2004/12/05}{Width parameters can have units now} % \changes{v1.1}{2004/12/05}{Documentation was prepared} +% \changes{v1.2}{2006/01/07}{Extend |\FloatStyle| syntax} +% \changes{v1.2}{2006/01/07}{Cover base floats with |\FloatStyle|} +% \changes{v1.2}{2006/01/07}{Introduce |\newminifloat| command} % %<*driver> +\let\makeindex\relax \documentclass{ltxdoc} \usepackage{desclist,nccfloats} \GetFileInfo{nccfloats.sty} @@ -30,26 +34,47 @@ % The standard \LaTeX\ floating environments, namely |figure| % and |table|, allow user to place floating material in a % document. But they do not introduce a style in which this -% material must be prepared. In this package, envelop commands are -% developed which join a style with a float and more -% features are introduced, namely -% mini-figures, mini-tables, side-figures, and side-tables. +% material must be formatted. In this package, styles are +% joined with floats and mini-floats are introduced. Mini-floats +% are prepared at a mini-page and allow captions within. +% Basing on mini-floats, a number of service commands for +% figures and tables are defined. The ability to create +% other types of mini-floats is introduced with the +% |\newminifloat| command. +% +% \tableofcontents % % \section{Basic Commands} % -% \DescribeMacro{\FloatingStyle} -% The |\FloatingStyle|\marg{style} command sets a style of -% floats in the document. It affects on the material prepared with -% commands described below. The default style is +% \DescribeMacro{\FloatStyle} +% The |\FloatStyle|\oarg{type}\marg{style} command sets a style for +% the float of the given \meta{type}. If the \meta{type} is omitted, +% the default style is specified. It will be applied to a float or +% mini-float if no specialized style was defined. +% This command is available in the preamble only. +% +% To specify the style of a mini-float and of service commands based on it, +% add the `|mini|' prefix to the float type. The default styles are % \begin{quote} -% |\FloatingStyle{\footnotesize\centering}| +% |\FloatStyle{}|\\ +% |\FloatStyle[minifigure]{\footnotesize\centering}|\\ +% |\FloatStyle[minitable]{\footnotesize\centering}| % \end{quote} -% This command is available in the preamble only. +% This means that the formatting of floats prepared with standard +% |figure| and |table| environments does not changed, but service +% commands based on mini-figures and mini-tables use a special +% formatting with |\footnotesize| font and the centered alignment. +% +% \DescribeMacro\normalfloatstyle +% This command is applied inside floats or mini-floats to reset +% formatting style of subsequent floating material to the standard +% formatting with paragraph alignment and the normal font of +% normal size. % % \DescribeMacro{\minifig} % \DescribeMacro{\minitabl} % We start with the basic commands, namely |\minifig| and -% |\minitabl|. They prepare a material in a minipage and allow +% |\minitabl|. They prepare a material in a mini-page and allow % using the |\caption| command in the body. Their syntax is % similar to the |\parbox| command: % \begin{quote} @@ -57,11 +82,11 @@ % |\minitabl|\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body} % \end{quote} % The \meta{pos} is a vertical alignment parameter for -% minipage (|t|, |b|, or |c|) with respect to -% surrounding text; the \meta{height} is a minipage height +% mini-page (|t|, |b|, or |c|) with respect to +% surrounding text; the \meta{height} is a mini-page height % required; the \meta{inner-pos} is a vertical alignment -% of text inside the minipage (|t|, |b|, |c|, or |s|); -% and the \meta{width} is the minipage width. +% of text inside the mini-page (|t|, |b|, |c|, or |s|); +% and the \meta{width} is the mini-page width. % The \meta{body} is prepared in the style specified by the % |\FloatingStyle| command and can contain the |\caption| command inside. % @@ -87,17 +112,17 @@ % |\sidetabl|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{table}\marg{text}\\ % |\sidetabl*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{table}\marg{text} % \end{quote} -% For simplicity, we further use the term \textit{minifloat\/} for the +% We use the term \textit{mini-float} for the % small illustrating material (figure or table), however % taking into account that it is not a float at all. It is inserted in % the main flow next to a paragraph box specified in the last % parameter of above described commands. % -% The no-star forms of above described commands place a minifloat +% The no-star forms of above described commands place a mini-float % next to the specified text on the outer side of page (to the % right for odd page and to the left for even page). In two-column -% or one-side mode, minifloat is always posed to the right. The -% star-forms provide the reverse placement. By default, minifloat +% or one-side mode, mini-float is always posed to the right. The +% star-forms provide the reverse placement. By default, mini-float % is vertically centered with respect to the text and the % |\strut| command is inserted at the beginning and at the end % of the \meta{text} to provide normal baseline @@ -107,14 +132,14 @@ % All parameters in square and round brackets are optional and mean % the following: % \begin{desclist}{}{}[\meta{pos}] -% \item[\meta{pos}] specifies minifloat alignment (|t|, +% \item[\meta{pos}] specifies mini-float alignment (|t|, % |b|, or |c|; default is |c|) with respect to text % box and can contain additional chars controlling the text body % preparation: |j| means the last line of the text to be % justified to the right and |n| means suppressing of struts % insertion (they should be inserted manually if necessary); % -% \item[$w_1$] is the width of minifloat; and +% \item[$w_1$] is the width of mini-float; and % % \item[$w_2$] is the width of the text box. % \end{desclist} @@ -123,16 +148,16 @@ % the width value is considered as a multiple of |\unitlength| % (similarly to the use of length dimensions in the picture environment). % -% If both width parameters are absent, the widths are calculated as\linebreak -% |(\linewidth-1.5em)/2|. If $w_2$ is absent, the text body -% width is calculated as |\linewidth-|$w_1$|-1.5em|. +% If both width parameters are absent, the width of both mini-float and +% text body is calculated as |(\linewidth-1.5em)/2|. If $w_2$ is absent, +% the text body width is calculated as |\linewidth-|$w_1$|-1.5em|. % % The placement of side-floats in the document consists in the following % steps: % \begin{enumerate} % \item Decide where you want to insert a side-float; % \item Insert a |\sidefig| or |\sidetabl| command after a word that finishes -% the line before the future side-float position; +% the line before the supposed side-float position; % \item Specify a width of float in its parameter and set the top alignment % as the \meta{pos} parameter (e.g.\ |\sidefig[t](|$w_1$|)|); % \item Prepare the side-float in the first mandatory parameter of the command @@ -142,24 +167,24 @@ % \item Find what part of the text is redundant in the \meta{text} parameter; % \item Move it after the close brace; % \item If the same paragraph continues after the close brace, add the |j| -% letter to the \meta{pos} parameter. Also change the top alignment -% to the centered alignment; +% letter to the \meta{pos} parameter. Also change the |t| alignment +% to |c| alignment in the \meta{pos} parameter; % \item Translate the document once more; % \item If the side-float has a wrong placement (this can appear when paragraph % with a side-float begins at the end of page), insert the star after -% the side-float command. +% the side-float command and translate the document once more. % \end{enumerate} % % \DescribeMacro{\ifleftsidefloat} % While preparing a side-float, it is sometimes necessary to -% provide conditional placement depending on the side a minifloat +% provide conditional placement depending on the side a mini-float % is posed. The command % \begin{quote} % |\ifleftsidefloat|\marg{left-clause}\marg{right-clause} % \end{quote} % provides this. It is useful in parameters of |\sidefig| or % |\sidetabl| and processes \meta{left-clause} if the -% minifloat is posed to the left and \meta{right-clause} +% mini-float is posed to the left and \meta{right-clause} % otherwise. % % Side-floats can be also used within floating environments to pos @@ -188,7 +213,7 @@ % % The |\fig| and |\tabl| commands envelop the |figure| % and |table| environments respectively. Their star-forms -% envelop corresponding starred |figure*| or |table*| environments. +% envelop |figure*| or |table*| environments respectively. % % \section{Two Floating Figures or Tables Side by Side} % @@ -217,8 +242,30 @@ % % In the |\tabls| command, boxes of the left and right bodies are % top-aligned, but, in the |\figs| command, the bottom alignment is -% used. The star-forms of this commands are based on the corresponding -% starred |figure*| or |table*| environments. +% used. The star-forms of this commands are based on the |figure*| +% or |table*| environments respectively. +% +% \section{Declare a Mini-float and Service Commands} +% +% \DescribeMacro\newminifloat +% If a new type of float is introduced, the respective mini-float +% and service commands can be helpful for it. To prepare them, use +% the following declaration: +% \begin{quote} +% |\newminifloat|\marg{gen}\marg{type}\marg{placement}\marg{pos} +% \end{quote} +% Here \meta{gen} is a root for command names to be generated, \meta{type} +% is a float type, \meta{placement} is a default placement on the page, +% and \meta{pos} is a vertical alignment for pair of floats. +% +% This command declares 4 commands: |\mini|\meta{gen}, |\side|\meta{gen}, +% |\|\meta{gen}, and |\|\meta{gen}|s|. For example, the commands +% described in previous sections are declared as follows: +% \begin{quote} +% |\newminifloat{fig}{figure}{ht}{b}|\\ +% |\newminifloat{tabl}{table}{ht}{t}| +% \end{quote} +% % \StopEventually{} % % \section{The Implementation} @@ -230,31 +277,74 @@ \RequirePackage{nccboxes}[2002/03/20] % \end{macrocode} % +% \subsection{Float Style} +% % \begin{macro}{\FloatStyle} -% \begin{macro}{\minifig} -% \begin{macro}{\minitabl} -% At the first, we define the basic commands. +% |\FloatStyle|\oarg{type}\marg{style} specifies a style for +% a given float type. % \begin{macrocode} -\newcommand*{\FloatStyle}[1]{\def\NCC@fltstyle{#1}} +\newcommand*{\FloatStyle}[2][]{% + \expandafter\def\csname NCC@fltstyle@#1\endcsname{#2}} \@onlypreamble\FloatStyle -\newcommand{\minifig}{\begingroup\def\@captype{figure}\NCC@minifloat} -\newcommand{\minitabl}{\begingroup\def\@captype{table}\NCC@minifloat} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@setfltstyle} +% |\NCC@setfltstyle|\marg{prefix} applies a style for a +% float of |\@captype| type. While selection a style to be +% applied it adds the given \meta{prefix} to the float type. +% \begin{macrocode} +\def\NCC@setfltstyle#1{% + \edef\@tempa{NCC@fltstyle@#1\@captype}% + \@ifundefined{\@tempa}{\NCC@fltstyle@}{\csname\@tempa\endcsname}% +} +% \end{macrocode} +% We add this style with empty prefix to the |\@floatboxreset| +% hook which is applied at the end of preamble of a float. +% \begin{macrocode} +\g@addto@macro\@floatboxreset{\NCC@setfltstyle{}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\normalfloatstyle} +% Reset a float style to par-box formatting with normal font of the +% normal size. +% \begin{macrocode} +\newcommand\normalfloatstyle{% + \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip + \parfillskip\@flushglue \let\\\@normalcr + \reset@font \normalsize +} +% \end{macrocode} +% \end{macro} +% +% \subsection{The Kernel} +% +% \begin{macro}{\NCC@minifloat} +% The base for mini-floats +% \begin{quote} +% |\NCC@minifloat|\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body} +% \end{quote} +% It finishes a mini-float with extra |\endgroup| command. +% A |\@captype| should be specified before it. +% \begin{macrocode} \newcommand*\NCC@minifloat[1][c]{% \@ifnextchar[{\NCC@mflt{#1}}{\NCC@@mflt{#1}\relax[s]}} \def\NCC@mflt#1[#2]{% \@ifnextchar[{\NCC@@mflt{#1}{#2}}{\NCC@mflt{#1}{#2}[#1]}} \long\def\NCC@@mflt#1#2[#3]#4#5{% - \@iiiminipage{#1}{#2}[#3]{#4}\normalfont - \NCC@fltstyle #5\endminipage\endgroup + \@iiiminipage{#1}{#2}[#3]{#4}\normalfloatstyle + \NCC@setfltstyle{mini}#5\endminipage\endgroup } % \end{macrocode} % \end{macro} -% \end{macro} -% \end{macro} % % \begin{macro}{\NCC@pair} -% The |\NCC@pair|\marg{c1}\marg{c2}\marg{def-dist}\marg{def-place}|*|\oarg{place}|(|$w_1$|)(|$w_2$|)| -% command executes \meta{c1}\marg{place}|{|$w_1$|}{|$w_2$|}| if star is absent or +% The command +% \begin{quote} +% |\NCC@pair|\marg{c1}\marg{c2}\marg{def-dist}\marg{def-place}|*|\oarg{place}|(|$w_1$|)(|$w_2$|)| +% \end{quote} +% executes \meta{c1}\marg{place}|{|$w_1$|}{|$w_2$|}| if star is absent or % \meta{c2}\marg{place}|{|$w_1$|}{|$w_2$|}| if star presents. % Four first parameters are mandatory. Others a optional. % The \meta{def-dist} parameter contains a default distance @@ -275,15 +365,12 @@ % % \begin{macro}{\NCC@setwidth} % The |\NCC@setwidth|\marg{register}\marg{width} command sets -% the given \meta{width} to the dimen \meta{register}. If units +% the given \meta{width} for the \meta{register}. If units % in \meta{width} are omitted, the |\unitlength| unit is used. % In other words, if \meta{width} is a real number, it is considered % as a multiple of |\unitlength|. % \begin{macrocode} -\def\NCC@setwidth#1#2{% - \afterassignment\NCC@setwidth@#1#2\unitlength\relax -} -\def\NCC@setwidth@#1\relax{} +\def\NCC@setwidth#1#2{\@defaultunits#1#2\unitlength\relax\@nnil} % \end{macrocode} % \end{macro} % @@ -315,8 +402,10 @@ % \end{macrocode} % \end{macro} % +% \subsection{Side Floats} +% % \begin{macro}{\ifleftsidefloat} -% This command is used in parameters of |\sidefig| or |\sidetabl|. +% This command is used in parameters of side-floats. % \begin{macrocode} \newif\ifNCC@smfltleft \newcommand{\ifleftsidefloat}{% @@ -329,15 +418,22 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\sidefig} -% \begin{macro}{\sidetabl} +% \begin{macro}{\NCC@sidemfloat} +% The command +% \begin{quote} +% |\NCC@sidemfloat|\marg{command}|*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{mini-float}\marg{text} +% \end{quote} +% is used for preparing a side-float. The \meta{command} parameter +% contains a |\mini|\meta{gen} command. The \meta{pos} parameter +% specifies vertical alignment and additional flags. The +% $w_1$ and $w_2$ parameters (if present) specify widthes of +% \meta{mini-float} and \meta{text} boxes. Starred version +% reverses the position of side-float and text boxes. % The implementation of these commands is based % on the |\NCC@pair| command that parses all optional % parameters. Finally the |\NCC@smflt| command is % executed. % \begin{macrocode} -\newcommand{\sidefig}{\NCC@sidemfloat{\minifig}} -\newcommand{\sidetabl}{\NCC@sidemfloat{\minitabl}} \def\NCC@sidemfloat#1{% \NCC@smfltleftfalse \if@twocolumn \else @@ -352,16 +448,14 @@ } % \end{macrocode} % \end{macro} -% \end{macro} % % \begin{macro}{\NCC@smflt} -% The |\NCC@smflt|\marg{command}\marg{pos}|{|$w_1$|}{|$w_2$|}|\marg{minifloat}\marg{text} -% prepares a side-float. The \meta{command} parameter contains -% a |\minifig| or |\minitabl| command. The \meta{pos} parameter -% specifies vertical alignment and additional flags. The -% $w_1$ and $w_2$ parameters (if present) specify widthes of -% \meta{minifloat} and \meta{text} boxes. The |\@tempdimc| register -% contains the default distance between the minifloat and text. +% The command +% \begin{quote} +% |\NCC@smflt|\marg{command}\marg{pos}|{|$w_1$|}{|$w_2$|}|\marg{mini-float}\marg{text} +% \end{quote} +% prepares a side-float. The |\@tempdimc| register +% contains the default distance between the mini-float and text. % \begin{macrocode} \long\def\NCC@smflt#1#2#3#4#5#6{% % \end{macrocode} @@ -437,15 +531,19 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\fig} -% \begin{macro}{\tabl} -% The implementation of these commands is quite simple: +% \subsection{Service Commands} +% +% \begin{macro}{\NCC@float} +% The command +% \begin{quote} +% |\NCC@float|\marg{type}\marg{def-place}|*|\oarg{placement}|(|$w$|)|\marg{body} +% \end{quote} +% is the envelope for a mini-float inside a float. The \meta{def-place} +% is the default placement specifier. % \begin{macrocode} -\newcommand{\fig}{\NCC@float{figure}} -\newcommand{\tabl}{\NCC@float{table}} -\def\NCC@float#1{\@ifstar{\NCC@flt{#1*}}{\NCC@flt{#1}}} -\def\NCC@flt#1{\@ifnextchar[{\NCC@flt@{#1}}{\NCC@flt@{#1}[ht]}} -\def\NCC@flt@#1[#2]{\begin{#1}[#2]\centering +\def\NCC@float#1#2{\@ifstar{\NCC@flt{#1*}{#2}}{\NCC@flt{#1}{#2}}} +\def\NCC@flt#1#2{\@ifnextchar[{\NCC@flt@{#1}}{\NCC@flt@{#1}[#2]}} +\def\NCC@flt@#1[#2]{\begin{#1}[#2]\normalfloatstyle\centering \@ifnextchar({\NCC@@flt{#1}}{\NCC@@flt{#1}()}} \long\def\NCC@@flt#1(#2)#3{% \if!#2!\@tempdima\linewidth \else \NCC@setwidth\@tempdima{#2}\fi @@ -454,33 +552,37 @@ } % \end{macrocode} % \end{macro} -% \end{macro} % -% \begin{macro}{\figs} -% \begin{macro}{\tabls} -% The implementation of these commands is based +% \begin{macro}{\NCC@floats} +% The command +% \begin{quote} +% |\NCC@floats|\marg{type}\marg{pos}\marg{def-place}|*|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\\ +% | |\marg{body1}\marg{body2} +% \end{quote} +% is the envelope for a pair of mini-floats inside a float. The implementation +% of these commands is based % on the |\NCC@pair| command that parses all optional % parameters. Finally the |\NCC@flts| command is % executed. % \begin{macrocode} -\newcommand{\figs}{\NCC@floats{figure}b} -\newcommand{\tabls}{\NCC@floats{table}t} -\def\NCC@floats#1#2{% - \NCC@pair{\NCC@@flts{#1}{#2}}{\NCC@@flts{#1*}{#2}}{1em}{ht}} +\def\NCC@floats#1#2#3{% + \NCC@pair{\NCC@@flts{#1}{#2}}{\NCC@@flts{#1*}{#2}}{1em}{#3}} % \end{macrocode} % \end{macro} -% \end{macro} % % \begin{macro}{\NCC@flts} -% The |\NCC@flts|\marg{env}\marg{pos}\marg{placement}|{|$w_1$|}{|$w_2$|}|\marg{body1}\marg{body2} -% command prepares a pair of floats within \meta{env} environment. -% The \meta{pos} contains relative alignment of floats. +% The command +% \begin{quote} +% |\NCC@flts|\marg{type}\marg{pos}\marg{placement}|{|$w_1$|}{|$w_2$|}|\marg{body1}\marg{body2} +% \end{quote} +% prepares a pair of floats within \meta{type} environment. +% The \meta{pos} contains relative vertical alignment of floats. % The $w_1$ and $w_2$ parameters (if present) specify widthes of % floats. The |\@tempdimc| register contains the default distance % between floats. % \begin{macrocode} \long\def\NCC@@flts#1#2#3#4#5#6#7{% - \begin{#1}[#3]\NCC@wcalc{#4}{#5}% + \begin{#1}[#3]\normalfloatstyle\NCC@wcalc{#4}{#5}% \begingroup\NCC@minifloat[#2]\@tempdima{#6}% \nobreak\hskip\@tempdimc \begingroup\NCC@minifloat[#2]\@tempdimb{#7}% @@ -489,9 +591,57 @@ % \end{macrocode} % \end{macro} % -% Defaults: +% \subsection{Declare a New Mini-float and Service Commands} +% +% \begin{macro}{\newminifloat} +% The command +% \begin{quote} +% |\newminifloat|\marg{gen}\marg{type}\marg{def-place}\marg{pos} +% \end{quote} +% declares a new mini-float and 3 service commands. +% \begin{macrocode} +\newcommand*\newminifloat[4]{% + \edef\@tempa{% +% \end{macrocode} +% Prepare |\mini|\meta{gen} definition: +% \begin{macrocode} + \noexpand\newcommand\expandafter\noexpand\csname mini#1\endcsname{% + \noexpand\begingroup\noexpand\def\noexpand\@captype{#2}% + \noexpand\NCC@minifloat}% +% \end{macrocode} +% Prepare |\side|\meta{gen} definition: +% \begin{macrocode} + \noexpand\newcommand\expandafter\noexpand\csname side#1\endcsname{% + \noexpand\NCC@sidemfloat{% + \expandafter\noexpand\csname mini#1\endcsname}}% +% \end{macrocode} +% Prepare |\|\meta{gen} definition: +% \begin{macrocode} + \noexpand\newcommand\expandafter\noexpand\csname #1\endcsname{% + \noexpand\NCC@float{#2}{#3}}% +% \end{macrocode} +% Prepare |\|\meta{gen}|s| definition: +% \begin{macrocode} + \noexpand\newcommand\expandafter\noexpand\csname #1s\endcsname{% + \noexpand\NCC@floats{#2}{#4}{#3}}% + }% +% \end{macrocode} +% Define all commands: +% \begin{macrocode} + \@tempa +} +\@onlypreamble\newminifloat +% \end{macrocode} +% \end{macro} +% +% \subsection{Base Mini-floats and Defaults} +% % \begin{macrocode} -\FloatStyle{\footnotesize\centering} +\newminifloat{fig}{figure}{ht}{b} +\newminifloat{tabl}{table}{ht}{t} +\FloatStyle{} +\FloatStyle[minifigure]{\footnotesize\centering} +\FloatStyle[minitable]{\footnotesize\centering} %</package> % \end{macrocode} \endinput |