[comp.text] vertical spacing in LaTeX

michael@boulder.Colorado.EDU (Michael Schmidt) (02/23/88)

I have a little question:

  How can I influence the vertical spacing in LaTeX? Say to
  achieve double spacing?

	  Michael Schmidt

lear@athos.rutgers.edu (eliot lear) (02/24/88)

In article <4445@sigi.Colorado.EDU> michael@boulder.Colorado.EDU (Michael Schmidt) writes:
>   How can I influence the vertical spacing in LaTeX? Say to
>   achieve double spacing?

The way we do it around here is as follows:

\newcommand{\doublespace}{\baselineskip 2\baselineskip}
and 
\newcommand{\halfspace}{\par \baselineskip .5\baselineskip}
to undo it.
-- 
Eliot Lear
[lear@rutgers.edu]

lamy@ai.toronto.edu (Jean-Francois Lamy) (02/24/88)

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 <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
#
# Contents:  doublespace.sty
#
# Wrapped by lamy@ai.toronto.edy on Wed Feb 24 07:41:43 1988
#
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f doublespace.sty -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"doublespace.sty\"
else
echo shar: Extracting \"doublespace.sty\" \(5440 characters\)
sed "s/^X//" >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 <doublespace.sty`; then
    echo shar: \"doublespace.sty\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0

tgl@ZOG.CS.CMU.EDU (Tom Lane) (02/24/88)

In article <4445@sigi.Colorado.EDU> michael@boulder.Colorado.EDU (Michael
Schmidt) writes:
>   How can I influence the vertical spacing in LaTeX? Say to
>   achieve double spacing?

to which lear@athos.rutgers.edu (eliot lear) replies:
>   \newcommand{\doublespace}{\baselineskip 2\baselineskip}
>   and 
>   \newcommand{\halfspace}{\par \baselineskip .5\baselineskip}
>   to undo it.

The LaTeX book (on p. 155) recommends changing \baselinestretch rather than
\baselineskip to achieve double spacing.  The latter value is set by
any type-size-changing command, so section headers, footnotes, and so forth
will not be doublespaced with lear's macros; moreover, a type-size-setting
command in open text (not inside a group) will destroy the spacing permanently.

To achieve true double spacing, I'd recommend putting something like

	\renewcommand{\baselinestretch}{2}

in the document preamble (before \begin{document}).

If you want to change the setting on the fly, you need to also cause
\baselineskip to be updated, which you can do as in lear's code; or you
could say "\large \normalsize" to force \baselineskip to be recomputed.
(The latter method has the advantage of being independent of the previous
state.)  You probably shouldn't be doing that at all, though; if what you
need is a little more space at particular places --- say around formulas ---
there are other parameters that you can diddle; or you can always throw in a
strut.

The LaTeX book points out that this approach is really only suitable for
producing draft copies for marking up; a wholesale revision of the document
format for wider line spacing would require numerous other adjustments
to produce good-looking results.

-- 
				tom lane
ARPA: tgl@zog.cs.cmu.edu
UUCP: <your favorite arpanet gateway>!zog.cs.cmu.edu!tgl
BITNET: tgl%zog.cs.cmu.edu@cmuccvma

sc@VLSI.CS.CMU.EDU (Siddhartha Chatterjee) (02/24/88)

> In article <4445@sigi.Colorado.EDU> michael@boulder.Colorado.EDU (Michael
> Schmidt) writes:
>   How can I influence the vertical spacing in LaTeX? Say to
>   achieve double spacing?
> 

There is a file called doublespace.sty in the rochester latex-style 
repository.  It does a few more things to make things look a little better,
but it comes with warnings about the evils of doublespacing.  It's available
by anonymous ftp from cs.rochester.edu.  The directory is public/latex-style.
If you don't have anonymous ftp access, send me mail and I'll send it to you.

-- 
----
ARPA:	Siddhartha.Chatterjee@vlsi.cs.cmu.edu
UUCP:	{seismo,decvax,allegra}!rochester!cmu-cs-pt!cmu-cs-vlsi!sc
----

rsr@wvucswv.UUCP (02/25/88)

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

I had posted a similar request about a year ago on comp.text, and 
Stan Dunn from Rutgers explained how it could be done.

Essentially, selective double-spacing can be obtained in LaTeX by defining
two new commands \bdouble and \edouble  (begin and end double-spacing!)
and enclosing any material to be double-spaced within these two commands.

These two definitions are:

\newcommand{\bdouble}{\baselineskip 2\baselineskip} % begin double space

\newcommand{\edouble}{\par \baselineskip .5\baselineskip} % end double space

USAGE: 

\bdouble
% Stuff to be double-spaced ...
\edouble

- ravi -
--------------------------------------------------------------------------
Ravi S. Raman
West Virginia University
USMAIL:	217 Knapp Hall, WVU, Morgantown, WV 26506
PHONE:	304 293-3607
USENET:  {allegra,bellcore, cadre,idis,psuvax1}!pitt!wvucsb!wvucswv!rsr