1

I would like to have each chapter precis be ragged right, but would like the text block itself to be centered. So, a short chapter precis would appear to be centered, but as soon as the lines start wrapping, then it would become clear that the text is actually ragged right.

Apart from that, I'm quite content with the look of memoir's chapter precises and for full-length chapter precises, I would like for them to look exactly alike.

My first thought has been to use a centered tabulary environment, but I can't seem to get it to compile.

Attempt 1

\documentclass[oneside, 11pt]{memoir}
\usepackage{showframe}
\usepackage{tabulary}
\chapterstyle{dash}
\renewcommand{\prechapterprecis}{%
  \vspace*{\prechapterprecisshift}%
  \begingroup\centering\precisfont\begin{tabulary}{0.75\linewidth}{@{}L@{}}}
\renewcommand{\postchapterprecis}{\end{tabulary}\endgroup}
\begin{document}
  \chapter{A chapter}
  \chapterprecishere{
    A short text
  }
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  \chapter{Another chapter}
  \chapterprecishere{
    A longer text that should be long enough to wrap and to ensure that it keeps going a little bit
  }
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}

Attempt 2

\documentclass[oneside, 11pt]{memoir}
\usepackage{showframe}
\usepackage{tabulary}
\chapterstyle{dash}
\renewcommand{\chapterprecishere}[1]{%
  \vspace*{\prechapterprecisshift}%
  \begingroup\centering\precisfont\begin{tabulary}{0.75\linewidth}{@{}L@{}}}%
  #1\end{tabulary}\endgroup%
}
\begin{document}
  \chapter{A chapter}
  \chapterprecishere{
    A short text
  }
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  \chapter{Another chapter}
  \chapterprecishere{
    A longer text that should be long enough to wrap and to ensure that it keeps going a little bit
  }
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}

1 Answer 1

2

I would use the varwidth package which allows you to set text in a box that matches its natural width up to a preset maximum. Here's a version that does what you want.

\documentclass[oneside, 11pt]{memoir}
\usepackage{showframe}
\usepackage{varwidth}
\chapterstyle{dash}
\renewcommand{\prechapterprecis}{%
  \vspace*{\prechapterprecisshift}%
  \begin{quote}%
  \centering%
  \begin{varwidth}{\linewidth}
  %Uncomment the next line if you have multiple paragraphs
  %in the precis
  %\parskip\parsep% 
  \precisfont}
\renewcommand{\postchapterprecis}{\end{varwidth}\end{quote}}
\begin{document}
  \chapter{A chapter}
  \chapterprecishere{
    A short text
  }
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  \chapter{Another chapter}
  \chapterprecishere{
    A longer text that should be long enough to wrap and to ensure that it keeps going a little bit
  }
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}

chapter 1 image chapter 2 image

9
  • This looks really good, but with this solution the chapters’ first paragraph is indented… Is there some way to avoid this?
    – Fredrik P
    Aug 31, 2023 at 21:47
  • @FredrikP I've updated the answer. Looking back at the memoir original definitions, it uses the quote environment, so we can just insert the varwidth box + \centering inside that.
    – Alan Munn
    Sep 1, 2023 at 1:27
  • Good idea! It fixed having to copy the width of the quote environment by some other means. However, it didn't solve the indent in the first paragraph. I've suggested an edit that fixes this (by adding \usepackage{noindentafter} and \NoIndentAfterCmd{\chapterprecishere} in the preamble). The only remaining issue I can see is that the varwidth environment seems to have a different the vertical space between paragraphs (\parskip?) than the quote environment. (Admittedly, it wasn't clear that this was needed in my example code.)
    – Fredrik P
    Sep 1, 2023 at 8:32
  • I added a fix to the vertical space between paragraphs in my edit
    – Fredrik P
    Sep 1, 2023 at 9:23
  • The code I posted did not have an indent before the first paragraph, so your indent fix is not needed. The varwidth package does nothing with the value of \parskip.
    – Alan Munn
    Sep 1, 2023 at 12:23

You must log in to answer this question.

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