summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/stubs/stubs.sty
blob: e39cd8538c60b8f7af0f829357702d27cae987e0 (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
%    This file is part of stubs.
%
%    stubs is free software; you can redistribute it and/or modify
%    it under the terms of the GNU General Public License as published by
%    the Free Software Foundation; either version 2 of the License, or
%    (at your option) any later version.
%
%    Stubs 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 Foobar; if not, write to the Free Software
%    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
%
%
% Version 0.1.1
%
% Changelog:
%
% see changelog.txt
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{stubs}[2005/12/16 Stubs 0.1.1 by N. Stuhrmann]

\RequirePackage[absolute]{textpos}[2005/10/13]
\RequirePackage{graphicx}[1999/02/16]

\DeclareOption{addmargin}{\newcommand*\st@addmargin{\relax}}%

\ProcessOptions

\newlength{\stubbmargin}
\setlength{\stubbmargin}{5mm}

\newlength{\stublmargin}
\setlength{\stublmargin}{5mm}

\newlength{\stubrmargin}
\setlength{\stubrmargin}{5mm}

\newcommand{\stubs}[2][0]{%
\def\st@number{#1}%
\def\st@size{#2}%
\st@b
}

\newcommand{\st@b}[2][\empty]{%
 {%
  \unitlength=1pt\relax
  \@tempdima=\paperheight\relax
  \@tempdimb=\paperwidth\relax
  \advance\@tempdimb by -\stublmargin\relax
  \advance\@tempdimb by -\stubrmargin\relax
  \textblockorigin{\stublmargin}{\paperheight}\relax
  \setbox\@tempboxa=\vbox{\parbox[b]{\st@size}{#1}\parbox[b]{\st@size}{#2}}\relax
  \count@=\st@number\relax
  \@ifundefined{st@addmargin}%
   {}%
   {\enlargethispage{-\st@size}}%
%\ifnum\count@=0\relax
% \dimen@=\ht\@tempboxa\relax
% \advance\dimen@ by 2\fboxsep\relax
% {\divide\@tempdimb by \dimen@\relax
% \global\count@=\@tempdimb}%
%\fi%
  \ifnum\count@=0\relax%
    \dimen@=\ht\@tempboxa\relax%
    \advance\dimen@ by 2\fboxsep\relax%
    {\divide\@tempdimb by \dimen@\relax%
    \expandafter}\expandafter\count@\expandafter=\number\@tempdimb
  \fi%
  \divide\@tempdimb by \count@\relax
  \setbox\@tempboxa=\vtop to \@tempdimb %
    {\vfill\hbox{\kern\fboxsep\parbox{\st@size}{#2}\kern\fboxsep}\vfill\hrule}\relax
  \advance\@tempdima by -\wd\@tempboxa\relax
  \begin{textblock}{0}(0,0)%
   \noindent
   \begin{picture}(0,0)%
    \put(0,\strip@pt\stubbmargin){\vrule height \wd\@tempboxa}
    \multiput(0,\strip@pt\stubbmargin)(\strip@pt\@tempdimb,0){\number\count@}{%
     \rotatebox{90}{\copy\@tempboxa}%
    }%
   \end{picture}%
  \end{textblock}\leavevmode%
  \ifx\empty#1\else%
   \newpage%
   \thispagestyle{empty}%
   \@ifundefined{st@addmargin}%
    {}%
    {\enlargethispage{-\st@size}}%
   \textblockorigin{\stubrmargin}{\paperheight}\relax
   \setbox\@tempboxa=\vtop to \@tempdimb %
     {\vfill\hbox{\kern\fboxsep\parbox{\st@size}{#1}\kern\fboxsep}\vfill}\relax
   \begin{textblock}{0}(0,0)%
    \noindent
    \begin{picture}(0,0)%
     %\put(0,\strip@pt\stubbmargin){\vrule height \wd\@tempboxa}
     \multiput(0,\strip@pt\stubbmargin)(\strip@pt\@tempdimb,0){\number\count@}{%
      \rotatebox{90}{\copy\@tempboxa}%
     }%
    \end{picture}%
   \end{textblock}\leavevmode%
  \fi%
 }%
 \ignorespaces%
}

\endinput