A TikzPicture can contain multiple Axis-like objects.

TikzPicture([options], contents...)

Corresponds to a tikzpicture block in PGFPlots.

Elements can also be added with push! after construction.



julia> tp = @pgf TikzPicture({ "scale" => 1.5 }, Axis(Plot(Coordinates([1, 2], [2, 4]))));

julia> print_tex(tp)
        coordinates {


A TikzDocument is the highest level object and represents a whole tex file. It includes a list of objects between \begin{document} and \end{document}.

TikzDocument(elements...; use_default_preamble = true, preamble = [])

Corresponds to a LaTeX document, usually wrapping TikzPictures.

use_default_preamble determines whether a preamble is added from the global variables (see CUSTOM_PREAMBLE and CUSTOM_PREAMBLE_PATH).

preamble is appended after the default one (if any).

push! can be used to append elements after construction, and similarly push_preamble! for the preamble.


A very simple example where we simply create a TikzDocument with a string is shown below. Normally you would also push Axis-like objects that contain plots.

julia> td = TikzDocument();

julia> push!(td, "Hello World");

julia> print_tex(td)
% Default preamble
Hello World

A TikzDocument uses global variables to construct a preamble, and allows the user to add extra lines to this (eg in case you want to add \usepackage lines), or disable it altogether.


There is usually no need to explicitly create a TikzDocument or TikzPicture. Only do this if you want to give special options to them. It is possible to show or save an Axis or e.g. a Plot directly, and they will then be wrapped in the default "higher level" objects.