# Center alignment of tikzpicture outside figure environment without vertical space [duplicate]

How to align tikzpicture outside figure environment without introducing vertical space? I'm aware of related questions, such as What is the correct way to center a \tikzpicture? and Should I use center or centering for figures and tables?. From there I notice that the following code:

\begin{center}
\begin{tikzpicture}
....
\end{tikzpicture}
\end{center}


does the center alignment of the tikzpicture as desired but it introduces unwanted vertical space. I tried to simply replace the \begin{center} \end{center} pair with \begin{centering} \end{centering}, but it doesn't work.

-

## marked as duplicate by egreg, Stefan Kottwitz♦Feb 22 '13 at 18:42

–  Claudio Fiandrino Feb 22 '13 at 15:21
\begin{center} is fine, what the links said was not to use \begin{center} if you're also using \begin{figure} –  Jake Feb 22 '13 at 15:21
@Jake Ya, \begin{center} is fine except that it introduce vertical spaces which I do not want. –  Indra Yudhistira Feb 22 '13 at 15:32
@egreg Thanks. I overlook that thread. Your answer in that questions also works well for my case. –  Indra Yudhistira Feb 22 '13 at 17:33

\centering is not intended to be an environment.

Just use

{\centering
\begin{tikz....

\end{tikz...}

}


and make sure that a blank line or end of the current environment is in scope of the declaration. You probably ended \end{centering} immediately after \end{tikzpicture} which would have finished centering before the paragraph finished, with the effect that the centering was ignored as TeX only consults line breaking parameters at the end of the paragraph and applies them to the whole paragraph.

-
But since the tikzpicture is outside figure environment, \centering would make all things below this command aligned center as well. Is there any way to avoid this? –  Indra Yudhistira Feb 22 '13 at 15:30
Unfortunately it doesn't work. Even a code as simple as {\centering sometexts} doesn't work. –  Indra Yudhistira Feb 22 '13 at 17:24
have you a blank line before the } it will not work if you go {\centering sometexts} for the reasons I give in the answer. –  David Carlisle Feb 22 '13 at 17:25
You mean {\centering sometexts } ? It doesn't work either. Sorry if I misunderstand what you mean correctly here. –  Indra Yudhistira Feb 22 '13 at 17:43
As always you should post a complete small document from \documentclass to \end{document} if \centering works but makes the whole document centered then {\centering stuff blank-line} will center just the stuff between { and } –  David Carlisle Feb 22 '13 at 18:36