3

I want the middle 5 equations to be aligned at the = and at the 'on'. I tried to use alignat environment for this, but unfortunately it won't work at all. The 'on...' parts keep going beyond the right margin, and I'm not sure why. I want to keep the bottom equation 'separate', so that it doesn't need to be aligned in two places with the rest of the equations, only at the = (due to its length). Below is the code I have tried which I need to fix, and a picture of it when compiled. enter image description here

   \begin{alignat}{2}
\phi &= \begin{cases}
-1 & \text{on }\textbf{$\Gamma$}^{(1)}, \\
+1 & \text{on }\textbf{$\Gamma$}^{(2)} 
\end{cases}
\\
-\Gamma u+\frac{a}{\kappa}u&=\Lambda p &&\text{on }\mathcal{A}
\\
p&=\mathbf{P}(\phi) &&\text{on }\mathcal{B}
\\
[u]^{(2)}_{(1)}&=0 &&\text{on }\gamma
\\
[\nabla_\Gamma u]^{(2)}_{(1)}\cdot\mu&=0 &&\text{on }\gamma
\\
[\nabla_\Gamma u]^{(2)}_{(1)}\cdot\mu&=0 &&\text{on }\gamma,\\
\widehat{\alpha}\mathcal{K}&=-\widehat{b}H_\alpha+\widehat{q}\dashint_\gamma H_\gamma\:{\textrm d}\gamma+\left(\frac{4\kappa\Lambda}{R^2}+2\sigma\Gamma\right)\left(u-\dashint_\gamma u\:{\textrm d}\gamma\right) \\
&\qquad-\kappa\Lambda^2\left(\mathbf{P}(\phi)^{(1)}+\mathbf{P}(\phi)^{(2)}-\dashint_\gamma \mathbf{P}(\phi)^{(1)}+\mathbf{P}(\phi)^{(2)}\:{\textrm d}\gamma\right)
&&\quad\text{on }\gamma.
\end{alignat}

I want the 'on..'s to be at least closer to the rest of the equations, not so far over to the right of the page. Does anyone know how to fix this? I'm guessing its leaving that gap because of the last equation, but I am not sure how to fix this.

2 Answers2

1

The following uses only 1 alignment point, and therefore resorts to align only. All elements to the right of = in the first six equations are set in zero-width (math) boxes, then jumped over by 3em to set their respective on X clauses. The final equation is set using aligned as in egreg's answer, with a minor hack (zero-width right-aligned math box) to align with the rest of the equation set.

The above finagling works because the largest LHS and RHS (used for placement with align; in this case equations 5/6 for LHS and 7 for RHS) can stand on their own. If adjustments were to involve them, some more legwork may be needed.

enter image description here

\documentclass{article}

\usepackage[margin=1in]{geometry}% Just for this example

\usepackage{amsmath}

% from https://tex.stackexchange.com/a/638315/5764, with thanks \makeatletter \newcommand\X@int[1]{% \mathop{}!% \mathchoice {\XX@int\displaystyle\textstyle{#1}}% {\XX@int\textstyle\scriptstyle{#1}}% {\XX@int\scriptstyle\scriptscriptstyle{#1}}% {\XX@int\scriptscriptstyle\scriptscriptstyle{#1}}% \int } \newcommand\XX@int[3]{% \begingroup \sbox0{$#1{#2#3}{\int}$}% \vcenter{\hbox{$#2#3!$}}\kern-.5\wd0 \endgroup } \newcommand\dashint{\X@int-}

