| 1 |
% \iffalse |
| 2 |
%% |
| 3 |
%% File: mboxfill.dtx Copyright (C) 2005 by Alexander I. Rozhenko |
| 4 |
%% |
| 5 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 6 |
%<package>\ProvidesPackage{mboxfill} |
| 7 |
%<package> [2005/05/13 v1.0 Fill space with mbox (NCC)] |
| 8 |
% |
| 9 |
% \changes{v1.0}{2005/05/13}{This version was uploaded to CTAN} |
| 10 |
% |
| 11 |
%<*driver> |
| 12 |
\let\makeindex\relax |
| 13 |
\documentclass{ltxdoc} |
| 14 |
\usepackage{mboxfill} |
| 15 |
\GetFileInfo{mboxfill.sty} |
| 16 |
\begin{document} |
| 17 |
\title{The \textsf{mboxfill} package\thanks{This file |
| 18 |
has version number \fileversion, last |
| 19 |
revised \filedate.}} |
| 20 |
\author{Alexander I. Rozhenko\\[email protected]} |
| 21 |
\date{\filedate} |
| 22 |
\maketitle |
| 23 |
\DocInput{mboxfill.dtx} |
| 24 |
\end{document} |
| 25 |
%</driver> |
| 26 |
% \fi |
| 27 |
% |
| 28 |
% \section{User Interface} |
| 29 |
% |
| 30 |
% \DescribeMacro\mboxfill |
| 31 |
% This package implements the command |
| 32 |
% \begin{quote} |
| 33 |
% |\mboxfill|\oarg{width}\oarg{leader-type}\marg{pattern} |
| 34 |
% \end{quote} |
| 35 |
% filling a free horizontal space with \meta{pattern}. |
| 36 |
% |
| 37 |
% The \meta{width} parameter specifies a width of box pattern |
| 38 |
% to be used as leaders. If it is omitted, the pattern width is used. |
| 39 |
% The |\width|, |\height|, |\depth|, |
| 40 |
% and |\totalheight| macros can be used in this parameter. |
| 41 |
% Length expressions are also allowed if the \textsf{calc} |
| 42 |
% package is loaded. |
| 43 |
% |
| 44 |
% The \meta{leader-type} parameter specifies a type of leaders |
| 45 |
% to be used: |c| means |\cleaders|, |x| means |\xleaders|, and |
| 46 |
% empty value (default) means |\leaders|. Depending on type, an |
| 47 |
% extra space is distributed between fill entries as follows: |
| 48 |
% in |c| case, fill entries are centered, in |x| case, fill entries |
| 49 |
% are uniformly distributed, and in other cases, fill entries are |
| 50 |
% aligned to the multiple of their width counted from the |
| 51 |
% left boundary of filled box. |
| 52 |
% |
| 53 |
% When the specified \meta{width} differs from the pattern |
| 54 |
% width, the pattern is centered inside the box to fill with. |
| 55 |
% As a consequence, when |x|-leaders are used, a bit of space |
| 56 |
% will be left from both sides of fill area. To remove this |
| 57 |
% space, use the special value of \meta{leader-type} parameter, |
| 58 |
% namely |s|. |
| 59 |
% |
| 60 |
% Example: |
| 61 |
% \begin{quote} |
| 62 |
% |\noindent\mboxfill{*}\mbox{}\\|\\ |
| 63 |
% |\mbox{}\mboxfill[2\width]{+}\mbox{}\\|\\ |
| 64 |
% |\mbox{}\mboxfill[2\width]{\hfill+}\mbox{}\\|\\ |
| 65 |
% |\mbox{}\mboxfill[2\width]{+\hfill}\mbox{}\\|\\ |
| 66 |
% |A text\mboxfill[1.5\width]{*}\mbox{}\\|\\ |
| 67 |
% |\mbox{}\mboxfill[1.5\width]{*}\mbox{}\\|\\ |
| 68 |
% |\mbox{}\mboxfill[1.5\width][c]{*}\mbox{}\\|\\ |
| 69 |
% |\mbox{}\mboxfill[1.5\width][x]{*}\mbox{}\\|\\ |
| 70 |
% |\mbox{}\mboxfill[1.5\width][s]{*}\mbox{}\\[-2ex]|\\ |
| 71 |
% |\mbox{}\hrulefill| |
| 72 |
% \end{quote} |
| 73 |
% It produces the following: |
| 74 |
% |
| 75 |
% \noindent\mboxfill{*}\mbox{}\\ |
| 76 |
% \mbox{}\mboxfill[2\width]{+}\mbox{}\\ |
| 77 |
% \mbox{}\mboxfill[2\width]{\hfill+}\mbox{}\\ |
| 78 |
% \mbox{}\mboxfill[2\width]{+\hfill}\mbox{}\\ |
| 79 |
% A text\mboxfill[1.5\width]{*}\mbox{}\\ |
| 80 |
% \mbox{}\mboxfill[1.5\width]{*}\mbox{}\\ |
| 81 |
% \mbox{}\mboxfill[1.5\width][c]{*}\mbox{}\\ |
| 82 |
% \mbox{}\mboxfill[1.5\width][x]{*}\mbox{}\\ |
| 83 |
% \mbox{}\mboxfill[1.5\width][s]{*}\mbox{}\\[-2ex] |
| 84 |
% \mbox{}\hrulefill |
| 85 |
% |
| 86 |
% \StopEventually{} |
| 87 |
% |
| 88 |
% \section{The Implementation} |
| 89 |
% |
| 90 |
% \begin{macrocode} |
| 91 |
%<*package> |
| 92 |
\newcommand*\mboxfill[1][\width]{% |
| 93 |
\def\@tempa{\setlength\@tempdima{#1}}% |
| 94 |
\@ifnextchar[{\NCC@mboxfill}{\NCC@mboxfill[]}% |
| 95 |
} |
| 96 |
\def\NCC@mboxfill[#1]#2{% |
| 97 |
\@begin@tempboxa\hbox{#2}% |
| 98 |
% \end{macrocode} |
| 99 |
% Set the required box width in |\@tempdima|: |
| 100 |
% \begin{macrocode} |
| 101 |
\@tempa |
| 102 |
% \end{macrocode} |
| 103 |
% Test the case of |s|-leaders. They work like |x|-leaders, |
| 104 |
% but a special kern is added to both sides of the fill area |
| 105 |
% to compensate extra-space added in the box. |
| 106 |
% \begin{macrocode} |
| 107 |
\edef\@tempa{#1}\def\@tempb{s}% |
| 108 |
\ifx\@tempa\@tempb |
| 109 |
\@tempdimb\width |
| 110 |
\advance\@tempdimb -\@tempdima |
| 111 |
\let\@tempa\xleaders |
| 112 |
\def\@tempb{\kern.5\@tempdimb}% |
| 113 |
\else |
| 114 |
% \end{macrocode} |
| 115 |
% Other cases: if leader-type is incorrect, we use |\leaders|. |
| 116 |
% \begin{macrocode} |
| 117 |
\@ifundefined{#1leaders}{\let\@tempa\leaders}% |
| 118 |
{\def\@tempa{\csname#1leaders\endcsname}}% |
| 119 |
\let\@tempb\@empty |
| 120 |
\fi |
| 121 |
% \end{macrocode} |
| 122 |
% |\@tempa| contains required leaders, |\@tempb| is a kern or empty. |
| 123 |
% Fill the space. |
| 124 |
% \begin{macrocode} |
| 125 |
\leavevmode\@tempb\@tempa |
| 126 |
\hb@xt@\@tempdima{\hss\unhbox\@tempboxa\hss}\hfill\@tempb |
| 127 |
\@end@tempboxa |
| 128 |
} |
| 129 |
%</package> |
| 130 |
% \end{macrocode} |
| 131 |
\endinput |