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