# My latex inside doc doesn't appear correctly

**URL:** https://discourse.julialang.org/t/my-latex-inside-doc-doesnt-appear-correctly/130128
**Category:** General Usage
**Tags:** question
**Created:** [June 23, 2025, 11:09am UTC](https://discourse.julialang.org/t/my-latex-inside-doc-doesnt-appear-correctly/130128 "2025-06-23T11:09:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![AbdelazimHussien](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abdelazimhussien/32/207723_2.png) [@AbdelazimHussien](https://discourse.julialang.org/u/AbdelazimHussien)
#### Post date: [June 23, 2025, 11:09am UTC](https://discourse.julialang.org/t/my-latex-inside-doc-doesnt-appear-correctly/130128/1 "2025-06-23T11:09:26Z")

</div>

Hello everyone,  
I am developing a new package https://github.com/AbdelazimHussien/MetaheuristicsAlgorithms.jl  
Now, I am trying to display the equation in latex format but it doesn’t work. For example Engineering\_F3 show strange appearance

I checked JuMP and follow the same but I don’t know why it doesn’t appear

Any help

---

<div class="post-metadata">

### Author: ![ForceBru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forcebru/32/21389_2.png) [@ForceBru](https://discourse.julialang.org/u/ForceBru)
#### Post date: [June 23, 2025, 11:41am UTC](https://discourse.julialang.org/t/my-latex-inside-doc-doesnt-appear-correctly/130128/2 "2025-06-23T11:41:25Z")

</div>

AFAIK docstrings with LaTeX should look like this:

```
@doc raw"""
This is an optimization algorithm.

Objective function:
```math
\xi + \eta^2
```

This is inline math: $\xi$ is positive.
"""
struct Algorithm
end
```

The main point is that LaTeX code should be surrounded by _triple backticks_, plus the first triple should be immediately followed by `math`. I used a raw string literal here to avoid escaping backslashes.

As a side note, many metaheuristics seem to be just particle swarm in disguise: [https://www.dei.unipd.it/~fisch/ricop/OR2/Metaheuristics-the%20metaphor%20exposed.pdf](https://www.dei.unipd.it/~fisch/ricop/OR2/Metaheuristics-the%20metaphor%20exposed.pdf).

---

<div class="post-metadata">

### Author: ![AbdelazimHussien](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abdelazimhussien/32/207723_2.png) [@AbdelazimHussien](https://discourse.julialang.org/u/AbdelazimHussien)
#### Post date: [June 23, 2025, 11:58am UTC](https://discourse.julialang.org/t/my-latex-inside-doc-doesnt-appear-correctly/130128/3 "2025-06-23T11:58:17Z")

</div>

U mean to put ```math before the matheamtical notation.  
Right?

---

<div class="post-metadata">

### Author: ![ForceBru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forcebru/32/21389_2.png) [@ForceBru](https://discourse.julialang.org/u/ForceBru)
#### Post date: [June 23, 2025, 12:01pm UTC](https://discourse.julialang.org/t/my-latex-inside-doc-doesnt-appear-correctly/130128/4 "2025-06-23T12:01:43Z")

</div>

Yes, that is correct. Three backticks + `math`, then your math, then _three_ backticks again (your code currently has two). This is used for “display” math, like important equations.

Perhaps there are other ways, but this works for me.

---

<div class="post-metadata">

### Author: ![ForceBru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/forcebru/32/21389_2.png) [@ForceBru](https://discourse.julialang.org/u/ForceBru)
#### Post date: [June 23, 2025, 1:02pm UTC](https://discourse.julialang.org/t/my-latex-inside-doc-doesnt-appear-correctly/130128/5 "2025-06-23T13:02:00Z")

</div>

As a concrete example from your latest commit, I’d write it like this:

```
@doc raw"""
    Engineering_F3(x::Vector{Float64}) -> Float64

Welded Beam Design Optimization Problem.

Minimizes the cost of a welded beam subject to constraints on shear stress, normal stress, deflection, and geometric properties.

# Objective

```math
\vec{z} = [z_1, z_2, z_3, z_4] = [h, l, t, b] \\
\min_{\vec{z}} f(\vec{z}) = 1.10471 z_1^2 z_2 + 0.04811 z_3 z_4 (14 + z_2)
```

# Constraints
...
"""
function Engineering_F3(x)
 5.0
end
```

---

<div class="post-metadata">

### Author: ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)
#### Post date: [June 23, 2025, 1:23pm UTC](https://discourse.julialang.org/t/my-latex-inside-doc-doesnt-appear-correctly/130128/6 "2025-06-23T13:23:15Z")

</div>

You can find the complete documentation on how to use LaTeX at

> **[LaTeX Syntax · Documenter.jl](https://documenter.juliadocs.org/stable/man/latex/)**
>
> Documentation for Documenter.jl.

So besides block environments being

````julia
```math
[your math goes here]
```

````

if also documents that inline math should look like ```[your inline math goes here]```, i.e. with two backticks.
