4

I am writing a document class where I want to set the default line spacing to be 1.5. How can I use the setspace package to achieve this? More particularly, where in my .cls file should I mention \onehalfspacing?
I have tried modifying \baselinestretch, but it does not work when I add \RequirePackage{setspace} in the .cls file.

2
  • 1
    Wouldn't \RequirePackage[onehalfspacing]{setspace} be sufficient?
    – egreg
    Commented Jan 16, 2012 at 12:08
  • @egreg: When trying to compile with \RequirePackage[onehalfspacing]{setspace}, I am getting the error: Package: `setspace' 6.7 <2000/12/01> ) ! Undefined control sequence. \setstretch ...ef \baselinestretch {#1}\@currsize Commented Jan 16, 2012 at 12:17

2 Answers 2

4

The error in your comment says, that \@currsize is undefined. It is set by \@setfontsize, which is called by LaTeX font size commands such as \Large, \small etc.

So you could fix it by defining \@currsize yourself, such as by

\let\@currsize\normalsize

but I recommend to define a font size in your class before you load setspace, which fixes it. Here's an example from bk10.clo, loaded by the book class:

\renewcommand\normalsize{%
   \@setfontsize\normalsize\@xpt\@xiipt
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}
\normalsize
1
  • 1
    The command \RequirePackage[onehalfspacing]{setspace} must go after a \LoadClass command (if used).
    – egreg
    Commented Jan 16, 2012 at 13:13
3

The new documentclass is baz.cls

\RequirePackage{filecontents}
\begin{filecontents}{baz.cls}
\PassOptionsToPackage{onehalfspacing}{setspace}
\LoadClass{report}
\RequirePackage{setspace}
\end{filecontents}

\documentclass{baz} 
\usepackage{lipsum}

\begin{document}
\lipsum  
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .