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!

  • What do you mean with glued to the following text? To avoid the paragraph break if you leave an empty line? – Johannes_B Jul 23 '18 at 15:06
  • @Johannes_B To avoid PAGE break. – Pygmalion Jul 23 '18 at 15:07
  • 1
    Have you ever heard of the \nopagebreak macro? – Johannes_B Jul 23 '18 at 15:09
  • The center environment probably allows a page break anyway, i would need to check. – Johannes_B Jul 23 '18 at 15:09
  • @Johannes_B I've tried that already, doesn't help. – Pygmalion Jul 23 '18 at 15:10
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
  • 1
    +1 ... but now I have to run ;-) – user121799 Jul 23 '18 at 15:26
  • 1
    @marmot oh! Run my little marmot, runnnnnn! – manooooh Jul 23 '18 at 15:30
  • 1
    @marmot Nothing to fear: "The Yeti [...] sees a marmot, grabs the hapless creature, and then sits on it—saving the delicious morsel for later. And then the Yeti sees another marmot and leaps up to snatch it while the first marmot makes a quick break for freedom. An image of bumbling, foolish effort." – gernot says Reinstate Monica Jul 23 '18 at 15:35
  • Mhm, it is alright, actually necessary, to split the following paragraph. Is there any other solution? – Pygmalion Jul 23 '18 at 15:35
  • @Pygmalion See updated solution – gernot says Reinstate Monica Jul 23 '18 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.