Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to use headings in a letter, more precisely in documentclass dinbrief.

Knowing that LaTeX does not support section or subsection commands in this document class I use the following workaround:

\newcommand{\section}[1]{ { \huge \textbf{#1}} }
\newcommand{\subsection}[1]{ {\Large \textbf{#1}} }

The problem is that the vertical space is different if I compare both snippets below. Wherever, using the document class article with both methods, LaTeX uses the same space.

Method 1

\section{test}
Lorem ipsum dolor sit amet.

Method 2

\section{test}

Lorem ipsum dolor sit amet

Is there a better alternative to use headings — and if not, how to achieve the same vertical space?

Thank you.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

If you want to reproduce the spacing from, say, the article class, you could more or less copy the definitions of the sectioning commands from article.cls, which use the LaTeX base macro \@startsection internally for typesetting of the title and appropriate spacing.

\documentclass{dinbrief}
\usepackage{lipsum}

\makeatletter
\setcounter{secnumdepth}{2}
\newcounter{section}
\newcounter{subsection}[section]
\renewcommand\thesection{\@arabic\c@section}
\renewcommand\thesubsection{\thesection.\@arabic\c@subsection}
\newcommand*\section{\@startsection{section}{1}{\z@}%
                    {-3.5ex \@plus -1ex \@minus -.2ex}%
                    {2.3ex \@plus.2ex}%
                    {\normalfont\huge\bfseries}}
\newcommand*\subsection{\@startsection{subsection}{2}{\z@}%
                       {-3.25ex\@plus -1ex \@minus -.2ex}%
                       {1.5ex \@plus .2ex}%
                       {\normalfont\Large\bfseries}}
\makeatother

\signature{Mr.\ Happy}

\begin{document}
  \begin{letter}{Mr.\ Grumpy}
    \opening{Hello,}
    \section{A Section}
    \lipsum[1]
    \subsection{A Subsection}
    \lipsum[2-3]
    \closing{Yours truly,}
  \end{letter}
\end{document}

I wasn't sure whether you also want section numbering. If not, just leave out the counter definitions or set secnumdepth to 0.

The arguments of \@startsection specify

  1. the counter to be used for this level
  2. the level of sectioning
  3. the indentation for the heading
  4. the vertical skip above the heading (a negative length means that the first paragraph of the section has no paragraph indentation, which doesn't make a difference in dinbrief)
  5. the skip after the heading (if positive it's the vertical skip, if negative it's a horizontal skip and there's no linebreak after the heading, e.g. for \paragraph-like section levels)
  6. and finally, the font used for the heading (here, I used the font sizes from your example, although it looks a bit huge IMO)

Of course, you can fiddle around with the lengths as you please. Also, I'm not sure whether dinbrief flushes the bottom of the page, so you might not even require rubber lengths for your spacing.

Edit:

You may also have to adjust the lengths in order to compensate for dinbrief's vertical paragraph spacing...

share|improve this answer
    
Awesome, thank you very much for your answer and explanation. Concerning the font size: Yes, you'd better use \Large and \large as in article.cls. –  Jan Mar 13 '13 at 17:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.