# math environment again

This follows a previous post which can be found here.
I'm now trying to used that command but I get lots of compilation mistakes and I really don't understand where the problem comes from. This is how I'm using the command:

\documentclass{article}
\usepackage{mathtools}
\newcommand{\twopartdef}[3]{%
\left\{
\begin{array}{ll}
#1 & \mbox{if } #2 \\
#3 & \mbox{otherwise}
\end{array}
\right.
}
\begin{document}
%some text ...
$join^\sharp_{KSet_n}(\{ \alpha_1, \hdots, \alpha_p \}, \{ \beta_1, \hdots, \beta_q \}) = \twopartdef{\{\alpha_1, \hdots, \alpha_p\} \cup \{\beta_1, \hdots, \beta_q\}}{p \leq n et q \leq n}{\top}$
%more text
\end{document}


Here are the main compilation errors:



in the second argument of the command in your code (otherwise, the firs \leq will appear in text mode and this will trigger the error message).

\documentclass{article}
\usepackage{amsmath}
\newcommand{\twopartdef}[3]{%
\begin{cases}
#1 & \text{if #2} \\
#3 & \text{otherwise}
\end{cases}
}
\DeclareMathOperator{\join}{join}

\begin{document}

$\join^\sharp_{KSet_n}(\{ \alpha_1, \hdots, \alpha_p \}, \{ \beta_1, \hdots, \beta_q \}) = \twopartdef{\{\alpha_1, \hdots, \alpha_p\} \cup \{\beta_1, \hdots, \beta_q\}}{p \leq n et q \leq n}{\top}$

\end{document}


And the result:

Notice that I used \DeclareMathOperator to define the operator \join that admits super/subscripts (in a similar fashion to \sum`).

-