# How do I produce exponents with variables? [duplicate]

I would like to do x^(2n), however, when I try to do it, it shows up as (x^2) * n, which is not what I want.

How do I do it the correct way?

• You have to put it all in braces: x^{2n} or x^{(2n)} if you want the parentheses. – Au101 Nov 9 '16 at 17:51
• @TheBitByte - For an answer to your follow-up question, see the posting Show inline math as if it were display math. (Basically, you need to acquaint yourself with when to write \sum and when to write \sum\limits.) – Mico Nov 9 '16 at 17:57
• If I might also make so bold as to plug my own answer, you might (I hope) find this valuable: tex.stackexchange.com/questions/301672/… In any case, much better to ask new questions as new questions, rather than in the comments on different questions, but obviously, hopefully, all your queries on this front have been cleared up :) – Au101 Nov 9 '16 at 18:04
• I usually recommend beginners to always use x^{...} even if the exponent is a single token. Similarly for subscripts. – egreg Nov 9 '16 at 18:08
• This surely must be a duplicate! – cgnieder Nov 9 '16 at 18:08

You have to put the entire exponent in braces, treat it like the argument of any other LaTeX command. You can get away with (for example) x^2 as a shortcut if you have only one character in your exponent. Otherwise, you need to put the whole thing in { ... }.

So you need x^{2n} or x^{(2n)} if you want the parentheses.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$x^{2n} \quad x^{(2n)}$

\end{document}


Personally, I always put braces around my exponents, because I find it more readable (though others may see it as clutter) and because it's a good habit to get into. It's easy to forget the braces when you do need them otherwise, and it's much more of a pain correcting x^n to x^{2n} than it is with x^{n}. I admit, though, it's a bit more cumbersome.