# How to use cases in docstring math mode?

**URL:** <https://discourse.julialang.org/t/how-to-use-cases-in-docstring-math-mode/46039>\
**Category:** General Usage\
**Tags:** question, package, documentation\
**Created:** [September 4, 2020, 4:54am UTC](https://discourse.julialang.org/t/how-to-use-cases-in-docstring-math-mode/46039 "2020-09-04T04:54:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [September 4, 2020, 4:54am UTC](https://discourse.julialang.org/t/how-to-use-cases-in-docstring-math-mode/46039/1 "2020-09-04T04:54:41Z")

</div>

I am using `Documenter.jl` to generate the documentation, and would like to use `\cases` to define piecewise functions. Currently I am adding the equation to the docstring. Something like this doesn’t seem to render as latex in the generated html file:

````julia
```math
b = \\begin{cases}
1 & a>0,\\
0 & \\text{otherwise}
\\end{cases} ```

````

Any suggestion on how to implement this?

---

<div class="post-metadata">

**Author:** ![mortenpi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mortenpi/32/158_2.png) [@mortenpi](https://discourse.julialang.org/u/mortenpi)\
**Post date:** [September 4, 2020, 5:18am UTC](https://discourse.julialang.org/t/how-to-use-cases-in-docstring-math-mode/46039/2 "2020-09-04T05:18:33Z")

</div>

I think it’s failing because you’re not escaping the line break backslashes on line 3 (you want `\\`, so you’d need to write `\\\\` to escape them properly in a docstring). I.e.:

````markdown
```math
b = \\begin{cases}
1 & a>0, \\\\
0 & \\text{otherwise}
\\end{cases}
```

````

However, you should actually be able to avoid the escaping altogether by using the `raw""` string macro:

````julia
@doc raw"""
```math
b = \begin{cases}
1 & a>0, \\
0 & \text{otherwise}
\end{cases}
```
"""
function foo end

````

---

<div class="post-metadata">

**Author:** ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)\
**Post date:** [September 4, 2020, 5:36am UTC](https://discourse.julialang.org/t/how-to-use-cases-in-docstring-math-mode/46039/3 "2020-09-04T05:36:03Z")

</div>

Aha thanks a lot, this works
