# Center every tikzpicture environment

I want every tikzpicture to be centered in my document but want to be able to deactivate this feature locally. For example:

%Pseudocode...
\documentclass{article}
\begin{document}

\usepackage{tikz}
\tikzset{
thalign=center
}

\begin{document}

\begin{tikzpicture}
%%Centered - should be equivalent to a normal tikzpicture enclosed in a center environment
\draw (0,0) circle (1cm);
\end{tikzpicture}

\begin{tikzpicture}[thalign=left]
%%Not centered
\draw (0,0) circle (1cm);
\end{tikzpicture}

\end{document}


How can I to this?

In particular I am interested of how to do it with keys as in my pseudocode above.

I would define a new environment using the answer of What is the correct way to center a \tikzpicture?:

\documentclass{article}

\usepackage{tikz}

\newenvironment{ctikzpicture}
{\begin{center}\begin{tikzpicture}}
{\end{tikzpicture}\end{center}}

\begin{document}

\begin{ctikzpicture}
\draw (0,0) circle (1cm);
\end{ctikzpicture}

\begin{tikzpicture}
\draw (0,0) circle (1cm);
\end{tikzpicture}

\end{document}


You can include the centered desired figure inside a centered paragraph: {\par\centering...\par} and leave the others as usual.

\documentclass{article}
\usepackage{tikz}

\begin{document}

{\par\centering
\begin{tikzpicture}
%%Centered - should be equivalent to a normal tikzpicture enclosed in a center environment
\draw (0,0) circle (1cm);
\end{tikzpicture}\par}

\begin{tikzpicture}
%%Not centered
\draw (0,0) circle (1cm);
\end{tikzpicture}

\end{document}


• That's clear, but doesn't answer my question. The point is that I want a global key as described in my pseudocode above. hzhr's answer does (almost) what I want, but without a key syntax. – Julia May 11 '17 at 14:42
• That key doesn't exist. A tikzpicture is like any other character. How do you force 'a' to be in the center of a line? – Ignasi May 11 '17 at 20:02
• @Maybe it could be implemented with a pre and post environment hook... – Julia May 12 '17 at 5:32