Math & ScienceMultiline Underset

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

Re: Multiline Underset

Post by ghostanime2001 »

I'm no expert here but i need the spacing between multiline things to be correct. I need it especially for maths to put something like 98.1 g/mol^- and have the correct, readable spacing when it's below 4.5 g say for example. I didn't like tabular because the vertical spacing was not so good, same with array and subarray that's why I asked what 'more' was. I also don't want to manually put spacing \\[2ex] since those are arbitrary amounts and if done like that then the general spacing of items with different formats might make my document look very ugly. I tried to use substack but instead it was used as subscripts and not as "Things below a chemical formula". Maybe there is a way to use multiline substacks. I don't know unfortunately :( I mainly want my items to be center aligned and where I can use \clap or \llap or \rlap those commands since putting amounts below chemical formula's might have units that take up more white space. Thanks once again.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Multiline Underset

Post by Stefan Kottwitz »

\substack usually chooses an appropriate font size and good inter line spacing. Use it like this:

Code: Select all

\documentclass{article}
\usepackage{amsmath}   
\usepackage[version=3]{mhchem}
\begin{document}
\ce{2Al + $\underset{\substack{4.5 \mathrm{g}\\98.1 \mathrm{g/mol}\\
    \text{Top shelf}\\\text{more}}}{\ce{Zn(OH)2}}$ -> Al2(SO4)3 + 3H2}
\end{document}
If it's not simple math content but text and math mixed or complex content, a manual adjustment would be ok - sometimes fine tuning necessary.

Stefan
LaTeX.org admin
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Multiline Underset

Post by ghostanime2001 »

I'm not satisfied with the vertical spacing using \substack. Instead I am happy with the vertical spacing using \parbox. Usually the stuff I need are simple things like 0.0459 mol, 27.1 g/mol^- or 4% m/v or 10 ppm. Nothing too special.

I am looking to combine the awesome vertical space and font size \parbox gives with the centered multiline alignment \substack gives. If \parbox can be somehow be made to look like \substack with \parbox vertical space then my document is complete. Thanks again.

Here is a comparison:

Code: Select all

\documentclass{article}
\usepackage{amsmath}   
\usepackage[version=3]{mhchem}
\begin{document}
\ce{2Al + $\underset{\substack{\text{4.5 g} \\ \text{98.1 g/mol} \\ \text{0.0459 mol}}}{\ce{Zn(OH)2}}$ -> Al2(SO4)3 + 3H2} 
\\[1cm]
\ce{2Al + $\underset{\parbox{2cm}{4.5 g \\ 98.1 g/mol \\ 0.0459 mol}}{\ce{Zn(OH)2}}$ -> Al2(SO4)3 + 3H2}
\end{document}
Post Reply