1

I am trying to figure out why does \newenvironment pushes the environment title down to the bottom of the page whenever the environment content is longer than 1 page. The following is an example. I would like the title in the longabstract environment to behave like that of the shortabstract (i.e., title and content stay on the same page).

\documentclass[12pt]{book}
\usepackage{setspace}
\usepackage{lipsum}
\begin{document}
\clearpage
\newenvironment{shortabstract}%
    {\cleardoublepage\thispagestyle{empty}\null\vfill\begin{center}%
    \bfseries \LARGE Short Abstract \end{center}}%
    {\vfill\null}
    \setstretch{1.5}
      \begin{shortabstract} 
      \lipsum[1]
       \end{shortabstract}
\newenvironment{longabstract}%
    {\cleardoublepage\null\vfill\begin{center}%
    \bfseries \LARGE Long Abstract\end{center}}%
    {\vfill\null}
        \begin{longabstract}
      \lipsum[2-5]
       \end{longabstract}
\end{document}

Any help is much appreciated.

Long

  • 2
    Well the ending \vfill is on the next page, so it can't counteract the starting \vfill. – Ulrike Fischer Aug 6 at 7:45
  • You could use a \savebox to test the size of abstract, but you would have to know how much space is left of the page (tricky). – John Kormylo Aug 6 at 14:47
2

I guess that the longabstract is assumed to be more than one page long, so centering it in a page doesn't make sense.

The definitions of the environments should go in the preamble. Avoid commands you don't know about, such as \null, and use standard LaTeX commands instead.

Here the short abstract is vertically centered; remove the leading \vspace*{\fill} if you want it flush with the top margin.

\documentclass[12pt]{book}
\usepackage{setspace}
\usepackage{lipsum}

\newenvironment{shortabstract}
 {\cleardoublepage\thispagestyle{empty}\vspace*{\fill}\begin{center}%
  \bfseries \LARGE Short Abstract\end{center}}%
 {\vspace*{\fill}\cleardoublepage}

\newenvironment{longabstract}
 {\cleardoublepage\begin{center}%
  \bfseries \LARGE Long Abstract\end{center}}%
 {\cleardoublepage}

\setstretch{1.5}

\begin{document}

\begin{shortabstract} 
\lipsum[1]
\end{shortabstract}

\begin{longabstract}
\lipsum[2-5]
\end{longabstract}

\end{document}

enter image description here

0

Thanks to @UlrikeFischer comments, I now figure out the answer: Just delete the beginning \vfill in these environments.

\documentclass[12pt]{book}
\usepackage{setspace}
\usepackage{lipsum}
\begin{document}
\clearpage
\newenvironment{shortabstract}%
    {\cleardoublepage\thispagestyle{empty}\null\begin{center}%
    \bfseries \LARGE Short Abstract \end{center}}%
    {\vfill\null}
    \setstretch{1.5}
      \begin{shortabstract} 
      \lipsum[1]
       \end{shortabstract}
\newenvironment{longabstract}%
    {\cleardoublepage\null\begin{center}%
    \bfseries \LARGE Long Abstract\end{center}}%
    {\vfill\null}
        \begin{longabstract}
      \lipsum[2-5]
       \end{longabstract}
\end{document}
  • 2
    Tip: mark the code and press the {} button to intent all the lines by four spaces to get the formatting above. On a PC you can also mark and press CTRL-k to get the same (not sure if the shortcut is the same on a Mac) – daleif Aug 6 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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