Newsgroups: comp.text Path: utzoo!utgpu!jarvis.csri.toronto.edu!ephemeral.ai.toronto.edu!lamy From: lamy@ai.toronto.edu (Jean-Francois Lamy) Subject: Re: vertical spacing in LaTeX Message-ID: <1988Feb24.074702.25493@jarvis.csri.toronto.edu> Organization: University of Toronto, AI group Date: Wed, 24-Feb-88 07:47:02 EST In article <4445@sigi.Colorado.EDU> michael@boulder.Colorado.EDU (Michael Schmidt) writes: > >I have a little question: > > How can I influence the vertical spacing in LaTeX? Say to > achieve double spacing? > > Michael Schmidt Double spacing in LaTeX is tricky. First, you don't want footnotes and the like to go be double-spaced, and most people probably want to be able to switch back to single-spacing for quotatations and so on. The following code is an attempt at doing double-spacing properly. The spacing after a single-spaced quotation may need manual adjustment (I *think* this is due to LaTeX itself) Jean-Francois Lamy AI Group, Department of Computer Science lamy@ai.toronto.edu University of Toronto, Canada M5S 1A4 uunet!ai.toronto.edu!lamy ---------------------------8<- coupez ici ---------------------------------- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh doublespace.sty <<'END_OF_doublespace.sty' X% X% LaTeX Document style option "doublespace" X% -- usage: \documentstyle[...,doublespace,...]{...} X% X% This style option produces a double-spaced document by redefining X% the LaTeX parameter \baselinestretch to 2. X% X% It also fixes a number of problems with standard LaTeX, as follows: X% X% 1. A new environment "singlespace" is provided, within which single X% spacing will apply. X% JFL - changed so that it works in regular text and so that vertical X% space is before and after is correctly computed X% 2. Double spacing is turned off within footnotes and floats (figures X% and tables). X% 3. Proper double spacing happens below tabular environments and in other X% places where LaTeX uses a strut. X% 4. Slightly more space is inserted before footnotes. X% 5. JFL - fixes spacing before and after displayed math X% X% Note: This version sets a baselinestretch of 2. If this is too much, X% put \setstretch{1.7} (or some appropriate value) before the X% \begin{document} command. To print the document with single spacing X% again, without removing "singlespace" environments, just put a X% \setstretch{1} at the top of the document. X% X% PLEASE REPORT ANY BUGS X% X% Modified by: Jean-Francois Lamy X% lamy@ai.toronto.edu X% lamy@utai.uucp X% X% Author: Stephen Page -- sdpage@prg.oxford.ac.uk X% sdpage%prg.oxford.ac.uk@cs.ucl.ac.uk X% X% Release date: 6 July 1986 - September 3, 1986 X% X% Known bugs: X% . It might be nice if spacing before the footnote rule (\footins) X% were provided in a tidier way. X% . Increasing struts may possibly cause some other obscure part of X% formatting to fall over. X% . \begin{singlespace}\begin{quote} produces the wrong spacing before X% the quote (extra glue is inserted). X% . shouldn't @setsize stretch parskip as well? X%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% X X%---Set up double spacing X X\def\baselinestretch{2} X X X%---New command "\setstretch" (slightly more mnemonic... and easier to type) X X\def\setstretch#1{\renewcommand{\baselinestretch}{#1}} X X%---Stretch the baseline BEFORE calculating the strut size. This improves X% spacing below tabular environments etc., probably... X% Comments are welcomed. X X\def\@setsize#1#2#3#4{\@nomath#1 X \let\@currsize#1\baselineskip X #2\baselineskip\baselinestretch\baselineskip X \parskip\baselinestretch\parskip X \setbox\strutbox\hbox{\vrule height.7\baselineskip X depth.3\baselineskip width\z@} X \normalbaselineskip\baselineskip#3#4} X X X%---Increase the space between last line of text and footnote rule. X% This is a very untidy way to do it! X X\skip\footins 20pt plus4pt minus4pt X X X%---Reset baselinestretch within footnotes and floats. Originally stolen X% from Stanford thesis style. X X\def\@xfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else X \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner X \@parmoderr\@floatpenalty\z@ X \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname X \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n X \@tfor \@tempa :=#2\do X {\if\@tempa h\advance\@tempcnta \@ne\fi X \if\@tempa t\advance\@tempcnta \tw@\fi X \if\@tempa b\advance\@tempcnta 4\relax\fi X \if\@tempa p\advance\@tempcnta 8\relax\fi X }\global\count\@currbox\@tempcnta}\@fltovf\fi X \global\setbox\@currbox\vbox\bgroup X \def\baselinestretch{1}\small\normalsize X \boxmaxdepth\z@ X \hsize\columnwidth \@parboxrestore} X\long\def\@footnotetext#1{\insert\footins{\def\baselinestretch{1}\footnotesize X \interlinepenalty\interfootnotelinepenalty X \splittopskip\footnotesep X \splitmaxdepth \dp\strutbox \floatingpenalty \@MM X \hsize\columnwidth \@parboxrestore X \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}\@makefntext X {\rule{\z@}{\footnotesep}\ignorespaces X #1\strut}}} X X% Stolen from MIT. X% X% A single spaced quote (say) is done by surrounding singlespace with quote. X% X\def\singlespace{% X\vskip\parskip% X\vskip\baselineskip% X\def\baselinestretch{1}% X\ifx\@currsize\normalsize\@normalsize\else\@currsize\fi% X\vskip-\parskip% X\vskip-\baselineskip% X} X X\def\endsinglespace{\par} X X% spacing, doublespace and onehalfspace all are meant to INCREASE the X% spacing (i.e. calling onehalfspace from within doublespace will not X% produce a graceful transition between spacings) X% X\def\spacing#1{\par% X \def\baselinestretch{#1}% X \ifx\@currsize\normalsize\@normalsize\else\@currsize\fi} X X\def\endspacing{\par% X \vskip \parskip% X \vskip \baselineskip% X \endgroup% X \vskip -\parskip% X \vskip -\baselineskip% X \begingroup} X X\def\onehalfspace{\spacing{1.5}} X\let\endonehalfspace=\endspacing X X\def\doublespace{\spacing{2}} X\let\doublespace=\endspacing X X% Fix up spacing before and after displayed math X% (arraystretch seems to do a fine job for inside LaTeX displayed math, X% since array and eqnarray seem to be affected as expected) X% Changing \baselinestretch and doing a font change also works if done here, X% but then you have to change @setsize to remove the call to @nomath) X% X\everydisplay{ X \abovedisplayskip \baselinestretch\abovedisplayskip% X \belowdisplayskip \abovedisplayskip% X \abovedisplayshortskip \baselinestretch\abovedisplayshortskip% X \belowdisplayshortskip \baselinestretch\belowdisplayshortskip} X X END_OF_doublespace.sty if test 5440 -ne `wc -c