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.

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?

share|improve this question
    
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Dec 8 '13 at 18:52
add comment

3 Answers

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}
share|improve this answer
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
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.