From ad46c6ca3e85f789ec6fea8358de4e640dfbf057 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 17 Dec 2020 10:14:27 +0000 Subject: [PATCH] Support for landscape figures and tables in pdf output. --- Artifacts.toml | 6 +++--- src/cells.jl | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Artifacts.toml b/Artifacts.toml index fa055f8..00ed7c5 100644 --- a/Artifacts.toml +++ b/Artifacts.toml @@ -1,6 +1,6 @@ [publish_theme_default] -git-tree-sha1 = "c4a004c05b3da9ee9916ef375c155f06305ef054" +git-tree-sha1 = "66ee25018081b7378b9ed4c8d50a251788f33219" [[publish_theme_default.download]] - sha256 = "00381b74d503e12fa339e2059adb28f766f78d25cc532acd5c2a1b397b7fe56f" - url = "https://github.com/MichaelHatherly/PublishThemes/releases/download/default-0.2.0/default-0.2.0.tar.gz" + sha256 = "233b90dd4f4427bd1d165c3e77f49f9b9e0037b427fe8ca3a11b0f129118c97c" + url = "https://github.com/MichaelHatherly/PublishThemes/releases/download/default-0.2.1/default-0.2.1.tar.gz" diff --git a/src/cells.jl b/src/cells.jl index 1b09d43..d37615e 100644 --- a/src/cells.jl +++ b/src/cells.jl @@ -266,6 +266,7 @@ Base.@kwdef struct Figure{T} placement::Symbol = :h alignment::Symbol = :center maxwidth::String = "\\linewidth" + landscape::Bool = false caption::String = "" desc::String = "" end @@ -275,6 +276,7 @@ Base.@kwdef struct Table{T} object::T placement::Symbol = :h alignment::Symbol = :center + landscape::Bool = false caption::String = "" desc::String = "" type::Symbol = :tabular @@ -291,6 +293,7 @@ function Base.show(io::IO, ::MIME"text/latex", f::Objects.Figure) open(filename, "w") do handle Base.invokelatest(show, handle, mime, f.object) end + f.landscape && println(io, "\\begin{landscape}") println(io, "\\begin{figure}[$(f.placement)]") println(io, "\\adjustimage{max width=$(f.maxwidth),$(f.alignment)}{./$filename}") if !isempty(f.caption) @@ -298,6 +301,7 @@ function Base.show(io::IO, ::MIME"text/latex", f::Objects.Figure) println(io, "\\caption$(desc){$(f.caption)}") end println(io, "\\end{figure}") + f.landscape && println(io, "\\end{landscape}") return nothing end end @@ -342,6 +346,7 @@ function Base.show(io::IO, ::MIME"text/latex", t::Objects.Table) # We only wrap tabular environments, since longtable does all this for us. # It is nessecary to pass along the options to pretty_table for longtables # since it handles captions and the like internally. + t.landscape && println(io, "\\begin{landscape}") if t.type == :tabular println(io, "\\begin{table}[$(t.placement)]") println(io, get(_LATEX_HORIZONTAL_ALIGNMENT_MAPPING, t.alignment, "\\centering")) @@ -365,6 +370,8 @@ function Base.show(io::IO, ::MIME"text/latex", t::Objects.Table) title=t.caption, ) end + t.landscape && println(io, "\\end{landscape}") + return nothing end function Base.show(io::IO, ::MIME"text/html", t::Objects.Table)