1

I would like to make a command to separate some blocks of text with an horizontal line.

However I don't want the line to be drawn at the end (or begininng) of a page, since the page break is already separating the content. Also it would be nice to encourage page breaks to only occur at these places.

Is there some simple way to implement this?

Here is an example. I would like to prevent the lines at the beginning of the new pages.

\documentclass{article}
\usepackage{lipsum}

\newcommand{\mybreak}{

  \bigskip

  \pagebreak[3]
  \begin{center}
    --------------------------
  \end{center}

  \bigskip

}
\begin{document}

\lipsum[1-2]

\mybreak

\lipsum[1-2]

\mybreak

\lipsum[1-2]

\mybreak

\lipsum[1-2]

\mybreak

\lipsum[1-2]

\mybreak


\end{document}
  • For part of your problem, you can force the text not to break by putting it in a minipage, e.g., \xdef\svparindent{\the\parindent}, then \noindent\begin{minipage}{\textwidth}\parindent=\svparindent\relax\strut \lipsum[1]\par \lipsum[2] \strut\end{minipage} (use [nopar] option of lipsum) – Steven B. Segletes May 25 '17 at 12:01

1 Answers1

0

This approach to defining \mybreak seems to keep bars from appearing at page top and, by using the defined blocktext, text in minipages will likewise avoid breaking.

\documentclass{article}
\usepackage[nopar]{lipsum}

\newcommand{\mybreak}{\nobreak%
\noindent\begin{minipage}{\textwidth}
  \vspace*{2em}
  \begin{center}
    --------------------------
  \end{center}
  \vspace{1em}
  \end{minipage}\allowbreak%
}
\newenvironment{blocktext}{%
  \xdef\svparindent{\the\parindent}%
  \noindent\begin{minipage}{\textwidth}\parindent=\svparindent‌​\relax\strut%
  \ignorespaces%
}{\strut\end{minipage}}
\begin{document}

\begin{blocktext}
\lipsum[1]\par
\lipsum[2] 
\end{blocktext}

\mybreak

\begin{blocktext}
\lipsum[1]\par
\lipsum[2] 
\end{blocktext}

\mybreak

\begin{blocktext}
\lipsum[1]\par
\lipsum[2] 
\end{blocktext}

\mybreak

\begin{blocktext}
\lipsum[1]\par
\lipsum[2] 
\end{blocktext}

\mybreak

\begin{blocktext}
\lipsum[1]\par
\lipsum[2] 
\end{blocktext}

\mybreak
\end{document}