2

I am using the amsmath & mhchem package to get the two equations below which should be aligned properly using the \begin{align} command. However after trying several constellations of &, I still wasn't able to produce a pretty output. The horrendous alignment looks like this: Output

My code looks like this:

\begin{align} 
\ce{^{1}_{0}n ->[\text{$\beta^-$}]& ^{1}_{1}p +& ^{0}_{-1}n^{-} +& \overline{\nu_e}}
\label{eq:n-p_e_v} \\
\ce{939.57 \times 10^6 ->& 938.28 \times 10^6 +& 0.51 \times 10^6 +& 0.78 \times 10^6}
\label{eq:n-p_e_v_energy}
\end{align}

BTW: If you are wondering why I used \ce for the second equation, I did that in order to get the -> reaction arrow, but I suppose there may be better ways to do that.

Any help or solutions will be greatly appreciated :)

whiterock
  • 177
  • Welcome to TeX.SE. Could you add the \documentclass and the package use in order to copy paste your code easily? – Romain Picot Dec 02 '15 at 07:57
  • 1
    what is "align properly" ? shouldn't the alignment just be on the arrow, not on the + (which is forcing the big space)? but as Romain says please make your example complete – David Carlisle Dec 02 '15 at 08:03
  • Sorry for answering so late, I'm quite busy with undergoing the last preparations for my final exams. Writing a 40 page paper is part of it. @RomainPicot The document class used is article. – whiterock Dec 05 '15 at 14:20

1 Answers1

1

Perhaps you want something like this:

\documentclass{article}
\usepackage{amsmath}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}

\makeatletter
\newcommand{\Cen}[2]{%
  \ifmeasuring@
    #2%
  \else
    \makebox[\ifcase\expandafter #1\maxcolumn@widths\fi]{$\displaystyle#2$}%
  \fi
}
\makeatother


\begin{document}

\begin{alignat}{4}
\Cen{1}{\ce{^{1}_{0}n}}
  & \xrightarrow{\beta^-}{}
  & \Cen{3}{\ce{^{1}_{1}p}}
  & +{}
  & \Cen{5}{\ce{^{0}_{-1}n^{-}}}
  & +{}
  & \Cen{7}{\overline{\nu_e}}
\label{eq:n-p_e_v} \\
\Cen{1}{\num{939.57e6}}
 & \xrightarrow{\hphantom{\beta^-}}{}
 & \Cen{3}{\num{938.28e6}}
 & +{}
 & \Cen{5}{\num{0.51e6}}
 & +{}
 & \Cen{7}{\num{0.78e6}}
\label{eq:n-p_e_v_energy}
\end{alignat}

\end{document}

The \Cen macro is taken from my answer to Aligning equations with left and right comment

enter image description here

egreg
  • 1,121,712
  • Thank you for this brilliant answer, it now looks exactly as I wanted it, and I could even modify your provided code without fiddling around for too long, as it was very understandable and clear :) – whiterock Dec 05 '15 at 14:22