sbrisard / Scapin.jl

A framework for FFT-based, full-field numerical simulation of heterogeneous materials
MIT License
2 stars 1 forks source link

Incorrect LaTeX output of equations #1

Closed sbrisard closed 2 years ago

sbrisard commented 3 years ago

In order to use numbered equations, MathJax was activated in this project. Then, equations in the documentation source files are defined as follows

```math
\begin{equation}
...
\end{equation}

This produces the desired HTML output. However, for LaTeX output, the above code block produces

```latex
\begin{equation*}
\begin{split}\begin{equation}
...
\end{equation}\end{split}\end{equation*}

The nested equation* and equation environment lead to a compilation error. A simple cure would be to change the function function latex(io::IO, math::Markdown.LaTeX) (see here) in the Documenter.jl package.

Indeed, this function reads

# This (equation*, split) math env seems to be the only way to correctly render all the
# equations in the Julia manual. However, if the equation is already wrapped in
# align/align*, then there is no need to further wrap it (in fact, it will break).
function latex(io::IO, math::Markdown.LaTeX)
    if occursin(r"^\\begin\{align\*?\}", math.formula)
        _print(io, math.formula)
    else
        _print(io, "\\begin{equation*}\n\\begin{split}")
        _print(io, math.formula)
        _println(io, "\\end{split}\\end{equation*}")
    end
end

The regex analysis should be widened to more mathematical environments.

sbrisard commented 3 years ago

Notes

Managing the PR

pkg> dev Documenter

LaTeX environments to be watched for

and the starred versions.

Modified RegEx

"^\\begin\{((equation)|(align)|(gather)|(flalign)|(multline)|(alignat)|(split))\*?\}"
sbrisard commented 3 years ago

PR submitted to Documenter.jl.

sbrisard commented 2 years ago

Closing this issue as the theoretical documentation is now a separate, pure LaTeX project (see LS-intro).