# [Tex/LaTex] How to produce exponents with variables?

math-mode

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 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.