From 7d66c502f45c85488e01b9dece3562443f58b75c Mon Sep 17 00:00:00 2001 From: Tom Breloff Date: Mon, 9 Jan 2017 13:19:37 -0500 Subject: [PATCH] support tex in pgfplots; closes #637 --- src/backends/pgfplots.jl | 8 +++++++- src/output.jl | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backends/pgfplots.jl b/src/backends/pgfplots.jl index 0eb97fd8..b42e8629 100644 --- a/src/backends/pgfplots.jl +++ b/src/backends/pgfplots.jl @@ -314,12 +314,18 @@ function _show(io::IO, mime::MIME"application/pdf", plt::Plot{PGFPlotsBackend}) PGFPlots.save(PGFPlots.PDF(fn), pgfplt) # read it into io - write(io, readall(open(fn))) + write(io, readstring(open(fn))) # cleanup PGFPlots.cleanup(plt.o) end +function _show(io::IO, mime::MIME"application/x-tex", plt::Plot{PGFPlotsBackend}) + fn = tempname()*".tex" + PGFPlots.save(fn, backend_object(plt), include_preamble=false) + write(io, readstring(open(fn))) +end + function _display(plt::Plot{PGFPlotsBackend}) # prepare the object pgfplt = PGFPlots.plot(plt.o) diff --git a/src/output.jl b/src/output.jl index ff4a1def..ee9972ab 100644 --- a/src/output.jl +++ b/src/output.jl @@ -154,6 +154,7 @@ const _mimeformats = Dict( "application/postscript" => "ps", "image/svg+xml" => "svg", "text/plain" => "txt", + "application/x-tex" => "tex", ) const _best_html_output_type = KW(