\NewDocumentCommand{\mathbox}{o O{c} m}{% \IfValueTF{#1} {\def\mathbox@##1##2{\makebox[#1][#2]{$##1##2$}}} {\def\mathbox@##1##2{\makebox{$##1##2$}}} \mathpalette\mathbox@{#3} } \makeatother

\begin{document}

\begin{align} \phi & % Mimic \begin{cases}...\end{cases} = \renewcommand{\arraystretch}{1.2} \mathbox[0pt][l]{ \left{\begin{array}{ @{} r} -1 \ +1 \end{array}\right.} \hspace{3em} \begin{array}{ @{} l} \text{on $\mathbf{\Gamma}^{(1)}$,} \ \text{on $\mathbf{\Gamma}^{(2)}$} \end{array} \ -\Gamma u + \frac{a}{\kappa} u & = \mathbox[0pt][l]{\Lambda p} \hspace{3em} \text{on $\mathcal{A}$} \ p & = \mathbox[0pt][l]{\mathbf{P}(\phi)} \hspace{3em} \text{on $\mathcal{B}$} \ [u]^{(2)}{(1)} & = \mathbox[0pt][l]{0} \hspace{3em} \text{on $\gamma$} \ [\nabla\Gamma u]^{(2)}{(1)} \cdot \mu & = \mathbox[0pt][l]{0} \hspace{3em} \text{on $\gamma$} \ [\nabla\Gamma u]^{(2)}{(1)} \cdot \mu & = \mathbox[0pt][l]{0} \hspace{3em} \text{on $\gamma$,} \ &\begin{aligned} \mathbox[0pt][r]{\widehat{\alpha} \mathcal{K}} & = -\widehat{b} H\alpha + \widehat{q} \dashint_\gamma H_\gamma:\mathrm{d}\gamma + \biggl(\frac{4 \kappa \Lambda}{R^2} + 2 \sigma \Gamma \biggr) \biggl(u - \dashint_\gamma u:\mathrm{d} \gamma \biggr) \ & \phantom{{}={}} - \kappa \Lambda^2 \biggl( \mathbf{P}(\phi)^{(1)} + \mathbf{P}(\phi)^{(2)} - \dashint_\gamma \mathbf{P}(\phi)^{(1)} + \mathbf{P}(\phi)^{(2)}:\mathrm{d}\gamma \biggr) \text{ on $\gamma$.} \end{aligned} \end{align}

\end{document}

Werner
  • 603,163
0

I'd use gather for this type of display.

\documentclass{article}
\usepackage{amsmath}

% from https://tex.stackexchange.com/a/204565/ with fixes \makeatletter \newcommand\X@int[1]{% \mathop{}!% \mathchoice {\XX@int\displaystyle\textstyle{#1}}% {\XX@int\textstyle\scriptstyle{#1}}% {\XX@int\scriptstyle\scriptscriptstyle{#1}}% {\XX@int\scriptscriptstyle\scriptscriptstyle{#1}}% \int } \newcommand\XX@int[3]{% \begingroup \sbox0{$#1{#2#3}{\int}$}% \vcenter{\hbox{$#2#3!$}}\kern-.5\wd0 \endgroup } \newcommand\dashint{\X@int-} \makeatother

\begin{document}

\begin{gather} \phi = \begin{cases} -1 & \text{on }\textbf{$\Gamma$}^{(1)}, \ +1 & \text{on }\textbf{$\Gamma$}^{(2)} \end{cases} \ {-}\Gamma u+\frac{a}{\kappa}u=\Lambda p \quad\text{on }\mathcal{A} \ p=\mathbf{P}(\phi) \quad\text{on }\mathcal{B} \ [u]^{(2)}{(1)}=0 \quad\text{on }\gamma \ [\nabla\Gamma u]^{(2)}{(1)}\cdot\mu=0 \quad\text{on }\gamma \ [\nabla\Gamma u]^{(2)}{(1)}\cdot\mu=0 \quad\text{on }\gamma \ \begin{aligned} \widehat{\alpha}\mathcal{K}= &-\widehat{b}H\alpha +\widehat{q}\dashint_\gamma H_\gamma,\mathrm{d}\gamma +\left(\frac{4\kappa\Lambda}{R^2}+2\sigma\Gamma\right) \left(u-\dashint_\gamma u,\mathrm{d}\gamma\right) \ &-\kappa\Lambda^2\left(\mathbf{P}(\phi)^{(1)} +\mathbf{P}(\phi)^{(2)} -\dashint_\gamma \mathbf{P}(\phi)^{(1)} +\mathbf{P}(\phi)^{(2)},\mathrm{d}\gamma\right)\quad\text{on }\gamma. \end{aligned} \end{gather}

\end{document}

enter image description here

egreg
  • 1,121,712