# Aligning numbering in a system of equation so it's centered

In the following code ...

$\begin{cases} 2y+4x=9 & \text{(I)} \\ 3x-2x=10 & \text{(II)} \end{cases}$


... I want the (I) to be centered above (II). Right now they are aligned above each other but to the left. How do I do this?

-
See my answer, you will gain 2 useful features when using systeme package. – kiss my armpit Dec 19 '13 at 18:24

Not too beautifull, but gives the desired effect:

\documentclass{amsart}

\begin{document}

\newlength\Ilength
\settowidth{\Ilength}{I}
$\begin{cases} 2y+4x=9 & \text{\hspace{0.5\Ilength}(I)} \\ 3x-2x=10 & \text{(II)} \end{cases}$

\end{document}


-
Thanks!! appreciate it. Now my eyes dont hurt anymore :=) – Hankyboy Dec 19 '13 at 17:05

You can be bold and redefine cases to take an optional argument for specifying the alignment in the second column:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\renewcommand\env@cases[1][l]{%
\let\@ifnextchar\new@ifnextchar
\left\lbrace
\def\arraystretch{1.2}%
}
\makeatother

\begin{document}
Here is a system
$\begin{cases}[c] 2y+4x=9 & \text{(I)} \\ 3x-2x=10 & \text{(II)} \end{cases}$
and here a famous function
$f(x)=\begin{cases} 0 & \text{if x is rational} \\ 1 & \text{if x is irrational} \end{cases}$

\end{document}


Explanation: in the original definition of \env@cases there is

  \array{@{}l@{\quad}l@{}}%


so we can easily change the second l to be what we like more.

If you prefer to use systeme, as suggested in another answer, here's the way:

\documentclass{article}
\usepackage{systeme}

\begin{document}

$\syscodeextracol{\quad\hfil}{\hfil\hfil} \systeme{ 2y+4x=9@(I), 3x-2y=10@(II) }$

\end{document}


For automatically numbered equations, here's the trick:

$\syscodeextracol{\quad\hfil}{\hfil\hfil} \systeme{ 2y+4x=9@(\uppercase\expandafter{\romannumeral*}), 3x-2y=10@(\uppercase\expandafter{\romannumeral*}) }$

-
@StiffJokes I can't see any difference from the standard output of (I) – egreg Dec 19 '13 at 18:31
@StiffJokes What bug are you talking about? – egreg Dec 19 '13 at 18:33
The unbalanced ends of the parenthesis where the buttom end seems to be moved downward. – kiss my armpit Dec 19 '13 at 18:35

Don't try to reinvent the wheel.

\documentclass[preview,border=12pt,varwidth]{standalone}
\usepackage{systeme,mathtools}

\sysautonum*{(\uppercase\expandafter{\romannumeral*})}

\begin{document}
\abovedisplayskip=0pt\relax% don't use this line in your production.
$\systeme{ 2y+4x=91, 3x-2y=10}$
\end{document}


With systeme package, you will get 2 advantages:

1. The coefficients of the system of equations will be automatically arranged. We typed

2y+4x=9
3x-2y=10


but they will be rendered as

4x+2y=9
3x-2y=10

2. The equation numbers will be automatically generated without our awareness.

-
Sorry the last edit accidentally removed the annotation that the third and fourth lines (from the top) were stolen from egreg's answer. :-) – kiss my armpit Dec 19 '13 at 19:16

In the first cases group below, the roman numerals are center-set by inserting \hfill directives to the left and right of the numerals. (I've added a third line and a number "III" to your example to make the effects of various alignment choices more obvious.)

When Roman numerals are used to enumerate items, typographic convention generally calls for right-aligning the numerals rather than for left-aligning or centering them. Right-alignment may be accomplished by inserting \hfill directives to the left of the numerals, as is done in the second cases environment below.

\documentclass{amsart}
\begin{document}
$\begin{cases} 2x+4y=11 & \hfill \text{(I)} \hfill\\ 3x-2y=10 & \hfill \text{(II)} \hfill\\ 5x+2x=21 & \text{(III)} \hfill \end{cases}$

$\begin{cases} 2x+4y=11 & \hfill \text{(I)} \\ 3x-2y=10 & \hfill \text{(II)}\\ 5x+2y=21 & \text{(III)} \end{cases}$
\end{document}


You may be wondering why this method works, especially as it functions without loading extra packages and/or defining and calculating auxiliary length parameters. The cases environment is defined internally as an array in which both columns are left-aligned through a behing-the-scenes insertion of \hfil directives to the right of each column's contents; \hfil inserts "infinitely stretchable glue" (to use a rather TeXnical term), which pushes the contents of the cell to the left. Because \hfill inserts glue that's "infinitely more stretchable" than that of \hfil, inserting \hfill either to the left (to right-align the contents) or to both the left and right (to center the contents) overrides the action of \hfil.

-