This question already has an answer here:

I am trying to center a graph made with pgfplots with \centering. If I put \centering within a group to limit its scope, the graph does not get centered. If I don't limit the scope of \centering, then everything gets centered.


This text should not be centered, but the graph should be.

% \begingroup
            \addplot coordinates { (0, 0) (1, 1)};
% \endgroup

This text should not be centered.

marked as duplicate by LaRiFaRi, David Carlisle horizontal-alignment Nov 27 '14 at 12:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • If you do not want to use a float (figure) here, which I would recommend, you should just wrap it in \begin{center}\end{center} – LaRiFaRi Nov 27 '14 at 12:19
  • Note that \begingroup is plain TeX. You could use {} as well. The \centering-command needs a paragraph in order to see the end of its use. If you add a blank line in front of \endgroup, you will succeed as well. – LaRiFaRi Nov 27 '14 at 12:25
  • @LaRiFaRi \begingroup is not necessarily Plain TeX. It's a primitive, but it's used everywhere. – Manuel Nov 27 '14 at 12:41

There is nothing special about tikzpicture here you would see the same with

{\centering X}

\centering works by setting the paragraph parameters, so if you close the group before the paragraph ends then nothing happens. You can use



To centre an X (or a tikzpicture). Or more naturally use


which also adds some vertical space.

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