Vincent Pit


LaTeX::TikZ::Formatter - LaTeX::TikZ formatter object.


Version 0.02


A formatter object turns a LaTeX::TikZ::Set tree into the actual TikZ code, depending on some parameters such as the scale, the unit or the origin.



The unit in which lengths are printed. Valid units are cm for centimeters and pt for points.

Defaults to cm.


The format used to print the numbers.

Defaults to %s.


The scale of the drawing.

Defaults to 1.


The width of the drawing area.

Defaults to undef for none.


The height of the drawing area.

Defaults to undef for none.


A point coerced into a LaTeX::TikZ::Point object that represents the logical origin of the printed area. If "width" and "height" are set, the canvas will be equivalent to a rectangle whose lower left corner at -$origin and of given width and length.

Defaults to (0, 0), meaning that the drawing area goes from (0, 0) to ($width, $height).



An unique identifier of the formatter object.

render @sets

Processes all the LaTeX::TikZ::Set objects given in @sets to produce the actual TikZ code to insert in the LaTeX file. First, all the mods applied to the sets and their subsets are collected, and a declaration is emitted if needed for each of them by calling "declare" in LaTeX::TikZ::Mod. Then, the image code is generated for each set.

This method returns a list of array references :

  • The first one contains the header lines to include between the \documentclass and the \begin{document}.

  • The second one contains the mod declaration lines to put inside the document, between \begin{document} and \end{document}.

  • Finally, there's one array reference for each given TikZ set, which contain the lines for the actual TikZ pictures.

The lines returned by "render" don't end with a line feed.

    my ($header, $declarations, $set1_body, $set2_body) = $formatter->render($set1, $set2);

    open my $tex, '>', 'test.tex' or die "open('>test.tex'): $!";

    print $tex "$_\n" for (
      "First set :"
      "Second set :"

len $len

Format the given length according to the formatter options.

angle $theta

Format the given angle (in radians) according to the formatter options.

label $name, $pos

Returns the TikZ code for a point labeled $name at position $pos according to the formatter options.


Format the given line thickness according to the formatter options.




Vincent Pit, <perl at>,

You can contact me by mail or on (vincent).


Please report any bugs or feature requests to bug-latex-tikz at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc LaTeX::TikZ


Copyright 2010 Vincent Pit, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.