2

Is there a way to add a small paragraph (a sort of abstract) at the beginning of every \part, in the book class ? i know that there are numerous way to do that with scrreprt class, but I need to keep my book class... If possible, I would like to have this paragraph on the same page as the part title one.

Thank you in advance for your answers

Brice

5
  • The book.cls does not have abstract at all. With some modification it is possible to use the article version of abstract and 'inject' it into \part
    – user31729
    Feb 9, 2017 at 17:05
  • Thank you for your answer. Do you know if there is a way to do something "manually", if there is no command for that ?
    – Brice
    Feb 9, 2017 at 17:07
  • 1
    KOMA-Script classes provide preambles for \part. So can use something like \setpartpreamble{\begin{quote}Blabla\end{quote}}. Feb 9, 2017 at 17:19
  • Sorry, but I specified that I have to keep my book class...
    – Brice
    Feb 9, 2017 at 17:22
  • scrbook is a book class and you don't have specified a class. This is one reason for the MWE that you always should add to the question and for correct markdown. BTW: scrbook has an option to emulate standard class book. Feb 9, 2017 at 17:25

3 Answers 3

3

You can define a partwithabstract environment:

\documentclass[oneside]{book}

\usepackage{xpatch}

\makeatletter
\xpatchcmd{\part}{\null\vfil}{\vspace*{.1\textheight}}{}{}

\providecommand{\abstractname}{Abstract}
\newenvironment{partwithabstract}
  {\begingroup\let\@endpart\relax\part@withabstract}
  {\endquotation\endgroup\@endpart}
\newcommand{\part@withabstract}{\@dblarg\part@@withabstract}
\def\part@@withabstract[#1]#2{%
  \part[#1]{#2}%
  \vfil
  \begin{center}\bfseries\abstractname\vspace{-.5em}\vspace{\z@}\end{center}
  \quotation
}
\makeatother

\usepackage{lipsum}

\begin{document}

\tableofcontents

\begin{partwithabstract}{First Part}
\lipsum[1-2]
\end{partwithabstract}

\begin{partwithabstract}[Second for the TOC]{Second Part}
\lipsum[2]
\end{partwithabstract}

\end{document}

enter image description here

The main change is that the title is set at a fixed height from the top; the abstract is vertically centered in the remaining space (it's your responsibility to make it fit).

If you change \vfil into \vfill in the definition of \part@@withabstract, that is, do

\def\part@@withabstract[#1]#2{%
  \part[#1]{#2}%
  \vfill
  \begin{center}\bfseries\abstractname\vspace{-.5em}\vspace{\z@}\end{center}
  \quotation
}

the abstract will be flush with the bottom margin.

enter image description here

You can remove the \abstractname related bit, if you so prefer: the code to remove is

  \begin{center}\bfseries\abstractname\vspace{-.5em}\vspace{\z@}\end{center}

Technical note I used oneside just for showing the two part pages side by side.

2
  • This patch seems to cause a hiccup in a two column book. If I use this environment between \mainmatter and the first chapter, the rest of the book defaults to single column. However, if I use this environment between chapter one and chapter two, all seems well. Would have a guess as to what causes this?
    – user45054
    Apr 24, 2018 at 21:20
  • @Robert I don't think this is going to work as is for two column format to begin with.
    – egreg
    Apr 24, 2018 at 21:30
2

I've copied abstract definition from article class and changed it slightly, also defining \abstractname.

In addition, there's a command \injectabstract which comes into action right before \@endpart, i.e. after the title of the part has been typeset.

\injectabstract checks whether \@localabstract is defined and typesets the abstract accordingly or does nothing, if it is not defined.

\localabstract is a wrapper command that is meant to store the content for the next abstract.

For each part that should have such an abstract use \localabstract with the relevant content.

\documentclass[notitlepage]{book}

\usepackage{xpatch}

\makeatletter

\newcommand{\abstractname}{Abstract}
\if@titlepage
\newenvironment{abstract}{%
  \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

\newcommand{\localabstract}[1]{%
  \def\@localabstract{#1}%
}

\newcommand{\injectabstract}{%
  \@ifundefined{@localabstract}{%
  }{%
    \begin{abstract}
      \@localabstract%
  \end{abstract}%
  }
  \let\@localabstract\relax%
}

\xpretocmd{\@endpart}{%
  \injectabstract\par%
}{}{}

\makeatother

\usepackage{blindtext}

\begin{document}
\localabstract{\blindtext}
\part{Foo}

\part{Foobar}
\end{document}

enter image description here

2

Very simple:

\documentclass{book}
\usepackage{xpatch}
\makeatletter
\xpretocmd{\@endpart}{%
  \ifx\@abstract\@empty\else
    \bigskip
    \begin{quote}\@abstract\end{quote}
    \global\let\@abstract\@empty
  \fi
}{}{}
\newcommand{\partabstract}[1]{%
  \renewcommand{\@abstract}{#1}%
}
\newcommand{\@abstract}{}
\makeatother
\usepackage{lipsum}

\begin{document}
\partabstract{\lipsum[1-2]}
\part{First Part}

\chapter{First Chapter}
\lipsum

\partabstract{\lipsum[3]}
\part{Second Part}

\chapter{Second Chapter}
\lipsum

\part{Third Part}
\chapter{Third Chapter}
\lipsum

\end{document}
2
  • This work perfectly, thank you very much ! ( I don't know how to edit my topic as "answered"...)
    – Brice
    Feb 9, 2017 at 17:53
  • @Brice Just click to the check mark left beside one of the answers to accept this answer and mark your question as answered. Additionally you can click at the up-vote mark above the number left beside every answer you like. See the tour for more information. Feb 9, 2017 at 17: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.