Possible Duplicate:
Should I use center or centering for figures and tables?

What is the correct way to cause a \tikzpicture to be centered? By default it appears to be aligned with the left margin.

  • I preffer to put \makeatletter \g@addto@macro\@floatboxreset\centering \makeatother in the preamble, so that every tikzpicture is centered =) Jul 7, 2012 at 10:52
  • 1
    @N3buchadnezzar Also covered in my answer to the linked question.
    – lockstep
    Jul 7, 2012 at 10:53
  • I know =) Exelent answer, that is why I posted it as a comment not as an answer. I guess this question can be closed as Jake said, it is a duplicate. Jul 7, 2012 at 10:55
  • 2
    Using adjustbox package: \begin{adjustbox}{center}\begin{tikzpicture}...\end{tikzpicture}\end{adjustbox} Jan 8, 2019 at 20:51

3 Answers 3

  • 2
    Hi, just want to share a sublety: I applied this solution and I got the following error: "There's no line here to end." I found the error was caused by using line-breaking (//) within an edge label. I just removed the line-breaking and all worked well.
    – FSp
    Feb 25, 2015 at 15:42
  • 4
    The figure environment doesn't just center the tikzpicture, it also adds a caption and some vertical spacing, which may not be desired.
    – PatrickT
    Feb 14, 2021 at 5:56

When the picture doesn't need to be put in a figure (i.e. when it doesn't need a caption), I use

  • 11
    In my case the picture is too wide, so it breaks the right margin. Is there a way to make it break the left and right margins equally? Oct 24, 2013 at 14:14

\hbox to \hsize{\hfil{Anything}\hfil}

Not the answer you're looking for? Browse other questions tagged .