TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been muddling along with Latex for a couple of weeks now so I keep hitting a bunch of errors; this one I haven't been able to find a solution for. Basically, I have an inline math function (I don't want it to be an equation) that says this,

$$n_{\text{Alice}}$ = $a$ \times $b$$


$gcd($n_{\text{Alice}}$, $n_{\text{Bob}}$)$
= $gcd($n_{\text{Alice}}$ mod $n_{\text{Bob}}, $n_{\text{Bob}}$)$

It didn't seem right when I wrote it this way but the other option I tried

${$n_{\text{Alice}}$ = $a$ \times $b$}$

Didn't work either.

share|improve this question
up vote 7 down vote accepted

Well, first of all, if your equation is intended to be inline you should be using single $s only - i.e. $ ... $.

In fact, in general, $$ ... $$ is deprecated in LaTeX:

Why is \[ ... \] preferable to $$ ... $$?

Now, onto the main point. I think what you're doing is enclosing the entire mathematical equation in $ ... $ (this is correct) and individual mathematical objects within the equation in $ ... $ as well. This is incorrect.

Try it like this:

$n_{\text{Alice}} = a \times b$

enter image description here


$\gcd(n_{\text{Alice}}, n_{\text{Bob}}) =
\gcd(n_{\text{Alice}} \mod n_{\text{Bob}}, n_{\text{Bob}})$

enter image description here

You may like to play around a bit with the spacing, here. For example, I prefer it like this:

$\gcd(n_{\text{Alice}}, n_{\text{Bob}}) =
\gcd(n_{\text{Alice}} \!\! \mod n_{\text{Bob}}, n_{\text{Bob}})$

enter image description here

Although, I'll be honest, I'm not sure what the optimal result is here.

Just FYI: \! inserts a thin negative space.

Final big word of advice. Don't continue to muddle along. Get yourself a good beginner's guide:

What are good learning resources for a LaTeX beginner?

And nail the basics first. Then, absolutely, the best way to learn is to get your hands dirty and try it out and just use LaTeX. Learn by doing and look up how to do things as and when you need them, and ask here if you need help. But you've got to get first principles out of the way first, and many of those guides are great ways to get information about more tricky stuff as well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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