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!
\nopagebreakmacro? – Johannes_B Jul 23 '18 at 15:09centerenvironment probably allows a page break anyway, i would need to check. – Johannes_B Jul 23 '18 at 15:09