@@ -5,8 +5,51 @@ using ..Weave, ..PGFPlotsX
55Base. showable (m:: MIME"text/latex" , plot:: PGFPlotsX.AxisLike ) = true
66Base. showable (m:: MIME"text/tikz" , plot:: PGFPlotsX.AxisLike ) = true
77
8+ const str_warning = " Could not add LaTeX preamble to document."
9+
10+ function add_standalone (format:: Weave.LaTeXFormat )
11+ str = print_tex (String, " \\ usepackage{standalone}" ) # Adds newline character.
12+ if ! contains (format. tex_deps, str)
13+ format. tex_deps *= str
14+ end
15+ return nothing
16+ end
17+
18+ function add_standalone (format:: Weave.LaTeX2PDF )
19+ return add_standalone (format. primaryformat)
20+ end
21+
22+ function add_standalone (format)
23+ @warn str_warning
24+ return nothing
25+ end
26+
27+ function add_preamble (format:: Weave.LaTeXFormat )
28+ for item in unique ([PGFPlotsX. DEFAULT_PREAMBLE; PGFPlotsX. CUSTOM_PREAMBLE])
29+ str = print_tex (String, item) # Adds newline character.
30+ if ! contains (format. tex_deps, str)
31+ format. tex_deps *= str
32+ end
33+ end
34+ return nothing
35+ end
36+
37+ function add_preamble (format:: Weave.LaTeX2PDF )
38+ return add_preamble (format. primaryformat)
39+ end
40+
41+ function add_preamble (format)
42+ @warn str_warning
43+ return nothing
44+ end
45+
46+
847function Base. display (report:: Weave.Report , m:: MIME"text/latex" , figure:: PGFPlotsX.AxisLike )
948
49+ add_standalone (report. format)
50+
51+ add_preamble (report. format)
52+
1053 chunk = report. cur_chunk
1154
1255 ext = chunk. options[:fig_ext ]
2467
2568function Base. display (report:: Weave.Report , m:: MIME"text/tikz" , figure:: PGFPlotsX.AxisLike )
2669
70+ add_preamble (report. format)
71+
2772 chunk = report. cur_chunk
2873
2974 ext = chunk. options[:fig_ext ]
0 commit comments