14

Indentation can be selectively suppressed using \noindent or completely with the option parindent=full to the KOMA document classes. Books (fiction) are usually structured using paragraphs, indented as the LaTeX default. Additionally, greater changes are indicated by an empty line that is followed by a non-indented paragraph, like the first one in a section.

Is there a possibility to insert such a line break into a LaTeX document or automatically omit indentation after empty lines?

1

3 Answers 3

15

First a variant of Werner's solution that allows empty lines after \changebreak:

\documentclass{scrreprt}
\usepackage{lipsum}

\makeatletter
\newcommand*{\changebreak}{%
  \par
  \vspace{\baselineskip}%
  \changebreak@skippar
}
\def\changebreak@skippar{%
  \@ifnextchar\par{%
    \expandafter\changebreak@skippar\@gobble
  }{%
    \noindent
    \ignorespaces
  }%
}
\makeatother

\begin{document}
\lipsum[1-3]
\changebreak
\lipsum[4-6]

\changebreak

\lipsum[7-9]
\end{document}

The detection of the empty line quickly fails if there is something inbetween, a macro definition, an assignment (but comments do not disturb).

LaTeX has the same problem for its section headers. There it uses macro \@afterheading that uses \everypar to get at the start of the next paragraph and undoes the paragraph indent with a \lastbox trick, because the paragraph indent is set as box. \@afterindentfalse tells the macro \@afterheading that the indent at the next paragraph is not wanted. The other task of \@afterheading to keep the first two lines of the starting paragraph together is here also welcome.

\documentclass{scrreprt}
\usepackage{lipsum}

\makeatletter
\newcommand*{\changebreak}{%
  \par
  \vspace{\baselineskip}%
  \@afterindentfalse
  \@afterheading
}
\makeatother

\begin{document}
\lipsum[1-2]
\changebreak
\lipsum[3-4]

\changebreak

\lipsum[5-6]
\changebreak
\typeout{Last changebreak}

\lipsum[7-8]
\end{document}

For the case (probably not likely) that it should be avoided that the break hits a page break, then the following prevents a page break at the break. And if the previous paragraph is not yet finished, a last lonely line could also be forbidden. LaTeX's \@afterheading tries the same with the next two lines.

\documentclass{scrreprt}
\usepackage[nopar]{lipsum}
% Option `nopar' suppresses the
% paragraph ends in lipsum paragraphs

\makeatletter
\newcount\chgbrk@widowpenalty
\newcommand*{\changebreak}{%
  % If we are happy and the previous paragraph
  % is not yet finished, we can change
  % the widowpenalty to prevent a previous
  % lonely line.
  \chgbrk@widowpenalty\widowpenalty
  \widowpenalty\@M
  \par
  \widowpenalty\chgbrk@widowpenalty
  \nobreak
  \vspace{\baselineskip}%
  \@afterindentfalse
  \@afterheading
}
\makeatother

%\setlength{\textheight}{\baselineskip}% stress test

\begin{document}
\lipsum[1]

\lipsum[2]
\changebreak
\lipsum[3]

\lipsum[4]

\changebreak

\lipsum[5]

\lipsum[6]
\end{document}
10

I would suggest defining a command to do this, for two reasons:

  1. This might be done in an ad-hoc fashion; and
  2. LaTeX interprets an empty line as a paragraph break anyway, so it may be difficult to construct something that (say) counts the number of blank lines in order to produce a "change break".

My suggestion would be something like \changebreak that is similar to \bigskip:

enter image description here

\documentclass{scrreprt}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\def\changebreak{\par\vspace{\baselineskip}\noindent}
\showthe\baselineskip
\begin{document}
\lipsum[1-3]
\changebreak
\lipsum[4-10]
\end{document}

The traditional \bigskip inserts \bigskipamount which is fixed at 12pt plus 4pt minus 4pt. I've modified that to use \baselineskip since you're after an empty line. \noindent is automatically inserted to remove the indentation in the subsequent paragraph.

1

The memoir class (of course) offers a good selection of 'anonymous' breaks. The simplest, \plainbreak{<num>} produces a gap of <num> * \baselineskip and then suppresses indentation of the next line (while the starred version does indent the next line:

\newcommand{\fancybreak}{\@ifstar{\@sfbreak}{\@fbreak}}
\newcommand{\@fbreak}[1]{\par
  \penalty -100
  \noindent\parbox{\linewidth}{\centering #1}%%\null
  \par
  \@afterindentfalse
  \@afterheading}
\newcommand{\@sfbreak}[1]{\par
  \penalty -100
  \noindent\parbox{\linewidth}{\centering #1}%%\null
\par                                                 
  \@afterindenttrue
  \@afterheading}

There are several other related commands, some of these will print arbitrary symbols or text (\fancybreak), others will give a plain or fancy break depending on whether they appear near the top or bottom of a page (\plainfancybreak and \pfbreak). If you are interested, consult the memoir manual; and note that the code for these commands are easily 'lifted' from memoir.cls if you can't use memoir itself for some reason. (As the above example hopefully shows, although I did remove some comments.)

You must log in to answer this question.

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