LaTeX forum ⇒ Math & ScienceUsing 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

Postby ghostanime2001 » Wed Sep 21, 2011 2:28 am

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.

  1. \documentclass[fleqn]{article}
  2. \usepackage{amsmath}
  3. \usepackage[version=3]{mhchem}
  4. \usepackage{chemmacros}
  5. \begin{document}
  6. $\begin{tabular}[t]{@{}lllllllll}
  7. \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{}}}$} \\
  8. &+&&\ce{->}&&+&
  9. \end{tabular}$
  10. \end{document}

Tags:

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

Postby ghostanime2001 » Thu Sep 22, 2011 4:45 pm

Anyone?

User avatar
justdeath
Posts: 69
Joined: Mon Sep 05, 2011 10:27 am

Postby justdeath » Thu Sep 22, 2011 6:42 pm

You write tabular a little strangely. Here is my tabular:

  1. \documentclass[fleqn]{article}
  2. \usepackage{amsmath}
  3. \usepackage[version=3]{mhchem}
  4. \usepackage{chemmacros}
  5.  
  6. \begin{document}
  7. \begin{tabular}{*{7}{c}}
  8. \ce{2 Na_{(s)}} & + & \ce{2H2O_{(l)}} & $\longrightarrow$ & \ce{2NaOH_{(aq)}} & + & \ce{H2\gas{}} \\
  9. 2 molecules & & 2 molecules & & 2 molecules & & 1 molecule \\
  10. 2 mols & & 2 mols & & 2 mols & & 1 mol \\
  11. 2(18) & & 2(22) & & 2(40) & & 2 \\
  12. 46g & + & 36g & $\longrightarrow$ & 80g & + & 2g
  13. \end{tabular}
  14. \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

Postby ghostanime2001 » Thu Sep 22, 2011 9:30 pm

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.

User avatar
justdeath
Posts: 69
Joined: Mon Sep 05, 2011 10:27 am

Postby justdeath » Thu Sep 22, 2011 10:37 pm

This is the closest I can get:

  1. \documentclass[fleqn]{article}
  2. \usepackage{amsmath}
  3. \usepackage[version=3]{mhchem}
  4. \usepackage{chemmacros}
  5.  
  6. \begin{document}
  7. $\begin{tabular}[t]{@{}lllllllll}
  8. \ce{$\underset{\begin{tabular}{@{}c@{}}2 molecules \\ 2 mols \\ 2(23) \\ 46g\end{tabular}}{\ce{2Na_{(s)}}}$}&
  9. \ce{$\underset{\begin{tabular}{@{}c@{}} \\ \\ \\ + \end{tabular}}+$}&
  10. \ce{$\underset{\begin{tabular}{@{}c@{}}2 molecules \\ 2 mols \\ 2(18) \\ 36g\end{tabular}}{\ce{2H2O_{(l)}}}$}&
  11. \ce{$\underset{\begin{tabular}{@{}c@{}} \\ \\ \\ $\longrightarrow$ \end{tabular}}\longrightarrow$}&
  12. \ce{$\underset{\begin{tabular}{@{}c@{}}2 molecules \\ 2 mols \\ 2(40) \\ 80g\end{tabular}}{\ce{2NaOH_{(aq)}}}$}&
  13. \ce{$\underset{\begin{tabular}{@{}c@{}} \\ \\ \\ + \end{tabular}}+$}&
  14. \ce{$\underset{\begin{tabular}{@{}c@{}}1 molecule \\ 1 mol \\ 2 \\ 2g\end{tabular}}{\ce{H2\gas{}}}$}
  15. \end{tabular}$
  16. \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

Postby ghostanime2001 » Fri Sep 23, 2011 12:02 am

hmmmm.... no sorry wasn't what I was looking for exactly.

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

Postby cgnieder » Fri Sep 23, 2011 8:10 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.

  1. \documentclass[fleqn]{article}
  2. \usepackage{amsmath}
  3. \usepackage[version=3]{mhchem}
  4. \usepackage{chemmacros,siunitx}
  5.  
  6. \begin{document}
  7. \newreaction*+{reactionsat}{alignat}
  8.  
  9. \begin{reactionsat*}{6}
  10. & 2 Na\solid{} && {} + 2 H2O\liquid{} && -> && 2 NaOH\aq{} && {} + H2\gas{} \\
  11. & 2 molecules && \quad{} 2 molecules && && 2 molecules && \quad{} 1 molecule \\
  12. & \SI{2}{\mole} && \quad \SI{2}{\mole} && && \SI{2}{\mole} && \quad \SI{1}{\mole} \\
  13. & \text{2(23)} && \quad \text{2(18)} && && \text{2(40)} && \quad 2 \\
  14. & \SI{46}{\gram} && {} + \SI{36}{\gram} && -> && \SI{80}{\gram} && {} + \SI{2}{\gram}
  15. \end{reactionsat*}
  16.  
  17. \end{document}

test.jpg
test.jpg (14.14 KiB) Viewed 5243 times


Regards
site moderator & package author

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

Postby ghostanime2001 » Fri Sep 23, 2011 10:35 pm

They are used because of the spacing between the chemical formulas the first line of text beneath it


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 3 guests