| 1 |
% S H A P E P A R . S T Y |
| 2 |
% |
| 3 |
% Typeset paragraphs in various shapes. |
| 4 |
% |
| 5 |
% Version 2.2 (Mar 2013) |
| 6 |
% |
| 7 |
% Copyright (c) 1993,2002,2006,2013 Donald Arseneau |
| 8 |
% This software may be freely used, transmitted, shared, copied, sold, |
| 9 |
% or modified, provided that any modifications are clearly identified |
| 10 |
% and this notice is left intact. |
| 11 |
% |
| 12 |
% \shapepar: a macro to typeset paragraphs in a specific shape. The |
| 13 |
% size is adjusted automatically so that the entire shape is filled |
| 14 |
% with text. There can be no displayed math, and no "\vadjust" |
| 15 |
% material (no "\vspace"). These macros work for both LaTeX and plain |
| 16 |
% TeX. For LaTeX, specify \usepackage{shapepar}, or for either, |
| 17 |
% \input shapepar.sty . Configuration parameters are set just |
| 18 |
% below here. Instructions for use are given in the LaTeX document |
| 19 |
% shapepar.ltx; a short summary is given after \endinput below. |
| 20 |
% |
| 21 |
% ToDo: |
| 22 |
% Vertical correction for character height applied to shape. |
| 23 |
% Shape-based bounding box and reference point for exact placement |
| 24 |
% Allow multiple paragraphs and displayed math in shape |
| 25 |
% Typeset shape text directly when fixed scale (or even always) (register conflicts) |
| 26 |
% Allow text overflow from fixed scale shapes (for magazine style) |
| 27 |
% More assertive \cutout processing |
| 28 |
% |
| 29 |
%--------------------- |
| 30 |
% make file load whatever status of @ (hold codes in \squarepar temporarily) |
| 31 |
\edef\squarepar |
| 32 |
{\catcode\string `\string @ \the\catcode `\@ |
| 33 |
\catcode\string `\string $ \the\catcode `$ |
| 34 |
\catcode\string `\string ! \the\catcode `\! |
| 35 |
\catcode\string `\string ^ \the\catcode `\^} |
| 36 |
\catcode\string`\@=11 \catcode\string`\$=11 |
| 37 |
\catcode\string`\^=14 \catcode\string`\!=10 |
| 38 |
|
| 39 |
% ------ Configuration parameters ------ |
| 40 |
|
| 41 |
% horizontal separation between shaped par and cut-out text |
| 42 |
\newskip\cutoutsep |
| 43 |
\cutoutsep=12pt |
| 44 |
|
| 45 |
% smallest gap allowed; smaller will be eliminated |
| 46 |
\def\SmallestGap{.4em} |
| 47 |
|
| 48 |
% small gap; smaller will be enlarged |
| 49 |
\def\SmallGap{1em} |
| 50 |
|
| 51 |
% smallest segment allowed; smaller will be omitted |
| 52 |
\def\SmallestSegment{.2em} |
| 53 |
|
| 54 |
% How many times will \shapepar try to get the size of the paragraph? |
| 55 |
\chardef\ScaleMaxTries=9 |
| 56 |
|
| 57 |
% fineness of cutout matching to lines (number of reference points |
| 58 |
% per line of text) |
| 59 |
\chardef\RefineBaselines=3 |
| 60 |
|
| 61 |
% Vertical extension of cutout gap (fraction of \baselineskip) |
| 62 |
\def\cutoutsepstretch{.5} |
| 63 |
|
| 64 |
% -------------------------------------- |
| 65 |
\ifx\DeclareOption\undefined\else |
| 66 |
|
| 67 |
\ProvidesPackage{shapepar}[2013/03/26 v 2.2x, Shaped paragraphs] |
| 68 |
\DeclareOption{quiet}{\catcode`\!=14} |
| 69 |
\DeclareOption{noisy}{\catcode`\^=10} |
| 70 |
\ProcessOptions |
| 71 |
|
| 72 |
\fi |
| 73 |
% -------------------------------------- |
| 74 |
|
| 75 |
% Define variables. Use LaTeX names for some, and use aliases to |
| 76 |
% LaTeX allocations and TeX parameters for many others. |
| 77 |
% In the future, the descriptive names may disappear altogether. |
| 78 |
|
| 79 |
\newdimen\SH@scale |
| 80 |
\mathchardef\@dxii=512 |
| 81 |
|
| 82 |
\def\@empty{} |
| 83 |
\long\def\@gobble#1{} |
| 84 |
\ifx\@tempdima\undefined \csname newdimen\endcsname \@tempdima \fi |
| 85 |
\ifx\@tempdimb\undefined \csname newdimen\endcsname \@tempdimb \fi |
| 86 |
\ifx\@tempcnta\undefined \csname newcount\endcsname \@tempcnta \fi |
| 87 |
\ifx\@tempcntb\undefined \csname newcount\endcsname \@tempcntb \fi |
| 88 |
\ifx\@tempboxa\undefined \csname newbox\endcsname \@tempboxa \fi |
| 89 |
|
| 90 |
\def\@tempa#1#2#3{% {"count"|"dimen"|"box"|"skip"}{\myname}{\realname} |
| 91 |
\ifx\undefined#3\csname new#1\endcsname#2% allocate new one |
| 92 |
\else\let#2#3\fi % alias is defined, so use it |
| 93 |
} |
| 94 |
|
| 95 |
\@tempa{box}\SH@boxa\rootbox |
| 96 |
\newbox\SH@boxb % global |
| 97 |
\@tempa{count}\SH@ntries\@cla % global |
| 98 |
\@tempa{dimen}\spec@bot\p@renwd |
| 99 |
\@tempa{dimen}\spec@top\jot |
| 100 |
\@tempa{dimen}\spec@height\@wholewidth |
| 101 |
\@tempa{dimen}\spec@incr\@halfwidth |
| 102 |
\@tempa{dimen}\spec@position\@picht |
| 103 |
\@tempa{dimen}\spec@nextpos\@ovxx |
| 104 |
\@tempa{dimen}\spec@prevpos\@ovyy |
| 105 |
\@tempa{dimen}\spec@hcenter\@xdim |
| 106 |
\@tempa{dimen}\SH@refbase\@ydim |
| 107 |
\@tempa{dimen}\SH@dscale\dimen@i % global |
| 108 |
\@tempa{dimen}\SH@tottext\@toproom % global |
| 109 |
\@tempa{dimen}\SH@posseg\@ovro |
| 110 |
\@tempa{dimen}\SH@widseg\@ovri |
| 111 |
\@tempa{dimen}\SH@posold\@ovdx |
| 112 |
\@tempa{dimen}\SH@widold\@ovdy |
| 113 |
\@tempa{dimen}\SH@weight\@dashdim |
| 114 |
\@tempa{count}\SH@npslines\interdisplaylinepenalty |
| 115 |
\@tempa{count}\SH@nline\@savsf |
| 116 |
\@tempa{count}\SH@lowline\delimiterfactor |
| 117 |
\@tempa{count}\SH@highline\doublehyphendemerits |
| 118 |
|
| 119 |
\let\SH@margin\@empty |
| 120 |
\let\SH@xoff\z@ |
| 121 |
\let\SH@yoff\z@ |
| 122 |
|
| 123 |
% ------- Begin main definitions ------- |
| 124 |
|
| 125 |
\def\cutout#1#2{% #1 = r|l #2 = ( or something else |
| 126 |
\par \endgraf |
| 127 |
\lowercase{\def\SH@margin{#1}}% |
| 128 |
\def\@tempa{#2}\def\@tempb{(}% |
| 129 |
\ifx\@tempa\@tempb \let\@tempb\SH@cutopt |
| 130 |
\else \def\@tempb{\SH@cutopt \z@,\z@)#2}% |
| 131 |
\fi \@tempb |
| 132 |
} |
| 133 |
|
| 134 |
\def\SH@cutopt #1,#2){% #1 = x-offset, #2 = y-offset |
| 135 |
\def\SH@xoff{#1}\def\SH@yoff{#2}% |
| 136 |
\edef\SH@cutoutbase{\the\baselineskip}% |
| 137 |
\ifx\SH@margin\@empty\else |
| 138 |
\def\@tempa{l}\ifx\SH@margin\@tempa\else \def\@tempa{r}\fi |
| 139 |
\ifx\SH@margin\@tempa\else |
| 140 |
\errhelp{The \string\cutout\space is ignored; the \string\shapepar\space |
| 141 |
will continue. }\errmessage{Shaped Paragraph Error: |
| 142 |
Cutout side \string"\SH@margin\string" not valid; should be l or r.}% |
| 143 |
\let\SH@margin\@empty |
| 144 |
\fi\fi |
| 145 |
\ifx\SH@margin\@empty\else \begingroup \fi |
| 146 |
} |
| 147 |
|
| 148 |
\def\Shapepar{\ifx\SH@margin\@empty \let\SH@usebox\box \fi \shapepar} |
| 149 |
\let\SH@usebox\unvbox |
| 150 |
|
| 151 |
\def\shapepar#1{\relax % #1 = shape specification or "[" |
| 152 |
\begingroup |
| 153 |
\ifx\SH@margin\@empty \let\SH@xoff\z@ \let\SH@yoff\z@ \fi |
| 154 |
\if [\noexpand#1\relax \expandafter\SH@scaledshape |
| 155 |
\else \SH@scale\z@ \SH@start{#1}\fi |
| 156 |
} |
| 157 |
|
| 158 |
\def\SH@scaledshape #1]{\SH@scale #1\relax \SH@start} |
| 159 |
|
| 160 |
\def\SH@start#1{% #1 = shape specification. May be a macro. |
| 161 |
\edef\SH@restog{\global\SH@ntries\the\SH@ntries |
| 162 |
\global\SH@dscale\the\SH@dscale \global\SH@tottext\the\SH@tottext}% |
| 163 |
\ifx\SH@usebox\box\else \par \endgraf \fi |
| 164 |
\xdef\SH@pd{\ifvmode \the\prevdepth \else \z@ \fi}% |
| 165 |
\let\\\relax \xdef\SH@spec{#1}% |
| 166 |
\expandafter\SH@checkspec\SH@spec $% check spec. $ |
| 167 |
\hyphenpenalty10 \exhyphenpenalty10 % optimise |
| 168 |
\doublehyphendemerits10 \adjdemerits10 |
| 169 |
\hfuzz\maxdimen |
| 170 |
\setbox\SH@boxa\vbox\bgroup % set whole text on one line |
| 171 |
\parindent\z@ \leftskip\z@skip % \rightskip set below |
| 172 |
% \spaceskip .333333emplus.8emminus.15em % optimise stretch |
| 173 |
\parfillskip\z@ plus\@ne fil |
| 174 |
\begingroup |
| 175 |
\linepenalty\@m \let\\\SH@newline |
| 176 |
\let\par\SH@endpar \hsize\maxdimen \rightskip\spaceskip |
| 177 |
\pretolerance\m@ne \hyphenpenalty 9000 % make discretionaries |
| 178 |
\ifx\textwidth\undefined\else \textwidth\hsize |
| 179 |
\linewidth\hsize \columnwidth\hsize \fi |
| 180 |
\def\vadjust{{\def\SH@dm{special vertical material}\the\everydisplay}}% |
| 181 |
\everydisplay{\errhelp{Press RETURN, and hope.}\errmessage |
| 182 |
{Shaped Paragraph Error: \SH@dm\space is illegal in a shaped paragraph}}% |
| 183 |
\noindent \penalty\@M \hskip\z@skip % allow hyphenation of first word |
| 184 |
\ignorespaces} |
| 185 |
|
| 186 |
\def\SH@dm{display-math} |
| 187 |
|
| 188 |
% Explicit \\ commands insert a marker (kern) that will later preserve a line-break |
| 189 |
\def\SH@newline{\unskip\hfill\kern9sp\break\ignorespaces} |
| 190 |
|
| 191 |
\def\SH@endpar{% Insert filler for fixed-scale paragraphs |
| 192 |
\ifdim\SH@scale>\z@ \def~{\hfil\null\hfil\null\hfil\null\hfil\null}% |
| 193 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\fi |
| 194 |
\xdef\SH@baseset{\noexpand\baselineskip\the\baselineskip \relax}% |
| 195 |
\endgraf \endgroup % still inside \vbox and \begingroup |
| 196 |
\SH@baseset |
| 197 |
% get tottext = total length / 256 because total length may be > \maxdimen |
| 198 |
\setbox\@tempboxa\box\voidb@x \global\SH@tottext\z@ |
| 199 |
\SH@sumlines % combine multiple lines -> \@tempboxa; width/256 ->\SH@tottext |
| 200 |
^ \message{total text length = \the\wd\@tempboxa, or 256 x \the\SH@tottext; |
| 201 |
^ \string\baselineskip=\the\baselineskip;}% |
| 202 |
^ {\let\\\relax\message{Spec is: \SH@spec}}% |
| 203 |
^ \message{spec height = \Pointless\spec@height. }% |
| 204 |
\unskip\unkern\unpenalty\unskip\unkern\unpenalty |
| 205 |
\setbox\SH@boxa\box\@tempboxa % all the text |
| 206 |
\ifdim\SH@scale>\z@ % for specified fixed scale: only format once |
| 207 |
\global\SH@ntries\ScaleMaxTries |
| 208 |
\else % Automatic scaling. Get a first-guess scale |
| 209 |
% Get 1/256 of total segment length into \@tempdima |
| 210 |
\@tempdima\z@ \spec@prevpos\z@ |
| 211 |
\expandafter\SH@measline\SH@spec \\\delimiter |
| 212 |
^ \message{Spec area/256 = \Pointless\@tempdima}% |
| 213 |
% scale = 1.01 * sqrt( [text_length/256]*\baselineskip / [spec_area/256] ) |
| 214 |
% Pull out some large factors from square-root to extend numeric range |
| 215 |
% available for division. |
| 216 |
\SH@dscale=1.01\p@ % optimize |
| 217 |
\loop \if\AbsVal\@tempdima<\p@ |
| 218 |
\multiply\@tempdima\@cclvi \multiply\SH@dscale\sixt@@n |
| 219 |
\repeat |
| 220 |
\SH@scale=\Pointless\SH@tottext\baselineskip |
| 221 |
\fpdivide\SH@scale\@tempdima |
| 222 |
\sqrtofdim\SH@scale |
| 223 |
\SH@scale=\Pointless\SH@dscale\SH@scale |
| 224 |
^ \message{Initial scale = \the\SH@scale}% |
| 225 |
\global\SH@ntries\z@ % will count maximum \ScaleMaxTries trial scales |
| 226 |
\fi |
| 227 |
\global\SH@dscale\z@ |
| 228 |
\SH@parpars \SH@tryparshape} |
| 229 |
|
| 230 |
% Measure the area covered by segments in the shape spec. Accumulate |
| 231 |
% as length \@tempdima |
| 232 |
|
| 233 |
\def\SH@measline#1#2\\#3{% #1 = this pos, #2 = segments, #3 = next pos |
| 234 |
\ifx\delimiter#3\expandafter\@gobble\else |
| 235 |
% Vertical space multiplier -> tempdimb -> \@tempa (temporarily) |
| 236 |
\@tempdimb #3\p@ \advance\@tempdimb-\spec@prevpos \divide\@tempdimb\@dxii |
| 237 |
\edef\@tempa{\Pointless\@tempdimb}% |
| 238 |
\SH@measseg #2t\fam\fam |
| 239 |
\spec@prevpos#1\p@ |
| 240 |
\expandafter\SH@measline |
| 241 |
\fi {#3}} |
| 242 |
|
| 243 |
% Recursively measure and accumulate widths of text segments on a line. |
| 244 |
% Invoke as \SH@measseg <segments>t\fam\fam, as the "t\fam\fam" serves |
| 245 |
% as an end-marker. All the widths are scaled by a factor \@tempa and |
| 246 |
% added to \@tempdima. (Overwrites \@tempdimb.) |
| 247 |
|
| 248 |
\def\SH@measseg#1t#2#3{% #1 = stuff before "t", #2,#3 = posn,wid |
| 249 |
\ifx \fam #3\else |
| 250 |
\@tempdimb #3\p@ |
| 251 |
\advance\@tempdima\@tempa\@tempdimb |
| 252 |
\expandafter\SH@measseg |
| 253 |
\fi} |
| 254 |
|
| 255 |
% \SH@tryparshape: try a parshape with scale factor \SH@scale for \SH@spec |
| 256 |
% For a given scale, it would take x lines of text to cover the shape, |
| 257 |
% but only an integer number of lines (counted by \SH@nline) will be |
| 258 |
% used. The excess is evenly distributed at the top and bottom to preserve |
| 259 |
% the symmetry of shapes. The starting point is thus: |
| 260 |
% |
| 261 |
% spec_top + 1/2 * { spec_height - floor[ (spec_height-delta)/incr ]*incr } |
| 262 |
% |
| 263 |
|
| 264 |
\def\SH@tryparshape{% |
| 265 |
\advance\SH@scale\SH@dscale % shift scale factor by delta |
| 266 |
^ \message{------------------------------------------------------------------------}% |
| 267 |
! \message{(\the\SH@ntries) Try shape with scale \the\SH@scale. \space |
| 268 |
! (Delta = \Pointless\SH@dscale). \space }% |
| 269 |
\spec@incr\baselineskip \fpdivide\spec@incr\SH@scale |
| 270 |
\spec@position\spec@height \advance\[email protected]\spec@incr % height-delta |
| 271 |
\SH@nline\spec@position \divide\SH@nline\spec@incr % number of lines |
| 272 |
\spec@position-\SH@nline\spec@incr % - height of n lines |
| 273 |
\advance\spec@position\spec@height % difference from desired height |
| 274 |
\divide\spec@position\tw@ % half the excess |
| 275 |
\advance\spec@position\spec@top % starting position |
| 276 |
\xdef\spec@firstposition{\the\spec@position}% |
| 277 |
\SH@widold-\maxdimen |
| 278 |
\SH@makeparshape} |
| 279 |
|
| 280 |
\def\SH@makeparshape{% |
| 281 |
\advance\spec@position-\spec@incr % pre-decrement |
| 282 |
\SH@nline\z@ % initialize counter for lines |
| 283 |
\spec@prevpos \spec@top % -\maxdimen% \spec@position |
| 284 |
\let\SH@Prevspec\@empty |
| 285 |
\let\@elt\relax % simply accumulate lines (reverse order) |
| 286 |
\gdef\SH@parshape{}\gdef\SH@lines{}\SH@npslines\z@ |
| 287 |
% \message{Parsing spec, starting at \Pointless\spec@position. }% |
| 288 |
\expandafter \SH@doaline \SH@spec \\\delimiter $\\$} |
| 289 |
% this macro ends instead of continuing with \SH@done so TeX will use |
| 290 |
% tail-recursion as \SH@tryparshape is iterated. |
| 291 |
|
| 292 |
\def\SH@doaline{\SH@updps \SH@widold-\maxdimen |
| 293 |
\advance\SH@nline\@ne \advance\spec@position\spec@incr |
| 294 |
\let\\\SH@findpos \\} |
| 295 |
|
| 296 |
% Get spec lines appropriate for given position (\spec@position): |
| 297 |
% \SH@prevspec,\spec@prevpos for spec line above |
| 298 |
% \SH@nextspec,\spec@nextpos for spec line below |
| 299 |
% (lines may contain several segments) |
| 300 |
% |
| 301 |
\def\SH@findpos#1#2\\{% #1 = spec line vert position, #2 = segments |
| 302 |
\ifx\delimiter#1\let\\\SH@dopara |
| 303 |
\else |
| 304 |
\ifdim#1\p@<\spec@prevpos \SH@backup{#1}\fi % handle backspace |
| 305 |
\ifdim#1\p@>\spec@position |
| 306 |
\def\SH@nextspec{#2{}}\spec@nextpos#1\p@ \def\\{\SH@found{#1}#2\\}% |
| 307 |
\expandafter\def\expandafter\SH@prevspec\expandafter{\SH@Prevspec}% |
| 308 |
\else |
| 309 |
\def\SH@Prevspec{#2{}}\spec@prevpos#1\p@ |
| 310 |
\fi\fi \\} |
| 311 |
|
| 312 |
\def\SH@found{% calculate weights to interpolate |
| 313 |
% \message{ -- \number\SH@nline\space-- SH@found \the\spec@position\space |
| 314 |
% between \the\spec@prevpos\space and \the\spec@nextpos. }% |
| 315 |
\ifdim\spec@position<\spec@prevpos |
| 316 |
\let\SH@next\SH@doaline |
| 317 |
\else |
| 318 |
\SH@weight\spec@position \advance\SH@weight-\spec@prevpos |
| 319 |
\@tempdimb\spec@nextpos \advance\@tempdimb-\spec@prevpos |
| 320 |
\fpdivide\SH@weight\@tempdimb % weight = interpolation factor |
| 321 |
\let\SH@next\SH@dosegment |
| 322 |
\fi |
| 323 |
\SH@next} |
| 324 |
|
| 325 |
\def\SH@backup#1{%\tracingall |
| 326 |
% \message{Backup for #1 after \Pointless\spec@prevpos, seeking \Pointless\spec@position. }% |
| 327 |
\ifdim#1\p@<\spec@position |
| 328 |
\advance\SH@nline\m@ne |
| 329 |
\advance\spec@position-\spec@incr |
| 330 |
\advance\spec@prevpos-\spec@incr |
| 331 |
\SH@backup{#1}% |
| 332 |
\fi} |
| 333 |
|
| 334 |
% Get the position and width of a segment of text by taking the weighted |
| 335 |
% average of the specifications from above and below (weighted by nearness). |
| 336 |
% We iterate \SH@dosegment while it handles the segments |
| 337 |
% Most of the confusing bits here are hueristics to deal with narrow gaps. |
| 338 |
% If a gap between two texts is less than a space, the texts are joined |
| 339 |
% over the gap. If the gap is less than 1em, the gap is increased to the |
| 340 |
% average of 1em and the given gap. |
| 341 |
|
| 342 |
\def\SH@dosegment{% do a segment of text on this line |
| 343 |
\SH@posseg\z@ \SH@widseg\z@ |
| 344 |
\advance\SH@weight-\p@ \SH@weight-\SH@weight % w1 = 1 - w2 |
| 345 |
\SH@getseg A\SH@prevspec % Above |
| 346 |
\advance\SH@weight-\p@ \SH@weight-\SH@weight % w2 = 1 - w1 |
| 347 |
\SH@getseg B\SH@nextspec % Below |
| 348 |
\ifdim\SH@widseg>10sp |
| 349 |
\SH@widseg\Pointless\SH@scale\SH@widseg |
| 350 |
\advance\SH@posseg-\spec@hcenter |
| 351 |
\SH@posseg\Pointless\SH@scale\SH@posseg |
| 352 |
\advance\[email protected]\hsize |
| 353 |
% Here are the small-gap heuristics. \@tempdima is the gap and the shift |
| 354 |
\ifdim\SH@widold>10sp |
| 355 |
\@tempdima\SH@posseg |
| 356 |
\advance\@tempdima-\SH@posold \advance\@tempdima-\SH@widold %gap |
| 357 |
\ifdim\@tempdima<\SmallestGap % gap too small; eliminate |
| 358 |
^ \message{Gap is \the\@tempdima--eliminate. }% |
| 359 |
\advance\SH@widold\@tempdimb \advance\SH@widold\SH@widseg % no update |
| 360 |
\else |
| 361 |
\ifdim\@tempdima<\SmallGap % gap small; enlarge it if text not too small |
| 362 |
\ifdim\SH@widold>\SmallGap \ifdim\SH@widseg>\SmallGap |
| 363 |
^ \message{Gap is \the\@tempdima--enlarge}% |
| 364 |
\@tempdima-.25\@tempdima \advance\@tempdima.25em |
| 365 |
^ \message{by 2 x \the\@tempdima. }% |
| 366 |
\advance\SH@widold-\@tempdima |
| 367 |
\advance\SH@widseg-\@tempdima |
| 368 |
\advance\SH@posseg \@tempdima |
| 369 |
\fi\fi\fi |
| 370 |
\SH@updps |
| 371 |
\fi |
| 372 |
\else % no previous, so no update. Just hold. |
| 373 |
\SH@widold\SH@widseg \SH@posold\SH@posseg |
| 374 |
\fi\fi |
| 375 |
\ifx\SH@prevspec\@empty \let\SH@next\SH@doaline \fi |
| 376 |
\ifx\SH@nextspec\@empty \let\SH@next\SH@doaline \fi |
| 377 |
\SH@next} |
| 378 |
|
| 379 |
\def\SH@updps{% Update parshape with `new' info |
| 380 |
^\message{Segment \Pointless\SH@posold, \Pointless\SH@widold}% |
| 381 |
\ifdim\SH@widold>\SmallestSegment |
| 382 |
! \message{.}% |
| 383 |
\xdef\SH@parshape{\SH@parshape\the\SH@posold\the\SH@widold\space}% |
| 384 |
\xdef\SH@lines{\@elt{\the\SH@nline}{\the\SH@posold}{\the\SH@widold}\SH@lines}% |
| 385 |
\advance\SH@npslines\@ne |
| 386 |
\fi \SH@widold\SH@widseg \SH@posold\SH@posseg} |
| 387 |
|
| 388 |
\def\SH@getseg#1#2{% A/B, spec |
| 389 |
\ifx#2\@empty \SH@sperror \fi |
| 390 |
\expandafter \SH@GetseG #2$#1#2} |
| 391 |
|
| 392 |
\def\SH@GetseG#1#2$#3#4{% command, rest of spec, $, A/B, spec |
| 393 |
\expandafter \ifx\csname spec#3$#1\endcsname \relax |
| 394 |
\SH@sperror |
| 395 |
\else |
| 396 |
\csname spec#3$#1\endcsname #2$#4% |
| 397 |
\fi} |
| 398 |
|
| 399 |
% b{pos} begin text at a point at horizontal position pos. |
| 400 |
% e{pos} end text at a point at horizontal position pos. |
| 401 |
% t{pos}{len} make a block of text at position pos with length len |
| 402 |
% s split text (begin whitespace) |
| 403 |
% j join two text blocks (end a gap) |
| 404 |
|
| 405 |
% Behavior of specs Above: |
| 406 |
\def\specA$b#1{\specA$t{#1}{0}}% b(pos) -> t(pos)(0) |
| 407 |
\def\specA$e#1#2{\csname specA$#2\endcsname}% e(pos) ignore |
| 408 |
\def\specA$s#1{\csname specA$#1\endcsname}% s ignore % should never happen |
| 409 |
\def\specA$t#1{\advance\SH@posseg#1\SH@weight \@spec$t jt{#1}} |
| 410 |
|
| 411 |
% Behavior of specs Below: |
| 412 |
\def\specB$e#1{\specB$t{#1}{0}} |
| 413 |
\def\specB$b#1#2{\csname specB$#2\endcsname} |
| 414 |
\def\specB$j#1{\csname specB$#1\endcsname} |
| 415 |
\def\specB$t#1{\advance\SH@posseg#1\SH@weight \@spec$t st{#1}} |
| 416 |
|
| 417 |
\def\@spec$t#1#2#3#4#5{% j|s t pos wid next |
| 418 |
\if t#2\else \SH@sperror \fi |
| 419 |
\advance\SH@widseg#4\SH@weight |
| 420 |
\if#1#5\relax % next is s (below) or j (above): unite two t |
| 421 |
\let\@tempa\@spec$t \else \let\@tempa\SH@redefine \fi |
| 422 |
\@tempa #5} |
| 423 |
|
| 424 |
\def\SH@redefine#1$#2{\def#2{#1}} |
| 425 |
\let\specA$\SH@redefine % bug fix to allow disjoint pieces |
| 426 |
\let\specB$\SH@redefine |
| 427 |
|
| 428 |
\def\SH@dopara#1${% eat remaining spec and test parshape $ |
| 429 |
\global\setbox\SH@boxb\vbox{% |
| 430 |
\advance\SH@npslines\@ne |
| 431 |
\parshape\the\SH@npslines\space \SH@parshape \z@ \maxdimen |
| 432 |
\advance\SH@npslines\m@ne |
| 433 |
! \message{Formatting. }% |
| 434 |
\noindent \unhcopy\SH@boxa \endgraf |
| 435 |
! \message{Expected \the\SH@npslines\space lines; |
| 436 |
! got \the\prevgraf\space lines}% |
| 437 |
\ifnum\prevgraf=\SH@npslines % maybe right size; check last line |
| 438 |
\ifdim\SH@widseg>\z@ % yes, we can check |
| 439 |
\ifnum\SH@ntries<\ScaleMaxTries % safe to screw around with \SH@npslines |
| 440 |
\SH@grablast \@tempdima\wd\SH@boxa \advance\@tempdima 20\p@ |
| 441 |
\ifdim\@tempdima<.8\SH@widseg % final line underfull % optimise |
| 442 |
! \message{but the last line is too empty. }% |
| 443 |
\advance\SH@npslines\@ne % flag underfullness |
| 444 |
\fi\fi\fi\fi |
| 445 |
\ifnum\prevgraf=\SH@npslines % right size, done |
| 446 |
\aftergroup\SH@done \global\SH@dscale\z@ |
| 447 |
\else % Try a new scale factor |
| 448 |
\ifdim\SH@dscale=\z@ % no previous step. Try to guess a good one |
| 449 |
\ifnum\prevgraf<\SH@npslines % underfull |
| 450 |
^ \message{First underfull. }% |
| 451 |
\@tempdima\prevgraf\p@ |
| 452 |
\divide\@tempdima\SH@npslines |
| 453 |
\else % overfull |
| 454 |
^ \message{First overfull. }% |
| 455 |
\SH@grablast |
| 456 |
\@tempdimb-\wd\SH@boxa \advance\@tempdimb-20\p@ |
| 457 |
\divide\@tempdimb\@cclvi |
| 458 |
\@tempdima\SH@tottext \advance\@tempdimb\@tempdima |
| 459 |
\fpdivide\@tempdima\@tempdimb |
| 460 |
^ \message{overfullness: \the\wd\SH@boxa; ratio: \Pointless\@tempdima}% |
| 461 |
\fi |
| 462 |
\sqrtofdim\@tempdima |
| 463 |
\advance\@tempdima-\p@ |
| 464 |
\divide\@tempdima\tw@ |
| 465 |
\global\SH@dscale\Pointless\@tempdima\SH@scale |
| 466 |
\gdef\SH@fac{1}% % optimise |
| 467 |
\else % Not first step, scale from previous |
| 468 |
\ifnum\prevgraf>\SH@npslines % overflow now |
| 469 |
\ifdim\SH@dscale>\z@ % previous Overflow |
| 470 |
\global\SH@dscale \SH@fac\SH@dscale |
| 471 |
\else % overflow now, but previous underflow |
| 472 |
\gdef\SH@fac{.53}% % optimise |
| 473 |
\global\SH@dscale -\SH@fac\SH@dscale |
| 474 |
\fi |
| 475 |
\else % underflow now |
| 476 |
\ifdim\SH@dscale>\z@ % previous Overflow |
| 477 |
\gdef\SH@fac{.54}% % optimise |
| 478 |
\global\SH@dscale -\SH@fac\SH@dscale |
| 479 |
\else % overflow now, but previous underflow |
| 480 |
\global\SH@dscale \SH@fac\SH@dscale |
| 481 |
\fi |
| 482 |
\fi |
| 483 |
\fi |
| 484 |
\ifdim-\SH@dscale>.6\SH@scale |
| 485 |
\global\SH@dscale -.6\SH@scale % avoid scale --> 0 ! |
| 486 |
\fi |
| 487 |
\global\advance\SH@ntries\@ne |
| 488 |
\ifdim\AbsVal\SH@dscale <.005\p@ \global\SH@ntries\@cclv \fi |
| 489 |
\ifnum \SH@ntries>\ScaleMaxTries \aftergroup\SH@done |
| 490 |
\else \aftergroup\SH@tryparshape |
| 491 |
\fi\fi |
| 492 |
}}% end \vbox, end macro. Must not insert anything between braces! |
| 493 |
|
| 494 |
% Get last hbox off list; rebox it into \SH@boxa, omitting final glue |
| 495 |
% |
| 496 |
\def\SH@grablast{\unskip\unkern\unskip\unpenalty |
| 497 |
\setbox\SH@boxa\lastbox |
| 498 |
\ifhbox\SH@boxa |
| 499 |
\setbox\SH@boxa\hbox{\unhbox\SH@boxa\unskip\unskip\unpenalty}% |
| 500 |
\fi} |
| 501 |
|
| 502 |
\def\SH@parpars{% |
| 503 |
\lineskiplimit-0\p@ \linepenalty\thr@@ |
| 504 |
\tolerance9999 |
| 505 |
\ifx\emergencystretch\undefined % TeX2 |
| 506 |
\rightskip\z@ plus.5emminus.2em % optimise |
| 507 |
\else \rightskip\z@skip \emergencystretch 2em % TeX 3 |
| 508 |
\fi \pretolerance\m@ne |
| 509 |
\hbadness\@MM \hfuzz\maxdimen % avoid formatting warning messages |
| 510 |
\SH@baseset |
| 511 |
} |
| 512 |
|
| 513 |
\def\SH@done{\SH@parpars |
| 514 |
\skip@ 1spplus2\p@ minus\p@ |
| 515 |
\parfillskip.5\maxdimen % this will drag text to the bottom point. |
| 516 |
\advance\SH@npslines\@ne |
| 517 |
\SH@reform % reformat paragraph with new parfillskip |
| 518 |
\ifx\SH@usebox\box % boxed \Shapepar: find min pos |
| 519 |
\let\@elt\SH@measureh \SH@posold\maxdimen \SH@lines |
| 520 |
\else |
| 521 |
\SH@posold\z@ |
| 522 |
\fi |
| 523 |
% {\let\@elt\relax \message{SH@lines: \SH@lines. }}% |
| 524 |
\SH@nline\m@ne \SH@highline-\@m \SH@lowline\m@ne \let\@elt\SH@restack |
| 525 |
^ \message{Restacking.}% |
| 526 |
% re-stack segments and re-justify lines; put in \vtop or \vbox appropriately |
| 527 |
\global\setbox\SH@boxb \ifx\SH@margin\@empty \vbox \else \vtop \fi {% |
| 528 |
\setbox\SH@boxa\vbox{}\leftskip=\z@ plus33sp minus66sp % optimise |
| 529 |
\unvbox\SH@boxb |
| 530 |
\SH@lines \unvbox\SH@boxa |
| 531 |
\ifnum\SH@highline<\SH@lowline |
| 532 |
\nobreak |
| 533 |
% \message{After restack, \the\SH@highline<\the\SH@lowline,} |
| 534 |
\advance\SH@lowline-\SH@highline |
| 535 |
% \message{so skip down \the\SH@lowline\space lines. }% |
| 536 |
\vskip\SH@lowline\baselineskip |
| 537 |
\fi |
| 538 |
}% Now we have final \SH@boxb |
| 539 |
\ifx\SH@margin\@empty % stand-alone |
| 540 |
\egroup % end original \setbox\SH@boxa\vbox\bgroup; but \SH@boxa is useless |
| 541 |
\ifx\SH@usebox\unvbox % ordinary \shapepar |
| 542 |
\unvbox\SH@boxb \prevdepth\SH@pd |
| 543 |
\else % boxed \Shapepar |
| 544 |
\vtop{\unvbox\SH@boxb}% |
| 545 |
\ifvmode |
| 546 |
\hrule height-\SH@pd width\z@ |
| 547 |
\hbox{\vrule depth\SH@pd width\z@}% |
| 548 |
\fi |
| 549 |
\fi |
| 550 |
\SH@restog % restore global registers |
| 551 |
\endgroup % forgets many local parameters. \prevdepth is global |
| 552 |
\else % \cutout\shapepar Placed on margin of cutout text |
| 553 |
\SH@docutout |
| 554 |
\fi |
| 555 |
\let\SH@usebox\unvbox % completely finished! |
| 556 |
\let\SH@margin\@empty |
| 557 |
\SH@ignorepar |
| 558 |
} |
| 559 |
|
| 560 |
% Note on height and depth: |
| 561 |
% Ordinary \shapepar uses \unvbox, which ignores ordinary \baselineskip |
| 562 |
% figuring, so we start the final formatting of the shape with the |
| 563 |
% prevdepth from outside and above. We use the depth of the \vbox |
| 564 |
% to set the \prevdepth after unboxing it. We can't record \prevdepth |
| 565 |
% from inside because we strip off a box from the bottom. |
| 566 |
% \Shapepar emits the shape in a box. The best way to do that is to |
| 567 |
% record the depth of the \vbox, rebox it as a \vtop (emitted) and then, |
| 568 |
% if vertical mode, make a strut with the proper depth. (Merely setting |
| 569 |
% \prevdepth gets the inter-line skips right, but not the placement at |
| 570 |
% the bottom of a page.) |
| 571 |
|
| 572 |
% Finally, \cutout requires a \smashed \vtop (only depth removed due to |
| 573 |
% the strange behavior of \vtop). |
| 574 |
|
| 575 |
\def\SH@reform{% |
| 576 |
\global\setbox\SH@boxb\vbox\bgroup |
| 577 |
! \message{Reformat paragraph with \string\rightskip = \the\rightskip.}% |
| 578 |
\advance\parfillskip-\rightskip \advance\parfillskip-\leftskip |
| 579 |
\parshape\the\SH@npslines\space \SH@parshape \z@ .5\maxdimen |
| 580 |
%% Maybe use prevdepth from outside, penalty puts \parskip and favors breaks |
| 581 |
\ifx\SH@margin\@empty \ifx\SH@usebox\unvbox |
| 582 |
\prevdepth\SH@pd \ifdim\SH@pd>-\@m\p@ \penalty-50 \fi |
| 583 |
\fi \fi |
| 584 |
\noindent \unhcopy\SH@boxa \unskip\unskip\unpenalty |
| 585 |
\lower\dp\strutbox\hbox{}% depth-only strut (\@finalstrut not defined in plain TeX) |
| 586 |
\penalty-\@M\hbox{\kern\maxdimen}\endgraf |
| 587 |
\ifnum\prevgraf=\SH@npslines % good, it worked. |
| 588 |
\setbox\SH@boxa\lastbox \unskip\unpenalty % remove mongo last box |
| 589 |
\egroup % end \SH@boxb, just above |
| 590 |
\xdef\SH@pd{\the\dp\SH@boxb}% |
| 591 |
\else % something wrong, increase flexibility and try again |
| 592 |
\egroup % end \SH@boxb, just above |
| 593 |
\ifnum\skip@<64 % try again |
| 594 |
\advance\rightskip\skip@ |
| 595 |
\multiply\skip@\tw@ |
| 596 |
\ifx\emergencystretch\undefined\else \advance\emergencystretch 1em\fi |
| 597 |
\expandafter\expandafter\expandafter \SH@reform |
| 598 |
\fi\fi} |
| 599 |
|
| 600 |
\def\SH@measureh#1#2#3{% line num, shift, width |
| 601 |
\ifdim#2<\SH@posold \SH@posold#2\relax \fi |
| 602 |
} |
| 603 |
|
| 604 |
\def\SH@restack#1#2#3{% line num, shift, width |
| 605 |
\unpenalty \skip@\lastskip \unskip \unpenalty |
| 606 |
\advance\skip@\lastskip \unskip \unpenalty\unpenalty |
| 607 |
\setbox\@tempboxa\lastbox |
| 608 |
\setbox\SH@boxa\vbox{% |
| 609 |
\ifhbox\@tempboxa |
| 610 |
\advance\SH@posold-#2% Trim box for \Shapepar |
| 611 |
\moveright-\SH@posold \hbox to#3% |
| 612 |
{\hskip\leftskip \SH@MT@corr\unhbox\@tempboxa \unskip \hskip\leftskip}% |
| 613 |
\nobreak % yes, \leftskip on right -- it is a scratch register here. |
| 614 |
\fi |
| 615 |
\vskip\skip@ |
| 616 |
\ifnum\SH@nline>\z@ \begingroup |
| 617 |
\count@=#1 \advance\count@-\SH@nline \advance\count@\@ne |
| 618 |
\vskip-\count@\baselineskip |
| 619 |
\endgroup\fi |
| 620 |
\unvbox\SH@boxa}% |
| 621 |
\SH@nline#1\relax |
| 622 |
% Keep track of line num for last box (\SH@highline) and |
| 623 |
% lowest box on page (\SH@lowline) |
| 624 |
\ifnum\SH@highline=-\@m \SH@highline\SH@nline \fi |
| 625 |
\ifnum\SH@lowline<\SH@nline \SH@lowline\SH@nline \fi |
| 626 |
} |
| 627 |
|
| 628 |
% Find and record parameters about the shape spec: |
| 629 |
% \spec@hcenter: Horizontal center of spec |
| 630 |
% \spec@top: Vertical position at top of spec |
| 631 |
% \spec@bot: Vertical position at bottom of spec |
| 632 |
% \spec@height: difference between them |
| 633 |
% \spec@left: Horizontal position at leftmost point of spec (macro) |
| 634 |
% \spec@width: Total width of spec (macro) |
| 635 |
% \spec@area: Area covered by spec |
| 636 |
% All in whatever units are used by the spec itself. |
| 637 |
% |
| 638 |
\def\SH@checkspec#1#2#3#4${% h-center, v-origin, "b", rest of spec |
| 639 |
\ifx b#3\else \SH@sperror \fi |
| 640 |
\spec@hcenter#1\p@ \spec@top#2\p@ |
| 641 |
\spec@bot-\maxdimen \spec@prevpos-\maxdimen |
| 642 |
\gdef\SH@spec{{#2}b#4}% |
| 643 |
% Measure vertical extrema and check for valid backspacing |
| 644 |
\let\\\SH@CheckSpecLine |
| 645 |
\\{#2}b#4\\{-12345.6}\\[$% |
| 646 |
\ifdim\spec@bot<-\@M\p@ \SH@sperror \fi |
| 647 |
% Measure horizontal extrema |
| 648 |
\spec@height\spec@bot \advance\spec@height-\spec@top |
| 649 |
\SH@posold\maxdimen \SH@widold-\maxdimen\relax |
| 650 |
\SH@CheckSpecSeg b#4\delimiter |
| 651 |
\edef\spec@left{\Pointless\SH@posold}% |
| 652 |
\advance\SH@widold-\SH@posold \edef\spec@width{\Pointless\SH@widold}% |
| 653 |
^ \message{Spec top: \Pointless\spec@top, bottom: \Pointless\spec@bot, height: |
| 654 |
^ \Pointless\spec@height, left: \spec@left, width: \spec@width. }% |
| 655 |
} |
| 656 |
|
| 657 |
% Record vertical positions. |
| 658 |
|
| 659 |
\def\SH@CheckSpecLine#1#2\\{\ifdim#1\p@<-\@M\p@ % finished |
| 660 |
\def\\[${}% $ |
| 661 |
\else |
| 662 |
\ifdim#1\p@>\spec@bot \spec@bot #1\p@\relax \fi |
| 663 |
\ifdim#1\p@<\spec@prevpos % allow backspace only between pieces |
| 664 |
\if\SH@only@b#2;\@empty \spec@prevpos#1\p@ |
| 665 |
\else \SH@sperror |
| 666 |
\spec@bot-\p@ \def\\##1[${}% $ eat rest |
| 667 |
\fi |
| 668 |
\else \spec@prevpos#1\p@ |
| 669 |
\fi\fi \\} |
| 670 |
|
| 671 |
\def\SH@only@b #1#2{% return bb if only "b" specs until ";" |
| 672 |
\if b\noexpand#1\expandafter\SH@only@b |
| 673 |
\else \if ;\noexpand#1bb\else ab\fi |
| 674 |
\fi} |
| 675 |
|
| 676 |
% Record horizontal positions. These are not used, but they anticipate |
| 677 |
% a shape-based bounding box. |
| 678 |
|
| 679 |
\def\SH@CheckSpecSeg#1#2#3{% |
| 680 |
\ifx t#1\relax \SH@SaveSpecSeg{#2}{#3}\else |
| 681 |
\ifx b#1\relax \SH@SaveSpecSeg{#2}0\else |
| 682 |
\ifx e#1\relax \SH@SaveSpecSeg{#2}0\fi\fi\fi |
| 683 |
\ifx\delimiter#3\def\SH@CheckSpecSeg##1##2{}\fi |
| 684 |
\SH@CheckSpecSeg{#2}{#3}} |
| 685 |
|
| 686 |
\def\SH@SaveSpecSeg#1#2{% |
| 687 |
\SH@posseg#1\p@\relax |
| 688 |
\ifdim\SH@posseg<\SH@posold \SH@posold\SH@posseg \fi |
| 689 |
\advance\SH@posseg#2\p@\relax |
| 690 |
\ifdim\SH@posseg>\SH@widold \SH@widold\SH@posseg \fi |
| 691 |
\relax |
| 692 |
} |
| 693 |
|
| 694 |
% Grab all the hboxes in the preceding list, combine their contents in |
| 695 |
% \@tempboxa (removing \rightskip, separating with space), and give |
| 696 |
% SH@tottext = total_width / 256 (note that the total width may be |
| 697 |
% greater than \maxdimen) |
| 698 |
% |
| 699 |
\def\SH@sumlines{\SH@grablast |
| 700 |
\ifhbox\SH@boxa |
| 701 |
\@tempdima\wd\SH@boxa \divide\@tempdima\@cclvi |
| 702 |
\global\advance\SH@tottext\@tempdima |
| 703 |
\setbox\@tempboxa\hbox{% |
| 704 |
\unhbox\SH@boxa |
| 705 |
\ifdim\lastkern=9sp \hfill\break \fi |
| 706 |
\ifvoid\@tempboxa\else \unhbox\@tempboxa \fi |
| 707 |
}% Repeat until complete: |
| 708 |
\expandafter\SH@sumlines |
| 709 |
\fi} |
| 710 |
|
| 711 |
\def\SH@sperror{\errhelp{It would be amazing if you can continue after |
| 712 |
this error.}\errmessage |
| 713 |
{Shaped Paragraph Error: Error in specification. Check carefully!}}% |
| 714 |
|
| 715 |
% Do the cutout in the surrounding text. Do so by regenerating |
| 716 |
% the a \parshape (\SH@lines actually) with a smaller line spacing. |
| 717 |
% Whichever of those lines fall near each line in the outer cutout |
| 718 |
% text contribute to the outer parshape. |
| 719 |
|
| 720 |
\def\SH@docutout{% |
| 721 |
% \message{\string\SH@docutout, with initial y-pos=\the\spec@position, scale=\the\SH@scale. }% |
| 722 |
\spec@position-\SH@yoff\relax \fpdivide\spec@position\SH@scale |
| 723 |
\advance\spec@position\spec@firstposition |
| 724 |
% \message{Spec position of first outer line is \the\spec@position. }% |
| 725 |
% line spacing of surrogate is fraction of the outer baselines. |
| 726 |
% Determine surrogate's "refined" baseline-skip (\SH@refbase), |
| 727 |
% its shape-spec increment (\spec@incr) and the number of lines |
| 728 |
% corresponding to the vertical (expanded) cutout-sep (\SH@highline) |
| 729 |
% Temporarily, \SH@posold is "shoulder" - height of octagon's corner. |
| 730 |
\SH@refbase\SH@cutoutbase |
| 731 |
\@tempdima\cutoutsep |
| 732 |
\[email protected]\cutoutsep |
| 733 |
\advance\@tempdima\cutoutsepstretch\SH@refbase % not refbase but cutoutbase |
| 734 |
\advance\SH@posold\cutoutsepstretch\SH@refbase |
| 735 |
\divide\SH@refbase\RefineBaselines % examine multiple positions per line |
| 736 |
% \message{Vertical gap \the\@tempdima, with refined spacing \the\SH@refbase. }% |
| 737 |
\divide\@tempdima\SH@refbase |
| 738 |
\SH@highline\@tempdima \SH@lowline-\SH@highline |
| 739 |
\spec@incr\SH@refbase |
| 740 |
\fpdivide\spec@incr\SH@scale |
| 741 |
% Pre-calculate excluded octagon shape (\SH@posold is "shoulder") |
| 742 |
\begingroup |
| 743 |
\gdef\SH@octcase{}\let\or\relax \SH@nextoctcase |
| 744 |
\xdef\SH@octcase{\noexpand\ifcase\SH@highline\SH@octcase\z@\noexpand\fi}% |
| 745 |
%\toks@\expandafter{\SH@octcase}\message{Octagon cases are: \the\toks@ }% |
| 746 |
\endgroup |
| 747 |
\SH@lowline-\SH@highline |
| 748 |
%\message{Range of lines of interest: \the\SH@lowline\space to \the\SH@highline. }% |
| 749 |
\advance\SH@lowline\@ne \advance\SH@highline\@ne |
| 750 |
% Generate the surrogate refined-lines shape |
| 751 |
\def\SH@dopara##1${}% Don't typeset the refined shape; just gobble to $ |
| 752 |
\SH@makeparshape % Get \SH@lines |
| 753 |
% Record highest line number in \SH@lines |
| 754 |
\let\@elt\SH@getmaxline \SH@nline\z@ \SH@lines |
| 755 |
% Use \SH@widold ("hold") to retain: x_off +/- (.5 hsize) |
| 756 |
\SH@widold\SH@xoff \advance\SH@widold\if l\SH@margin-\fi .5\hsize |
| 757 |
% Use \SH@posold ("hold") for initialization for outermost position |
| 758 |
\if l\SH@margin\relax |
| 759 |
\def\@tempb##1##2{##1##2}% |
| 760 |
\SH@posold -\SH@widold |
| 761 |
\else |
| 762 |
\def\@tempb##1##2{\z@##1}% |
| 763 |
\SH@posold\hsize \advance\SH@posold-\SH@widold |
| 764 |
\fi |
| 765 |
% Build cutout's parshape in \SH@parshape |
| 766 |
\gdef\SH@parshape{\@empty\@empty\@empty}\SH@npslines\z@ |
| 767 |
\expandafter\let\expandafter\@elt\csname SH@mostopposite\SH@margin\endcsname |
| 768 |
\SH@cutoutline % Builds parshape |
| 769 |
% Pull out indentation of first line |
| 770 |
\afterassignment\SH@dopara % a type of "gobble", see a bit above |
| 771 |
\@tempdima\SH@parshape $% the $ terminates gobble |
| 772 |
\advance\@tempdima-\SH@xoff |
| 773 |
\xdef\SH@xoff{-\the\@tempdima}% |
| 774 |
% Now finalize the parshape lines |
| 775 |
\advance\SH@npslines\@ne |
| 776 |
\xdef\SH@parshape{\number\SH@npslines\space\SH@parshape \z@\hsize}% |
| 777 |
\egroup % end original \setbox\SH@boxa\vbox\bgroup; but \SH@boxa is useless |
| 778 |
\SH@restog % restore global registers |
| 779 |
\endgroup% Have the parshape; end group started by \shapepar |
| 780 |
\global\setbox\SH@boxb\rlap{% |
| 781 |
\kern\if\SH@margin l-\fi.5\hsize |
| 782 |
\kern\SH@xoff |
| 783 |
\lower\SH@yoff \box\SH@boxb |
| 784 |
}% |
| 785 |
% Encourage page break above |
| 786 |
\@tempdima\dp\SH@boxb |
| 787 |
\advance\@tempdima-\SH@cutoutbase |
| 788 |
\advance\@tempdima\cutoutsep |
| 789 |
\dp\SH@boxb\z@ |
| 790 |
\vskip \z@ plus .3\@tempdima % optimize |
| 791 |
\penalty \@cclv % optimize |
| 792 |
\vskip \z@ plus -.3\@tempdima % undo above skip |
| 793 |
\ifdim20\p@<\@tempdima % optimize |
| 794 |
\vskip \@tempdima plus 9\p@ % optimize |
| 795 |
\penalty \@m % optimize |
| 796 |
\vskip -\@tempdima plus -9\p@ % undo above skip |
| 797 |
\fi |
| 798 |
\noindent % Outer text is not indented. To indent, use \indent. |
| 799 |
\vadjust{\penalty\@M \vskip\@tempdima |
| 800 |
\penalty9999 % exercise page builder |
| 801 |
\vskip-\@tempdima}% |
| 802 |
\endgroup % end group started by \cutout; out of all groups |
| 803 |
%\message{Parshape: \noexpand\parshape\SH@parshape }% |
| 804 |
\parshape\SH@parshape |
| 805 |
\box\SH@boxb |
| 806 |
} |
| 807 |
|
| 808 |
% for r indent = 0pt (done by \@tempb) |
| 809 |
% width = leftmost_pos + x_offset + ( .5\hsize - gap ) |
| 810 |
% for l indent = rightmost_pos + x_offset - ( .5\hsize - gap ) |
| 811 |
% width = \hsize - indent |
| 812 |
% Because I allow backspacing, I can't go through the spec, building |
| 813 |
% the parshape. Instead, I have to scan the whole spec, or rather, its |
| 814 |
% instantiation in \SH@lines, for every line of the \parshape... |
| 815 |
% Well, I *could* sort the instantiation first; then I could move |
| 816 |
% though it sequentially. |
| 817 |
% |
| 818 |
% Here I am re-using some scratch variables: |
| 819 |
% \SH@posold = +/- \maxdimen -- starting value of rightmost/leftmost |
| 820 |
% \SH@widold = x_offset +/- ( .5\hsize ) |
| 821 |
% \SH@posseg = leftmost/rightmost position |
| 822 |
% \SH@nline = highest number of \@elt lines in \SH@lines |
| 823 |
|
| 824 |
\def\SH@cutoutline{% |
| 825 |
\ifnum\SH@lowline>\SH@nline |
| 826 |
\let\SH@cutoutline\relax |
| 827 |
\else |
| 828 |
\SH@posseg\SH@posold |
| 829 |
\advance\SH@npslines\@ne |
| 830 |
%\message{SH@cutoutline \the\SH@npslines\space between \the\SH@lowline\space and \the\SH@highline. }% |
| 831 |
\SH@lines % Use \@elt to get leftmost/rightmost at this line |
| 832 |
%\message{ posseg \the\SH@posseg, posold \the\SH@posold. }% |
| 833 |
\advance\SH@posseg \SH@widold |
| 834 |
{\advance\hsize-\SH@posseg |
| 835 |
\xdef\SH@parshape{\SH@parshape \@tempb{\the\SH@posseg}{\the\hsize}}}% |
| 836 |
\fi |
| 837 |
\advance\SH@highline\RefineBaselines \advance\SH@lowline\RefineBaselines |
| 838 |
\SH@cutoutline} |
| 839 |
|
| 840 |
% choose leftmost position among \SH@posseg and lines near \SH@nline |
| 841 |
\def\SH@mostoppositer#1#2#3{% #1: line, #2: indent, #3: width |
| 842 |
\ifnum #1<\SH@lowline\else |
| 843 |
\ifnum #1>\SH@highline\else |
| 844 |
\advance\SH@highline-#1 |
| 845 |
% \message{Compare #2 #3 at #1. Case \the\SH@highline: \SH@octcase}% |
| 846 |
\dimen@#2\advance\dimen@-\SH@octcase\relax |
| 847 |
\ifdim \dimen@<\SH@posseg \SH@posseg\dimen@\fi |
| 848 |
\advance\SH@highline#1 |
| 849 |
\fi\fi} |
| 850 |
|
| 851 |
% choose rightmost position among \SH@posseg and lines near \SH@nline |
| 852 |
\def\SH@mostoppositel#1#2#3{% #1: line, #2: indent, #3: width |
| 853 |
\ifnum #1<\SH@lowline\else |
| 854 |
\ifnum #1>\SH@highline\else |
| 855 |
\advance\SH@highline-#1 |
| 856 |
\dimen@#2\advance\dimen@#3\advance\dimen@\SH@octcase\relax |
| 857 |
% \message{Compare #2 #3 at #1. Case \the\SH@highline=\SH@octcase: \the\dimen@}% |
| 858 |
\ifdim \dimen@>\SH@posseg \SH@posseg\dimen@\fi |
| 859 |
\advance\SH@highline#1 |
| 860 |
\fi\fi} |
| 861 |
|
| 862 |
%\def\SH@updCOlines{% Update list of lines for cut-out |
| 863 |
%\message{.}% |
| 864 |
% \xdef\SH@lines{\SH@lines\@elt{\the\SH@nline}{\the\SH@posold}{\the\SH@widold}}% |
| 865 |
% \advance\SH@npslines\@ne |
| 866 |
% \SH@widold\SH@widseg \SH@posold\SH@posseg} |
| 867 |
|
| 868 |
\def\SH@getmaxline#1#2#3{\ifnum#1>\SH@nline \SH@nline#1\relax\fi} |
| 869 |
|
| 870 |
\def\SH@nextoctcase{% |
| 871 |
\SH@posseg\AbsVal\SH@lowline\SH@refbase |
| 872 |
\SH@widseg\cutoutsep |
| 873 |
\ifdim\SH@posseg>\SH@posold |
| 874 |
\advance\SH@widseg-\SH@posseg |
| 875 |
\advance\SH@widseg \SH@posold |
| 876 |
\fi |
| 877 |
\xdef\SH@octcase{\SH@octcase \the\SH@widseg \or}% |
| 878 |
\advance\SH@lowline\@ne |
| 879 |
\ifnum\SH@lowline>\SH@highline\else |
| 880 |
\expandafter\SH@nextoctcase \fi} |
| 881 |
|
| 882 |
% Ignore following spaces and \par |
| 883 |
\def\SH@ignorepar{\afterassignment\SH@ignorepaR \let\SH@next=} |
| 884 |
\def\SH@ignorepaR{%\show\SH@next |
| 885 |
\edef\SH@nextspec{\noexpand\SH@next}% Hide \outer macros |
| 886 |
\ifx\par\SH@next \let\SH@nextspec\SH@ignorepar \fi |
| 887 |
\expandafter\ifx\space\SH@next \let\SH@nextspec\SH@ignorepar \fi |
| 888 |
\SH@nextspec} |
| 889 |
|
| 890 |
|
| 891 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 892 |
% Take a square root of counter \sqrtcount using Newton's method. |
| 893 |
% Usage: \sqrtcount=<number> \sqrtofcount; gives square root in \sqrtcount |
| 894 |
% To take sqrt of a dimen, do: |
| 895 |
% \sqrtcount=\thedimen \sqrtofcount |
| 896 |
% \multiply\sqrtcount by 256 \thedimen=\sqrtcount sp |
| 897 |
% -- see \sqrtofdim |
| 898 |
% |
| 899 |
% (\@tempcnta and \@tempcntb are used and modified.) |
| 900 |
\newcount\sqrtcount |
| 901 |
\def\sqrtofcount{\relax\ifnum\sqrtcount>\z@ |
| 902 |
\@tempcnta\sqrtcount \sqrtcount\@ne |
| 903 |
\expandafter\squinitial\the\@tempcnta\relax\relax\relax |
| 904 |
\squiterate |
| 905 |
\else |
| 906 |
\sqrtcount\@ne |
| 907 |
\fi} |
| 908 |
\def\squinitial#1#2{\ifx#1\relax \else |
| 909 |
\ifx #2\relax \multiply\sqrtcount \thr@@ % 3 ~ sqrt(10) |
| 910 |
\else \multiply\sqrtcount 10 |
| 911 |
\fi \expandafter \squinitial |
| 912 |
\fi} |
| 913 |
\def\squiterate{\@tempcntb\@tempcnta \divide\@tempcntb\sqrtcount |
| 914 |
%\message{sqrt(\the\@tempcnta) guess: \the\sqrtcount. }% |
| 915 |
\advance\sqrtcount\@tempcntb \divide\sqrtcount\tw@ |
| 916 |
\advance \@tempcntb -\sqrtcount |
| 917 |
\ifnum \AbsVal\@tempcntb>\thr@@ % approximate, use 1 for exact |
| 918 |
\expandafter \squiterate \fi}% expandafter to avoid stack overflows |
| 919 |
|
| 920 |
% Take sqrt of dimen register, as described above. |
| 921 |
\def\sqrtofdim#1{% #1 = dimen register |
| 922 |
\sqrtcount#1\sqrtofcount \multiply\sqrtcount\@cclvi #1=\sqrtcount sp\relax} |
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
% Approximate Fixed Point Division of two dimensions |
| 928 |
% 3.14159/2.71828 = 1.15573 |
| 929 |
% Two parameters: Numerator and denominator. The answer is returned |
| 930 |
% in the numerator (which must be a register). The denominator is |
| 931 |
% unchanged, but it should also be a dimen register. (It may be given |
| 932 |
% as an explicit *integer* string, "123", which is treated as 0.001877 |
| 933 |
% = 123/65536.) % \@tempcntb is used and altered. |
| 934 |
% |
| 935 |
\ifx\dimexpr\undefined % Use original TeX's integer \divide |
| 936 |
|
| 937 |
\def\fpdivide#1#2{\let\FPD@nume#1\@tempcntb#2\relax |
| 938 |
\FPD@scale\FPD@scale\FPD@scale\FPD@scale |
| 939 |
\FPD@scale\FPD@scale\FPD@scale\FPD@scale |
| 940 |
\divide#1\@tempcntb} |
| 941 |
|
| 942 |
% Rescale numbers to preserve accuracy. The magnum is the level of |
| 943 |
% uncertainty. Use a lower power of 2 for more accuracy (2 is most precise). |
| 944 |
% But if you change it, you must change the repetions of \FPD@scale in |
| 945 |
% \fpdivide above: magic_number^repetitions = 65536 (16^4 = 4^8 = 65536). |
| 946 |
% |
| 947 |
\chardef\FPD@magnum=4 |
| 948 |
\newcount\FPD@hi \FPD@hi=\maxdimen \divide\FPD@hi\FPD@magnum |
| 949 |
|
| 950 |
\def\FPD@scale{% |
| 951 |
\ifnum\AbsVal\FPD@nume<\FPD@hi |
| 952 |
\multiply\FPD@nume\FPD@magnum |
| 953 |
\else |
| 954 |
\divide\@tempcntb\FPD@magnum |
| 955 |
\fi} |
| 956 |
|
| 957 |
\else % Else, use eTeX's \dimexpr |
| 958 |
|
| 959 |
\def\fpdivide#1#2{\@tempcntb#2\relax |
| 960 |
#1=\dimexpr #1*\p@/\@tempcntb \relax |
| 961 |
} |
| 962 |
|
| 963 |
\fi |
| 964 |
|
| 965 |
% Take absolute value of TeX number or dimension (dimen must be a register) |
| 966 |
\def\AbsVal#1{\ifnum#1<\z@-\fi#1} |
| 967 |
|
| 968 |
\def\Pointless#1{\expandafter\remove@PT\the#1} |
| 969 |
{\catcode`p=12 \catcode`t=12 \gdef\remove@PT#1pt{#1}} |
| 970 |
|
| 971 |
% Restore microtype boundary kerns that are stripped away when doing |
| 972 |
% \unhbox and \unhcopy. |
| 973 |
% \SH@MT@corr <command><box_num><tail_action> |
| 974 |
% <command> is \unhbox or \unhcopy |
| 975 |
% <box_num> is box number (prefer single token) |
| 976 |
% <tail_action> is whatever needs to see the contents, e.g., \unskip |
| 977 |
% If each argument is a single token, the syntax is compatible |
| 978 |
% with regular \unhbox or \unhcopy. |
| 979 |
|
| 980 |
\ifnum \ifx\rightmarginkern\undefined 1\fi \ifx\rightmarginkern\relax 1\fi0>0 |
| 981 |
\let\SH@MT@corr\relax |
| 982 |
\else |
| 983 |
% This definition is specific to usage where box number is a single token |
| 984 |
\protected\def\SH@MT@corr#1#2#3{% #1 = \unhbox or \unhcopy; #2 = box num; #3 = \unskip |
| 985 |
\kern\leftmarginkern#2\relax |
| 986 |
\dimen@\rightmarginkern#2\relax |
| 987 |
#1#2#3% |
| 988 |
\kern\dimen@ |
| 989 |
} |
| 990 |
\fi |
| 991 |
|
| 992 |
\squarepar % restore catcodes |
| 993 |
|
| 994 |
% ---------------- Pre-defined shapes -------------------- |
| 995 |
% If you have (computer) memory problems, the following shape |
| 996 |
% definitions can be eliminated. |
| 997 |
|
| 998 |
\def\diamondshape{{3}{0}b{3}\\{4}t{0}{6}\\{8}e{3}} |
| 999 |
\def\diamondpar#1{\shapepar\diamondshape $\diamondsuit$ {#1} $\diamondsuit$\par} |
| 1000 |
|
| 1001 |
\def\squareshape{% |
| 1002 |
{1}% centerline at x=1 |
| 1003 |
{0}b{0}\\% begin at (0,0) |
| 1004 |
{0}t{0}{2}\\% text at y=0, width=2 |
| 1005 |
{2}t{0}{2}\\% text at y=2, width=2 |
| 1006 |
{2}e{1}% end at (1,2) |
| 1007 |
} |
| 1008 |
\def\squarepar#1{\shapepar{\squareshape}#1\par} |
| 1009 |
|
| 1010 |
\def\rectangleshape#1#2{% <height> <width> |
| 1011 |
{0}% "center" the left edge... sorry, better use \Shapepar |
| 1012 |
{0}b{0}\\% |
| 1013 |
{0}t{0}{#2}\\% |
| 1014 |
{#1}t{0}{#2}\\% |
| 1015 |
{#1}e{0}% |
| 1016 |
} |
| 1017 |
|
| 1018 |
\def\heartshape{% |
| 1019 |
{20}{0}b{13.32}b{26.68}% |
| 1020 |
\\{.14}t{10.12}{4.42}t{25.46}{4.42}% |
| 1021 |
\\{.7}t{9.14}{7.16}t{23.7}{7.16}% |
| 1022 |
\\{1.4}t{8.4}{9.02}t{22.58}{9.02}% |
| 1023 |
\\{2.1}t{7.82}{10.42}t{21.76}{10.42}% |
| 1024 |
\\{2.8}t{7.36}{11.58}t{21.06}{11.58}% |
| 1025 |
\\{3.5}t{6.98}{12.56}t{20.46}{12.56}% |
| 1026 |
\\{4.2}t{6.68}{13.32}jt{20}{13.32}% |
| 1027 |
\\{4.9}t{6.48}{27.04}% |
| 1028 |
\\{5.6}t{6.34}{27.32}% |
| 1029 |
\\{6.3}t{6.28}{27.44}% |
| 1030 |
\\{7}t{6.26}{27.48}% |
| 1031 |
\\{7.7}t{6.27}{27.46}% |
| 1032 |
\\{8.4}t{6.32}{27.36}% |
| 1033 |
\\{9.1}t{6.4}{27.2}% |
| 1034 |
\\{9.8}t{6.52}{26.96}% |
| 1035 |
\\{10.5}t{6.68}{26.64}% |
| 1036 |
\\{11.9}t{7.12}{25.76}% |
| 1037 |
\\{13.3}t{7.72}{24.56}% |
| 1038 |
\\{14.7}t{8.51}{22.98}% |
| 1039 |
\\{16.1}t{9.5}{21}% |
| 1040 |
\\{17.5}t{10.69}{18.62}% |
| 1041 |
\\{18.9}t{12.08}{15.84}% |
| 1042 |
\\{20.3}t{13.7}{12.6}% |
| 1043 |
\\{21.7}t{15.62}{8.76}% |
| 1044 |
\\{22.4}t{16.7}{6.6}% |
| 1045 |
\\{23.1}t{17.87}{4.26}% |
| 1046 |
\\{24.6}e{20}% |
| 1047 |
} |
| 1048 |
\def\heartpar#1{\shapepar{\heartshape}#1\unskip\unskip\penalty-300 |
| 1049 |
\ \ $\heartsuit$\par} |
| 1050 |
|
| 1051 |
\def\circleshape{% |
| 1052 |
{0.0}% |
| 1053 |
{0.0}b{0}\\% |
| 1054 |
{0.017}t{-0.129}{0.259}\\% |
| 1055 |
{0.067}t{-0.250}{0.500}\\% |
| 1056 |
{0.146}t{-0.354}{0.707}\\% |
| 1057 |
{0.250}t{-0.433}{0.866}\\% |
| 1058 |
{0.371}t{-0.483}{0.966}\\% |
| 1059 |
{0.500}t{-0.500}{1.000}\\% |
| 1060 |
{0.629}t{-0.483}{0.966}\\% |
| 1061 |
{0.750}t{-0.433}{0.866}\\% |
| 1062 |
{0.854}t{-0.354}{0.707}\\% |
| 1063 |
{0.933}t{-0.250}{0.500}\\% |
| 1064 |
{0.983}t{-0.129}{0.259}\\% |
| 1065 |
{1.0}e{0} |
| 1066 |
} |
| 1067 |
\def\circlepar#1{\Shapepar\circleshape #1\par} |
| 1068 |
|
| 1069 |
\def\nutshape{% |
| 1070 |
{0}% |
| 1071 |
{0}b{0}\\% |
| 1072 |
{0}t{-12.5}{25}\\% |
| 1073 |
{11.65}t{-19.23}{19.23}st{0}{19.23}\\% |
| 1074 |
{11.99}t{-19.42}{16.835}t{2.59}{16.835}\\% |
| 1075 |
{12.99}t{-20}{15}t{5}{15}\\% |
| 1076 |
{14.58}t{-20.92}{13.85}t{7.07}{13.85}\\% |
| 1077 |
{16.65}t{-22.11}{13.45}t{8.66}{13.45}\\% |
| 1078 |
{19.06}t{-23.51}{13.85}t{9.66}{13.85}\\% |
| 1079 |
{21.65}t{-25}{15}t{10}{15}\\% |
| 1080 |
{24.24}t{-23.51}{13.85}t{9.66}{13.85}\\% |
| 1081 |
{26.65}t{-22.11}{13.45}t{8.66}{13.45}\\% |
| 1082 |
{28.72}t{-20.92}{13.85}t{7.07}{13.85}\\% |
| 1083 |
{30.31}t{-20}{15}t{5}{15}\\% |
| 1084 |
{31.31}t{-19.42}{16.835}t{2.59}{16.835}\\% |
| 1085 |
{31.65}t{-19.23}{19.23}jt{0}{19.23}\\% |
| 1086 |
{43.3}t{-12.5}{25}\\% |
| 1087 |
{43.3}e{0}% |
| 1088 |
} |
| 1089 |
\def\nutpar#1{\Shapepar\nutshape #1\par} |
| 1090 |
|
| 1091 |
% Just the nut shape with the central hole erased: |
| 1092 |
\def\hexagonshape{% |
| 1093 |
{0}% |
| 1094 |
{0}b{0}\\% |
| 1095 |
{0}t{-12.5}{25}\\% |
| 1096 |
{21.65}t{-25}{50}\\% |
| 1097 |
{43.3}t{-12.5}{25}\\% |
| 1098 |
{43.3}e{0}% |
| 1099 |
} |
| 1100 |
\def\hexagonpar#1{\Shapepar\hexagonshape #1\par} |
| 1101 |
|
| 1102 |
\def\CDlabshape{% |
| 1103 |
{0}% |
| 1104 |
{-5.5}b{0}\\% |
| 1105 |
{-5.3}t{-1.47}{2.94}\\% |
| 1106 |
{-4.8}t{-2.685}{5.37}\\% |
| 1107 |
{-3.9}t{-3.878}{7.756}\\% |
| 1108 |
{-2.8}t{-4.734}{9.468}\\% |
| 1109 |
{-2.5}t{-4.899}{4.899}st{0}{4.899}\\% |
| 1110 |
{-2.2}t{-5.04}{3.853}t{1.187}{3.853}\\% |
| 1111 |
{-1.2}t{-5.376}{3.174}t{2.193}{3.174}\\% |
| 1112 |
{0}t{-5.5}{3}t{2.5}{3}\\% |
| 1113 |
{1.2}t{-5.376}{3.174}t{2.193}{3.174}\\% |
| 1114 |
{2.2}t{-5.04}{3.853}t{1.187}{3.853}\\% |
| 1115 |
{2.5}t{-4.899}{4.899}jt{0}{4.899}\\% |
| 1116 |
{2.8}t{-4.734}{9.468}\\% |
| 1117 |
{3.9}t{-3.878}{7.756}\\% |
| 1118 |
{4.8}t{-2.685}{5.37}\\% |
| 1119 |
{5.3}t{-1.47}{2.94}\\% |
| 1120 |
{5.5}e{0}% |
| 1121 |
} |
| 1122 |
\def\CDlabel#1{\Shapepar[1cm]{\CDlabshape}#1\par} |
| 1123 |
|
| 1124 |
\def\starshape{% |
| 1125 |
{0}% |
| 1126 |
{-3}b{0}\\% |
| 1127 |
{-.927}t{-.674}{1.348}\\% |
| 1128 |
{-.927}t{-2.853}{5.706}\\% |
| 1129 |
{.354}t{-1.09}{2.18}\\% |
| 1130 |
{1.146}t{-1.347}{1.347}st{0}{1.347}\\% |
| 1131 |
{2.427}e{-1.763}e{1.763}% |
| 1132 |
} |
| 1133 |
\def\starpar#1{\shapepar\starshape #1\par} |
| 1134 |
|
| 1135 |
\endinput |
| 1136 |
|
| 1137 |
%------------------------------------------------------------------- |
| 1138 |
|
| 1139 |
S H A P E P A R . S T Y -- Short Instructions |
| 1140 |
|
| 1141 |
\shapepar is a macro to typeset paragraphs of a specified shape. |
| 1142 |
|
| 1143 |
See shapepar.ltx (or shapepar.pdf etc) for full instructions. |
| 1144 |
|
| 1145 |
Loading: |
| 1146 |
|
| 1147 |
plain TeX: \input shapepar.sty |
| 1148 |
|
| 1149 |
LaTeX: \usepackage{shapepar} |
| 1150 |
|
| 1151 |
LaTeX package options: [quiet], [noisy] |
| 1152 |
|
| 1153 |
Usage: |
| 1154 |
|
| 1155 |
\shapepar [<scale>]{<shape_spec>} Text of the paragraph... |
| 1156 |
|
| 1157 |
The <scale> is a length (like \unitlength for the picture environment) |
| 1158 |
used for scaling the <shape_spec> to positions on the page. When the |
| 1159 |
<scale> parameter is absent, the scaling is adjusted automatically so |
| 1160 |
that the entire shape is filled with text. |
| 1161 |
|
| 1162 |
\Shapepar (capital S) is just like \shapepar except the paragraph |
| 1163 |
is boxed and not centered. |
| 1164 |
|
| 1165 |
\cutout {<side>} (<hoffset>,<voffset>) \shapepar...as above... |
| 1166 |
|
| 1167 |
This cuts out a section of the surrounding text to fit the shaped par. |
| 1168 |
The <side> is l (left) or r (right). The pair of offsets is optional. |
| 1169 |
|
| 1170 |
Pre-defined shapes, and commands to use the shape: |
| 1171 |
|
| 1172 |
\diamondshape, \diamondpar; \squareshape, \squarepar; \heartshape, |
| 1173 |
\heartpar; \circleshape, \circlepar; \nutshape, \nutpar; \CDlabshape, |
| 1174 |
\CDlabel; \starshape, \starpar; \hexagonshape, \hexagonpar. |
| 1175 |
|
| 1176 |
Shape generator: |
| 1177 |
|
| 1178 |
\rectangleshape{height}{width} |
| 1179 |
|
| 1180 |
Typeset shapepar.ltx (or see shapepar.pdf) for detailed instructions. |
| 1181 |
|
| 1182 |
|
| 1183 |
%----------------------------------------- |
| 1184 |
Version 2.2 (Mar 2013) Retain microtype boundary items |
| 1185 |
Version 2.1 (Sep 2006) Repair \\, fix multibox ordering, \rectangleshape, hexagon. |
| 1186 |
Version 2.01 (Jun 2006) Avoid some numeric overflows. |
| 1187 |
Version 2.00 (Dec 2002) \cutout, disjoint parts, set scale, much rewrite |
| 1188 |
Version 1.01 (Mar 1993) Small changes from initial release. |
| 1189 |
|
| 1190 |
% |
| 1191 |
% Test integrity of file: |
| 1192 |
% brackets: round, square, curly, angle: () [] {} <> |
| 1193 |
% backslash, slash, vertical, at, dollar, and: \ / | @ $ & |
| 1194 |
% hat, grave, acute (apostrophe), quote, tilde: ^ ` ' " ~ |