summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/adjmulticol/adjmulticol.sty
blob: f8a11b9abf01dd09321235b04f44289d02736122 (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
%%
%% This is file `adjmulticol.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% adjmulticol.dtx  (with options: `style')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from adjmulticol.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file adjmulticol.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% Copyright 2022, Boris Veytsman <borisv@lk.net>
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any
%% later version.
%% The latest version of the license is in
%%    http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2003/06/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Boris Veytsman
%%
%% This work consists of the file adjmulticol.dtx and the
%% derived file adjmulticol.sty,
%%
%%
%% Since this package is based on the multicol package,
%% Copyright 1989-2005 Frank Mittelbach, the following additional
%% condition is added to the licensing terms.  The term ``multicol''
%% here should be interpreted as ``multicol and/or adjmulticol''
%% package, as appropriate.
%%
%%  In addition to the terms of LPPL any distributed version
%%  (unchanged or modified) of multicol has to keep the statement
%%  about the moral obligation for using multicol. In case of major
%%  changes where this would not be appropriate the author of the
%%  changed version should contact the copyright holder.
%%
%%
%%  Moral obligation for using multicol:
%%  ------------------------------------
%%
%%  Users of multicol who wish to include or use multicol or a modified
%%  version in a proprietary and commercially market product are asked
%%  under certain conditions (see below) for the payment of a license
%%  fee.  The size of this fee is to be determined, in each instance,
%%  by the commercial user, depending on his/her judgment of the value of
%%  multicol for his/her product.
%%
%%
%%  The conditions for this are as follows:
%%
%%   The producer of a proprietary and commercially market product
%%   that involves typesetting using multicol is asked to determine
%%   the value of a license fee for using multicol if
%%
%%   - the product is a document and the producer has decided to
%%     include multicol to typeset (parts of) the document or has
%%     directed the author of the document to include multicol (for
%%     example, by providing a class file to be used by the author)
%%
%%   - the product is a LaTeX class or package that includes multicol
%%
%%
%%   There is no moral obligation in case
%%
%%   - the product is a document but producer has not directed
%%     the author to include multicol (in that case the moral obligation
%%     lies with the author of the document)
%%
%%   - the product does not involve typesetting, e.g., consists, for
%%     example, of distributing multicol and its documentation.
%%
%%   - the product is not proprietary, i.e., is made available as free
%%     software itself (which doesn't prohibit its commercial marketing)
%%
%%   - multicol is used for non-commercial purposes
%%
%%
%% Determinating a license fee might result in a license fee of zero
%% (i.e., no payment) in case a producer has determined that the use
%% of multicol has no enhancing effect on the product. This is a
%% plausible scenario, i.e., in the above two cases the producer is
%% only asked to evaluate the value of multicol for the product
%% not for the payment of a license fee per se (which might or might
%% not follow from this evaluation).
%%
%% The license fee, if any, can be payed either to the LaTeX3 fund
%% (see ltx3info.txt in the base LaTeX distribution) or to the author of
%% the program who can be contacted at
%%
%%     Frank.Mittelbach@latex-project.org
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{adjmulticol}
[2022/05/15 v1.5 Adjusted margins for multicolumn layout]
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{multicol}}
\ProcessOptions\relax
\RequirePackage{multicol}
\newdimen\adjmc@inner
\newdimen\adjmc@outer
\newdimen\adjmc@saved@leftmargin
\def\adjmulticols#1#2#3{\col@number#1\relax
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\adjmc@inner\z@\else\adjmc@inner#2\fi
  \def\@tempa{#3}%
  \ifx\@tempa\@empty\adjmc@outer\z@\else\adjmc@outer#3\fi
  \ifnum\col@number<\@ne
     \PackageWarning{adjmulticol}%
      {Using `\number\col@number'
       columns doesn't seem a good idea.^^J
       I therefore use one columns instead}%
     \col@number\@ne\fi
  \ifnum\col@number>10
     \PackageError{adjmulticol}%
      {Too many columns}%
      {Current implementation doesn't
       support more than 10 columns.%
       \MessageBreak
       I therefore use 10 columns instead}%
     \col@number10 \fi
     \ifnum\col@number=\@ne\relax
     \let\balance@columns\adjmc@process@ne@column
     \fi
     \ifx\@footnotetext\mult@footnotetext\else
       \let\orig@footnotetext\@footnotetext
       \let\@footnotetext\mult@footnotetext
     \fi
  \@ifnextchar[\adjmult@cols{\adjmult@cols[]}}
\def\adjmult@cols[#1]{\@ifnextchar[%
  {\adjmult@@cols{#1}}%
  {\adjmult@@cols{#1}[\premulticols]}}
\def\adjmult@@cols#1[#2]{%
    \advance\linewidth by -\adjmc@inner\relax
    \advance\linewidth by -\adjmc@outer\relax
\let\page@sofar=\adjmc@page@sofar
   \mult@@cols#1[#2]}
\def\set@mult@vsize#1{%
    \vsize\@colroom
    \@tempdima\baselineskip
    \advance\@tempdima-\topskip
    \advance\vsize\@tempdima
    \vsize\col@number\vsize
    \advance\vsize-\@tempdima
    \ifnum\col@number>1\relax
    \advance\vsize\col@number\baselineskip
    \else
    \advance\vsize-2\baselineskip
    \fi
    #1\advance\vsize
        \c@collectmore\baselineskip}
\def\endadjmulticols{%
  \global\let\@ADJMC@checkend\@checkend
  \gdef\@checkend##1{}%
  \ifnum\col@number=\@ne\relax\vfill\fi
  \endmulticols
  \global\let\@checkend\@ADJMC@checkend}
\let\adjmc@page@sofar@orig=\page@sofar
\def\adjmc@page@sofar{%
   \adjmc@saved@leftmargin=\multicol@leftmargin
   \if@twoside
      \ifodd\c@page
        \advance\multicol@leftmargin by \adjmc@inner\relax
     \else
        \advance \multicol@leftmargin by \adjmc@outer\relax
    \fi
   \else
      \advance \multicol@leftmargin by \adjmc@inner\relax
  \fi
   \adjmc@page@sofar@orig
   \multicol@leftmargin=\adjmc@saved@leftmargin}
\def\adjmc@process@ne@column{%
  \setbox\mult@firstbox\vbox{\unvbox\mult@box\vfill}}
\newenvironment{adjmulticols*}{%
   \ifinner
     \PackageWarning{multicol}%
       {multicols* inside a box does
        not make sense.\MessageBreak
        Going to balance anyway}%
   \else
     \ifnum\col@number=\@ne\relax
        \let\balance@columns\adjmc@process@ne@column
     \else
        \let\balance@columns@out\multi@column@out
     \fi
   \fi
   \adjmulticols}{%
   \vfill
  \endadjmulticols}
\endinput
%%
%% End of file `adjmulticol.sty'.