Skip to content

Commit 27d6498

Browse files
Merge pull request #287 from SciML/abstractlatex
Generalize LaTeXify for AbstractSystem
2 parents 294cb99 + 7378b39 commit 27d6498

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/latexify_recipes.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@latexrecipe function f(eqs::Vector{ModelingToolkit.Equation}; iv=:t)
1+
@latexrecipe function f(eqs::Vector{ModelingToolkit.Equation})
22
# Set default option values.
33
env --> :align
44
cdot --> false
@@ -11,18 +11,18 @@
1111
rhs = [postwalk(x -> x isa ModelingToolkit.Constant ? x.value : x, eq) for eq in rhs]
1212
rhs = [postwalk(x -> x isa Expr && length(x.args) == 1 ? x.args[1] : x, eq) for eq in rhs]
1313
rhs = [postwalk(x -> x isa Expr && x.args[1] == :derivative && length(x.args[2].args) == 2 ? :($(Symbol(:d, x.args[2]))/($(Symbol(:d, x.args[2].args[2])))) : x, eq) for eq in rhs]
14-
rhs = [postwalk(x -> x isa Expr && x.args[1] == :derivative ? "\\frac{d\\left($(Latexify.latexraw(x.args[2]))\\right)}{d$iv}" : x, eq) for eq in rhs]
14+
rhs = [postwalk(x -> x isa Expr && x.args[1] == :derivative ? "\\frac{d\\left($(Latexify.latexraw(x.args[2]))\\right)}{d$(Latexify.latexraw(x.args[3]))}" : x, eq) for eq in rhs]
1515

1616
lhs = getfield.(eqs, :lhs)
1717
lhs = convert.(Expr, lhs)
1818
lhs = [postwalk(x -> x isa ModelingToolkit.Constant ? x.value : x, eq) for eq in lhs]
1919
lhs = [postwalk(x -> x isa Expr && length(x.args) == 1 ? x.args[1] : x, eq) for eq in lhs]
2020
lhs = [postwalk(x -> x isa Expr && x.args[1] == :derivative && length(x.args[2].args) == 2 ? :($(Symbol(:d, x.args[2]))/($(Symbol(:d, x.args[2].args[2])))) : x, eq) for eq in lhs]
21-
lhs = [postwalk(x -> x isa Expr && x.args[1] == :derivative ? "\\frac{d\\left($(Latexify.latexraw(x.args[2]))\\right)}{d$iv}" : x, eq) for eq in lhs]
21+
lhs = [postwalk(x -> x isa Expr && x.args[1] == :derivative ? "\\frac{d\\left($(Latexify.latexraw(x.args[2]))\\right)}{d$(Latexify.latexraw(x.args[3]))}" : x, eq) for eq in lhs]
2222

2323
return lhs, rhs
2424
end
2525

26-
@latexrecipe function f(sys::ModelingToolkit.ODESystem; iv=:t)
27-
return latexify(sys.eqs; iv=iv)
26+
@latexrecipe function f(sys::ModelingToolkit.AbstractSystem)
27+
return latexify(equations(sys))
2828
end

0 commit comments

Comments
 (0)