Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2015-2020 by Scott Pakin <[email protected]>
4 % ------------------------------------------------------------
5 %
6 % This file may be distributed and/or modified under the conditions of
7 % the LaTeX Project Public License, either version 1.3c of this license
8 % or (at your option) any later version. The latest version of this
9 % license is in:
10 %
11 % http://www.latex-project.org/lppl/
12 %
13 % and version 1.3c or later is part of all distributions of LaTeX version
14 % 2008/05/04 or later.
15 %
16 % \fi
17 %
18 % \iffalse
19 %<*driver>
20 \ProvidesFile{boxedminipage.dtx}
21 %</driver>
22 %<package|old-package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
23 %<package>\ProvidesPackage{boxedminipage}
24 %<old-package>\ProvidesPackage{boxedminipage2e}
25 %<*package>
26 [2020/04/19 v1.1 Boxed LaTeX2e minipages]
27 %</package>
28 %
29 %<*driver>
30 \documentclass{ltxdoc}
31 \usepackage[T1]{fontenc}
32 \usepackage{boxedminipage}
33 \usepackage{needspace}
34 \usepackage{tocbibind}
35 \usepackage{hyperref}
36 \usepackage{hyperxmp}
37 \usepackage{cleveref}
38 \EnableCrossrefs
39 \CodelineIndex
40 \RecordChanges
41
42 % Specify this document's metadata.
43 \GetFileInfo{boxedminipage.dtx}
44 \title{The \pkgname{boxedminipage} package\thanks{This document
45 corresponds to \pkgname{boxedminipage}~\fileversion, dated \filedate.}}
46 \author{Scott Pakin \\ \textit{[email protected]}}
47 \makeatletter
48 \edef\versionnumber{\expandafter\@gobble\fileversion} % Drop the "v" in the file version.
49 \makeatother
50 \hypersetup{%
51 pdftitle={The boxedminipage package},
52 pdfauthor={Scott Pakin},
53 pdfsubject={LaTeX2e minipages with a surrounding frame},
54 pdfkeywords={LaTeX, minipages, boxes, frames, fbox, fboxsep},
55 pdfcopyright={Copyright (C) 2015-2020, Scott Pakin},
56 pdflicenseurl={http://www.latex-project.org/lppl/},
57 pdfcaptionwriter={Scott Pakin},
58 pdfcontactemail={[email protected]},
59 pdfcontacturl={http://www.pakin.org/\xmptilde scott/},
60 pdfversionid={\versionnumber},
61 pdflang={en-US},
62 pdftrapped={False},
63 pdfstartpage={},
64 pdfurl={http://mirror.ctan.org/macros/latex/contrib/boxedminipage/boxedminipage.pdf},
65 baseurl={http://mirror.ctan.org/macros/latex/contrib/boxedminipage/}
66 }
67
68 % Begin the documentation.
69 \begin{document}
70 \DocInput{boxedminipage.dtx}
71 \Needspace{10\baselineskip}
72 \phantomsection\addcontentsline{toc}{section}{Change History}
73 \PrintChanges
74 \makeatletter
75 \let\orig@index@prologue=\index@prologue
76 \def\index@prologue{%
77 \phantomsection\addcontentsline{toc}{section}{Index}
78 \orig@index@prologue
79 }%
80 \makeatother
81 \Needspace{12\baselineskip}
82 \PrintIndex
83 \end{document}
84 %</driver>
85 % \fi
86 %
87 % \CheckSum{62}
88 %
89 % \CharacterTable
90 % {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
91 % 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
92 % Digits \0\1\2\3\4\5\6\7\8\9
93 % Exclamation \! Double quote \" Hash (number) \#
94 % Dollar \$ Percent \% Ampersand \&
95 % Acute accent \' Left paren \( Right paren \)
96 % Asterisk \* Plus \+ Comma \,
97 % Minus \- Point \. Solidus \/
98 % Colon \: Semicolon \; Less than \<
99 % Equals \= Greater than \> Question mark \?
100 % Commercial at \@ Left bracket \[ Backslash \\
101 % Right bracket \] Circumflex \^ Underscore \_
102 % Grave accent \` Left brace \{ Vertical bar \|
103 % Right brace \} Tilde \~}
104 %
105 %
106 % \changes{v1.0}{2015/03/09}{Initial version}
107 % \changes{v1.1}{2020/04/19}{Renamed the package from
108 % \protect\pkgname{boxedminipage2e} to \protect\pkgname{boxedminipage}}
109 %
110 % \DoNotIndex{\@ifnextchar,\MessageBreak,\addtolength,\begin,\def,\else}
111 % \DoNotIndex{\end,\fi,\ifx,\ifx,\newcommand,\newenvironment,\relax}
112 % \DoNotIndex{\setlength,\the}
113 %
114 % ^^A Define a shortcut for typesetting package names.
115 % \let\pkgname=\textsf
116 %
117 % \maketitle
118 % \sloppy
119 %
120 % \section{Introduction}
121 %
122 % This is a very simple package. It defines a single environment,
123 % |boxedminipage| that is essentially equivalent to
124 % |\fbox{\begin{minipage}|\dots |\end{minipage}}|. The difference is
125 % that the width of a |boxedminipage| includes the width of the frame,
126 % while the width of the |\fbox|~$+$ |minipage| combination is wider
127 % than the width specified to the |minipage|.
128 %
129 % The following example exaggerates the effect by setting
130 % |\fboxrule=8pt| and |\fboxsep=4pt| and defining |minipage|s of width
131 % |\linewidth|:
132 %
133 % \begin{center}
134 % \setlength{\fboxrule}{8pt}
135 % \setlength{\fboxsep}{4pt}
136 % \begin{minipage}{0.8\linewidth}
137 % \setlength{\parindent}{2em}
138 % Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce
139 % condimentum id elit in fringilla. Vivamus tempus magna non tortor
140 % aliquet, ac porta justo venenatis. Suspendisse quis efficitur
141 % nibh.
142 %
143 % \noindent\fbox{%
144 % \begin{minipage}[t]{\linewidth}
145 % This box was created by putting a |minipage| within an
146 % \cs{fbox}. Notice how the frame is aligned with the left margin
147 % of the surrounding text but juts out into the right margin.
148 % \end{minipage}}
149 %
150 % Suspendisse pulvinar vel elit at dapibus. Interdum et malesuada
151 % fames ac ante ipsum primis in faucibus. Cras nibh orci, posuere
152 % quis viverra a, gravida nec velit. Pr\ae{}sent porta semper
153 % tellus, eu pulvinar ante mollis faucibus.
154 %
155 % \noindent
156 % \begin{boxedminipage}[t]{\linewidth}
157 % This box was created with the |boxedminipage| environment.
158 % Notice how the frame is aligned properly with both margins of
159 % the surrounding text.
160 % \end{boxedminipage}
161 %
162 % Duis est neque, aliquet at augue a, auctor condimentum orci. Donec
163 % arcu magna, eleifend a consequat in, vehicula non elit. Sed id est
164 % sed ipsum interdum posuere.
165 % \end{minipage}
166 % \end{center}
167 %
168 % \paragraph{History}
169 % Prior to \pkgname{boxedminipage}~v1.1 (April 2020), the package was
170 % known as \pkgname{boxedminipage2e} to distinguish it from Mario
171 % Wolczko's \pkgname{boxedminipage} package, developed for \LaTeX~2.09.
172 % Mario's package, last updated in~1992, lacks support for the
173 % \LaTeXe\ |minipage|'s \meta{height} and \meta{inner-pos} arguments.
174 % In contrast, this package supports |minipage|'s complete functionality.
175 %
176 % At Frank Mittelbach's suggestion and with Mario Wolczko's consent,
177 % this \pkgname{boxedminipage} replaces the \LaTeX~2.09 version.
178 % \pkgname{boxedminipage2e} is now an alias for \pkgname{boxedminipage}
179 % except that it issues a warning message that new documents should
180 % instead use \pkgname{boxedminipage}.
181 %
182 %
183 % \section{Usage}
184 %
185 % \DescribeEnv{boxedminipage}
186 % The \pkgname{boxedminipage} package defines a single environment,
187 % |boxedminipage|. It takes the same parameters as \LaTeXe's |minipage|
188 % environment:
189 %
190 % \bigskip
191 % \DeleteShortVerb{\|}
192 % \hspace*{-2em}%
193 % \begin{tabular}{|l|}
194 % \hline
195 % \verb|\begin{boxedminipage}|
196 % \oarg{pos} \oarg{height} \oarg{inner-pos} \marg{width} \\
197 % \quad\meta{text} \\
198 % \verb|\end{boxedminipage}| \\
199 % \hline
200 % \end{tabular}
201 % \MakeShortVerb{\|}
202 % \bigskip
203 %
204 % The semantic difference is that the values specified by the \meta{height}
205 % and \meta{width} arguments are reduced to accommodate the space needed
206 % by the surrounding frame.
207 %
208 %
209 % \section{Implementation}
210 %
211 % Most readers can ignore this section. It presents an annotated
212 % version of \pkgname{boxedminipage}'s source code.
213 % \Cref{sec:boxedminipage} describes the contents of |boxedminipage.sty|.
214 % \Cref{sec:boxedminipage2e} represents a separate stub file,
215 % |boxedminipage2e.sty|, which merely issues a warning message and
216 % instructs the author to load \pkgname{boxedminipage} instead of
217 % \pkgname{boxedminipage2e}.
218 %
219 % \subsection{boxedminipage}
220 % \label{sec:boxedminipage}
221 %
222 % \iffalse
223 %<*package>
224 % \fi
225 %
226 % \begin{macro}{\bmp@box}
227 % The contents of the |minipage| are collected into |\bmp@box|.
228 % \begin{macrocode}
229 \newsavebox{\bmp@box}
230 % \end{macrocode}
231 % \end{macro}
232 %
233 % \begin{macro}{\bmp@width}
234 % \begin{macro}{\bmp@height}
235 % The adjusted width and height of the |minipage| are stored in
236 % |\bmp@width| and |\bmp@height|, respectively.
237 % \begin{macrocode}
238 \newlength{\bmp@width}
239 \newlength{\bmp@height}
240 % \end{macrocode}
241 % \end{macro}
242 % \end{macro}
243 %
244 % \begin{macro}{\bmp@relax}
245 % We determine if the |minipage|'s \meta{height} argument contains only
246 % |\relax| by comparing it to |\bmp@relax|.
247 % \begin{macrocode}
248 \def\bmp@relax{\relax}
249 % \end{macrocode}
250 % \end{macro}
251 %
252 % \begin{environment}{boxedminipage}
253 % The |boxedminipage| environment is the only environment exposed by the
254 % \pkgname{boxedminipage} package. It takes the same parameters as
255 % \LaTeXe's ordinary |minipage| environment:\par
256 % \smallskip
257 % \begin{tabular}{lcccc}
258 % \emph{Arguments}: & \oarg{pos} & \oarg{height} & \oarg{inner-pos} & \marg{width} \\
259 % \emph{Default values}: & |c| & |\relax| & |s| & --- \\
260 % \end{tabular}
261 % \begin{macrocode}
262 \newcommand{\boxedminipage}[1][c]{%
263 \@ifnextchar[{\bminipage@i[#1]}{\bminipage@i[#1][\relax]}%
264 }
265 % \end{macrocode}
266 % \end{environment}
267 %
268 % \begin{macro}{\bminipage@i}
269 % The top-level |boxedminipage| environment invokes |\bminipage@i| with
270 % the \meta{pos} and \meta{height} arguments. |\bminipage@i| checks for
271 % an \meta{inner-pos} argument and provides ``|s|'' if absent.
272 % \begin{macrocode}
273 \def\bminipage@i[#1][#2]{%
274 \@ifnextchar[{\bminipage@ii[#1][#2]}{\bminipage@ii[#1][#2][s]}%
275 }
276 % \end{macrocode}
277 % \end{macro}
278 %
279 % \begin{macro}{\bminipage@ii}
280 % The |\bminipage@ii| macro is passed all four of |boxedminipage|'s
281 % arguments. It subtracts two |\fboxrule| and two |\fboxsep| lengths
282 % from each of the \meta{height}~(|#2|) and \meta{width}~(|#4|)
283 % arguments to make room for the lines and padding that |\fbox|
284 % introduces. |\bminipage@ii| then begins a |minipage| with the
285 % appropriate parameters and prepares to store it in box |\bmp@box|.
286 % \begin{macrocode}
287 \def\bminipage@ii[#1][#2][#3]#4{%
288 \setlength{\bmp@width}{#4}%
289 \addtolength{\bmp@width}{-2\fboxrule}%
290 \addtolength{\bmp@width}{-2\fboxsep}%
291 \def\bmp@heighttext{#2}%
292 \begin{lrbox}{\bmp@box}%
293 \ifx\bmp@heighttext\bmp@relax
294 \begin{minipage}[#1][#2][#3]{\the\bmp@width}%
295 \else
296 \setlength{\bmp@height}{\bmp@heighttext}%
297 \addtolength{\bmp@height}{-2\fboxrule}%
298 \addtolength{\bmp@height}{-2\fboxsep}%
299 \begin{minipage}[#1][\bmp@height][#3]{\the\bmp@width}%
300 \fi
301 }
302 % \end{macrocode}
303 % \end{macro}
304 %
305 % \begin{macro}{\endboxedminipage}
306 % When the document invokes |\end{boxedminipage}| we typeset the
307 % |minipage| we just created within an |\fbox|.
308 % \begin{macrocode}
309 \def\endboxedminipage{%
310 \end{minipage}%
311 \end{lrbox}%
312 \fbox{\usebox{\bmp@box}}%
313 }
314 % \end{macrocode}
315 % \end{macro}
316 %
317 % \iffalse
318 %</package>
319 % \fi
320 %
321 % \subsection{boxedminipage2e}
322 % \label{sec:boxedminipage2e}
323 %
324 % Issue a warning if the user loaded \pkgname{boxedminipage2e} instead of
325 % the newer name, \pkgname{boxedminipage}. Then load \pkgname{boxedminipage}.
326 %
327 % \medskip
328 % \noindent
329 % {\sffamily\small
330 %<*old-package>
331 % }
332 % \begin{macrocode}
333 \PackageWarningNoLine{boxedminipage2e}{%
334 The boxedminipage2e package has been\MessageBreak
335 renamed to boxedminipage. New documents\MessageBreak
336 should load boxedminipage instead of\MessageBreak
337 boxedminipage2e}
338 % \end{macrocode}
339 %
340 % \begin{macrocode}
341 \RequirePackage{boxedminipage}
342 % \end{macrocode}
343 % {\sffamily\small
344 %</old-package>
345 % }
346 %
347 %
348 % \Finale
349 \endinput