Debian Codegraph @

texmf-dist/source/latex/makebox/makebox.dtx

raw
1 % \iffalse meta comment
2 % File: makebox.dtx Copyright (C) 1999 Harald Harders
3 % \fi
4 %
5 % \iffalse
6 %
7 %<*driver>
8 \documentclass{ltxdoc}
9 \IfFileExists{makebox.sty}{\usepackage{makebox}
10 \let\makeboxSTYfound\active}{\GenericWarning{makebox.dtx}{Package
11 file makebox.sty not found (Documentation will be messed up!^^J^^A
12 Generate makebox.sty by (La)TeXing makebox.ins, process
13 makebox.dtx again)^^J}\stop}
14 \usepackage[T1]{fontenc}
15 \usepackage{longtable}
16 \usepackage{graphicx}
17 \usepackage{url}
18 \GetFileInfo{makebox.sty}
19 \title{The \texttt{makebox} package\thanks{This file has version
20 \fileversion\ last revised \filedate.}}
21 \author{Harald Harders\\\texttt{[email protected]}}
22 \date{File Date \filedate, Printed \today}
23 \newlength{\tempdima}%
24 \makeatletter
25 \renewenvironment{table}[1][]{%
26 \@float{table}[#1]%
27 \centering%
28 \setlength{\tempdima}{\abovecaptionskip}%
29 \setlength{\abovecaptionskip}{\belowcaptionskip}%
30 \setlength{\belowcaptionskip}{\tempdima}%
31 }{%
32 \end@float
33 }
34 \makeatother
35 \EnableCrossrefs
36 \CodelineIndex
37 \DoNotIndex{\def,\edef,\let,\newcommand,\newenvironment,\newcounter}
38 \DoNotIndex{\setcounter,\space,\ifx,\else,\fi}
39 \CodelineNumbered
40 \RecordChanges
41 \CheckSum{18}
42 \begin{document}
43 \DocInput{makebox.dtx}
44 \end{document}
45 %</driver>
46 % \fi
47 %
48 % \maketitle
49 % \begin{abstract}
50 % \noindent
51 % This package defines a \cs{makebox*} command that allows to give the
52 % width for the \cs{makebox} command by a sample text instead of a
53 % measure.
54 % \end{abstract}
55 %
56 % \tableofcontents
57 %
58 % \section*{Copyright}
59 % Copyright 2004 Harald Harders.
60 %
61 % This program can be redistributed and/or modified under the terms
62 % of the LaTeX Project Public License Distributed from CTAN
63 % archives in directory macros/latex/base/lppl.txt; either
64 % version 1 of the License, or any later version.
65 %
66 % \section{Using this package}
67 %
68 % Sometimes you want to put a text into a box that has the same width
69 % as another text.
70 % Normally, you have to use \cs{settowidth} to set a length to the
71 % width of the reference text and use \cs{makebox} afterwards.
72 %\DescribeMacro{\makebox*}%
73 %With this package, you can use the \cs{makebox*} command for that.
74 % The width of the box is then given by a mandatory first argument
75 % (instead of the optional first argument of the \cs{makebox}
76 % command).
77 % The following arguments are identically to the normal \cs{makebox}
78 % command.
79 %
80 % For example,
81 %\begin{verbatim}
82 %--longer reference text--\\*
83 %--\makebox*{longer reference text}{short text}--\\*
84 %--\makebox*{longer reference text}[r]{short text}--\\*
85 %--\makebox*{longer reference text}[r]{even longer text than the reference}--\end{verbatim}
86 % leads to\\
87 %--longer reference text--\\*
88 %--\makebox*{longer reference text}{short text}--\\*
89 %--\makebox*{longer reference text}[r]{short text}--\\*
90 %--\makebox*{longer reference text}{even longer text than the reference}--
91 %
92 %
93 % \StopEventually{\PrintChanges \PrintIndex}
94 %
95 %
96 % \section{The implementation}
97 % \iffalse
98 %<*package>
99 % \fi
100 % \changes{1.04}{2003/11/09}{Avoide usage of \cs{textversion} etc.}%
101 % Heading of the package:
102 % \begin{macrocode}
103 \NeedsTeXFormat{LaTeX2e}
104 \ProvidesPackage{makebox}
105 [2004/07/31 v0.1 extend makebox command]
106 % \end{macrocode}
107 % \begin{macro}{\makebox*}
108 % Save the original \cs{makebox} command since it has to be redefined.
109 % \begin{macrocode}
110 \newcommand*\hh@orig@makebox{}
111 \let\hh@orig@makebox\makebox
112 % \end{macrocode}
113 % Redefine \cs{makebox}.
114 % If using normally call the original command.
115 % If using with a star, get the width of the box by a text and call
116 % \cs{hh@makebox} for doing so.
117 % \begin{macrocode}
118 \renewcommand*\makebox{%
119 \@ifnextchar*%
120 {\hh@makebox}{\hh@orig@makebox}%
121 }
122 % \end{macrocode}
123 % The \cs{hh@makebox} is defined with two mandatory arguments since
124 % the star is the first argument and ignored.
125 % First, the width of the reference text is stored in the length
126 % \cs{@tempdima}.
127 % Then, the original \cs{makebox} command ist called to typeset the
128 % box.
129 % \begin{macrocode}
130 \newcommand*\hh@makebox[2]{%
131 \settowidth\@tempdima{#2}%
132 \hh@orig@makebox[\@tempdima]%
133 }
134 % \end{macrocode}
135 % \end{macro}
136 % \iffalse
137 %</package>
138 % \fi
139 % \Finale