summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/continue/continue.sty
blob: 859de04ba0afd4e6c122bbf88106b15d533c2f47 (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
%%
%% This is file `continue.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% continue.dtx  (with options: `usc')
%% ------------------------------------------------------------------
%%   Author: Peter Wilson (Herries Press) herries dot press at earthlink dot net
%%   Copyright 2015, 2018 Peter R. Wilson, Donald Arseneau, Luca Merciadri
%% 
%%   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 "unmaintained".
%% 
%%   This work consists of the files listed in the README file.
%% ------------------------------------------------------------------

 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{continue}[2018/12/09 v0.2 Continues on the following page]
 \PackageInfo{continue}{This is continue using e-TeX.}

 \newif{\ifcontmargin} \contmarginfalse
 \newif{\ifcontword}   \contwordfalse
 \newif{\ifcontallpages} \contallpagesfalse
 \DeclareOption{margin}{\contmargintrue}
 \DeclareOption{word}{\contwordtrue}
 \DeclareOption{allpages}{\contallpagestrue}
 \ProcessOptions

\newif{\ifc@go} \c@gotrue
\newcommand{\contgo}{\c@gotrue}
\newcommand{\contstop}{\c@gofalse}

 \RequirePackage{atbegshi}
 \RequirePackage{picture}
 \RequirePackage{zref-abspage}
 \RequirePackage{zref-lastpage}

 \mathchardef\LWC@pen 13452
 \newbox\FirstWordBox     \global\setbox\FirstWordBox\hbox{}
 \newbox\NextWordBox      \global\setbox\NextWordBox\hbox{}
 \newbox\LastWordBox      \global\setbox\LastWordBox\hbox{}
 \newbox\LWC@box           \global\setbox\LWC@box\hbox{}
 \newbox\LWC@saved
 \edef\FWLWCnorm@L@output{\the\output}

 \output{\@tempswafalse
 \ifnum \outputpenalty>-\@MM \ifnum\outputpenalty<-\@M \@tempswatrue\fi\fi
 \if@tempswa % special (float) output
    \FWLWCnorm@L@output
 \else
   \ifvoid\LWC@saved % end of real page
      \global\setbox\LWC@saved\copy\@cclv % save page
      \setbox\@tempboxa\vbox{\unvbox\@cclv \unskip\unkern\unpenalty%
       \unskip\unkern\unpenalty \unskip\unkern\unpenalty
        \setbox\@tempboxa\lastbox
        \LWC@getlast@word\@tempboxa\LastWordBox
      }
      \ifnum\outputpenalty>-\@MM % not \supereject
        \xdef\LWC@vsize{\global\vsize\the\vsize
           \global\holdinginserts\the\holdinginserts}%
        \global\vsize\z@ \global\holdinginserts\@ne
      \else % \supereject, just output, don't look for word on next page
        \global\setbox\@cclv\box\LWC@saved
        \global\setbox\NextWordBox\hbox{}%
        \FWLWCnorm@L@output
        \global\setbox\FirstWordBox\box\NextWordBox
      \fi
   \else % saved page => just did tiny page to get next word
      \setbox\@tempboxa\vbox{\penalty\LWC@pen\unvcopy\@cclv \LWC@getall@boxes
        \ifvbox\LWC@box \penalty\LWC@pen\unvbox\LWC@box \LWC@getall@boxes\fi
        \ifvbox\LWC@box \global\setbox\NextWordBox\hbox{}\else
          \LWC@getfirst@word\LWC@box\NextWordBox
        \fi}%  Return tiny page to page list:
      \unvbox\@cclv \ifnum\outputpenalty<\@M \penalty\outputpenalty\fi
      \LWC@vsize\relax
      \global\setbox\@cclv\box\LWC@saved
      \FWLWCnorm@L@output
      \global\setbox\FirstWordBox\box\NextWordBox
 \fi\fi}

 \def\LWC@getlast@word#1#2{\setbox\@tempboxa\vbox{\hsize\maxdimen \@parboxrestore
   \hyphenpenalty\@M \exhyphenpenalty\@M
   \rightskip\fill \looseness\@M \linepenalty\z@
   \noindent\unhbox#1\endgraf
   \unskip\unkern\unpenalty \global\setbox\LWC@box\lastbox
   }\LWC@repack{#2}}

 \def\LWC@getfirst@word#1#2{\setbox\@tempboxa\vbox{\@parboxrestore
   \parshape\thr@@ \z@\z@ \z@\z@ \z@\maxdimen \parfillskip\fill
   \hyphenpenalty\@M \exhyphenpenalty\@M
   \hbadness\@MM \overfullrule\z@ \hfuzz\maxdimen
   \ifhbox#1\noindent
    \vadjust{\penalty\LWC@pen}\penalty-\@M\unhbox#1% eliminate previous \leftskip
   \else\ifvbox#1\penalty\LWC@pen\unvbox#1\fi\fi
   \endgraf
   \@tempcnta\z@  \LWC@getall@boxes}\LWC@repack{#2}}

 \def\LWC@getall@boxes{\global\setbox\LWC@box\lastbox \unskip\unkern \unskip\unkern
   \let\@tempa\relax
   \ifvoid \LWC@box \advance\@tempcnta\@ne \else \@tempcnta\z@ \fi
   \ifnum\lastpenalty=\LWC@pen \else \unpenalty\fi
   \ifnum\lastpenalty=\LWC@pen \else \unpenalty\fi
   \ifnum\lastpenalty=\LWC@pen \else \ifnum\@tempcnta<5
     \let\@tempa\LWC@getall@boxes \fi \fi \unpenalty \@tempa}

 \def\LWC@repack#1{\global\setbox#1\hbox{\ifhbox\LWC@box
    \unhbox\LWC@box\unskip\unskip\unpenalty\unskip
   \else\ifvbox\LWC@box\box\LWC@box\fi\fi}}

 \newcommand*{\preflagword}{}
 \newcommand*{\postflagword}{}
 \newcommand*{\flagcont}{Continued}
 \newcommand*{\flagend}{End}
 \newcommand*{\flagword}{\preflagword\usebox\NextWordBox\postflagword}
 \newlength{\contsep}\setlength{\contsep}{\marginparsep}
 \newlength{\contdrop}\setlength{\contdrop}{0.5\footskip}
 \ifcontword
  \let\flagcont\flagword
 \fi
 \newcommand{\c@ntoddpagepos}{%
     \dimen1=1in
     \advance\dimen1 by \textwidth
     \advance\dimen1 by \oddsidemargin
     \dimen3=1in
     \advance\dimen3 by \topmargin
     \advance\dimen3 by \headheight
     \advance\dimen3 by \headsep
     \advance\dimen3 by \textheight
     \ifcontmargin
       \advance\dimen1 by \contsep
     \else
       \advance\dimen3 by \contdrop
     \fi
 }
 \newcommand{\c@ntevenpagepos}{%
     \dimen1=1in
     \advance\dimen1 by \textwidth
     \advance\dimen1 by \evensidemargin
     \dimen3=1in
     \advance\dimen3 by \topmargin
     \advance\dimen3 by \headheight
     \advance\dimen3 by \headsep
     \advance\dimen3 by \textheight
     \ifcontmargin
       \advance\dimen1 by \contsep
     \else
       \advance\dimen3 by \contdrop
     \fi
 }
\newcommand{\c@outcontpage}{%
  \ifnum\zref@extract{LastPage}{abspage}>\c@abspage
    \ifcontmargin
      \put(\dimen1,-\dimen3){{\flagcont}}%
    \else
      \put(\dimen1,-\dimen3){\llap{\flagcont}}%
    \fi
  \else
    \ifcontmargin
      \put(\dimen1,-\dimen3){{\flagend}}%
    \else
      \put(\dimen1,-\dimen3){\llap{\flagend}}%
    \fi
  \fi
}% end of \c@outcontpage
\AtBeginShipout{%
\AtBeginShipoutUpperLeft{%
 \ifc@go
  \ifodd\c@page
    \c@ntoddpagepos
    \c@outcontpage
  \else
    \ifcontallpages
      \c@ntevenpagepos
      \c@outcontpage
    \fi
  \fi
 \fi
} % end AtBeginShipoutUpperLeft
} % end AtBeginShipout

%% \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         \~}
\endinput
%%
%% End of file `continue.sty'.