8

Here's a minimal LaTeX document that shows (describes) what I'll like to achieve: zero-width parindent after a chapter or section title (which happens), a little parindent for a subsequent paragraph in the same section (which happens too), but no/zero parindent after a visual separator like a dinkus or a blank line. Those separators make a positive parindent unnecessary, and not nice to look at.

I tried several things in the commands for \dinkus and \blank, but with no result. And since the body of the body is supplied as Markdown, I don't want to include parindent commands in the document source. I guess (or hope) that the solution can be applied to the \dinkus and \blank commands, and not to the body.

(To distinguish between my description and the lorem ipsum text, I'm marking the latter as italic. That's all.)

\documentclass[]{memoir}

\usepackage{lipsum}
\usepackage{parskip}

% Page style.
\pagestyle{plain}
\setlrmarginsandblock{1.5in}{1.5in}{*} % FIX Fore-edge and spine margins equal (especially for B5 page size).
\setulmarginsandblock{1in}{1in}{*} % FIX Make top and bottom margin larger (especially for B5 page size).
\checkandfixthelayout

% Chapter style.
\chapterstyle{section}

% Create command to insert dinkus on request: * * *.
\newcommand{\dinkus}{
  \vspace{0.5\baselineskip}
  \begin{center}
  {{*\hspace{0.5em}*\hspace{0.5em}*}} % Dinkus to end section.
  \end{center}
  \vspace{0\baselineskip}

  %Insert some `parindent` magic here?
}

% Create command to insert blank line on request.
\newcommand{\blank}{
  \vspace{2.0\baselineskip}

  %Insert similar `parindent` magic here?
}

% Paragraph indenting.
% For stories, make skip less.
\setlength{\parskip}{0\baselineskip}
% For stories, theres no parskip, so a parindent is appropriate.
\setlength{\parindent}{1em}

% Begin of document.
\begin{document}

\chapter{Pay attention to parindents}

This paragraph has zero parindent because it is the
first after a chapter title.
\emph{\lipsum[1][1-3]}

This section has a parindent of 1em, as is common for
novels: no or limited parskip but a parindent to show
a new paragraph started.
\emph{\lipsum[1][1-3]}

\section{Wish: no parindents after a dinkus}

This paragraph does not have parindent since it is the
first after a section title. Fine.
\emph{\lipsum[2][1-3]}

\dinkus

But then, after a dinkus separator, Id like to see no
parindent because the new paragraph start does not need 
to be visually separated; it started after a clear separator.
\emph{\lipsum[3][1-3]}

That this paragraph has a parindent is okay, to show that
a new paragrpah started.
\emph{\lipsum[3][1-3]}

\section{And: no parindents after a blank line}

Again, this paragraph has a zero parindent. Great.
\emph{\lipsum[4][1-3]}

This paragraph has a 1em parindent, to visually separate
it from the previous one. Nice.
\emph{\lipsum[5][1-3]}

\blank

But then, after a blank line, again no parindent is necessary.
\emph{\lipsum[6][1-3]}

\end{document}

2 Answers 2

8

You can use the same mechanism as \chapter and \section, that is, \@afterheading.

\documentclass[]{memoir}

\usepackage{lipsum}

% Page style.
\pagestyle{plain}
\setlrmarginsandblock{1.5in}{1.5in}{*}
\setulmarginsandblock{1in}{1in}{*}
\checkandfixthelayout

% Chapter style.
\chapterstyle{section}

\makeatletter
% Create command to insert dinkus on request: * * *.
\newcommand{\dinkus}{% <--- IMPORTANT
  \par\nopagebreak\nointerlineskip
  \vspace{\baselineskip}%
  \noindent\makebox[\columnwidth]{$*$\enspace$*$\enspace$*$}% Dinkus to end section.
  \par\nointerlineskip\vspace{\baselineskip}%
  \@afterindentfalse\@afterheading % <---
}

% Create command to insert blank line on request.
\newcommand{\blank}{% <--- IMPORTANT
  \vspace{2.0\baselineskip}%
  \@afterindentfalse\@afterheading % <---
}
\makeatother

\begin{document}

\chapter{Pay attention to parindents}

This paragraph has zero parindent because it is the
first after a chapter title.
\emph{\lipsum[1][1-3]}

This section has a parindent of 1em, as is common for
novels: no or limited parskip but a parindent to show
a new paragraph started.
\emph{\lipsum[1][1-3]}

\section{Wish: no parindents after a dinkus}

This paragraph does not have parindent since it is the
first after a section title. Fine.
\emph{\lipsum[2][1-3]}

\dinkus

But then, after a dinkus separator, Id like to see no
parindent because the new paragraph start does not need 
to be visually separated; it started after a clear separator.
\emph{\lipsum[3][1-3]}

That this paragraph has a parindent is okay, to show that
a new paragrpah started.
\emph{\lipsum[3][1-3]}

\section{And: no parindents after a blank line}

Again, this paragraph has a zero parindent. Great.
\emph{\lipsum[4][1-3]}

This paragraph has a 1em parindent, to visually separate
it from the previous one. Nice.
\emph{\lipsum[5][1-3]}

\blank

But then, after a blank line, again no parindent is necessary.
\emph{\lipsum[6][1-3]}

\end{document}

I made some fixes to the definition of \dinkus and \blank. In the first case I used the math asterisk, which is centered on its line and also \nointerlineskip in order to better control the spacing above and below. Also \nopagebreak is important or you could have the \dinkus at the start of a new page (would you like it?).

Don't load parskip with memoir: the class has its own methods for emulating it.

enter image description here

3
  • 1
    Is the internal bool @afterindent always false? This boolean triggers the \lastbox to remove the indentation box. IMHO it is possible that the boolean is set to true if some of the sectioning commands will be defined in a way that the first paragraph can be indented. Therefore it is needed to set \@afterindentfalse before \@afterheading. Jan 9, 2023 at 10:47
  • 1
    @BerndRaichle Right.
    – egreg
    Jan 9, 2023 at 10:57
  • 1
    Great, exactly what I wanted. Thanks for the quick answer. (I guess you don't need it for your stellar reputation, but I accepted the answer :-)) Jan 9, 2023 at 13:00
4

LaTeX already has a similar mechanism for sectioning commands. These can be defined in such a way that the following paragraph starts with no indentation (see internal command \@startsection, if its afterskip argument value is negative the following paragraph starts without indentation).

Internally the macro \@afterheading is used in conjunction with a boolean @afterindent which needs to be set to false to suppress the indentation.

Add the following (it uses internal commands, thus either move everything into a .sty file or surround it with make at letter/other commands):

\newcommand{\suppressfollowingindent}{%
  \par  %\nobreak  % uncomment \nobreak to avoid a page break
  \@afterindentfalse
  \@afterheading
}

and add this new command where your "parindent magic" is.

1
  • Thanks for the useful explanation on the internal logic behind. Jan 9, 2023 at 13:01

You must log in to answer this question.

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