Skip to content

Commit

Permalink
Merge 2517aa6 into 4431a08
Browse files Browse the repository at this point in the history
  • Loading branch information
korsbo committed Nov 6, 2019
2 parents 4431a08 + 2517aa6 commit 53c6f91
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
9 changes: 4 additions & 5 deletions src/latexalign.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ julia> latexalign(ode)
"""
function latexalign end

function latexalign(arr::AbstractMatrix; separator=" =& ", double_linebreak=false, starred=false, kwargs...)
function latexalign(arr::AbstractMatrix; separator=" =& ", double_linebreak=false, eol = double_linebreak ? " \\\\\\\\\n" : " \\\\\n", starred=false, kwargs...)
(rows, columns) = size(arr)
eol = double_linebreak ? " \\\\\\\\\n" : " \\\\\n"
arr = latexraw(arr; kwargs...)

str = "\\begin{align$(starred ? "*" : "")}\n"
Expand All @@ -52,9 +51,9 @@ function latexalign(arr::AbstractMatrix; separator=" =& ", double_linebreak=fals
end
str *= join(arr[end,:], separator) * "\n" # No EOL on the last line.
str *= "\\end{align$(starred ? "*" : "")}\n"
latexstr = LaTeXString(str)
COPY_TO_CLIPBOARD && clipboard(latexstr)
return latexstr
#= latexstr = LaTeXString(str) =#
#= COPY_TO_CLIPBOARD && clipboard(latexstr) =#
return output(str; kwargs...)
end

function latexalign(lhs::AbstractArray, rhs::AbstractArray; kwargs...)
Expand Down
4 changes: 1 addition & 3 deletions src/latexarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ function latexarray(arr::AbstractArray; adjustment::Symbol=:c, transpose=false,
str *= "\\end{array}\n"
str *= "\\right]\n"
str *= "\\end{equation$(starred ? "*" : "")}\n"
latexstr = LaTeXString(str)
COPY_TO_CLIPBOARD && clipboard(latexstr)
return latexstr
return output(str; kwargs...)
end


Expand Down
4 changes: 1 addition & 3 deletions src/latexequation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ function latexequation(eq; starred=false, kwargs...)
str *= latexstr
str *= "\n"
str *= "\\end{equation$(starred ? "*" : "")}\n"
latexstr = LaTeXString(str)
COPY_TO_CLIPBOARD && clipboard(latexstr)
return latexstr
return output(str; kwargs...)
end

10 changes: 10 additions & 0 deletions src/latexify_function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,13 @@ function get_latex_function(x::AbstractArray{T}) where T <: AbstractArray
end

get_latex_function(lhs::AbstractVector, rhs::AbstractVector) = latexalign


function output(str; post_processing=x->x, escape_underscores=false, kwargs...)
str = post_processing(str)
str == nothing && return nothing
escape_underscores && (str = replace(str, "_"=>"\\_"))
latexstr = LaTeXString(str)
COPY_TO_CLIPBOARD && clipboard(latexstr)
return latexstr
end
3 changes: 1 addition & 2 deletions src/latexinline.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
function latexinline(x; kwargs...)
latexstr = latexstring( latexraw(x; kwargs...) )
COPY_TO_CLIPBOARD && clipboard(latexstr)
return latexstr
return output(latexstr.s; kwargs...)
end

latexinline(x::Union{AbstractArray, Tuple}; kwargs...) = [ latexinline(i; kwargs...) for i in x]
Expand Down
4 changes: 1 addition & 3 deletions src/latextabular.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ function latextabular(arr::AbstractMatrix; latex::Bool=true, head=[], side=[], a
end

str *= "\\end{tabular}\n"
latexstr = LaTeXString(str)
COPY_TO_CLIPBOARD && clipboard(latexstr)
return latexstr
return output(str; kwargs...)
end


Expand Down
4 changes: 1 addition & 3 deletions src/plugins/DiffEqBiological.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ function chemical_arrows(rn::DiffEqBase.AbstractReactionNetwork;

str *= starred ? "\\end{align*}\n" : "\\end{align}\n"

latexstr = LaTeXString(str)
COPY_TO_CLIPBOARD && clipboard(latexstr)
return latexstr
return output(str; kwargs...)
end


Expand Down

0 comments on commit 53c6f91

Please sign in to comment.