blob: 62ced86e050b64fdc5b97ab57d0ad98b32751c96 (
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
|
%%
%% This is file `marginfit.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% marginfit.dtx (with options: `package')
%%
%% Copyright 2017, 2018 Maurice Leclaire <leclaire@in.tum.de>
%%
%% 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 this license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `author-maintained'.
%%
%% This work consists of the files marginfit.dtx and marginfit.ins
%% and the derived file marginfit.sty.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{marginfit}[2018/06/08 v1.1 Fit Margin Paragraphs]
\newinsert\marginfit@insert
\count\marginfit@insert0
\skip\marginfit@insert\z@
\dimen\marginfit@insert\maxdimen
\newbox\marginfit@reverse
\chardef\marginfit@box0
\chardef\marginfit@left0
\chardef\marginfit@right1
\newcount\c@marginfit@w
\newcount\c@marginfit@r
\newcount\c@marginfit@t
\newdimen\marginfit@top
\newdimen\marginfit@min
\newdimen\marginfit@pos
\def\marginfit@writepos#1{%
\pdfsavepos%
\write\@auxout{\string\@newl@bel{label@marginfit}{#1}{\the\pdflastypos}}%
}
\def\marginfit@boxforeach#1#2{%
\setbox#1\vbox{\unvbox#1 \global\setbox\marginfit@box\lastbox}%
\ifvoid\marginfit@box\else%
#2%
\marginfit@boxforeach#1{#2}%
\fi%
}
\def\marginfit@pass@i{%
\setbox\marginfit@left\hbox{\unhbox\marginfit@box%
\global\setbox\marginfit@right\lastbox}%
\setbox\marginfit@right\hbox{\box\marginfit@right}%
\advance\marginfit@min\ht\marginfit@side%
\advance\marginfit@min\dp\marginfit@side%
\advance\marginfit@min\marginparpush%
\setbox\marginfit@reverse\vbox{\unvbox\marginfit@reverse%
\box\marginfit@side}%
}
\def\marginfit@pass@ii{%
\global\advance\c@marginfit@r\@ne%
\ifcsname label@marginfit@\the\c@marginfit@r @m\endcsname%
\marginfit@pos\csname label@marginfit@\the\c@marginfit@r @m\endcsname sp%
\fi%
\advance\marginfit@pos\ht\marginfit@box%
\ifdim\marginfit@pos<\marginfit@min%
\marginfit@pos\marginfit@min%
\fi%
\advance\marginfit@top-\marginfit@pos%
\ifdim\marginfit@top<\marginparpush%
\advance\marginfit@pos\marginfit@top%
\advance\marginfit@pos-\marginparpush%
\marginfit@top\marginparpush%
\fi%
\vskip\marginfit@top%
\marginfit@top\marginfit@pos%
\advance\marginfit@top-\ht\marginfit@box%
\advance\marginfit@top-\dp\marginfit@box%
\advance\marginfit@min-\ht\marginfit@box%
\advance\marginfit@min-\dp\marginfit@box%
\advance\marginfit@min-\marginparpush%
\hrule height\z@%
\box\marginfit@box%
\hrule height\z@%
}%
\def\marginfit@marginbox{%
\vbox to\@colht {%
\global\advance\c@marginfit@t\@ne%
\expandafter\marginfit@writepos\expandafter{\the\c@marginfit@t @t}%
\ifcsname label@marginfit@\the\c@marginfit@t @t\endcsname%
\marginfit@top\csname label@marginfit@\the\c@marginfit@t @t\endcsname sp%
\fi%
\marginfit@min\marginfit@top%
\advance\marginfit@min-\@colht%
\advance\marginfit@min-\marginparpush%
\advance\marginfit@top\marginparpush%
\vskip-\marginparpush%
\marginfit@boxforeach\marginfit@insert\marginfit@pass@i%
\marginfit@boxforeach\marginfit@reverse\marginfit@pass@ii%
\vfill%
}%
}%
\def\marginfit@leftmargin{%
\let\marginfit@side\marginfit@left%
\hss%
\marginfit@marginbox%
\hskip\marginparsep%
\box\@outputbox%
}
\def\marginfit@rightmargin{%
\let\marginfit@side\marginfit@right%
\box\@outputbox%
\hskip\marginparsep%
\marginfit@marginbox%
\hss%
}
\let\marginfit@makecol\@makecol
\def\@makecol{%
\marginfit@makecol%
\wd\@outputbox\columnwidth%
\ifvoid\marginfit@insert\else%
\setbox\@outputbox\vbox to\@colht {%
\hbox to\columnwidth {%
\if@twocolumn%
\if@firstcolumn%
\marginfit@leftmargin%
\else%
\marginfit@rightmargin%
\fi%
\else%
\if@twoside%
\ifodd\c@page%
\marginfit@rightmargin%
\else%
\marginfit@leftmargin%
\fi%
\else%
\marginfit@rightmargin%
\fi%
\fi%
}%
}%
\fi%
}
\def\marginpar{%
\global\advance\c@marginfit@w\@ne%
\expandafter\marginfit@writepos\expandafter{\the\c@marginfit@w @m}%
\@ifnextchar[\marginfit@mpar@ii\marginfit@mpar@i%
}
\long\def\marginfit@mpar@i#1{%
\@savemarbox\marginfit@box{#1}%
\setbox\marginfit@box\hbox{\copy\marginfit@box\box\marginfit@box}%
\marginfit@mpar@iii%
}
\long\def\marginfit@mpar@ii[#1]#2{%
\@savemarbox\marginfit@left{#1}%
\@savemarbox\marginfit@right{#2}%
\setbox\marginfit@box\hbox{\box\marginfit@left\box\marginfit@right}%
\marginfit@mpar@iii%
}
\def\marginfit@mpar@iii{%
\insert\marginfit@insert{\box\marginfit@box}%
}
\endinput
%%
%% End of file `marginfit.sty'.
|