13

I want to define an abstract environment for \documentclass{book}. Therefore, I copied the relevant definitions from report.cls from here into my preamble. But it doesn't work. Where's the problem?

\documentclass[11pt, a4paper]{book}

\usepackage{lipsum}

\makeatletter
\if@titlepage
  \newenvironment{abstract}{%
      \titlepage
      \null\vfil
      \@beginparpenalty\@lowpenalty
      \begin{center}%
        \bfseries \abstractname
        \@endparpenalty\@M
      \end{center}}%
     {\par\vfil\null\endtitlepage}
\else
  \newenvironment{abstract}{%
      \if@twocolumn
        \section*{\abstractname}%
      \else
        \small
        \begin{center}%
          {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
        \end{center}%
        \quotation
      \fi}
      {\if@twocolumn\else\endquotation\fi}
\fi
\makeatother

\begin{document}

\begin{titlepage}
\begin{abstract}
  \lipsum[1]
\end{abstract}
\end{titlepage}

\chapter{This and That}

\lipsum[2]

\end{document}

I know there are lot's of solutions on the web on how to write abstracts in the book class. I am mainly interested in the question why my solution of defining the environment technically doesn't work.

14

You are using \abstractname in the environment, but latex does not know it. This is the error you got. Hence defining it solves the issue. You have to define \abstractname by

\newcommand\abstractname{Abstract}

Your MWE becomes:

\documentclass[11pt, a4paper]{book}

\usepackage{lipsum}
\newcommand\abstractname{Abstract}  %%% here
\makeatletter
\if@titlepage
  \newenvironment{abstract}{%
      \titlepage
      \null\vfil
      \@beginparpenalty\@lowpenalty
      \begin{center}%
        \bfseries \abstractname
        \@endparpenalty\@M
      \end{center}}%
     {\par\vfil\null\endtitlepage}
\else
  \newenvironment{abstract}{%
      \if@twocolumn
        \section*{\abstractname}%
      \else
        \small
        \begin{center}%
          {\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
        \end{center}%
        \quotation
      \fi}
      {\if@twocolumn\else\endquotation\fi}
\fi
\makeatother

\begin{document}

\begin{titlepage}
\begin{abstract}
  \lipsum[1]
\end{abstract}
\end{titlepage}

\chapter{This and That}

\lipsum[2]

\end{document}
  • Thanks. Could you provide a short explanation why this is necessary? – lpdbw Aug 22 '12 at 13:03
  • 1
    @lpdbw: You are using \abstractname in the environment, but latex does not know it. This is the error you got. Hence defining it solves the issue. – user11232 Aug 22 '12 at 13:05
  • 1
    You could just have used the memoir class instead, it is book-like and provide an abstract environment – daleif Aug 22 '12 at 13:14
  • Thanks for the solution, Harish! Unfortunately, as the title page, abstract and the ToC appear only on odd-numbered pages when using the book document class, there are two blank pages surrounding the abstract. This would be no problem if they didn't carry the same page number (namely 2 instead of 2 and 4). Is there any way to correct this? – balu Aug 8 '15 at 15:23
  • 1
    @balu: Use openany in the option for book\documentclass[openany]{book} – user11232 Aug 8 '15 at 17:31
0
\newenvironment{abstract}[1]{%
\begin{center}\normalfont\textbf{Abstract}\end{center}
\begin{quotation} #1 \end{quotation}
}{%
\vspace{1cm}
}

works for me reasonably well. Simply call with \abstract{}.

screen shot of example output

  • Please as usual here make your given code snippet compilable for a fast proof. Can you please also add your result as screenshot to your answer? – Mensch Aug 19 at 19:25

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.