16

I've constated that I can use tikzpicture even if I comment \usepackage{tikz} out, as long as I keep \usepackage{pgfplots}. Isn't tikzpicture provided by package tikz? In which situation should I load both pgfplots and tikz?

2
  • 2
    Package pgfplots is based on tikz package. When you load it, it also load tikz. Actually it (simplified said) different axis environments to tikzpicture and simple and rich possibilities to draw graphs.
    – Zarko
    Jan 4, 2016 at 14:10
  • 3
    I'm guessing pgfplots is specialty use of tikz+pgf, thus it loads tikz. There is nothing wrong in loading both as latex make sure you do not accidentally loading, say, tikz twice
    – daleif
    Jan 4, 2016 at 14:12

1 Answer 1

18

You can in a nutshell imagine that when you write \usepackage{pgfplots} some code in the pgfplots uses the equivalent of \usepackage{tikz} for you. TikZ also has other packages that it depends on (graphicx,xcolor,atbegshi and more) and it requires for you too. So you don't need to add those again.

If you load even only pgfplotstable it loads pgfplots, TikZ and hence xcolor, graphicx and so on many packages. LaTeX has an internal consistency check whether some package is already loaded or not. Hence requesting it twice wouldn't cause any harm (as long as there are no option clashes)

I usually add pgfplotstable to load all the relevant gang with minimal code.

pgfplots is written by one of the TikZ developers, Christian Feuersanger. However pgfplots development is independent from TikZ with certain libraries being synced such as fpu.

1
  • 6
    Although you have the TikZ manual burned into your brain, I find it helpful explicitly load the packages I use even if other packages load them as well. It's the best reminder of which documentation to look at when something goes wrong.
    – Alan Munn
    Jan 4, 2016 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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