Skip to content

Commit

Permalink
Support for landscape figures and tables in pdf output.
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelHatherly committed Dec 17, 2020
1 parent 63858d5 commit ad46c6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 7 additions & 0 deletions src/cells.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -291,13 +293,15 @@ 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)
desc = isempty(f.desc) ? "" : "[$(f.desc)]"
println(io, "\\caption$(desc){$(f.caption)}")
end
println(io, "\\end{figure}")
f.landscape && println(io, "\\end{landscape}")
return nothing
end
end
Expand Down Expand Up @@ -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"))
Expand All @@ -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)
Expand Down

0 comments on commit ad46c6c

Please sign in to comment.