Debian Codegraph @

texmf-dist/tex/latex/setspace/setspace.sty

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2022 by LaTeX Team
4 % Copyright (C) 2011 by Robin Fairbairns ([email protected])
5 % Copyright (C) 2000 by Geoffrey Tobin
6 %
7 % ---------------------------------------------------------------------------
8 % This work may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.3
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in
12 % http://www.latex-project.org/lppl.txt
13 % and version 1.3 or later is part of all distributions of LaTeX
14 % version 2005/12/01 or later.
15 %
16 % This work has the LPPL maintenance status `maintained'.
17 %
18 % The Current Maintainer of this work is Robin Fairbairns
19 %
20 % This work consists of the files setspace.sty and setspace-test.tex
21 %
22 % \fi
23 %
24 %%% ======================================================================
25 %%% @LaTeX-style-file{
26 %%% filename = "setspace.sty",
27 %%% version = "6.7b",
28 %%% date = "4 December 2022",
29 %%% supported = "yes",
30 %%% archived = "CTAN",
31 %%% keywords = "LaTeX package, line spacing",
32 %%% codetable = "ISO/ASCII",
33 %%% docstring = "setspace.sty is a LaTeX (2e) package.
34 %%% Comments and bug reports welcome!
35 %%%
36 %%% This includes GDG's modification to Erica Harris'
37 %%% setspace.sty. The main aspects of this
38 %%% modification deal with the definitions of
39 %%% \singlespacing \onehalfspacing, and
40 %%% \doublespacing, (these are near the beginning of
41 %%% the file). Primarily, these deal with adding
42 %%% fontsize changes to guarantee that the new
43 %%% baseline is properly defined and placed into
44 %%% action. The extra \vskip in the definition of
45 %%% \singlespacing seems to make for a cleaner
46 %%% transition from multiple spacing back to single
47 %%% spacing. These did not appear warrranted for
48 %%% other size changes.
49 %%%
50 %%% Modified by GDG on November 1, 1992, to allow
51 %%% for use of New Font Selection Scheme.
52 %%%
53 %%% Modified by GDG on June 4, 1993, to correct
54 %%% for spacing tokens in definition of \@setsize
55 %%% Thanks to Kaja P. Christiansen <[email protected]>
56 %%% for the fix!!
57 %%%
58 %%% Modified by GDG on May 24, 1994, to change toggle
59 %%% definition from \selectfont to \@newbaseline.
60 %%%
61 %%% Modified by GDG on May 25, 1994, to add
62 %%% definition of \everydisplay -- this part of
63 %%% the code was apparently written by Geoffrey
64 %%% Tobin on Thu 23 Jan 1992 and was provided by
65 %%% [email protected] (Richard Stanton).
66 %%% This should help with some of the awkward math
67 %%% placements in changing spacings.
68 %%%
69 %%% Modified by GT on 23 Jan 1996, to correct
70 %%% \everymath bug, first reported by Mario
71 %%% Wolczko <[email protected]> on 9 June 1992.
72 %%%
73 %%% Modified by GT on 23 Jan 1996, to correct
74 %%% usage of comment characters in macro
75 %%% definitions.
76 %%%
77 %%% Modified by GT on 23 Jan 1996, to update
78 %%% (adjusted) \@xfloat definition for LaTeX2e.
79 %%% Bug report was courtesy of Kay Nettle.
80 %%%
81 %%% Modified by GT on 24 Jan 1996, to update
82 %%% (adjusted) \@footnotetext definition for
83 %%% LaTeX2e, and to add an adjusted LaTeX2e
84 %%% \@mpfootnotext definition for minipages.
85 %%% Bug report was courtesy Kay Nettle.
86 %%%
87 %%% Changed by GT on 6 Feb 1996, into a LaTeX2e
88 %%% package.
89 %%%
90 %%% Made more package-like by GT on 14 Feb 1996,
91 %%% by adding standard messages.
92 %%%
93 %%% GT replaced \@normalsize by \normalsize on 28
94 %%% Sep 1996. This change was successively
95 %%% advised by:
96 %%%
97 %%% Rowland J.~Bartlett
98 %%% <[email protected]>
99 %%% on Tue 6 Aug 96,
100 %%%
101 %%% Ted Stern
102 %%% <[email protected]>
103 %%% on Wed 7 Aug 96,
104 %%%
105 %%% Michal Jaegermann
106 %%% <[email protected]>
107 %%% on Fri 27 Sep 96.
108 %%%
109 %%% GT: Sat 28 Sep 1996: Added call to
110 %%% \setspace@size in \setstretch, as suggested
111 %%% by David Hull <[email protected]>
112 %%% on Wed 24 July 1996.
113 %%%
114 %%% GT: Sat 28 Sep 1996: Pared \setspace@size
115 %%% mercilessly down to \@currsize, following
116 %%% advice given on Fri 27 Sep 1996 by Michal
117 %%% Jaegermann <[email protected]>.
118 %%% Retained this macro for flexibility.
119 %%%
120 %%% Code rearranged by GT, Sat 28 Sep 1996, to give
121 %%% greater prominence to \setstretch.
122 %%%
123 %%% Also, GT changed (Sat 28 Sep 1996) many
124 %%% occurrences of \def to \newcommand,
125 %%% \renewcommand, or \newenvironment,
126 %%% as seemed appropriate.
127 %%%
128 %%% GT, Tue 10 Dec 1996: Following a suggestion
129 %%% by Ted Stern, the `single' spacing is now
130 %%% settable by the user. This is for slightly
131 %%% large fonts such as Lucida Bright.
132 %%%
133 %%% GT, Wed 11 Dec 1996: For simplicity and
134 %%% maintainability, call \onehalfspacing in
135 %%% the onehalfspace environment, and
136 %%% \doublespacing in the doublespace
137 %%% environment.
138 %%%
139 %%% GT, Wed 11 Dec 1996: Also deleted
140 %%% \setspace@size from \setstretch,
141 %%% as \@currsize suffices.
142 %%%
143 %%% Modified by Brett Presnell (BP)
144 %%% <[email protected]> on 21 Mar 1998
145 %%% to add nodisplayskipstretch option, which
146 %%% turns off the stretching of the space
147 %%% before and after displays, which is often
148 %%% excessive, particularly with doublespaced
149 %%% documents. Also added the
150 %%% setdisplayskipstretch command, which allows
151 %%% the user to choose by how much to stretch
152 %%% the space before and after displays
153 %%% independently from the setting of
154 %%% baselinestretch. This works regardless of
155 %%% whether the nodisplayskipstretch option is
156 %%% in effect.
157 %%%
158 %%% GT, Wed 15 Apr 1998: Added the singlespace*
159 %%% environment requested by
160 %%% Mark Olesen <[email protected]>
161 %%% on Sat 24 May 1997 and Wed 18 June 1997.
162 %%% This is reported to give improved vertical
163 %%% spacing around itemize and quote environments.
164 %%%
165 %%% GT, Wed 15 Apr 1998: David Hull pointed out on
166 %%% Fri 12 Dec 1997 that the \belowdisplayskip line
167 %%% in the \everydisplay was mistyped. Now fixed.
168 %%%
169 %%% GT, Thu 26 Nov 1998: Finally got round to
170 %%% fixing the absence of \begingroup from
171 %%% onehalfspace and doublespace environments.
172 %%% Thanks to: Bernd Schandl, Ron Smith,
173 %%% Himanshu Gohel, and Kevin Ruland, for bringing
174 %%% it to my long overdue attention.
175 %%%
176 %%% GT, Tue 27 July 1999: On Saturday 24 July
177 %%% 1999, Alexander L. Wolf <[email protected]>
178 %%% informed me that the \doublespace and
179 %%% \onehalfspace _macros_ are still at fault.
180 %%%
181 %%% GT, Fri 3 March 2000: Today Stefano
182 %%% Lacaprara of Italy brought my attention to
183 %%% the need to extend the commands and macros
184 %%% to point sizes other than 10, 11 and 12.
185 %%% Since there's no general formula for the
186 %%% line stretch values in terms of point size,
187 %%% and they vary only slightly between 10, 11
188 %%% and 12 pt, and furthermore the values were
189 %%% presumably optimised specifically for the
190 %%% Computer Modern fonts, i've chosen to use
191 %%% the 10 pt values as the generic defaults.
192 %%%
193 %%% GT, Fri 1 December 2000: George Pearson
194 %%% requested package options for the three
195 %%% common spacings.
196 %%%
197 %%% DPC Guard against \@ptsize not being defined
198 %%% https://github.com/rf-latex/setspace/issues/5
199 %%%
200 %%% }
201 %%% ======================================================================
202 %% FILE: setspace.sty in SYS2.TEX.PUB.ISULATEX.STYLES
203 %% AUTHOR: Erica M. S. Harris
204 %% DATE: April 1990
205 %% MOD: March 1991
206 %%%
207 %%% Update to LaTeX (2e) : 6 Feb 1996.
208 %%% Description: LaTeX Document Package "setspace"
209 %%%
210 %%% Usage:
211 %%% \documentclass[...]{...}
212 %%% \usepackage{setspace}
213 %%%
214 %% Based on the doublespace option created by Stephen Page.
215 %%
216 %% This style option provides commands and environments for doing
217 %% double and one-and-a-half spacing based on pt size.
218 %%
219 %% Single spacing is the default.
220 %%
221 %% Three commands, \singlespacing, \onehalfspacing, and
222 %% \doublespacing, are for use in the preamble to set the overall
223 %% spacing for the document. If a different spacing is required then
224 %% the \setstretch{baselinestretch} command can be used in the
225 %% preamble to set the baselinestretch appropriately. The default
226 %% spacing with this style option is single spacing.
227 %%
228 %% Three environments, singlespace, onehalfspace, and doublespace,
229 %% allow the spacing to be changed within the document. Both the
230 %% onehalfspace and doublespace environments are intended to increase
231 %% the spacing, so the onehalfspace environment should not be used in
232 %% a double spaced document. If an increased spacing different from
233 %% one-and-a-half or double spacing is required then the spacing
234 %% environment can be used. The spacing environment takes one
235 %% argument which is the larger baselinestretch to use,
236 %% e.g., \begin{spacing}{2.5}.
237 %%
238 %% \footins is adjusted the same as \parskip - appears to work. Lose
239 %% stretch parts but don't consider that to be crucial
240 %%
241 %% Removed code for altering spacing before and after displayed
242 %% equations - just looked too much.
243 %%
244 %% MODS:
245 %% Redefinition of \spacing and \endspacing for consistency with
246 %% TeX 3.x inserted by George Greenwade. Modification provided by
247 %% Philip Ross ([email protected]) and John Byrne via INFO-TeX.
248 %%
249 %% PLEASE REPORT ANY BUGS
250 %%
251 %% Old Documentation follows:
252 %% 1. A new environment "singlespace" is provided, within which single
253 %% spacing will apply.
254 %% JFL - changed so that it works in regular text and so that
255 %% vertical space before and after is correctly computed
256 %% 2. Double spacing is turned off within footnotes and floats (figures
257 %% and tables).
258 %% 3. Proper double spacing happens below tabular environments and in
259 %% other places where LaTeX uses a strut.
260 %% 4. Slightly more space is inserted before footnotes.
261 %% 5. JFL - fixes spacing before and after displayed math
262 %%
263 %%
264 %% mods: Jean-Francois Lamy
265 %% [email protected]
266 %% [email protected]
267 %%
268 %% POSSIBLE BUGS:
269 %% . Increasing struts may possibly cause some other obscure part of
270 %% formatting to fall over.
271 %% . \begin{singlespace}\begin{quote} produces the wrong spacing before
272 %% the quote (extra glue is inserted).
273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274
275 \@ifundefined{NeedsTeXFormat}{% 2.09 version
276 \def \filename {setspace.sty}
277 \def \filedate {2022/12/04}
278 \def \fileversion {6.7b}
279 \typeout {Package: `setspace' \fileversion\space <\filedate>}
280 }{% 2e version
281 \NeedsTeXFormat {LaTeX2e}[1994/12/01]
282 \ProvidesPackage {setspace}[2022/12/04 v6.7b set line spacing]
283 }
284
285 % BP: add nodisplayskipstretch option and \setdisplayskipstretch command.
286
287 \newcommand{\displayskipstretch}{\baselinestretch}
288 \newcommand{\setdisplayskipstretch}[1]{\renewcommand{\displayskipstretch}{#1}}
289 \DeclareOption{nodisplayskipstretch}{\setdisplayskipstretch{1.0}}
290
291 % GT: add George Pearsons' suggested options.
292
293 \DeclareOption{singlespacing}{\AtEndOfPackage{\singlespacing}}
294 \DeclareOption{onehalfspacing}{\AtEndOfPackage{\onehalfspacing}}
295 \DeclareOption{doublespacing}{\AtEndOfPackage{\doublespacing}}
296
297 \ProcessOptions
298
299 % GT: Sat 28 Sep 1996: Widely using \newcommand, \renewcommand, and
300 % \newenvironment, instead of \def.
301
302 % ** Line space commands.
303
304 \newcommand{\setstretch}[1]{%
305 \def\baselinestretch{#1}%
306 \@currsize
307 }
308
309 % GT: Sat 28 Sep 1996: spacing commands and environments modified to
310 % use \setstretch instead of \baselinestretch.
311 %
312 % GT: Sat 28 Sep 1996: No, I don't know understand the line spacing
313 % algorithms! If someone (LaTeX team) can enlighten me as to the
314 % general rule, please do! It would be very pleasant if setspace.sty
315 % were suited for document font sizes other than 10, 11 and 12 pt.
316 %
317 % GT: Tue 10 Dec 1996: Instead of fixing singlespacing to exact unity,
318 % allow user to redefine it (only slightly, please!) from its initial
319 % value of unity, in the case when a particular font is slightly larger
320 % or slightly smaller than its point size would indicate. This change
321 % affects setspace's single spacing commands, and LaTeX's footnote and
322 % float environments. The one and a half, double, and arbitrary
323 % spacing commands are unaltered.
324
325 \newcommand{\SetSinglespace}[1]{%
326 \def\setspace@singlespace{#1}%
327 }
328
329 % Here's the default single line spacing value.
330 \SetSinglespace{1}
331
332 \newcommand{\singlespacing}{%
333 \setstretch {\setspace@singlespace}% normally 1
334 \vskip \baselineskip % Correction for coming into singlespace
335 }
336
337 \newcommand{\onehalfspacing}{%
338 \setstretch{1.25}% default
339 % DPC 6.7b guard \@ptsize
340 \ifx\@ptsize\@undefined\else
341 \ifcase \@ptsize \relax % 10pt
342 \setstretch {1.25}%
343 \or % 11pt
344 \setstretch {1.213}%
345 \or % 12pt
346 \setstretch {1.241}%
347 \fi
348 \fi
349 }
350
351 \newcommand{\doublespacing}{%
352 \setstretch {1.667}% default
353 % DPC 6.7b guard \@ptsize
354 \ifx\@ptsize\@undefined\else
355 \ifcase \@ptsize \relax % 10pt
356 \setstretch {1.667}%
357 \or % 11pt
358 \setstretch {1.618}%
359 \or % 12pt
360 \setstretch {1.655}%
361 \fi
362 \fi
363 }
364
365 % ** Modification of the LaTeX command \@setsize.
366
367 %---Stretch the baseline BEFORE calculating the strut size. This improves
368 % spacing below tabular environments etc., probably...
369 % Comments are welcomed.
370
371 % GT: Sun 29 Sep 1996: Question: Is this code anywhere near correct
372 % since this part of LaTeX (in, eg, latex.ltx) has been greatly changed?
373
374 % GT: Sun 29 Sep 1996: The meanings of the arguments to \@setsize
375 % appear to be (whatever these may signify) :
376 % current size; font baselineskip; ignored (!); and font size.
377
378 % GT: Sun 29 Sep 1996: Note that \@setsize (in latest LaTeX,
379 % \@setfontsize, which is called by \@setsize) seems to be the only
380 % place in purely modern LaTeX where \@currsize is set, and ltxguide.cls
381 % seems to be the only file in the LaTeX base distribution that uses it!
382
383 % RF: 2011-12-19: only redefine \@setsize if under 2e; there have been
384 % reports of ltx209 packages failing when run with setspace under
385 % ltx2e, with this definition
386 \@ifundefined{NeedsTeXFormat}{%
387 \def\@setsize#1#2#3#4{%
388 % Modified 1993.04.07--GDG per KPC
389 \@nomath#1%
390 \let\@currsize#1%
391 \baselineskip #2%
392 \baselineskip \baselinestretch\baselineskip
393 \parskip \baselinestretch\parskip
394 \setbox\strutbox \hbox{%
395 \vrule height.7\baselineskip
396 depth.3\baselineskip
397 width\z@}%
398 \skip\footins \baselinestretch\skip\footins
399 \normalbaselineskip\baselineskip#3#4}%
400 }{}%
401
402 % ** Float and footnote adjustments to compensate for a change in the
403 % ** main text's line spacing.
404
405 %---Increase the space between last line of text and footnote rule.
406 %\skip\footins 20pt plus4pt minus4pt
407
408 %---Reset baselinestretch within floats and footnotes.
409
410 % GT: Tue 23 Jan 1996: This is where the conflict with the combination
411 % of the color package and the figure environment used to occur.
412
413 % Floats.
414
415 % GT: Sat 28 Sep 1996: \@xfloat is the only place where \normalsize
416 % is still used in setspace.sty !
417
418 \let\latex@xfloat=\@xfloat
419 \def\@xfloat #1[#2]{%
420 \latex@xfloat #1[#2]%
421 \def\baselinestretch{\setspace@singlespace}%
422 \normalsize
423 }
424
425 % GT: Wed 24 Jan 1996: This footnote code was copied from LaTeX and
426 % modified rather naively. It had to be brought up to date, not only
427 % because of LaTeX's new color ability, but also because there had
428 % been major changes to this code in LaTeX at least as far back as
429 % March 1992.
430
431 % Normal, bottom of the page, footnotes.
432 %
433 % GT: Based HEAVILY on original LaTeX (2e) code. A standard hook would
434 % be MUCH preferred, so that LaTeX's footnote implementation needn't be
435 % copied each time it changes.
436 %
437 % GT: The \protected@edef requires at least the December 1994 LaTeX.
438 % This is precisely the kind of VERSION DEPENDENCY situation that
439 % cannot (AFAIK) be avoided, because LaTeX (2e) LACKS appropriate
440 % standard hooks and/or context markers.
441
442 \long\def\@footnotetext#1{%
443 \insert\footins{%
444 % GT: Next line added. Hook desired here!
445 \def\baselinestretch {\setspace@singlespace}%
446 \reset@font\footnotesize
447 \interlinepenalty\interfootnotelinepenalty
448 \splittopskip\footnotesep
449 \splitmaxdepth \dp\strutbox \floatingpenalty \@MM
450 \hsize\columnwidth
451 \@parboxrestore
452 % DPC 6.7b added from latex.ltx
453 \def\@currentcounter{footnote}%
454 \protected@edef\@currentlabel{%
455 \csname p@footnote\endcsname\@thefnmark
456 }%
457 \color@begingroup
458 \@makefntext{%
459 \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
460 % DPC 6.7b added from latex.ltx
461 \par
462 \color@endgroup}}
463
464 % Minipage footnotes.
465
466 \long\def\@mpfootnotetext#1{%
467 \global\setbox\@mpfootins\vbox{%
468 \unvbox \@mpfootins
469 % GT: Next line added. Hook desired here!
470 \def\baselinestretch {\setspace@singlespace}%
471 \reset@font\footnotesize
472 \hsize\columnwidth
473 \@parboxrestore
474 % DPC 6.7b added from latex.ltx
475 \def\@currentcounter{mpfootnote}%
476 \protected@edef\@currentlabel{%
477 \csname p@mpfootnote\endcsname\@thefnmark}%
478 \color@begingroup
479 \@makefntext{%
480 \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
481 % DPC 6.7b added from latex.ltx
482 \par
483 \color@endgroup}}
484
485 % ** Line space environments.
486
487 % A single spaced quote (say) is done by surrounding singlespace with quote.
488
489 \newenvironment{singlespace}{%
490 \vskip \baselineskip
491 \setstretch {\setspace@singlespace}%
492 \vskip -\baselineskip
493 }{%
494 \par
495 }
496
497 % GT (c/o Mark Olesen), Wed 15 April 1998.
498
499 \newenvironment{singlespace*}{%
500 \setstretch {\setspace@singlespace}%
501 \vskip -\baselineskip
502 }{%
503 \vskip -0.5\baselineskip
504 }
505
506 % spacing, doublespace and onehalfspace all are meant to INCREASE the
507 % spacing (i.e. calling onehalfspace from within doublespace will not
508 % produce a graceful transition between spacings)
509 %
510 % Next two definitions fixed for consistency with TeX 3.x
511
512 % In order to use \newenvironment, while easily using same code for
513 % end of each environment, the code that used to be in \endspacing has
514 % been moved into a new (but internal) macro, \restore@spacing.
515
516 \newcommand{\restore@spacing}{%
517 \par
518 \vskip \parskip
519 \vskip \baselineskip
520 \endgroup
521 \vskip -\parskip
522 \vskip -\baselineskip
523 }
524
525 \newenvironment{spacing}[1]{%
526 \par
527 \begingroup % moved from \endspacing by PGBR 29-1-91
528 \setstretch {#1}%
529 }{%
530 \restore@spacing
531 }
532
533 % one and a half spacing is 1.5 x pt size
534 \newenvironment{onehalfspace}{%
535 \begingroup
536 \onehalfspacing
537 }{%
538 \restore@spacing
539 }
540
541 % double spacing is 2 x pt size
542 \newenvironment{doublespace}{%
543 \begingroup
544 \doublespacing
545 }{%
546 \restore@spacing
547 }
548
549 % GT: EMSH chose to omit display math part that follows.
550 % She wrote (see above) that the "altered spacing before and after displayed
551 % equations ... just looked too much".
552 %
553 % Fix up spacing before and after displayed math
554 % (arraystretch seems to do a fine job for inside LaTeX displayed math,
555 % since array and eqnarray seem to be affected as expected).
556 % Changing \baselinestretch and doing a font change also works if done here,
557 % but then you have to change @setsize to remove the call to @nomath)
558 %
559 % GT: The \belowdisplayskip line was mistyped; now fixed, courtesy of
560 % David Hull.
561 %
562 % GT: Brett Parnell has addressed EMSH's concern by replacing
563 % \baselinestretch by \displayskipstretch in displays, as follows.
564
565 \everydisplay\expandafter{%
566 \the\everydisplay
567 \abovedisplayskip \displayskipstretch\abovedisplayskip
568 \belowdisplayskip \displayskipstretch\belowdisplayskip
569 \abovedisplayshortskip \displayskipstretch\abovedisplayshortskip
570 \belowdisplayshortskip \displayskipstretch\belowdisplayshortskip
571 }
572
573 \endinput
574
575 %%% EOF.