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 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.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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}
share|improve this answer
    
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. –  Harish Kumar Aug 22 '12 at 13:05
    
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
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.