+The first one contains the header lines to include between the C<\documentclass> and the C<\begin{document}>.
+
+=item *
+
+The second one contains the mod declaration lines to put inside the document, between C<\begin{document}> and C<\end{document}>.
+
+=item *
+
+Finally, there's one array reference for each given TikZ set, which contain the lines for the actual TikZ pictures.
+
+=back
+
+The lines returned by L</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 (
+ "\\documentclass[12pt]{article}",
+ @$header,
+ "\\begin{document}",
+ "\\pagestyle{empty}",
+ @$declarations,
+ "First set :"
+ "\\begin{center}",
+ @$set1_body,
+ "\\end{center}",
+ "Second set :"
+ "\\begin{center}",
+ @$set2_body,
+ "\\end{center}",
+ "\\end{document}",
+ );
+
+=cut
+
+my $find_mods = do {
+ our %seen;
+
+ my $find_mods_rec;
+ $find_mods_rec = do {
+ no warnings 'recursion';
+
+ Sub::Name::subname('find_mods_rec' => sub {
+ my ($set, $layers, $others) = @_;
+
+ for ($set->mods) {
+ my $tag = $_->tag;
+ next if $seen{$tag}++;
+
+ if ($_->isa('LaTeX::TikZ::Mod::Layer')) {
+ push @$layers, $_;
+ } else {
+ push @$others, $_;
+ }