This approach use a HTML
header loading a script in the final HTML
doc pages. You need to set environmental variable RUSTDOCFLAGS
with paramenter html-in-header
to a fragment of HTML
file with the script that load and configure Katex
.
The html
file is something like this
```html
```
In this minimal example repo is in src/docs-header.html
.
And you put Latex
in your docs like
```rust /// $$E = mc^2 $$ /// $$m = \frac{m_0}{\sqrt{1-\frac{v^2}{c^2}}}$$ fn energy(v: Velocity) -> Energy {...}
```
.cargo/config
)sh
RUSTDOCFLAGS="--html-in-header src/docs-header.html" cargo doc --open
bat
set RUSTDOCFLAGS=--html-in-header src\docs-header.html
cargo doc --open
bat
$env:RUSTDOCFLAGS="--html-in-header .\src\docs-header.html"
cargo doc --open
Because the solution could not work in docs.rs
, you can publish the docs on your own host.
This minimal example is hosted with github pages. You can see the docs generated, with LaTeX
at
minimal example docs with LaTex
sh
cargo doc -- && cp -r target/doc/ docs/