summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fullminipage/fullminipage.dtx
blob: 10bfd8945d4a0711709afad5b7a3d6cadbac3ecd (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \iffalse meta-comment
%
% DocStrip file for fullminipage package
%
% Copyright 2012 Christian Schneider <software(at)chschneider(dot)eu>
%
% This file is part of fullminipage.
%
% fullminipage is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License version 3 as
% published by the Free Software Foundation, not any later version.
%
% fullminipage is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with fullminipage.  If not, see <http://www.gnu.org/licenses/>.
%
% WARNING: THIS IS ALPHA SOFTWARE AND MAY CONTAIN SERIOUS BUGS!
%
% \fi
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{fullminipage}
%<package>  [2014/07/06 v0.1.1 fullpage minipage environment]
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage{fullminipage}
\usepackage{hyperref}
\usepackage{units}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%
% modified description environment
\newcommand{\listmark}{$\bullet$}
\newcommand{\listlengths}{%
  \setlength{\parsep}{0pt}%
  \setlength{\itemsep}{0pt}%
  \setlength{\leftmargin}{10.5em}%
  \setlength{\rightmargin}{0pt}%
  \setlength{\labelsep}{1em}%
  \setlength{\labelwidth}{9.5em}}
\newenvironment{mydescription}{%
  \begin{list}{\listmark}{\listlengths}%
}{%
  \end{list}%
}
%
\begin{document}
  \DocInput{fullminipage.dtx}
\end{document}
%</driver>
% \fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \changes{v0.1.0}{2014/06/22}{initial public version}
% \changes{v0.1.1}{2014/07/06}{corrected README file; no \LaTeX{} changes}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \CheckSum{151}
%
% \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        \~}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \GetFileInfo{fullminipage.sty}
%
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ }
% \DoNotIndex{\@ne}
% \DoNotIndex{\advance,\begingroup,\catcode,\closein}
% \DoNotIndex{\closeout,\day,\def,\edef,\else,\empty,\endgroup}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \title{The \textsf{fullminipage} package\thanks{This document corresponds
%   to \textsf{fullminipage}~\fileversion, dated~\filedate. Copyright
%   2012,2014 Christian Schneider
%   \texttt{<software(at)chschneider(dot)eu>}, \url{http://chschneider.eu}.}}
% \author{Christian Schneider\\ \texttt{<software(at)chschneider(dot)eu>}}
%
% \maketitle
%
% \tableofcontents
% \clearpage
%
% \begin{abstract}
%   This package provides the environment |fullminipage|, which generates a
%   |minipage| spanning a new, complete page with page style |empty|.
%   The environment provides options to set margins around the |minipage| and
%   configure the background.
% \end{abstract}
%
% \section{Usage}
%
% \subsection{The Environment}
%
% \DescribeEnv{fullminipage}
% The environment |fullminipage| generates a new page with page style |empty|,
% which is spanned by a |minipage|.
% The available horizontal and vertical sizes are |\hsize| and |\vsize|,
% respectively.
%
% Caveat: The clearing of the page before/after the |fullminipage| might not
% be done correctly in certain circumstances, in particular, multi-column
% documents.
% Please refer to the |pagebreak| option for details.
%
% \subsection{Options}
%
% The environment |fullminipage| has an optional argument, which accepts
% a comma-separated list of \meta{key}|=|\meta{value} pairs:
% \begin{mydescription}
%   \item[\textsf{left}] left margin (default: $\unit[0]{pt}$)
%   \item[\textsf{right}] right margin (default: $\unit[0]{pt}$)
%   \item[\textsf{top}] top margin (default: $\unit[0]{pt}$)
%   \item[\textsf{bottom}] bottom margin (default: $\unit[0]{pt}$).
%     Note that content exceeding the vertical size of the minipage will not be
%     ``stopped'' by the bottom margin.
%     The value is rather used to calculate the vertical size of the minipage.
%   \item[\textsf{alignment}] the vertical alignment inside the minipage (one
%     of |tcb|; default: |t|)
%   \item[\textsf{bgcolor}] color of the background (except for the
%     margins, empty by default).
%     Omitting the \meta{value} will lead to a black background.
%     A blue background can, for example, be generated with |bgcolor=blue|.
%   \item[\textsf{background}] arbitrary macro for the background (empty by
%     default).
%     This allows, for example, to put an image into the background with
%     |background=\includegraphics{<file>}|.
%     The image will be aligned in the lower left corner of the minipage.
%     Note that |background| is put on top of the background color defined by
%     |bgcolor|.
%   \item[\textsf{pagebreak}] macro for clearing page before and after inserting
%     the |fullminipage|.
%     By default, |\newpage| will be used in single-column documents and
%     |\clearpage|, if a multi-column style is detected.
%     This detection, however, might fail and the user might want to explicitly
%     set |pagebreak=\clearpage|.
%     Note that |\clearpage| has the side-effect of flushing all pending floats.
% \end{mydescription}
%
% \section{License}
%
% \textsf{fullminipage} is free software: you can redistribute it and/or
% modify it under the terms of the GNU General Public License version~3 as
% published by the Free Software Foundation, not any later version.
%
% \textsf{fullminipage} is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
% Public License for more details.
%
% You should have received a copy of the GNU General Public License along with
% fullminipage.  If not, see \texttt{<http://www.gnu.org/licenses/>}.
%
% \section{Bugs, problems, and suggestions}
%
% Please report bugs and problems or send suggestions for this package to
% Christian Schneider.
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \section{Implementation}
%
% The implementation is briefly described in this section. First of all, we
% need the \textsf{keyval} package for \meta{key}|=|\meta{value} options.
% The \textsf{color} package will only be required, if the background color
% needs to be defined.
%    \begin{macrocode}
\RequirePackage{keyval}
\RequirePackage{color}
%    \end{macrocode}
%
% Next, the \meta{key}s are defined:
%    \begin{macrocode}
\define@key{fullminipage}{left}{\def\fullminipage@left{#1}}
\define@key{fullminipage}{right}{\def\fullminipage@right{#1}}
\define@key{fullminipage}{top}{\def\fullminipage@top{#1}}
\define@key{fullminipage}{bottom}{\def\fullminipage@bottom{#1}}
\define@key{fullminipage}{alignment}{\def\fullminipage@alignment{#1}}
\define@key{fullminipage}{bgcolor}[black]{\def\fullminipage@bgcolor{#1}}
\define@key{fullminipage}{background}{\def\fullminipage@background{#1}}
\define@key{fullminipage}{pagebreak}{\def\fullminipage@pagebreak{#1}}
%    \end{macrocode}
%
% Finally, the environment is defined:
%    \begin{macrocode}
\newenvironment{fullminipage}[1][]{%
  \begingroup
%    \end{macrocode}
%
% The \meta{key}|=|\meta{value} pairs are evaluated and a simple detection
% for two-column layout is performed.
%    \begin{macrocode}
    \setkeys{fullminipage}{left=\z@,right=\z@,top=\z@,bottom=\z@,%
                           alignment=t,background={},pagebreak=\newpage}%
    \@ifundefined{twocolumn@sw}{}%
      {\twocolumn@sw{\setkeys{fullminipage}{pagebreak=\clearpage}}{}}%
    \if@twocolumn\setkeys{fullminipage}{pagebreak=\clearpage}\fi%
    \setkeys{fullminipage}{#1}%
%    \end{macrocode}
%
% A new page is started with pagestyle |empty|.
%    \begin{macrocode}
    \fullminipage@pagebreak
    \thispagestyle{empty}%
%    \end{macrocode}
%
% The top position is calculated and the top (vertical) position adjusted
% with |\vspace*|.
%    \begin{macrocode}
    \@tempdima=-1in
    \advance\@tempdima by-\voffset
    \advance\@tempdima by-\topmargin
    \advance\@tempdima by-\headheight
    \advance\@tempdima by-\headsep
    \@tempdimb=\@tempdima
    \advance\@tempdima by-\parskip
    \advance\@tempdima by-\topskip
    \advance\@tempdima by\fullminipage@top
    \vspace*{\@tempdima}%
%    \end{macrocode}
%
% The bottom position is calculated and the current page size enlarged
% accordingly with |\enlargethispage|.
%    \begin{macrocode}
    \@tempdima=\paperheight
    \advance\@tempdima by\@tempdimb
    \advance\@tempdima by-\textheight
    \advance\@tempdima by-\fullminipage@bottom
    \enlargethispage{\@tempdima}%
%    \end{macrocode}
%
% The position corresponding to the left margin is calculated.
%    \begin{macrocode}
    \leftmargin=-1in
    \advance\leftmargin by-\hoffset
    \if@twoside
      \ifodd\value{page}%
        \advance\leftmargin by-\oddsidemargin
      \else
        \advance\leftmargin by-\evensidemargin
      \fi
    \else
      \advance\leftmargin by-\oddsidemargin
    \fi
    \advance\leftmargin by\fullminipage@left
%    \end{macrocode}
%
% The length of a line is calculated and the margins are set with
% |\parshape|.
%    \begin{macrocode}
    \linewidth=\paperwidth
    \advance\linewidth by-\fullminipage@left
    \advance\linewidth by-\fullminipage@right
    \parshape \@ne \leftmargin \linewidth
%    \end{macrocode}
%
% Prepare output without extra spaces.
%    \begin{macrocode}
    \nointerlineskip
    \noindent
%    \end{macrocode}
%
% The value of |\vsize| is calculated and set.  (If it is set before the
% |\noindent| above, it will be overwritten in some cases.)
%    \begin{macrocode}
    \vsize=\paperheight
    \advance\vsize by-\fullminipage@top
    \advance\vsize by-\fullminipage@bottom
%    \end{macrocode}
%
% A zero-sized |picture| environment containing the background is output and the
% |minipage| is started.
%    \begin{macrocode}
    \begin{picture}(0,0)
      \@ifundefined{fullminipage@bgcolor}{}{%
        \put(0,0){\makebox(0,0)[bl]%
          {\color{\fullminipage@bgcolor}{\rule{\linewidth}{\vsize}}}%
        }%
      }%
      \put(0,0){\makebox(0,0)[bl]%
        {\fullminipage@background}%
      }%
    \end{picture}%
    \begin{minipage}[b][\vsize][\fullminipage@alignment]{\linewidth}
}%
%    \end{macrocode}
%
% The |minipage| is closed and a new page is started.
%    \begin{macrocode}
{%
    \end{minipage}%
    \parfillskip=\z@
    \fullminipage@pagebreak
  \endgroup
}
%    \end{macrocode}
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \Finale
%
\endinput