setspace.sty 22 KB

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