5

I was advised to repost the question. I try and give as much input as possible.

Currently I use this code

\begin{flalign*}
\noindent \tab \rho \textsubscript{KOH} & = \num{2.04}\,\si{\g\per\cubic\cm} &\\[-1pt]
\text{M}\textsubscript{KOH} & =  \num{56.10}\,\si{\g\per\mol} &\\[-1pt]
\text{c}\textsubscript{KOH} & =  \num{0.05}\,\si{\mol\per\L}\\
\end{flalign*}

This results in this

enter image description here

I want the = and fractions to be aligned. Svend gave me in my older question the following code

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

Works like a charme for the units and alignment. However the explanations is centered then. Fleqn will left align all my equations, right? Equations should stay centered. I just would like to add the explanations with a little indent and left aligned.

Also is it possible to make the fractions smaller to avoid those big spaces? If anyone knows what I mean by adding explanations and has a even cooler theme for it I'm open to it. I just want it to look neat in my papers/lab reports.

PS: I am aware that the equation is wrong.

8

I'd define a specific environment:

\documentclass{article}
\usepackage{amsmath,siunitx,chemmacros}
\sisetup{per-mode=fraction}

\newenvironment{wobei}[1][Wobei]
 {#1:\\*[\medskipamount]% <--- Adjust at will
  \hspace*{2em}%             <--- Adjust at will
  $\!\begin{alignedat}{2}}
 {\end{alignedat}$\par\addvspace{\belowdisplayskip}}

\begin{document}
\[
A+B=C
\]
\begin{wobei}
\rho_{\ch{KOH}} &= \num{2.04}  &&\,\si{\g\per\cubic\cm} \\
M_{\ch{KOH}}    &= \num{56.10} &&\,\si{\g\per\mol}      \\
c_{\ch{KOH}}    &= \num{0.05}  &&\,\si{\mol\per\L}
\end{wobei}
\end{document}

My equation is not as wrong as yours. ;-)

enter image description here

You can also call the environment as

\begin{wobei}[Whatever]

and “Whatever:” will be printed instead of “Wobei:”


Following Barbara Beeton's idea in comments, here's a different implementation that allows you to align numbers to their decimal point.

\documentclass{article}
\usepackage{amsmath,siunitx,chemmacros,array}
\sisetup{per-mode=fraction}

\newenvironment{wobei}[2][Wobei]
 {\renewcommand{\arraystretch}{2}%
  #1:\\*[\medskipamount]
  \hspace*{2em}\begin{tabular}{
    @{}
    >{$}r<{$}
    @{${}={}$}
    S[table-format=#2]
    @{\thinspace}
    >{\everymath{\displaystyle}}l
    @{}
  }}
 {\end{tabular}\par}

\begin{document}
\[
A+B=C
\]
\begin{wobei}{2.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{wobei}
\end{document}

Here we have to add a mandatory argument, that is, the number of digits before and after the decimal point in the values. Notice that the equal sign is part of the environment so it shouldn't be typed.

enter image description here

  • in one of the answers to the original (closed) question, the decimal points were aligned. although in math it's more usual to expect the spaces following the equals signs to be the same width, i think in this case (chemistry), the numeric values are more closely tied to the fractional designations; also, although the units are different, having the decimal values aligned makes it easier (for me, at least) to see at first glance the meaning of what is being presented. in that sense, this is more tabular than "equational". – barbara beeton Jan 16 '14 at 18:26
  • @barbarabeeton It's a good idea indeed. – egreg Jan 16 '14 at 18:29
  • I like the idea of having an own command for that. If you like, could you elaborate (shortly) what exactly you did? I would like to understand and learn that. Is there a way to add a little bit more space to the bottom so it does not line up exactly with the next sentence? Also @barbarabeeton made a good point. Thank you! – idkfa Jan 16 '14 at 23:55
3

Here is a solution using flalign*; the idea is to use 3 alignments, the first being empty, and the last one for the explanations – if I understood what you require.

\documentclass[ a4paper]{article}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{lmodern} 
\usepackage[showframe, textwidth = 15cm, nomarginpar, noheadfoot]{geometry} 
\usepackage{mathtools}
\usepackage[per-mode = fraction]{siunitx}
\newcommand\koh{\textsc{\scriptsize koh}}

\begin{document}

This results in this : 
   \begin{flalign*}
      & & c_{\scriptscriptstyle FS} & = \frac{V_{\scriptscriptstyle KOH} \cdot ρ_  {\scriptscriptstyle KOH} }{M_\mathrm{\scriptscriptstyle KOH}} \cdot \frac{100}{V_\mathrm  {{\scriptscriptstyle L}sg}} \cdot c_\mathrm{\scriptscriptstyle KOH}\\
   \shortintertext{Wobei: }
      \mathrlap{\qquad\begin{aligned}
      \rho_\koh & =\hphantom{0}\num{2 .04}\,\si{\g\per\cubic\cm}  \\%
      \mathrm{M}_\koh & =  \num{56.10}\,  \si{\g\per\mol} \\[1pt]
      \mathrm{c}_\koh & = \hphantom{0} \num{0.05}\,  \si{\mol\per\L}
      \end{aligned}}
   \end{flalign*}

\end{document}​

Which results in:

  • I'm sorry if what I wrote was confusing (by the text you can tell I'm not a native speaker) however p,M,c = [...] are the explanations, so the reader knows what values I used. In most cases there is no need to explain that further. I appreciate your answer and effort though! – idkfa Jan 16 '14 at 18:43
  • OK. I modified the code (and the image) accordingly. Does it look more like you want? – Bernard Jan 16 '14 at 19:50
  • Yes this is more like it. Although I don't understand why you defined KOH as a new command. I always use \textsubscript for that. – idkfa Jan 16 '14 at 23:52
  • Oh, that! It's just it was shorter for me to type: I find using smallcaps look better than big caps. But actually, it would have been as good to patch \textsubscript so as to re-define it as \textsubscript{\scshape ...}. – Bernard Jan 17 '14 at 0:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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