# I'm getting an error with the $\frac$ function and can't seem to figure out what the issue is

I am trying to get a fraction to show up that has multiple terms in the numerator and only one term in the denominator. I would like the numerator to be "2pi(12,500mi)" and the denominator to be "2pi." In this case I have spelled out pi because I don't know how to make the symbol on this website but I do know how to do it in LaTeX. The code I currently have is:

C=$\frac{2$\pi$(12,500)}{$\pi$}$\\\


When I run this it gives me an error that says:

! Missing \endgroup inserted.
<inserted text>
\endgroup
l.46 C=$\frac{2$\pi$(12,500)}{$\pi$}$\\
?


I originally had this set up as a \nicefrac with the following code:

C=\nicefrac{2$\pi$(12,500)}{$\pi$}\\\


This runs fine without any errors but I would like to use the regular \frac function because it is neater for the particular problem. I'm a bit confused as to why this isn't working when it works for \nicefrac without issue. I was under the impression that the general form of \frac was $\frac{numerator}{denominator}$. I realize that my numerator is a bit more complicated than just a single number but I can't seem to find the mistake. If anyone has any suggestions on how to fix it, I would greatly appreciate it. Also this is my first time posting anything here so hopefully the formatting works out.

• You are already in math mode so don't use $\pi$ but only \pi – Ulrike Fischer Sep 11 '18 at 20:21
• Welcome to TeX.SX! $ is used to open and close math-mode, you don't need to use it everywhere. Use C=$\frac{2\pi(12,500)}{\pi}$. – Phelype Oleinik Sep 11 '18 at 20:21 • Thank you so much for the help. Getting rid of the$$around \pi fixed the problem. This is my second time using LateX so I'm still getting used to the basics. – Alex Adinolfi Sep 11 '18 at 20:26 • @PhelypeOleinik or rather $C=\frac{2\pi(12,500)}{\pi}$ – David Carlisle Sep 11 '18 at 20:37 • I've seen a lot of MathJax code where $ is used like an “escape for strange characters to be input with a backslash in front”. This is not how math mode is supposed to behave. The \nicefrac command is very misleading in this regard, besides producing very dubious output from the typographic point of view. The whole thing you need is a single math formula: $C=\frac{2\pi(12{,}500}{2\pi}$. Note also that paragraphs are not terminated by \\, but by a blank line; the combination \\\ makes very little sense. – egreg Sep 11 '18 at 22:03

I would like the numerator to be 2pi(12,500mi) and the denominator to be 2pi.
In addition to not entering and exiting math mode inside a formula, you also need to take care of displaying a number (12500) and its associated units (miles) correctly. To achieve the latter objective, I suggest you use the \SI macro of the siunitx package. LaTeX strongly encourages writing formulas in a "high level manner", so that the meaning and the specific display choices (use comma as thousands separator? how much space between the number and the units?) are kept separate.
\documentclass{article}
$% start display-math mode C=\frac{2\pi(\SI{12500}{mi})}{2\pi}$  % end display-math mode