1

If want to align the code such that all the `if ...' part are also aligned. But I can't make it happen, because two of the three equations are in a cases environment and the other one isn't.

\begin{align}
    g^B(x)&=
    \begin{cases}
      T & \text{if $x$ is $\tr$,} \\
      F & \text{if $x$ is $\fa$.}
    \end{cases}\\
    g^\ell (x)&= 
    a \xor g^B(z) &\text{if $x = y\lef a \rig z$}\\
    g^B(x)&=
    \begin{cases}
      T & \text{if $x$ is $\tr$,} \\
      F & \text{if $x$ is $\fa$.}
    \end{cases}
\end{align}

This is still wrong, I want the ifs to be aligned

Sven
  • 203

2 Answers2

1

Welcome to TeX-SE! We usually provide complete compilable examples that start with \documentclass and end with \end{document}. I did not have your definitions \fa and so on so I replaced them with random stuff. If I had them, this would not be necessary. As for your question, one way is to use blkarray.

\documentclass{article}
\usepackage{blkarray}
\usepackage{multirow}
\usepackage{amsmath}
\begin{document}  
\[\begin{blockarray}{rll} 
\begin{block}{r\{ll} 
\multirow{2}{*}{$g^B(x)=$}&
      $T$ & \text{if $x$ is $x$,} \\
&      $F$ & \text{if $x$ is $x$.}\\
\end{block}
g^\ell (x)=& 
    a \wedge g^B(z) & \text{if $x = y\dots a \dots z$}\\
\begin{block}{r\{ll} 
\multirow{2}{*}{$g^B(x)=$}&
      $T $& \text{if $x$ is $x$,} \\
&      $F$ & \text{if $x$ is $x$.}\\
\end{block}
\end{blockarray}\]
\end{document}

enter image description here

1

A solution based on alignedat:

\documentclass{article}
\usepackage{blkarray}
\usepackage{multirow}
\usepackage{amsmath, amssymb}
\usepackage{stackengine}
\newcommand{\xor}{\mathrel{\stackMath\stackinset{l}{-1pt}{c}{0pt}{\scriptscriptstyle\bullet}{ + }}}


\begin{document}

\begin{alignat}{2}
g^B(x )& = \begin{cases}T \\ F \end{cases}
& &\begin{aligned}
    & \text{if } x \text{ is }\mathsf{T}, \\
    & \text{if } x \text{ is }\mathsf{F}.
\end{aligned} \\
g^\ell (x) & = a \xor
 g^B(z) &\qquad & \text{if }x = y\triangleleft a \triangleright z \\
g^B(x )& = \begin{cases}T \\ F \end{cases}
 & &\begin{aligned}
    & \text{if } x \text{ is }\mathsf{T}, \\%
    & \text{if } x \text{ is }\mathsf{F}.
\end{aligned}
\end{alignat}

\end{document}

enter image description here

Bernard
  • 271,350