Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

Any possibility to align the fractions (units in general) too?

Wobei:
\begin{flalign*}
\noindent \tab \rho _{KOH} & = 2.04 \frac{g}{cm^3} &\\
M_{KOH} & = 56.10 \frac{g}{mol} &\\
c_{KOH} & = 0.05 \frac{mol}{L} &\\
\end{flalign*}

If I add another & they end up completely at the right.

share|improve this question

marked as duplicate by egreg, Jesse, Peter Jansson, Thorsten, Jubobs Jan 15 at 17:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
@EthanBolker How would I insert fractions within text then? –  idkfa Jan 15 at 16:57
    
See tex.stackexchange.com/questions/80165/… - or either of the answers below. –  Ethan Bolker Jan 15 at 17:10

2 Answers 2

up vote 7 down vote accepted

You can use the following:

\documentclass{article}

\usepackage{amsmath}
\usepackage[per-mode = fraction]{siunitx}
\usepackage{chemmacros}

\begin{document}

\begin{alignat*}{2}
\rho_{\ch{KOH}} &=  &  2.04\,&\si{\g\per\cubic\cm} \\
   M_{\ch{KOH}} &={}& 56.10\,&\si{\g\per\mol}      \\
   c_{\ch{KOH}} &=  &  0.05\,&\si{\mol\per\L}
\end{alignat*}

\end{document}

output

Note: It's a guess that "KOH" is a chemical formula; if not, remove the chemmacros package and write \textup{KOH} instead of \ch{KOH}.

share|improve this answer
    
It might be a bit more in keeping with the syntax of the siunitx package if you wrote \SI{2.04}{\gram\per\cubic\centi\meter} instead of \num{2.04} \,&\frac{\si{\g}}{\si{\cubic\cm}}, etc. -- and loaded the package with the option per-mode = fraction, of course. –  Mico Jan 15 at 17:13
    
Ah, I overlooked that part. Your solution works like a charm for that. –  Mico Jan 15 at 17:15
    
Thank you very much! That helped a lot! I guess indenting it wouldn't be a problem. And yes KOH is potassium hydroxide. –  idkfa Jan 15 at 18:33
    
@SvendTveskæg I finally got around to test your code however I can't get it left-aligned or left-aligned with an indent. –  idkfa Jan 16 at 0:06
    
@SvendTveskæg As far as I know all equations will be left aligned then. I would like my equations centered and my explanation for the values left aligned with an indent. –  idkfa Jan 16 at 14:23

This uses the (in progress) tabstackengine package (introduced at Writing a table with equally spaced columns, based on the widest column, source code at Measuring align). I really need to finish up the documentation to release the code.

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\setstackgap{S}{1.5ex}
\begin{document}
\noindent Wobei:
\par\medskip\noindent\tabbedShortstack[l]{
\rho _{KOH} &= 2.04 &\frac{\mathrm{g}}{\mathrm{cm}^3} \\
M_{KOH} &= 56.10 &\frac{\mathrm{g}}{\mathrm{mol}} \\
c_{KOH} &= 0.05 &\frac{\mathrm{mol}}{\mathrm{L}} \\
}
\end{document}

enter image description here

share|improve this answer
    
Thank you very much, I will definitly look at the tabstack engine however from a first glance I prefer @Svend 's solution. –  idkfa Jan 15 at 18:31
    
I wanted to try your engine however it seems as it is not released yet. Anyway to subscripe to you to get informed on release? –  idkfa Jan 16 at 15:50
    
@idkfa You can copy the source code (tabstackengine.sty) at the link provided in my answer. I have no way to automatically alert you when I get around to releasing it, however, if I am able to remember, I will send a comment your way. Thanks for your interest. –  Steven B. Segletes Jan 16 at 15:52

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