# Equation errors - I want to use units in the equation

I´m trying to get some simple equations into my document. However it seems my used units are not equation friendly.

\documentclass[a4paper,DIV10,12pt,headsepline,headings=small]{scrreprt}
\usepackage{lmodern}
%\usepackage[ngerman]{babel}
\usepackage[english]{babel}
\usepackage{cite}
\usepackage[margin=10pt,font=small,labelfont=bf,
labelsep=endash,singlelinecheck=off]{caption}
\usepackage{longtable}
\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{float}
\usepackage{parskip}
\usepackage{setspace}
\usepackage{graphicx}
\onehalfspacing
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{tocloft}
\usepackage{ragged2e}
\usepackage{array}
\usepackage{amsmath}
\usepackage {picins}

\begin{gather}
Thickness&=\frac{100 $\mu$g/$\mathrm{cm}^{2}$}{8.38 $\mu$g/$\mathrm{cm}^{3}$} \\[1ex]
Thickness&=0.199 $\mu$m
\end{gather}


The equation should give me something like: Thickness = (100 µg/cm²) / (8.38 µg /cm³) [without brackets of course]

It seems that my unit definitions are not working properly in equations. There is no problem while using them in a normal text.

I really appreciate any hints!

(hope I used the correct tags)

-
Welcome to TeX.SX! To make life for people trying to help you easier, have a look at meta.tex.stackexchange.com/questions/228/…. Your question would be easier to answer, if you include \begin{document} and \end{document} in your code. Try as well to leave out all packages which are not required to reproduce the problem. – samcarter Oct 22 '13 at 9:29

Use a specialized package such as siunitx that make quite easy to input numbers and units; I'll show three ways to get the same output:

\documentclass[a4paper,DIV10,12pt,headsepline,headings=small]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{textgreek}
\usepackage{siunitx}
\sisetup{text-micro=\textmu,math-micro=\mathmu} % better micro symbol

\begin{document}
\begin{align}
\mathit{Thickness}&=\frac{\SI{100}{\micro\gram/\centi\meter^{2}}}{\SI{8.38}{\micro\gram/\centi\meter^{3}}} \\[1ex]
\mathit{Thickness}&=\SI{0.199}{\micro\meter}
\end{align}
\begin{align}
\mathit{Thickness}&=\frac{\SI{100}{\ug/\cm^{2}}}{\SI{8.38}{\ug/\cm^{3}}} \\[1ex]
\mathit{Thickness}&=\SI{0.199}{\um}
\end{align}
\begin{align}
\mathit{Thickness}&=\frac{\SI{100}{μg/cm^{2}}}{\SI{8.38}{μg/cm^{3}}} \\[1ex]
\mathit{Thickness}&=\SI{0.199}{μm}
\end{align}
\end{document}


-
@HarishKumar I wanted to show three input styles, so it took me a couple of minutes more than you. – egreg Oct 22 '13 at 9:25
Hehe, I was joking. Your μ is really beautiful. +1 for that. :-) – Harish Kumar Oct 22 '13 at 9:28
If you want to show the three input styles, you should also include \square/\squared ad \cubic/\cubed as well as the more generic \raiseto/\tothe macros in the first two examples (the second only being an abbreviated version of the first). – Qrrbrbirlbel Oct 22 '13 at 23:07

For units, you should be using siunitx package.

\documentclass[a4paper,DIV10,12pt,headsepline,headings=small]{scrreprt}
\usepackage{lmodern}
\usepackage{array}
\usepackage{amsmath}
\usepackage[detect-all,per-mode=symbol]{siunitx}
\begin{document}
\begin{align}
\mathit{Thickness} &=\frac{\SI{100}{\micro\gram \per \centi\meter^{2}}}{\SI{8.38}{\micro \gram \per \centi\meter^{3}}} \\[1ex]
\mathit{Thickness} &=\SI{0.199}{\micro \meter}
\end{align}
\end{document}


For details, run texdoc siunitx from command line.

Further your equation with gather shouldn't have &. With gather, your equation will be:

\documentclass[a4paper,DIV10,12pt,headsepline,headings=small]{scrreprt}
\usepackage{lmodern}
\usepackage{array}
\usepackage{amsmath}
\usepackage[detect-all,per-mode=symbol]{siunitx}
\begin{document}
\begin{gather}
\mathit{Thickness} =\frac{\SI{100}{\micro\gram \per \centi\meter^{2}}}{\SI{8.38}{\micro \gram \per \centi\meter^{3}}} \\[1ex]
\mathit{Thickness} =\SI{0.199}{\micro \meter}
\end{gather}
\end{document}


-
please, Thickness should be \mathit. – barbara beeton Oct 22 '13 at 12:28
@barbarabeeton I could not see anything on LHS ;-) – Harish Kumar Oct 22 '13 at 14:31
hmmm. gather enforces math mode. just look at the gap between T and h -- as you have it, Thickness is just a bunch of letter variables multiplying one another. – barbara beeton Oct 22 '13 at 16:28
@barbarabeeton You are right. I was joking. Actually I looked only at the RHS. Thanks for the suggestion. I will correct it. :-) – Harish Kumar Oct 22 '13 at 22:45
@egreg -- nah, i looked at your answer first to make sure you did do it right. (and you did, of course.) – barbara beeton Oct 23 '13 at 7:17