# LaTeX support in docstrings - how?

**URL:** https://discourse.julialang.org/t/latex-support-in-docstrings-how/4952
**Category:** Internals & Design
**Tags:** documentation
**Created:** [July 19, 2017, 6:41pm UTC](https://discourse.julialang.org/t/latex-support-in-docstrings-how/4952 "2017-07-19T18:41:56Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)
#### Post date: [July 19, 2017, 6:41pm UTC](https://discourse.julialang.org/t/latex-support-in-docstrings-how/4952/1 "2017-07-19T18:41:56Z")

</div>

It appears that any docstrings that have LaTeX in them (surrounded by double backticks) need to be preceded by `@doc_str`. Is that correct? [The documentation](https://docs.julialang.org/en/stable/manual/documentation/#%5CLaTeX-1) hints at this, but it’s not very clear.

Also, do backslashes need to be escaped within double backticks or not? The documentation shows examples both ways.

---

<div class="post-metadata">

### Author: ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)
#### Post date: [July 19, 2017, 9:26pm UTC](https://discourse.julialang.org/t/latex-support-in-docstrings-how/4952/2 "2017-07-19T21:26:24Z")

</div>

I’ve found that you don’t need to use the macro version, but you do need to escape the dollar sign inline. For displayed math, use a `math` codeblock and escape backslashes. See [here](https://github.com/jebej/Schrodinger.jl/blob/master/src/library/states.jl#L22) and [rendered](https://jebej.github.io/Schrodinger.jl/latest/api/states.html#Schrodinger.coherent).

---

<div class="post-metadata">

### Author: ![anon94023334](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@anon94023334](https://discourse.julialang.org/u/anon94023334)
#### Post date: [July 19, 2017, 10:01pm UTC](https://discourse.julialang.org/t/latex-support-in-docstrings-how/4952/3 "2017-07-19T22:01:58Z")

</div>

Thanks - this is helpful. What about equations that I’d prefer to be rendered inline?

---

<div class="post-metadata">

### Author: ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)
#### Post date: [July 19, 2017, 10:18pm UTC](https://discourse.julialang.org/t/latex-support-in-docstrings-how/4952/4 "2017-07-19T22:18:35Z")

</div>

I’ve always used `\$\\cos x ^ 2 + \\sin x ^ 2 = 1\$` and it always worked.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [July 19, 2017, 11:23pm UTC](https://discourse.julialang.org/t/latex-support-in-docstrings-how/4952/5 "2017-07-19T23:23:14Z")

</div>

You can also use the `doc"..."` string macro if you don’t want to escape `$` and `\`, e.g. `doc"$\cos x^2$"`.
