I have a cases
environment inside an align
environment, and I'm trying to align part of one line of the align
environment with part of the cases
environment via an ugly \phantom
command. Here's a MWE:
\documentclass{article}
\usepackage{amsmath,mathtools}
\begin{document}
\begin{align}
f(x)&=\mathrlap{2}\phantom{\begin{cases}1&\\0&\end{cases}}\text{if }x>0\\
g(x)&=\begin{cases}1&\text{if }x>0\\0&\text{if }x<0\end{cases}
\end{align}
\end{document}
I'd like the 'if's to be horizontally aligned, and I don't understand why they're not - maybe something to do with the spacing that LaTeX puts around a cases
environment.
Can anyone see a fix (other than just doing it 'by hand' with \vspace
)?
mathtools
loadsamsmath