I am having a tough time reproducing the following equation in LaTeX:

C = 2/(ω^2 N^(2 )µπa)

This is the code I have:

C = \frac{2}{\omega^2N^2\mu\pia}

However, this throws an error. What am I doing wrong?


The correct solution is to seperate the \pia into \pi a. A slightly more in-depth explanation can be read below.

When you write

  C = \frac{2}{\omega^2N^2\mu\pia}

TeX sees only tokens. The character ^, which initiates an "assignment" to use a superscript for the next token, takes a single token only. \omega^2N^2 then produces the optical result of {omega}superscript{2}<math kern/space*>{N}superscript{2}.

A common way to include multiple tokens is to use the construction with braces. This allows you to typeset multiple tokens in superscript mode, e.g. \omega^{2N+5}. You already did this automatically with the \frac command, which takes two tokens. You can experiment with this by using for instance the command \frac12 (not recommended, just for the purpose of showing the mechanism). This will typeset exactly the same as \frac{1}{2} (which is probably the notation you're used to), and for the same reason \omega^2 and N^2 will work, also in the context of \omega^2N^2, since TeX goes back into regular math mode after having scanned the number 2 after \omega, and so N^2 is typeset correctly as a regular N and consequently a superscript 2.

The same cannot be said about \pia. The issue here is that TeX cannot know that you wish to typeset the character corresponding to "assignment" \pi, to consequently typeset the character a. Furthermore, \pia has no corresponding character or assignment to it, unless you \def it as such:

\def\pia{\ifmmode\pi a\fi}

...but that may be somewhat superfluous and won't contribute to prettier code or an easier workflow.

As Harish Kumar pointed out, a space between the two does the job.

* = This is almost the same as the textual space.

** = I used the term "assignment" rather loosely here.

  • 1
    Why not showing first the correct solution, which is typing \pi a?
    – egreg
    Jan 23 '15 at 10:25

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.