## LaTeX forum ⇒ Math & Science ⇒ Using tabular/array with chemical equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

### Using tabular/array with chemical equations

How can I set the plus signs and right arrow on the last line align between the masses (46 g + 36 g --> 80 g + 2 g) AND align vertically with the plus and right arrow on the first line? This is the closest to what I can get please see the latex code... And yes this is my minimal example believe me.. I've got a huge table with many more equations.

\documentclass[fleqn]{article}\usepackage{amsmath}   \usepackage[version=3]{mhchem}\usepackage{chemmacros}\begin{document}$\begin{tabular}[t]{@{}lllllllll}\ce{$\underset{\begin{tabular}{@{}c@{}}2 molecules \\ 2 mols \\ 2(23) \\ 46g\end{tabular}}{\ce{2Na_{(s)}}}$}&+&\ce{$\underset{\begin{tabular}{@{}c@{}}2 molecules \\ 2 mols \\ 2(18) \\ 36g\end{tabular}}{\ce{2H2O_{(l)}}}$}&\ce{->}&\ce{$\underset{\begin{tabular}{@{}c@{}}2 molecules \\ 2 mols \\ 2(40) \\ 80g\end{tabular}}{\ce{2NaOH_{(aq)}}}$}&+&\ce{$\underset{\begin{tabular}{@{}c@{}}1 molecule \\ 1 mol \\ 2 \\ 2g\end{tabular}}{\ce{H2\gas{}}}$} \\&+&&\ce{->}&&+&\end{tabular}$\end{document}

Tags:

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am
Anyone?

justdeath
Posts: 69
Joined: Mon Sep 05, 2011 10:27 am
You write tabular a little strangely. Here is my tabular:

\documentclass[fleqn]{article}\usepackage{amsmath}   \usepackage[version=3]{mhchem}\usepackage{chemmacros} \begin{document}\begin{tabular}{*{7}{c}}\ce{2 Na_{(s)}} & + & \ce{2H2O_{(l)}} & $\longrightarrow$ & \ce{2NaOH_{(aq)}} & + & \ce{H2\gas{}} \\2 molecules & & 2 molecules & & 2 molecules & & 1 molecule \\2 mols & & 2 mols & & 2 mols & & 1 mol \\2(18) & & 2(22) & & 2(40) & & 2 \\46g & + & 36g & $\longrightarrow$ & 80g & + & 2g\end{tabular}\end{document}

Nikolay
Last edited by justdeath on Thu Sep 22, 2011 11:22 pm, edited 1 time in total.

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am
I'd like to keep the \underset and tabular environment in my code. I am looking for minor tweak if there is one which will allow me to do what you did.

justdeath
Posts: 69
Joined: Mon Sep 05, 2011 10:27 am
This is the closest I can get:

\documentclass[fleqn]{article}\usepackage{amsmath}   \usepackage[version=3]{mhchem}\usepackage{chemmacros} \begin{document}$\begin{tabular}[t]{@{}lllllllll}\ce{$\underset{\begin{tabular}{@{}c@{}}2 molecules \\ 2 mols \\ 2(23) \\ 46g\end{tabular}}{\ce{2Na_{(s)}}}$}&\ce{$\underset{\begin{tabular}{@{}c@{}} \\ \\ \\ + \end{tabular}}+$}&\ce{$\underset{\begin{tabular}{@{}c@{}}2 molecules \\ 2 mols \\ 2(18) \\ 36g\end{tabular}}{\ce{2H2O_{(l)}}}$}&\ce{$\underset{\begin{tabular}{@{}c@{}} \\ \\ \\ $\longrightarrow$ \end{tabular}}\longrightarrow$}&\ce{$\underset{\begin{tabular}{@{}c@{}}2 molecules \\ 2 mols \\ 2(40) \\ 80g\end{tabular}}{\ce{2NaOH_{(aq)}}}$}&\ce{$\underset{\begin{tabular}{@{}c@{}} \\ \\ \\ + \end{tabular}}+$}&\ce{$\underset{\begin{tabular}{@{}c@{}}1 molecule \\ 1 mol \\ 2 \\ 2g\end{tabular}}{\ce{H2\gas{}}}$}\end{tabular}$\end{document}

And the signs on the last row are aligned vertically, but not horizontally (with the masses).

Nikolay

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am
hmmmm.... no sorry wasn't what I was looking for exactly.

cgnieder
Site Moderator
Posts: 1993
Joined: Sat Apr 16, 2011 7:27 pm
Hi,

I don't understand, why you want to keep the \underset command and the tabular environment?

Otherwise I would propose you use the possibilities which the chemmacros package offers, seeing that you are using it already.

\documentclass[fleqn]{article}\usepackage{amsmath}   \usepackage[version=3]{mhchem}\usepackage{chemmacros,siunitx} \begin{document}\newreaction*+{reactionsat}{alignat} \begin{reactionsat*}{6}  & 2 Na\solid{}   && {}  + 2 H2O\liquid{} && -> && 2 NaOH\aq{}    && {}  + H2\gas{} \\  & 2 molecules    && \quad{} 2 molecules  &&    && 2 molecules    && \quad{} 1 molecule \\  & \SI{2}{\mole}  && \quad \SI{2}{\mole}  &&    && \SI{2}{\mole}  && \quad \SI{1}{\mole} \\  & \text{2(23)}   && \quad \text{2(18)}   &&    && \text{2(40)}   && \quad 2 \\  & \SI{46}{\gram} && {}  + \SI{36}{\gram} && -> && \SI{80}{\gram} && {}  + \SI{2}{\gram}\end{reactionsat*} \end{document}

test.jpg (14.14 KiB) Viewed 5243 times

Regards
site moderator & package author

ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am
They are used because of the spacing between the chemical formulas the first line of text beneath it