3

After getting the solution to my first problem thanks to egreg, I have came across the second one: very often I am in a situation when I want that the center environment is glued (no page break) to the trailing text, something like that:

\begin{center}
\begin{tikzpicture}
some commands
\end{tikzpicture}
\end{center}
%
Some text

Is it possible to make a general solution for that, for example defining new environment based on center or completely new environment to do the task?

Thanks for answers!

Pygmalion
  • 6,387
  • 4
  • 34
  • 68

1 Answers1

3

Use \samepage{...}.

\samepage{%
\begin{center}
\begin{tikzpicture}
some commands
\end{tikzpicture}
\end{center}
%
Some text%
}% end of \samepage

If Some text itself should be allowed to break across pages, replace the center environment and use \nopagebreak.

{\centering
 \begin{tikzpicture}
 some commands
 \end{tikzpicture}%
 \par
}\nopagebreak
%
Some text
gernot
  • 49,614