diff --git a/docs/src/index.md b/docs/src/index.md
index 4931ed1d..57a463e7 100644
--- a/docs/src/index.md
+++ b/docs/src/index.md
@@ -54,6 +54,14 @@ See `Examples` in the left side bar to see examples of such reports.
See [`report`](@ref) for more information on the options available.
+You may also generate a TeX/PDF version using
+Documenter.jl's [TeX support](https://documenter.juliadocs.org/stable/man/other-formats/)
+as follows:
+
+```@example pigeons
+report(pt; writer=InferenceReport.Documenter.LaTeX(platform = "docker"))
+```
+
### From MCMCChains
@@ -238,4 +246,4 @@ See our [Documenter.jl make file](https://github.com/Julia-Tempering/InferenceRe
integrate InferenceReport into a broader documentation page.
The key functions used are [`headless`](@ref),
[`report_to_docs`](@ref) and
-[`as_doc_page`](@ref).
\ No newline at end of file
+[`as_doc_page`](@ref).
\ No newline at end of file
diff --git a/src/InferenceReport.jl b/src/InferenceReport.jl
index dd2734eb..3cf89107 100644
--- a/src/InferenceReport.jl
+++ b/src/InferenceReport.jl
@@ -1,6 +1,8 @@
module InferenceReport
using CairoMakie
+CairoMakie.activate!(type = "png", px_per_unit = 2)
+
using Documenter
using MCMCChains
using PairPlots
@@ -121,8 +123,14 @@ as_doc_page(context) = "`$(target_name(context))`" => "generated/$(basename(dirn
"""
$SIGNATURES
"""
-view_webpage(exec_folder) = open_in_default_browser("$exec_folder/build/index.html")
-
+function view_webpage(exec_folder)
+ # Try to autodect if we built HTML or a PDF
+ if isfile("$exec_folder/build/InferenceReport.pdf")
+ open_in_default_browser("$exec_folder/build/InferenceReport.pdf")
+ else
+ open_in_default_browser("$exec_folder/build/index.html")
+ end
+end
"""
$SIGNATURES
"""
@@ -131,7 +139,7 @@ render(context) =
root = dirname(context.output_directory),
sitename = "InferenceReport",
repo="https://github.com/Julia-Tempering/Pigeons.jl/blob/{commit}{path}#{line}",
- format = Documenter.HTML(size_threshold=nothing),
+ format = context.options.writer,
pages = ["`$(target_name(context))`" => "index.md"])
# Controls defaults such as whether to render and open webpage right away
diff --git a/src/ReportOptions.jl b/src/ReportOptions.jl
index 452dbf57..52a68928 100644
--- a/src/ReportOptions.jl
+++ b/src/ReportOptions.jl
@@ -59,6 +59,12 @@ $FIELDS
"""
reproducibility_command::Union{String, Nothing} = nothing
+ """
+ A Documenter.Writer instance used to render the document. Default is an HTML
+ page, but other options including Documenter.LaTeX() are also possible.
+ """
+ writer::Documenter.Writer=Documenter.HTML(size_threshold=nothing)
+
"""
Useful for debugging, false by default.
"""
diff --git a/src/building_blocks.jl b/src/building_blocks.jl
index 26bad75f..45d31bda 100644
--- a/src/building_blocks.jl
+++ b/src/building_blocks.jl
@@ -30,18 +30,28 @@ end
$SIGNATURES
"""
function add_plot(context; file, title, url_help = nothing, description = "", movie = nothing)
- info_link = isnothing(url_help) ? "" : """⏐🔗 Info """
- movie_link = isnothing(movie) ? "" : """⏐🍿 Movie """
- add_markdown(context;
- title,
- contents = """
- $description
- ```@raw html
-
- 🔍 Full page $movie_link $info_link
- ```
- """
- )
+ if context.options.writer isa Documenter.HTML
+ info_link = isnothing(url_help) ? "" : """⏐🔗 Info """
+ movie_link = isnothing(movie) ? "" : """⏐🍿 Movie """
+ add_markdown(context;
+ title,
+ contents = """
+ $description
+ ```@raw html
+
+ 🔍 Full page $movie_link $info_link
+ ```
+ """
+ )
+ else
+ add_markdown(context;
+ title,
+ contents = """
+ $description
+ ![]($file)
+ """
+ )
+ end
end
"""
diff --git a/src/processors.jl b/src/processors.jl
index 05be19a1..9f946a4b 100644
--- a/src/processors.jl
+++ b/src/processors.jl
@@ -5,8 +5,8 @@ Create a pair plot using [PairPlot.jl](https://github.com/sefffal/PairPlots.jl).
"""
function pair_plot(context)
plot = PairPlots.pairplot(get_chains(context))
- file = output_file(context, "pair_plot", "svg")
- CairoMakie.save(file, plot)
+ file = output_file(context, "pair_plot", "png")
+ CairoMakie.save(file, plot, px_per_unit=2)
description = """
Diagonal entries show estimates of the marginal
@@ -25,7 +25,7 @@ function pair_plot(context)
end
add_plot(context;
- file = "pair_plot.svg",
+ file = "pair_plot.png",
title = "Pair plot",
url_help = "https://sefffal.github.io/PairPlots.jl",
movie = moving_pair_plot(context),
@@ -127,10 +127,10 @@ function trace_plot(context, cumulative)
resize_to_layout!(fig)
name = cumulative ? "cumulative_trace_plot" : "trace_plot"
- file = output_file(context, name, "svg")
- CairoMakie.save(file, fig, size= (800, 200 * n_params))
+ file = output_file(context, name, "png")
+ CairoMakie.save(file, fig, size= (800, 200 * n_params), px_per_unit=2)
add_plot(context;
- file = "$name.svg",
+ file = "$name.png",
title = cumulative ? "Cumulative traces" : "Trace plots",
description = cumulative ? """
For each iteration ``i``, shows the running average up to ``i``,
@@ -268,10 +268,10 @@ function lcb(context)
ax.xlabel = "β"
ax.ylabel = "λ(β)"
name = "local_barrier"
- file = output_file(context, name, "svg")
- CairoMakie.save(file, f)
+ file = output_file(context, name, "png")
+ CairoMakie.save(file, f, px_per_unit=2)
add_plot(context;
- file = "$name.svg",
+ file = "$name.png",
title = "Local communication barrier",
url_help = "https://pigeons.run/dev/output-pt/#Local-communication-barrier",
description = """
@@ -319,10 +319,10 @@ function pigeons_progress(context; property, title, args...)
mapping(:round, property) *
visual(Lines)
plot = draw(recipe)
- file = output_file(context, "$(property)_progress", "svg")
+ file = output_file(context, "$(property)_progress", "png")
CairoMakie.save(file, plot)
add_plot(context;
- file = "$(property)_progress.svg",
+ file = "$(property)_progress.png",
title,
args...)
end
diff --git a/test/test_pdf.jl b/test/test_pdf.jl
new file mode 100644
index 00000000..467f9a24
--- /dev/null
+++ b/test/test_pdf.jl
@@ -0,0 +1,28 @@
+@testset "PDF output" begin
+
+ if (get(ENV, "CI", "false") == "true") && !Sys.islinux()
+
+ @warn "on github action CI, docker available out of the box on linux only"
+
+ else
+
+ inputs, reproducibility_command =
+ @reproducible Inputs(
+ target = toy_mvn_target(2),
+ n_rounds = 4,
+ record = [traces; round_trip; record_default()])
+
+ pt = pigeons(inputs)
+
+ context = report(pt;
+ view = false,
+ writer=InferenceReport.Documenter.LaTeX(platform = "docker"),
+ target_description = "Description",
+ reproducibility_command)
+
+ @test isfile("$(context.options.exec_folder)/build/InferenceReport.pdf")
+
+ @test length(context.generated_markdown) ==
+ length(InferenceReport.default_postprocessors()) - 1 # MPI output
+ end
+end
\ No newline at end of file