From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/shortlst/shortlst.dtx | 794 +++++++++++++++++++++++++++++ macros/latex/contrib/shortlst/shortlst.pdf | Bin 0 -> 294108 bytes 2 files changed, 794 insertions(+) create mode 100644 macros/latex/contrib/shortlst/shortlst.dtx create mode 100644 macros/latex/contrib/shortlst/shortlst.pdf (limited to 'macros/latex/contrib/shortlst') diff --git a/macros/latex/contrib/shortlst/shortlst.dtx b/macros/latex/contrib/shortlst/shortlst.dtx new file mode 100644 index 0000000000..74a6b7773f --- /dev/null +++ b/macros/latex/contrib/shortlst/shortlst.dtx @@ -0,0 +1,794 @@ +% \iffalse +% This is the shortlst package +% Copyright 1998 by Mogens Lemvig Hansen +% Run this file through LaTeX and read the documentation in shortlst.dvi +% \fi +% \CheckSum{366} +% \CharacterTable +% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +% Digits \0\1\2\3\4\5\6\7\8\9 +% Exclamation \! Double quote \" Hash (number) \# +% Dollar \$ Percent \% Ampersand \& +% Acute accent \' Left paren \( Right paren \) +% Asterisk \* Plus \+ Comma \, +% Minus \- Point \. Solidus \/ +% Colon \: Semicolon \; Less than \< +% Equals \= Greater than \> Question mark \? +% Commercial at \@ Left bracket \[ Backslash \\ +% Right bracket \] Circumflex \^ Underscore \_ +% Grave accent \` Left brace \{ Vertical bar \| +% Right brace \} Tilde \~} +% +% \def\fileversion{1.1} \def\filedate{1998/11/27} \def\docdate{\filedate} +% \title{The \textsf{shortlst} Package\thanks{This file describes version +% \fileversion, \filedate, which is a bug-fix release containing no new +% functionality since version 1.0.}} +% \author{\copyright\ Mogens Lemvig Hansen\\mlhansen@uniserve.com} +% \date{\docdate} +% \maketitle +% \begin{abstract} +% The \textsf{shortlst} package provides environments similar +% to \textsf{itemize} and \textsf{enumerate} designed especially +% for lists of short items. +% \end{abstract} +% +% \tableofcontents +% +% \section{The Basics} +% When you have a list of short items, the regular \textsf{itemize} +% environment leaves +% \begin{itemize} +% \item a lot +% \item of +% \item white +% \item space. +% \end{itemize} +% The obvious alternative is to use a \textsf{tabular}, but tables are +% difficult to type and harder to edit if you decide to interchange two items. +% \DescribeEnv{shortitemize} +% This package allows you to type input very similar to \textsf{itemize} +% input. +% \begin{verbatim} +% \begin{shortitemize} +% \item the \textsf{itemize} environment +% \item leaves +% \item a lot +% \item of +% \item white space +% \end{shortitemize} +% \end{verbatim} +% The code above yields output like\footnote{All ``output'' in this document +% is simulated since you probably did not install the \textsf{shortlst} +% package before \LaTeX ing the documentation. The \emph{real} output is +% nicer\dots} this: +% \newlength\mlh +% \begin{quote}\raggedright\setlength\mlh{65pt} +% \makebox[2\mlh][l]{$\bullet$\hspace{\labelsep}the \textsf{itemize} +% environment}\ignorespaces +% \makebox[\mlh][l]{$\bullet$\hspace{\labelsep}leaves}\\ +% \makebox[\mlh][l]{$\bullet$\hspace{\labelsep}a lot}\ignorespaces +% \makebox[\mlh][l]{$\bullet$\hspace{\labelsep}of}\ignorespaces +% \makebox[\mlh][l]{$\bullet$\hspace{\labelsep}white space} +% \end{quote} +% Above, \LaTeX\ decided that the first item needs twice as much space as the +% other items. You may give an optional argument to the \textsf{shortitemize} +% environment specifying the width of the default allotment of space. +% \begin{verbatim} +% \begin{shortitemize}[the \textsf{itemize} environment] +% \end{verbatim} +% Now each item gets as much space as the first. +% \begin{quote}\raggedright +% \settowidth\mlh{the \textsf{itemize} environment}% +% \addtolength\mlh{2\labelsep}\addtolength\mlh\labelwidth +% \makebox[\mlh][l]{$\bullet$\hspace{\labelsep}the \textsf{itemize} +% environment}% +% \makebox[\mlh][l]{$\bullet$\hspace{\labelsep}leaves}\\% +% \makebox[\mlh][l]{$\bullet$\hspace{\labelsep}a lot}% +% \makebox[\mlh][l]{$\bullet$\hspace{\labelsep}of}\\% +% \makebox[\mlh][l]{$\bullet$\hspace{\labelsep}white space}% +% \end{quote} +% +% You may not put any list environment inside a +% \textsf{shortitemize} environment---but a \textsf{shortitemize} environment +% can be (part of) an item of a regular list environment. +% If you put a \textsf{shortitemize} environment inside a regular +% \textsf{itemize} environment, \textsf{shortitemize} will use the next level +% of labels. +% \DescribeMacro{\item} +% You may use the optional argument to \verb:\item: to override +% the label---just as for the regular \textsf{itemize} environment. +% +% \DescribeEnv{shortenumerate} +% The \textsf{shortlst} package also provides a \textsf{shortenumerate} +% environment. You may use \textsf{shortenumerate} in the same way as +% \textsf{shortitemize}, \emph{mutatis mutandis}. +% \begin{verbatim} +% \begin{enumerate} +% \item An item. +% \item This item contains a sub-list: +% \begin{shortenumerate} +% \item One +% \item[\%] One and a half +% \item Two +% \item \label{here}Three +% \end{shortenumerate} +% \item Back in the outer list. +% \end{enumerate} +% \end{verbatim} +% The code above yields this output: +% \begin{enumerate} +% \item An item. +% \item \label{here}This item contains a sub-list: +% \begin{quote}\raggedright\setlength\mlh{1.2in} +% \makebox[\mlh][l]{(a)\hspace{\labelsep}One}% +% \makebox[\mlh][l]{\%\hspace{\labelsep}One and a half}% +% \makebox[\mlh][l]{(b)\hspace{\labelsep}Two}% +% \makebox[\mlh][l]{(c)\hspace{\labelsep}Three}% +% \end{quote} +% \item Back in the outer list. +% \end{enumerate} +% Now you may use \verb:\ref{here}: to refer to item \ref{here}(c) in the +% usual manner. +% +% \DescribeEnv{runenumerate} +% Some lists do not deserve a displayed paragraph. For such you may use the +% \textsf{runenumerate} environment. +% \begin{verbatim} +% You have three choices: +% \begin{runenumerate} +% \item wash you hands, +% \item postpone it until tomorrow, or +% \item \label{choice}stay dirty. +% \end{runenumerate} +% I choose \ref{choice}! +% \end{verbatim} +% Here is then the output: +% \begin{quotation}\setlength\mlh{1em plus .5em minus .5em} +% You have three choices: +% \mbox{1.\hspace\labelsep}wash you hands,\hspace\mlh +% \mbox{2.\hspace\labelsep}postpone it until tomorrow, or\hspace\mlh +% \mbox{3.\hspace\labelsep}stay dirty.\hspace\mlh +% I choose 3! +% \end{quotation} +% The main advantage of the \textsf{runenumerate} environment is the automatic +% (and nested) numbering and cross references. +% \DescribeEnv{runitemize} +% For completeness, the \textsf{shortlst} package also provides a +% \textsf{runitemize} environment. +% +% \section{The Parameters} +% +% \DescribeMacro{\runitemsep} +% The length \verb:\runitemsep: stores the space +% between items of a \textsf{runenumerate} or \textsf{runitemize} +% environment. Here is the default value: +% \begin{verbatim} +% \setlength{\runitemsep}{1em plus .5em minus .5em} +% \end{verbatim} +% +% \DescribeMacro{\labelsep} +% All four environments, \textsf{shortitemize}, \textsf{shortenumerate}, +% \textsf{runitemize}, and \textsf{runenumerate} use \verb:\labelsep: (from +% the \LaTeX\ kernel, see \cite[p.~113]{LaTeXbook}, \cite[p.~62]{companion}, +% or \cite{ltlists}) for the space between the label and +% the item itself. The two short-list environments use the same space as the +% minimal space between one item and the next label. +% +% \DescribeMacro{\labelwidth} +% The labels of the \textsf{shortitemize} and \textsf{shortenumerate} +% environments may overlap the previous item if the length \verb:\labelwidth: +% (from the \LaTeX\ kernel, see \cite[p.~113]{LaTeXbook}, +% \cite[p.~62]{companion}, or \cite{ltlists}) is too small. +% +% \DescribeMacro{\shortitemwidth} +% Instead of giving optional arguments to each \textsf{shortitemize} and +% \textsf{shortitemize} environment, you may change the length +% \verb:\shortitemwidth:, which stores the default width of each item (without +% the label and a bit of space on each side). +% \begin{verbatim} +% \setlength{\shortitemwidth}{65pt} +% \end{verbatim} +% Inside a \textsf{shortitemize} or \textsf{shortenumerate} environment +% \verb:\shortitemwidth: is the width of the optional argument to the +% environment. Thus you may use +% \verb:\parbox[t]{\shortitemwidth}{:\meta{paragraph}\verb:}: to typeset a +% long item. +% \begin{verbatim} +% \begin{shortenumerate}[A little paragraph] +% \item A short item +% \item \parbox[t]{\shortitemwidth}{A little paragraph +% that\footnote{To parbox} will be too long to fit on one line +% no matter what\strut.} +% \item Another short +% \item \newlength{\mylength}% +% \setlength{\mylength}{2\shortitemwidth}% +% \addtolength{\mylength}{2\labelsep}% +% \addtolength{\mylength}{\labelwidth}% +% \begin{minipage}[t]{\mylength} +% A little paragraph that\footnote{To minipage} +% will be too long to fit on one line no matter what. +% \end{minipage} +% \item Bla +% \item Bla +% \end{shortenumerate} +% \end{verbatim} +% The \verb:\strut: on the last line of the \verb:\parbox: improves the +% spacing between the \verb:\parbox: and the following line. +% \begin{quote} +% \raggedright +% \newlength\mylength +% \settowidth\mylength{A little paragraph} +% \setlength\mlh{100pt} +% \makebox[\mlh][l]{1.\hspace\labelsep A short item}^^A +% \makebox[\mlh][l]{2.\hspace\labelsep \parbox[t]{\mylength}{A little +% paragraph that\footnotemark{} will be too long to fit on one line +% no matter what.\strut}}\footnotetext{To parbox}^^A +% \makebox[\mlh][l]{3.\hspace\labelsep Another short}\\ +% \makebox[2\mlh][l]{4.\hspace\labelsep +% \begin{minipage}[t]{180pt} +% A little paragraph that\footnote{To minipage} +% will be too long to fit on one line +% no matter what. +% \end{minipage}}^^A +% \makebox[\mlh][l]{5.\hspace\labelsep Bla}\\ +% \makebox[\mlh][l]{6.\hspace\labelsep Bla}^^A +% \end{quote} +% +% +% \section{The Limitations} +% \begin{itemize} +% \item The \textsf{shortitemize} and \textsf{shortenumerate} environments +% cannot contain any list environment. These include \textsf{shortitemize}, +% \textsf{shortenumerate}, \textsf{itemize}, \textsf{enumerate}, +% \textsf{description}, \textsf{quote}, \textsf{quotation}, \textsf{verse}, +% \textsf{center}, \textsf{flushleft}, \textsf{flushright}, +% \textsf{verbatim}\footnote{But \texttt{\bslash verb} is ok.}, +% \textsf{tabbing}, \textsf{trivlist}, \textsf{list}, and all environments +% made with \verb:\newtheorem:. +% +% \item All four environments handle footnotes\footnote{In the case of +% \textsf{shortitemize} and \textsf{shortenumerate} due to a technique found +% in the \textsf{tabularx} package by David Carlisle +% \cite[code lines 121--127]{tabularx}.}; +% however, the \textsf{shortitemize} and \textsf{shortenumerate} environments +% do not handle other types of floats. +% +% \item The \textsf{shortitemize} and \textsf{shortenumerate} environments +% cannot handle items that are longer than one line; use \verb:\parbox: or the +% \textsf{minipage} environment---with the implications that has on footnotes. +% +% \item The \textsf{shortlst} package does not define a version of the +% \textsf{description} environment because I do not know what it should do. +% +% \item You cannot use the \verb:\label: command if your +% \textsf{shortenumerate} or \textsf{runenumerate} environment is nested +% inside a \textsf{tabularx} environment. +% +% \item All four environments defined by the \textsf{shortlst} package make +% (parts of) paragraphs not boxes. If you want your list centred, you must +% therefore include it in a \verb:\parbox: (or \textsf{minipage}) and centre +% the box. +% +% \end{itemize} +% +% +% \section{The Alternatives} +% \begin{description} +% \item[multiple columns] +% You may use the regular \textsf{itemize} and \textsf{enumerate} environments +% in a multi-column format. The \textsf{multicol} package \cite{multicol} +% creates multiple columns very nicely. The items end up ordered vertically +% where this package orders them horizontally. +% +% \item[\textsf{tabular}] +% You can put your items in a table---but such are difficult to edit and you +% do not get automatic numbering and cross references. +% +% \item[\textsf{multienum}] +% The \textsf{multienum} package \cite{multienum} provides an environment +% similar to \textsf{shortenumerate}. However, the input syntax is more +% similar to \textsf{tabular} than to \textsf{enumerate}. +% +% \item[\textsf{paralist}] +% The \textsf{paralist} package \cite{paralist} provides environments +% similar to \textsf{runitemize} and \textsf{runenumerate} except that +% nesting inside \textsf{itemize} or \textsf{enumerate} is not considered. +% +% \end{description} + +% +% +% \section{The Copyright} +% \begin{itemize} +% \item +%% You may use this software. +% \item +%% You may copy this software and the documentation for your own use. +% \item +%% You may distribute the file \texttt{shortlst.dtx} to others provided +%% you do not make a profit doing so. +% \item +%% You may modify my code and the documentation---including incorporating +%% it into your own work---provided you do not make a profit on my work +%% or allow others to. +% \end{itemize} +% +% +% \section{The Installation} +% \begin{itemize} +% \item Run the file \texttt{shortlst.dtx} through \LaTeX\ (thrice to resolve +% cross references\footnote{If you want an index you must run MakeIndex +% (\texttt{makeindex -s gind.ist shortlst}) between the second and third +% \LaTeX{} run.}). +% \begin{verbatim} +% latex shortlst.dtx +% \end{verbatim} +% \item Run the file \texttt{shortlst.ins} which now exists through \LaTeX. +% \begin{verbatim} +% latex shortlst.ins +% \end{verbatim} +% \item You now have to decide what to do with several files. +% \begin{itemize} +% \item You may now have to move the file \texttt{shortlst.sty} to some +% directory where \LaTeX\ can find it; \texttt{texmf/tex/latex/misc} would be +% the natural choice~\cite{tds}. +% \item Move the documentation, \texttt{shortlst.dvi}, to +% \texttt{texmf/doc/latex/misc}. +% \item You may discard the source file, \texttt{shortlst.dtx}, or store it in +% the directory \texttt{texmf/source/latex/misc}. +% \item Discard all remaining \texttt{shortlst.*} files. +% \end{itemize} +% \end{itemize} +% +%\StopEventually{ +% \bibliographystyle{is-plain} +% ^^A\bibliography{tex} +% \begin{thebibliography}{1} +% +% \bibitem{ltlists} +% Johannes Braams, David Carlisle, Alan Jeffrey, Leslie Lamport, Frank +% Mittelbach, Tobias Oetiker, Chris Rowley, and Rainer Sch{\"{o}}pf. +% \newblock {\em ltlists.dtx}. +% \newblock CTAN, 1997/02/21 edition, 1997. +% +% \bibitem{tabularx} +% David Carlisle. +% \newblock {\em The \textsf{tabularx} Package}. +% \newblock CTAN, 1997/09/18 v2.05 edition, 1997. +% +% \bibitem{ltboxes} +% David Carlisle, Leslie Lamport, Frank Mittelbach, and Chris Rowley. +% \newblock {\em ltboxes.dtx}. +% \newblock CTAN, 1998/06/05 edition, 1998. +% +% \bibitem{companion} +% Michel Goossens, Frank Mittelbach, and Alexander Samarin. +% \newblock {\em The {\LaTeX} Companion}. +% \newblock Addison-Wesley, 1994. +% \newblock ISBN 0-201-54199-8. +% +% \bibitem{multienum} +% Dennis Kletzing. +% \newblock {\em A Multienumerate Package}. +% \newblock CTAN. +% \newblock The author does not provide a version number. +% +% \bibitem{LaTeXbook} +% Leslie Lamport. +% \newblock {\em {\LaTeX}, A Document Preparation System, User's Guide and +% Reference Manual}. +% \newblock Addison-Wesley, second edition, 1994. +% \newblock ISBN 0-201-52983-1. +% +% \bibitem{multicol} +% Frank Mittelbach. +% \newblock {\em An environment for multicolumn output}. +% \newblock CTAN, 1997/12/16 v1.5p edition, 1997. +% +% \bibitem{paralist} +% Bernd Schandl. +% \newblock {\em \textsf{paralist}, Enumerate and Itemize as and within +% Paragraphs}. +% \newblock CTAN, 1998/10/11 v1.0 edition. +% +% \bibitem{tds} +% {TUG Working Group on a {\TeX} Directory Structure (TWG-TDS)}. +% \newblock {\em A Directory Structure for {\TeX} Files}. +% \newblock CTAN, version 0.9995, january 26, 1998 edition, 1998. +% +% \end{thebibliography} +% \PrintIndex +%} +% +% +% \section{The Driver} +% The following few lines of code allow \LaTeX\ to generate +% the \texttt{.sty} file and the documentation from this source. +% First, a \textsf{filecontents} environment creates the installation script, +% \texttt{shortlst.ins}, for \textsc{DocStrip}. +% \begin{macrocode} +%<*docstrip> +\begin{filecontents}{shortlst.ins} +\input docstrip.tex +\preamble + The shortlst Package + Copyright 1998 by Mogens Lemvig Hansen + mlhansen@uniserve.com +\endpreamble +% \end{macrocode} +% I think that \texttt{shortlst.sty} should go into the directory +% \texttt{tex/latex/misc}; however, \textsc{DocStrip} will not heed my advise +% unless your configuration file, \texttt{docstrip.cfg}, allows it to. +% \begin{macrocode} +\usedir{tex/latex/misc} +\generate{\file{shortlst.sty}{\from{shortlst.dtx}{package}}} +\endbatchfile +\end{filecontents} +% +% \end{macrocode} +% Then the driver to typeset the documentation. +% \begin{macrocode} +%<*docdriver> +\documentclass{ltxdoc}[1996/01/11] +\CodelineIndex%\EnableCrossrefs +\begin{document} \DocInput{shortlst.dtx} \end{document} +% +% \end{macrocode} +% +% +% \section{The Implementation} +% +% Declare the package name. I made this package with the December 1997 +% version of \LaTeX; it may work with earlier versions. +% \begin{macrocode} +%<*package> +\NeedsTeXFormat{LaTeX2e}[1997/12/01] +\ProvidesPackage{shortlst} + [1998/11/27 version 1.1] +% \end{macrocode} +% +% \subsection{The run-in lists} +% \begin{macro}{\runitemsep} +% Run-in items are separated by the length \verb:\runitemsep:. The same +% amount of space is also placed before the first item and after the last. +% \begin{macrocode} +\newlength\runitemsep +\setlength\runitemsep{1em plus .5em minus .5em} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{runitemize} +% The \textsf{runitemize} environment first checks if the current level of +% nesting of \textsf{itemize}-like environments is shallow enough to proceed. +% \begin{macrocode} +\newenvironment{runitemize}{% + \ifnum \@itemdepth >\thr@@\@toodeep\else + \advance\@itemdepth\@ne +% \end{macrocode} +% Define the default label, \verb:\@itemlabel:, as \verb:\labelitem:\meta{i} +% which expand to the bullet, dash, etc.\ used by \textsf{itemize}. +% \begin{macrocode} + \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}% + \def\@itemlabel{\csname\@itemitem\endcsname}% +% \end{macrocode} +% The regular \verb:\item: command calls \verb:\@item:, so make it use a +% custom version. +% \begin{macrocode} + \let\@item\run@item +% \end{macrocode} +% Disable \verb:\par: inside the \textsf{runitemize} environment, ignore +% spaces following the \verb:\begin{runitemize}:, and close the \verb:\ifnum: +% at the beginning of this definition. +% \begin{macrocode} + \let\par\relax + \ignorespaces\fi} +% \end{macrocode} +% At the end of the \textsf{runitemize} environment you must remove the space +% (if any) between the last item and the \verb:\end{runitemize}:; replace it +% by \verb:\runitemsep: amount of space. Then ignore spaces following the +% \verb:\end{runitemize}:. +% \begin{macrocode} + {\unskip\hspace\runitemsep\ignorespacesafterend} +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{runenumerate} +% The definition of the \textsf{runenumerate} environment is similar to that +% of the \textsf{runitemize} environment. +% \begin{macrocode} +\newenvironment{runenumerate}{% + \ifnum \@enumdepth >\thr@@\@toodeep\else + \advance\@enumdepth\@ne +% \end{macrocode} +% The call to \verb:\usecounter{enum:\meta{i}\verb:}: sets \verb:\if@nmbrlist: +% true and defines \verb:\@listctr: as \verb:enum:\meta{i} which is the +% counter used by the \textsf{enumerate} environment at this level. +% \begin{macrocode} + \edef\@enumctr{enum\romannumeral\the\@enumdepth}% + \usecounter{\@enumctr}% +% \end{macrocode} +% Define the default label, \verb:\@itemlabel:, as \verb:\labelenum:\meta{i}. +% \begin{macrocode} + \def\@itemlabel{\csname label\@enumctr \endcsname}% + \let\@item\run@item + \let\par\@empty + \ignorespaces\fi} + {\unskip\hspace\runitemsep\ignorespacesafterend} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\run@item} +% The regular \verb:\item: command checks if it has an optional argument, +% stores the answer in \verb:\if@noitemarg:, and calls \verb:\@item: or +% \verb:\@item[\@itemlabel]: as appropriate. The \verb:\run@item: command is +% the custom version of \verb:\@item: for the run-in list environments. +% +% First remove the space (if any) between the last item and this one; replace +% it by \verb:\runitemsep: amount of space. However, this could be the first +% item of a list which is the first object in a paragraph. In that case, just +% begin a new paragraph. +% \begin{macrocode} +\def\run@item[#1]{% + \ifhmode\unskip\hspace\runitemsep\else\leavevmode\fi +% \end{macrocode} +% If the \verb:\item: had no optional argument and if this is a numbered list, +% increment the counter. +% \begin{macrocode} + \if@noitemarg + \@noitemargfalse + \if@nmbrlist\refstepcounter{\@listctr}\fi + \fi +% \end{macrocode} +% Set the label. +% \begin{macrocode} + \mbox{#1}\kern\labelsep\ignorespaces} +% \end{macrocode} +% \end{macro} +% +% \subsection{The short-lists} +% \begin{macro}{\shortitemwidth} +% The idea is to typeset each item in a box of width +% ``a multiple of a fixed length.'' \TeX\ will then stack the boxes so that +% they line up nicely. +% The default ``fixed length'' is $\verb:\shortitemwidth: + \verb:\labelwidth: +% + 2\verb:\labelsep:$ (one \verb:\labelsep: between the label and the item; +% another \verb:\labelsep: between this item and the next label). +% The default value is rather arbitrary. +% \begin{macrocode} +\newlength\shortitemwidth +\setlength\shortitemwidth{65pt} +% \end{macrocode} +% \end{macro} +% +% \begin{environment}{shortitemize} +% The default value of the optional argument to the \textsf{shortitemize} +% environment is a box of width \verb:\shortitemwidth:. +% \begin{macrocode} +\newenvironment{shortitemize}[1][\hbox to \shortitemwidth{\hfil}]{% +% \end{macrocode} +% Check the level of nesting and define the default label as for +% \textsf{runitemize} above. +% \begin{macrocode} + \ifnum \@itemdepth >\thr@@\@toodeep\let\endsh@rtitem\relax\else + \ifx\item\sh@rtitem\sh@rtnesterr\let\endsh@rtitem\relax\else + \advance\@itemdepth\@ne + \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}% +% \end{macrocode} +% Measure the width of the optional argument. +% Since short-list environments +% cannot be nested anyway, you may store the value locally in +% \verb:\shortitemwidth:. +% \begin{macrocode} + \settowidth\shortitemwidth{#1}% +% \end{macrocode} +% +% Use the \textsf{list} environment to create a displayed paragraph for the +% short-list. +% If the end-user has mismatched environments, \LaTeX\ should not mention a +% \textsf{list} environment from the workings of this code, so use +% \verb:\list: and \verb:\endlist: instead of \verb:\begin{list}: and +% \verb:\end{list}:. +% +% In the \textsf{itemize} environment labels stick out in the margin; to get +% things to line up here, it is easier to move the left margin instead. +% \begin{macrocode} + \list{}{\addtolength\leftmargin\itemindent + \addtolength\leftmargin{-\labelwidth}% + \addtolength\leftmargin{-\labelsep}% +% \end{macrocode} +% You cannot have any indentation inside the \textsf{shortitemize} +% environment. +% \begin{macrocode} + \setlength\itemindent\z@}% +% \end{macrocode} +% The \verb:\item: command gets the \textsf{list} environment started. Then +% it is safe to set up a custom version of \verb:\item: +% \changes{1.1}{98/11/27}{Fixed the ragged right.} +% and a \verb:\raggedright: style right-hand margin. +% The \verb:\endsh@rtitem: command is explained below. +% \begin{macrocode} + \item\relax + \@rightskip\@flushglue \rightskip\@rightskip + \let\endsh@rtitem\noindent + \let\item\sh@rtitem + \def\@itemlabel{\csname\@itemitem\endcsname}% + \fi\fi\ignorespaces}% +% \end{macrocode} +% +% At the end of the \textsf{shortitemize} environment you must process the +% last item and close the \textsf{list} environment. +% \begin{macrocode} + {\endsh@rtitem\endlist} +% \end{macrocode} +% \end{environment} +% +% +% \begin{environment}{shortenumerate} +% The definition of the \textsf{shortenumerate} environment is straight +% forward once you comprehend the \textsf{runenumerate} and +% \textsf{shortitemize} environments. +% \changes{1.1}{98/11/27}{Fixed the ragged right.} +% \begin{macrocode} +\newenvironment{shortenumerate}[1][\hbox to \shortitemwidth{\hfil}]{% + \ifnum \@enumdepth >\thr@@\@toodeep\let\endsh@rtitem\relax\else + \ifx\item\sh@rtitem\sh@rtnesterr\let\endsh@rtitem\relax\else + \advance\@enumdepth\@ne + \edef\@enumctr{enum\romannumeral\the\@enumdepth}% + \settowidth\shortitemwidth{#1}% + \list{}{\addtolength\leftmargin\itemindent + \addtolength\leftmargin{-\labelwidth}% + \addtolength\leftmargin{-\labelsep}% + \setlength\itemindent\z@}% + \item\relax + \@rightskip\@flushglue \rightskip\@rightskip + \let\endsh@rtitem\noindent + \let\item\sh@rtitem + \usecounter{\@enumctr}% + \def\@itemlabel{\csname label\@enumctr \endcsname}% + \fi\fi\ignorespaces}% + {\endsh@rtitem\endlist} +% \end{macrocode} +% \end{environment} +% +% \begin{macro}{\TX@ftn}\begin{macro}{\TX@ftntext}\begin{macro}{\TX@xftntext} +% Since each item is typeset inside a box, \TeX\ gobbles up all footnotes. +% David Carlisle has solved that problem in his \textsf{tabularx} package +% \cite[code lines 122--127]{tabularx}. To +% require all of that package every time seems a bit much, so just copy those +% lines of code if needed. +% These special versions of \verb:\@footnotetext: and \verb:\@xfootnotetext: +% store appropriate \verb:\footnotetext: commands in the token list +% \verb:\TX@ftn: for later processing. +% \begin{macrocode} +\ifx\TX@ftn\undefined + \newtoks\TX@ftn + \long\def\TX@ftntext#1{% + \edef\@tempa{\the\TX@ftn\noexpand\footnotetext + [\the\csname c@\@mpfn\endcsname]}% + \global\TX@ftn\expandafter{\@tempa{#1}}}% + \long\def\TX@xftntext[#1]#2{% + \global\TX@ftn\expandafter{\the\TX@ftn\footnotetext[#1]{#2}}} +\fi +% \end{macrocode} +% \end{macro}\end{macro}\end{macro} +% +% \begin{macro}{\sh@rtitem} +% You need to capture each item in a box. Thus each \verb:\item: must close +% and process the previous box before it begins capturing the next item. The +% custom version of \verb:\item: therefore first calls \verb:\endsh@rtitem: to +% finish off the last item, then checks for an optional argument, stores the +% answer in \verb:\@noitemarg:, and calls \verb:\sh@rt@item: or +% \verb:\sh@rt@item[\@itemlabel]: as appropriate. Here \verb:\@itemlabel: is +% the default label. +% \begin{macrocode} +\def\sh@rtitem{% + \endsh@rtitem + \@inmatherr\item + \@ifnextchar [\sh@rt@item{\@noitemargtrue \sh@rt@item[\@itemlabel]}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sh@rt@item} +% \begin{macro}{\endsh@rtitem} +% The \verb:\sh@rt@item: command first (re-)defines \verb:\endsh@rtitem:. An +% \textsf{lrbox} environment captures the label and the text of the item in +% the box \verb:\@tempboxa:, so close that environment---only use +% \verb:\begingroup\lrbox: and \verb:\endlrbox\endgroup: instead of +% \verb:\begin{lrbox}: and \verb:\end{lrbox}: as for \verb:\list: above (the +% extra group is necessary due to the convoluted workings of \textsf{lrbox} +% \cite[code lines 69--80]{ltboxes}). +% \begin{macrocode} +\def\sh@rt@item[#1]{% + \def\endsh@rtitem{\endlrbox\endgroup% +% \end{macrocode} +% Measure the width of the box---that is, the width of the label, the space +% between the label and the item, and the item itself. Let $a$ be that width +% plus one \verb:\labelsep: (for the separation between this item and the next +% label). +% \begin{macrocode} + \setlength\@tempdima{\wd\@tempboxa}% + \addtolength\@tempdima\labelsep +% \end{macrocode} +% Then let $b$ be the ``fixed length;'' that is, $\verb:\labelwidth: + +% 2\verb:\labelsep: + \verb:\shortitemwidth:$. +% \begin{macrocode} + \setlength\@tempdimb\shortitemwidth + \addtolength\@tempdimb{2\labelsep}% + \addtolength\@tempdimb{\labelwidth}% +% \end{macrocode} +% Then calculate how many multiples of $b$ you need to contain $a$; that is, +% calculate $\lceil \frac ab \rceil b$. However, \LaTeX\ does not provide a +% ceiling function, so use \TeX's integer division command, which (for +% positive integers) calculates $\lfloor \frac ab \rfloor$, and add one. The +% result is fine except when $b$ divides $a$ perfectly---which could happen if +% the item is a \verb:\parbox{\shortitemwidth}:, so cheat: decrease $a$ by A +% Very Small Length first. +% \begin{macrocode} + \addtolength\@tempdima{-1sp}% subtract a Very Small Length + \divide\@tempdima by \@tempdimb% + \addtolength\@tempdima{1sp}% add one + \multiply\@tempdimb by \@tempdima% +% \end{macrocode} +% Now $b$ is the desired width of the box. Instead of actually making a box of +% that width, typeset the box as is followed by a suitable amount of space +% (which will then nicely disappear if it happens to land on the right-hand +% margin). +% \begin{macrocode} + \addtolength\@tempdimb{-\wd\@tempboxa}% + \usebox\@tempboxa +% \end{macrocode} +% Now $b$ is the amount of space which you must remember to set once the +% footnotes have been processed.. +% +% The following line of code (from \cite[code line 50]{tabularx}) inserts the +% footnotes (or, rather, \verb:\footnotetext:-s) that were collected inside +% the box. +% The \verb:\expandafter: trickery causes \TeX\ to first clear the token list +% \verb:\TX@ftn:, then execute the \verb:\footnotetext: commands that it +% contained. This convoluted order ensures that the \verb:\footnotetext:-s go +% back into \verb:\TX@ftn: if the short-list is nested inside a +% \textsf{tabularx} environment (so that \textsf{tabularx} can typeset them in +% due time). +% \begin{macrocode} + \global\TX@ftn\expandafter{\expandafter}\the\TX@ftn + \hspace\@tempdimb}% +% \end{macrocode} +% \end{macro} +% +% That was the end---now back to the beginning. First ref-step the counter if +% appropriate. +% \begin{macrocode} + \if@noitemarg + \@noitemargfalse + \if@nmbrlist\refstepcounter{\@listctr}\fi + \fi +% \end{macrocode} +% Issue a warning if the label is too wide---it may overlap the previous item. +% \begin{macrocode} + \settowidth\@tempdima{#1}% + \ifdim\@tempdima>\labelwidth\PackageWarning{shortlst}% + {label too wide + (set \string\labelwidth\space to at least \the\@tempdima)}% + \fi +% \end{macrocode} +% Then begin collecting an lrbox. Once inside the box, use the custom +% footnotes and set the label and some space before the item itself. +% \begin{macrocode} + \begingroup\lrbox{\@tempboxa}% + \let\@footnotetext\TX@ftntext\let\@xfootnotenext\TX@xftntext + \makebox[\labelwidth][r]{#1}% + \hspace{\labelsep}\ignorespaces} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sh@rtnesterr} +% That's it! You just need a single custom error message. +% \begin{macrocode} +\newcommand{\sh@rtnesterr}{\PackageError{shortlst} + {nested short-lists} + {don't nest short-list environments within each other}} +% +% \end{macrocode} +% \end{macro} +% \Finale diff --git a/macros/latex/contrib/shortlst/shortlst.pdf b/macros/latex/contrib/shortlst/shortlst.pdf new file mode 100644 index 0000000000..d975200673 Binary files /dev/null and b/macros/latex/contrib/shortlst/shortlst.pdf differ -- cgit v1.2.3