I want to write conditional statement with one-sided curly brackets in Sphinx as shown below:
In Latex, the best I could do is given below:
\[
x = \begin{cases}
\begin{split}
d&, & I_x &\leq I_p - t \\
s&, \; \; I_p - t &\leq I_x &\leq I_p + t \\
b&, \; \; I_p + t &\leq I_x
\end{split}
\end{cases}
\]
But it provides some blank spaces in middle of condition (marked in red) as shown below:
But even that also, doesn't work in Sphinx. It ends up in big error.
So how can I achieve it in both Latex and Sphinx?
Best Answer
For LaTeX I'd use an
array
:If the center terms of the inequalities don't have the same width, more alignment points are needed to make them centered.
We don't want any of the automatic padding between colums that
array
usually inserts, so between columns (and also at the start and end of the array) I put@{}
that disables the insertion. Exception: between the first and second column we want some space.The mysterious
>{{}}
bit is readily explained: when TeX is doing the second and third column in the second row, it would essentially dobecause it treats each cell as a separate formula. This doesn't give the correct spacing, so we insert
{}
at the start of the cells in the third column and the final result iswhich typesets exactly like
and the desired outcome is obtained.