5

I want to write something like a table with states and the corresponding equations but the equations are supposed to be aligned, as seen in the picture.

enter image description here

Unfortunately I haven't found a solution yet. I already tried align but then the text isn't centered. That's the code I tried:

\begin{align*}
\textit{State} && \textit{Rate leave} &= \textit{rate enter} \\
(0,0) && \lambda P_{0,0} &= \sum\limits_{n=1}^{\infty} \mu_n P_{0,n} \\
(0,n), n > 0 && (\lambda + \mu_n)P_{0,n} &= \sum\limits_{m=1}^{\infty} \mu_m P_{n,m} \\
(m,n), mn > 0 && (\lambda + \mu_n)P_{m,n} &= \lambda P_{m-1,n}
\end{align*}

Has anybody an idea what I should use to get the text centered?

5

I'd use an array too, but I simplify the header by removing qquad and inserting @{{}={}} instead. Also, I add \renewcommand{\arraystretch}{1.3} for better line spacing. And I agree with @Sebastiano that using text is better.

\documentclass{article}
\usepackage{amsmath}    
\begin{document}

\[ 
\renewcommand{\arraystretch}{1.3}
\begin{array} {c r @{{}={}} l}
\text{State}   & \text{Rate leave}             & \text{rate enter}                 \\ 
(0,0)          & \lambda P_{0,0}               & \sum_{n=1}^{\infty} \mu_n P_{0,n} \\ 
(0,n),\ n > 0  & (\lambda + \mu_n)P_{0,n}      & \sum_{m=1}^{\infty} \mu_m P_{n,m} \\ 
(m,n),\ mn > 0 & \quad(\lambda + \mu_n)P_{m,n} & \lambda P_{m-1,n}
\end{array}
\]

\end{document}

enter image description here

  • Surely +1. IMHO I think that is better \text{State} instead of \textit{State} and the same for \textit{Rate leave}& \textit{rate enter}. – Sebastiano Dec 5 '19 at 21:54
  • 1
    I agree, I updated my answer, thank you. – AboAmmar Dec 5 '19 at 21:59
4

Welcome! A simple array might do.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[\begin{array}{cc@{}r@{\,}@{\,}l}
\textit{State} && \textit{Rate leave} &= \textit{rate enter} \\
(0,0) && \lambda P_{0,0} &= \sum\limits_{n=1}^{\infty} \mu_n P_{0,n} \\
(0,n), n > 0 && (\lambda + \mu_n)P_{0,n} &= \sum\limits_{m=1}^{\infty} \mu_m P_{n,m} \\
(m,n), mn > 0 &\quad& (\lambda + \mu_n)P_{m,n} &= \lambda P_{m-1,n}\\
\end{array}\]
\end{document}

enter image description here

  • Thank you! I didn't know that you could also align equations inside an array. – Marie Dec 5 '19 at 16:15
4

Use array, with a small trick to get the spacing right (no, the correct spacing is not \,).

\documentclass{article}
\usepackage{amsmath,array}

\begin{document}

\begin{equation*}
\begin{array}{@{}  c @{\qquad} r @{} >{{}}l @{}}
\textit{State}     & \textit{Rate leave}      &= \textit{rate enter} \\[1ex]
(0,0)              & \lambda P_{0,0}          &= \sum_{n=1}^{\infty} \mu_n P_{0,n} \\[1ex]
(0,n),\ n > 0  & (\lambda + \mu_n)P_{0,n} &= \sum_{m=1}^{\infty} \mu_m P_{n,m} \\[1ex]
(m,n),\ mn > 0 & (\lambda + \mu_n)P_{m,n} &= \lambda P_{m-1,n}
\end{array}
\end{equation*}

\end{document}

I'd avoid \limits, that will unbalance the whole thing.

enter image description here

  • Sorry, why is your spacing "correct"? (It is a bit sad, really. Rather than acknowledging that someone made the main point, you claim your spacing is "correct", and copy the main point without attribution. IMHO "correct" is what the the OP wants.) – Schrödinger's cat Dec 5 '19 at 18:26
  • @Schrödinger'scat Because it uses the default \thickmuskip instead of a double \thinspace. – egreg Dec 5 '19 at 18:28
  • This does not say it is "correct". – Schrödinger's cat Dec 5 '19 at 18:29
  • @Schrödinger'scat Sorry? As “correct” I mean “the same as around equals signs in all other formulas in the document”. – egreg Dec 5 '19 at 18:29
  • This is different from "correct". Again, IMHO what's going on here is just picking, sorry. – Schrödinger's cat Dec 5 '19 at 18:31
4

Another solution, with a gathered and an aligned environments, together with a couple of \vphantom{\sum...}:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\begin{gathered}[t]
\textit{State} \\
\vphantom{\sum\nolimits_{n=1}^{\infty}}(0,0)\\
\vphantom{\sum\nolimits_{n=1}^{\infty}}(0,n), n > 0 \\
(m,n), mn > 0
\end{gathered}
\hspace{4em}
\begin{aligned}[t]
\textit{Rate leave} &= \textit{rate enter} \\
\lambda P_{0,0} &= \sum\nolimits_{n=1}^{\infty} \mu_n P_{0,n} \\
 (\lambda + \mu_n)P_{0,n} &= \sum\nolimits_{m=1}^{\infty} \mu_m P_{n,m} \\
\lambda + \mu_n)P_{m,n} &= \lambda P_{m-1,n}
\end{aligned}
 \]
 \vskip 4ex
\[
\begin{gathered}[t]
\textit{State} \\
\vphantom{\sum_{n=1}^{\infty}}(0,0)\\
\vphantom{\sum_{n=1}^{\infty}}(0,n), n > 0 \\
(m,n), mn > 0
\end{gathered}
\hspace{4em}
\begin{aligned}[t]
\textit{Rate leave} &= \textit{rate enter} \\
\lambda P_{0,0} &= \sum_{n=1}^{\infty} \mu_n P_{0,n} \\
 (\lambda + \mu_n)P_{0,n} &= \sum_{m=1}^{\infty} \mu_m P_{n,m} \\
\lambda + \mu_n)P_{m,n} &= \lambda P_{m-1,n}
\end{aligned}
 \]

\end{document} 

enter image description here

2

If you want to stick to align, eqparbox's \eqmakebox[<tag>][<align>]{<stuff>} aligns all <stuff> with the same <tag> in the centre. You can change the <align>ment to be left, centre (default) or right.

enter image description here

\documentclass{article}

\usepackage{amsmath,eqparbox}

\begin{document}

\begin{align*}
  \eqmakebox[LHS]{  \textit{State} } &&        \textit{Rate leave} &= \textit{rate enter} \\[1ex]
  \eqmakebox[LHS]{$     (0, 0)    $} &&           \lambda P_{0, 0} &= \textstyle\sum_{n = 1}^\infty \mu_n P_{0, n} \\
  \eqmakebox[LHS]{$ (0, n), n > 0 $} && (\lambda + \mu_n) P_{0, n} &= \textstyle\sum_{m = 1}^\infty \mu_m P_{n, m} \\
  \eqmakebox[LHS]{$(m, n), m n > 0$} && (\lambda + \mu_n) P_{m, n} &= \lambda P_{m - 1, n}
\end{align*}

\end{document}

Since eqparbox's macros uses the auxiliary file to store maximum widths related to a <tag>, you'll have to compile at least twice with every change in the contents of <stuff>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.