# Adding a number in front of a vertical line in bracket equations

I want to add a number in front of this vertical line in this equation here but without it aligning to the middle of the equation, instead aligining to one of the equations.

\begin{equation*}
\left. \begin{cases}
A + B = 1 \\
Ae + Be^2 = 2e^2
\end{cases} \right|
\end{equation*}

• Welcome to TeX.SE.
– Mico
Commented May 14, 2023 at 7:28
• Since you really want the number following the vertical line, it would be better to chnge the title and clarify the question text. Commented May 15, 2023 at 23:31
• A regular array would also do in this case.
– Werner
Commented May 16, 2023 at 15:15

(I edited this answer after the OP clarified that the number should actually come after, not before, the vertical line.)

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{equation*}
\left\{
\begin{matrix*}[l]
A + B = 1 \\
Ae + Be^2 = 2e^2
\end{matrix*}
\right|
\begin{matrix}
5 \\
\phantom{.}
\end{matrix}
\left\{
\begin{matrix*}[l]
A + B = 1 \\
Ae + Be^2 = 2e^2
\end{matrix*}
\right|
\begin{matrix}
\\
9
\end{matrix}
\end{equation*}

\end{document}

\documentclass{article}
\usepackage{amsmath}
\usepackage{tabularray}
\begin{document}
\begin{equation*}
\left\{
\begin{tblr}{columns={colsep=2pt}}
A + B = 1        \\
Ae + Be^2 = 2e^2 \\
\end{tblr}
\middle|
\begin{tblr}{columns={colsep=2pt}}
5 \\
\\
\end{tblr}
\right.
\end{equation*}

\begin{equation*}
\left\{
\begin{tblr}{columns={colsep=2pt}}
A + B = 1        \\
Ae + Be^2 = 2e^2 \\
\end{tblr}
\middle|
\begin{tblr}{columns={colsep=2pt}}
\\
9 \\
\end{tblr}
\right.
\end{equation*}
\end{document}


You can use nicematrix

\documentclass{article}
\usepackage{amsmath}
\usepackage{nicematrix}

\begin{document}

$\begin{NiceArray}{l@{\;\;}l} A+B=1 & e \\ Ae+Be^2=2e^2 \CodeAfter \SubMatrix\{{1-1}{2-1}| \end{NiceArray} \qquad \begin{NiceArray}{l@{\;\;}l} Ae+Be=e \\ Ae+Be^2=2e^2 & -1 \CodeAfter \SubMatrix\{{1-1}{2-1}| \end{NiceArray}$

\end{document}


Another solution with nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

$\setlength{\arraycolsep}{2pt} \begin{NiceArray}{\{l|l} A+B=1 & 5 \\ Ae+Be^2=2e^2 \end{NiceArray} \qquad \begin{NiceArray}{\{l|l} Ae+Be=e \\ Ae+Be^2=2e^2 & 9 \end{NiceArray}$

\end{document}


Using spalign package....

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,spalign}

\begin{document}
\spalignsys{A + B = 1; Ae + Be^2 = 2e^2}\left| \begin{aligned} & \alpha \\ & \end{aligned}\right.\to \spalignsys{A + B = 1; Ae + Be^2 = 2e^2}\left| \begin{aligned} & \\ & \beta \end{aligned}\right.
\end{document}


or this.......

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,spalign}

\begin{document}
\spalignsys{A + B = 1; eA + e^2B = 2e^2}\left| \begin{aligned} & \pi \\ & \end{aligned}\right.\to \spalignsys{A + B = 1; eA + e^2B = 2e^2}\left| \begin{aligned} & \\ & \lambda \end{aligned}\right.
\end{document}


• The vertical alignment across the two components (\spalignsys and aligned) isn't considered here in general. In this instance, you can see that the \alpha is not on the same baseline as 1 (to it's left), for example.
– Werner
Commented May 15, 2023 at 19:25
• @Werner Yes I have seen it but I didn't put a big emphasis on it. Thank you very much. Commented May 15, 2023 at 19:27