mirror of https://github.com/mpastell/Weave.jl
Append LaTeX preambles
parent
5b10a1b3b7
commit
7f8b613e61
|
@ -5,8 +5,51 @@ using ..Weave, ..PGFPlotsX
|
|||
Base.showable(m::MIME"text/latex", plot::PGFPlotsX.AxisLike) = true
|
||||
Base.showable(m::MIME"text/tikz", plot::PGFPlotsX.AxisLike) = true
|
||||
|
||||
const str_warning = "Could not add LaTeX preamble to document."
|
||||
|
||||
function add_standalone(format::Weave.LaTeXFormat)
|
||||
str = print_tex(String, "\\usepackage{standalone}") # Adds newline character.
|
||||
if !contains(format.tex_deps, str)
|
||||
format.tex_deps *= str
|
||||
end
|
||||
return nothing
|
||||
end
|
||||
|
||||
function add_standalone(format::Weave.LaTeX2PDF)
|
||||
return add_standalone(format.primaryformat)
|
||||
end
|
||||
|
||||
function add_standalone(format)
|
||||
@warn str_warning
|
||||
return nothing
|
||||
end
|
||||
|
||||
function add_preamble(format::Weave.LaTeXFormat)
|
||||
for item in unique([PGFPlotsX.DEFAULT_PREAMBLE; PGFPlotsX.CUSTOM_PREAMBLE])
|
||||
str = print_tex(String, item) # Adds newline character.
|
||||
if !contains(format.tex_deps, str)
|
||||
format.tex_deps *= str
|
||||
end
|
||||
end
|
||||
return nothing
|
||||
end
|
||||
|
||||
function add_preamble(format::Weave.LaTeX2PDF)
|
||||
return add_preamble(format.primaryformat)
|
||||
end
|
||||
|
||||
function add_preamble(format)
|
||||
@warn str_warning
|
||||
return nothing
|
||||
end
|
||||
|
||||
|
||||
function Base.display(report::Weave.Report, m::MIME"text/latex", figure::PGFPlotsX.AxisLike)
|
||||
|
||||
add_standalone(report.format)
|
||||
|
||||
add_preamble(report.format)
|
||||
|
||||
chunk = report.cur_chunk
|
||||
|
||||
ext = chunk.options[:fig_ext]
|
||||
|
@ -24,6 +67,8 @@ end
|
|||
|
||||
function Base.display(report::Weave.Report, m::MIME"text/tikz", figure::PGFPlotsX.AxisLike)
|
||||
|
||||
add_preamble(report.format)
|
||||
|
||||
chunk = report.cur_chunk
|
||||
|
||||
ext = chunk.options[:fig_ext]
|
||||
|
|
|
@ -96,7 +96,7 @@ function render_figures(docformat::LaTeXFormat, chunk)
|
|||
end
|
||||
|
||||
for fig in fignames
|
||||
if splitext(fig)[2] == ".tex" # Tikz figures
|
||||
if splitext(fig)[2] in [".tex", ".tikz"] # Tikz figures
|
||||
figstring *= "\\resizebox{$width}{!}{\\input{$fig}}\n"
|
||||
else
|
||||
if isempty(attribs)
|
||||
|
|
Loading…
Reference in New Issue