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.

When I use the amsart class with a lot of in-text figures, I find that the section headings do not stand out quite as much as I would like. Thus, I have taken to adding the following to my preamble, which adds a extra vertical space before each section heading:

\let \oldsection \section
\renewcommand{\section}{\vspace{8pt plus 3pt}\oldsection}

This works well for me, except when I have a section heading right after the document title; in this case, I find would prefer that no extra space be added.

How can I eliminate this extra space "automatically"--i.e., without explicitly adjusting spacing in the body of the document?


Examples:

Here are three examples side-by-side: enter image description here

You may want to zoom in.

The example on the left is the result of the code below:

\documentclass{amsart}

\let \oldsection \section
\renewcommand{\section}{\vspace{8pt plus 3pt}\oldsection}

\usepackage{lipsum}

\title{Random title}
\author{Fred P.~Author}
\date{\today}

\begin{document}
\maketitle
\section{The first section}
\lipsum[2]
\section{The next section}
\lipsum[4]
\end{document}

enter image description here Notice the extra space after "Fred P. Author" compared to the result I would like (the image on the right, in the side-by-side picture):

\documentclass{amsart}

\usepackage{lipsum}

\title{Random title}
\author{Fred P.~Author}
\date{\today}

\begin{document}
\maketitle
\section{The first section}
\lipsum[2]
\vspace{8pt plus 3pt}
\section{The next section}
\lipsum[4]
\end{document}

enter image description here

Finally, the image in the middle was given simply to illustrate that the titlesec package does not seem to solve the problem--at least, not in any naively obvious way. The code I used for it was the following (which I do not claim is exactly equivalent, but which still demonstrates the same extra space after the document title/author):

\documentclass{amsart}

\usepackage{titlesec}
\titleformat{\section}[hang]
  {\scshape\filcenter}
  {\thesection.}
  {1ex}
  {}
\titlespacing{\section}
  {0pt}{18pt}{6pt}

\usepackage{lipsum}

\title{Random title}
\author{Fred P.~Author}
\date{\today}

\begin{document}
\maketitle
\section{The first section}
\lipsum[2]
\section{The next section}
\lipsum[4]
\end{document}
share|improve this question
    
try \addvspace instead of \vspace in the redefinition of \section. if the previous element ends with vertical space, this should check the amount, and add only enough space to yield the larger of the original or the added amount. –  barbara beeton Dec 7 '12 at 21:14
    
@barbarabeeton: When I change \vspace to \addvspace, it gets rid of the additional space everywhere. If I increase the value enough to have an effect, it gives the same extra space after \maketitle. –  Charles Staats Dec 7 '12 at 21:19
    
Note: The real question here, for me, may be, "Can it be set up so that \vspace right after \maketitle gets eliminated, much as \vspace at the top of a page does?" –  Charles Staats Dec 7 '12 at 21:21
1  
very peculiar. the space before the second section shouldn't be decreased, but you're correct, it is. i will try to figure out why. –  barbara beeton Dec 7 '12 at 21:30
    
have you looked at the titling package? –  cmhughes Dec 7 '12 at 22:13

2 Answers 2

I wouldn't redefine \section like that, but use the standard method. If you're sure that your document starts with a section title, use

\documentclass{amsart}

\makeatletter
\def\amsartsection{\@startsection{section}{1}%
  \z@{2.5\linespacing\@plus\linespacing}{.5\linespacing}%
  {\normalfont\scshape\centering}}
\def\section{\vspace*{-34pt}\vspace{\baselineskip}\let\section\amsartsection\section}
\makeatother

\usepackage{lipsum}

\title{Random title}
\author{Fred P.~Author}
\date{\today}

\begin{document}
\maketitle
\section{The first section}
\lipsum[2]
\section{The next section}
\lipsum[4]
\end{document}

The \maketitle command adds 34pt space minus the value of \baselineskip. Adjust the multiples of \linespacing used in the definition of \amsartsection (which is the definition of \section that will be actually used in the document).

share|improve this answer
    
I think this is helpful. At the same time, I would point out that at my current level of TeX knowledge, the code block you are using is largely incomprehensible to me (as are most things involving @); so I have absolutely no chance of applying, on my own, this mythical "standard method" to which you refer. –  Charles Staats Dec 8 '12 at 4:31
    
Nevertheless, it looks to me as if the key point your answer is not so much the use of \amsartsection, as the fact that the \section macro incorporates a redefinition of itself, so that it will behave differently after the first time it is used. This is a hack (I would like a solution that works even when I am not sure the document starts with a section title), but (arguably) an improvement on inserting a \vspace*{negative length} before an initial \section command. –  Charles Staats Dec 8 '12 at 4:39
1  
@CharlesStaats Actually, on second thought, I believe that adding a negative spacing is just the right thing to do. I guess that adding some conditionals could automatically solve the problem; but this is probably a false problem: how many articles are you writing? :) –  egreg Dec 8 '12 at 9:55
    
I'm using this for lecture notes that I pass out to my students. I give three lectures per week, at an institution that has three ten-week quarters in a standard academic year. So, I'm using this for about ninety documents per academic year. And I'd like to be able to reorder sections without worrying about spacing. –  Charles Staats Dec 8 '12 at 15:14

The following code seems to work, so far as I can tell. When \maketitle is immediately followed by a \section (or \section*) command, some negative space is added immediately after \maketitle.

However, there are a few easy ways to break it--for instance, skipping a line between \maketitle and the first \section command, or (I assume) putting a \comment in the same place (or a \newcommand or any other command that would not normally affect the layout when placed there).

Additional note: If the hyperref package is used with this hack, the hyperref package should be loaded first.

\documentclass{amsart}

\let \oldsection \section
\def \newsection {\vspace{8pt plus 3pt}\oldsection}
\renewcommand{\section}{\newsection}

\let \oldmaketitle = \maketitle
\def \newmaketitle {\oldmaketitle \vspace*{-34pt}\vspace{\baselineskip}}

\def \titleDecide {%
    \ifx \nextToken \section
        \let \next = \newmaketitle
    \else
        \let \next = \oldmaketitle
    \fi
    \next
}

\renewcommand{\maketitle}{\futurelet \nextToken \titleDecide}

\usepackage{lipsum}

\title{Random title}
\author{Fred P.~Author}
\date{\today}

\begin{document}
\maketitle
\section{The first section}
\lipsum[2]
\section{The next section}
\lipsum[4]
\end{document}

enter image description here

share|improve this answer
    
This is very far from being bullet-proof to empty line after \maketitle, which is what most people who tidy their code do. You could check for \par first and throw it away if present, but what if I put \newcommand after \maketitle? It is a nice idea, but as barbara suggests above, this needs investigation of amsart and proper correction of how spacing is coded there. –  tohecz Jan 21 '13 at 5:22
1  
@tohecz: As I say in the answer itself, it breaks quite easily. But as long as I know to make sure that e.g. any empty line after \maketitle starts with %, it should serve my purposes. And since this answer already took me well beyond the previous boundaries of my TeX knowledge, I will have to leave any further investigations of the sort you suggest up to others, at least for the time being. –  Charles Staats Jan 21 '13 at 15:49

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.