0

I need a hand with the code below.

I'd like to place the abstract either in the middle of a page, if the content takes less than a page, or start it from the top of a page, otherwise or perhaps slightly lower than that. Currently, the title and the very next center environment is pushed down to the bottom while all other paragraphs start from the next page.

\documentclass{article}
\usepackage[latin]{babel}
\usepackage{lipsum}

\begin{document}

\section{Introduction}

%%%%%%%%%% ABSTRACT %%%%%%%%%%
\clearpage

\vspace*{\fill}

\noindent {\Huge \bfseries Abstract \par}

\vspace{\baselineskip}
 
\begin{center}
    \MakeUppercase{TITLE EXAMPLE} \linebreak
    Subtitle \linebreak
    \MakeUppercase{Author} \linebreak
\end{center}

\vspace{\baselineskip}

\noindent
\lipsum[1-4]

\lipsum[5-8]

\lipsum[9-14]   % pushes abstract title down
% \lipsum[1-3]                                         % working

\vspace*{\fill}

\clearpage
Long abstract Short abstract
enter image description here enter image description here
6
  • \null and \vfill aren't really latex syntax \vspace*{\fill} adds space that is not dropped at start of page Commented Jan 7, 2022 at 18:16
  • ypu are allowing page breaks at all spaces, by default white space after a page break is dropped so you are left with just the \vfill at the top so the text is at the bottom of the page Commented Jan 7, 2022 at 18:18
  • @DavidCarlisle I am sorry but it's confusing. I can't understand it. If I allow for page breaks at all spaces, why does it not break right after the title "Abstract"? There is also space right before a title group, which is where it should place a page break. Thanks
    – Celdor
    Commented Jan 7, 2022 at 18:48
  • Also, I understand I probably can't do much but either add \vspace*{\fill} if the abstract is short or remove it if it's long. I was wondering if it's possible to somehow estimate the content would take more than a page.
    – Celdor
    Commented Jan 7, 2022 at 18:50
  • latex normally handles page breaks around headings but this is just set with a font change, not any normal heading control. But don't you just want to always vertically centre the first page? if the text is longer than the page then it will naturally go from top to bottom anyway so centre or top alignment is the same thing Commented Jan 7, 2022 at 19:27

2 Answers 2

1

As far as I can see you want ragged bottom on all pages except page 2 which should be centred, so

Short

enter image description here

Long

enter image description here

\documentclass{article}
\usepackage[latin]{babel}
\usepackage{lipsum}

\begin{document}

\section{Introduction}

%%%%%%%%%% ABSTRACT %%%%%%%%%%
\clearpage

\makeatletter
\def\@texttop{%
    \ifnum\value{page}=2 \vfill \fi}
\def\@textbottom{\vfill}
\makeatother

\noindent {\Huge \bfseries Abstract \par}

\vspace{\baselineskip}
 
\begin{center}
    \MakeUppercase{TITLE EXAMPLE} \linebreak
    Subtitle \linebreak
    \MakeUppercase{Author} \linebreak
\end{center}

\vspace{\baselineskip}

\noindent
\lipsum[1]

\lipsum[5-8]

%\lipsum[9-14]   % pushes abstract title down
%\lipsum[1-3]                                         % working



\end{document}
6
  • Thanks for the working example. I would rather say ragged bottom on all pages except page 2 in this environment. All other pages should probably be handled normally by LaTeX.
    – Celdor
    Commented Jan 8, 2022 at 11:12
  • @Celdor "normally" depends on the document class, you used single column article class which uses raggedbottom by default (with exactly the \@textbottom value that I used here) Commented Jan 8, 2022 at 11:17
  • I can see many times that kinds of things require knowledge of more primitive or internal commands of LaTeX. What position would you suggest? I read some suggested "The LaTeX Companion, 2nd edition (TTCT series)" The LaTeX Project
    – Celdor
    Commented Jan 8, 2022 at 11:18
  • 1
    \@texttop and \@textbottom are not normally accessed directly but are used in \raggedbottom and \flushbottom (latex doesn't have a vertically centred page by default, except on float pages, which is why I had to drop this level) texdoc source2e gives documented latex sources. Commented Jan 8, 2022 at 11:21
  • I should have changed that to "report". I am sorry, I did not realise that would be important. How can I know if ragged bottom or anything else is also used for the report?
    – Celdor
    Commented Jan 8, 2022 at 11:22
0

I may be wrong (I have been known to err in the past) but I don't see any simple way to automatically change the page layout depending on the length of a text.

I suggest you define two abstract environments for long and short abstracts.

% abstractprob.tex  SE 629406

\documentclass{article}
\usepackage[latin]{babel}
\usepackage{lipsum}

\newenvironment{shortabstract}{\mbox{}\vfill}{\vfill\mbox{}}
\newenvironment{longabstract}{}{}

\begin{document}

\section{Introduction}

%%%%%%%%%% ABSTRACTS %%%%%%%%%%
\clearpage

\begin{longabstract}
\noindent {\Huge \bfseries Long Abstract \par}

\vspace{\baselineskip}
 
\begin{center}
    \MakeUppercase{TITLE EXAMPLE} \linebreak
    Subtitle \linebreak
    \MakeUppercase{Author} \linebreak
\end{center}

    \vspace{\baselineskip}

\noindent
\lipsum[1-4] \par \lipsum[5-8] \par \lipsum[9-14]   % pushes abstract title down

\end{longabstract}
\clearpage

\begin{shortabstract}

\noindent {\Huge \bfseries Short Abstract \par}

\vspace{\baselineskip}
 
\begin{center}
    \MakeUppercase{TITLE EXAMPLE} \linebreak
    Subtitle \linebreak
    \MakeUppercase{Author} \linebreak
\end{center}

    \vspace{\baselineskip}

\noindent

 \lipsum[1-2] 

 \end{shortabstract}

\clearpage

\section{First section}

\end{document}

In your final document it would then be easy to change between long and short abstracts by using the different environments.

BTW. I don't know why but I have always used \mbox{} and not \null but above you can swap them.

3
  • \mbox{} and \null will have different effects, \mbox makes a paragraph so will produce a box the width of the page and aligned on baseline, \null is just \hbox{} so will make a zero width zero height box. Commented Jan 8, 2022 at 11:19
  • I thought I'd make two separate environments but David came with a solution. Thanks for the answer.
    – Celdor
    Commented Jan 8, 2022 at 12:24
  • @DavidCarlisle Thank you for pointing out the difference between \mbox{} and \null. I think that in my contexts the difference is too subtle to be noted in the final document, but perhaps that is an err. Commented Jan 8, 2022 at 18:26

You must log in to answer this question.

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