Although the two outputs look quite similar, what is the advantage of using $f^\prime$ instead of $f'$? By the way, here is my code:

\[‎ ‎f^‎\prime ‎(x)=y‎ ‎\]‎
\[‎ ‎f'‎ ‎(x)=y‎ ‎\]‎‎
  • 52
    There's no advantage in using $f^\prime$; it's just more awkward to type than $f'$ and the result is exactly the same.
    – egreg
    Commented Dec 15, 2012 at 17:14
  • 5
    just don't do f^' Commented Jul 7, 2020 at 0:51
  • 4
    Actually, there is one situation you need ^\prime; when you want to make a parenthesis around the \prime so that you denote it applies to un-primed and primed respectively, you cannot do something like $f^('^)$, you would need $f^{(\prime)}$.
    – Hojin Cho
    Commented Sep 13, 2022 at 12:03

6 Answers 6


TL;DR: ' is a shorthand for ^{\prime}.

' is defined in latex.ltx as active math character:

{\catcode`\'=\active \global\let'\active@math@prime}

The active ' looks for following ' and puts them together as superscript, a''' becomes a^{\prime\prime\prime}. Thus using ' makes the input easier to write.


Sometimes you may want to pass LaTeX code as an argument to another program. In that case the code is typically wrapped in quotes. Using quote to mean a prime will confuse the second program. For example to type TeX in graphical output of MATLAB one may use something like


to print $F'$ at location $(0,0)$. Using $F'$ in the code however becomes problematic.

  • 1
    use double quotes or escapes for the String?
    – MaxNoe
    Commented Jan 26, 2015 at 10:21
  • 2
    @MaxNoe Double quotes don't work in Matlab. String escaping is done with a double quote. So you'd have to write things like 'The symbol f'' is used to represent the first derivative of a function', which looks wrong at a first glance. All things considered, f^\prime doesn't look so bad. Commented Feb 9, 2015 at 22:18

Tl;DR: You can use \prime with additional superscripts.

There is certainly one advantage to using \prime under a particular situation. Suppose you have a map \pi which necessitates the use of another map \pi', which at first seems to be appropriately named.

That is, until you have to pullback something with respect to \pi'. Now you can either write (\pi')^* or \pi^{\prime,*}. The latter looks, arguably, a little better.

But both look horrible.

  • 9
    \pi'^{,*} is perfectly equivalent to \pi^{\prime,*}
    – egreg
    Commented May 16, 2017 at 15:11
  • 2
    @egreg \pi'^{,*} fails with error "double superscript"; \pi^{\prime,*} doesn't (using scrartcl and amsmath). So I prefer the latter … ;-)
    – CL.
    Commented Feb 6, 2019 at 11:32
  • @CL. Works for me with a minimal document. Some more details would be necessary.
    – egreg
    Commented Feb 6, 2019 at 12:08
  • @egreg Figured it out. It's the breqn package that breaks it. MWE.
    – CL.
    Commented Feb 6, 2019 at 13:10
  • 5
    @CL. Besides equations, breqn breaks so many things…
    – egreg
    Commented Feb 6, 2019 at 13:27

I give a practical difference for Emacs users.

If you write $x^{\prime\prime}$ it is all right, if you write $x''$ you completely mess up the AUCTeX syntax coloring.

  • 1
    Which version opf AUCTEX, I have no issues with $x''$
    – daleif
    Commented Jan 10, 2019 at 12:21
  • "12.1.1" I am using the default latex configuration of the latest release version of Spacemacs, so I guess many other people share my latex setting
    – Nisba
    Commented Jan 10, 2019 at 12:25
  • 1
    Interesting, I still use 11.90. Just had a PhD student come by yesterday, who also had problems with AUCTEX 12.1.1, which went away when he downgraded (he installed the Emacs + auctex for Windows there is on CTAN, instead). Seems like I'd better stay of 12.1 for while. Perhaps you should mention this on the auctex mailiing this such that they are aware of the issue.
    – daleif
    Commented Jan 10, 2019 at 13:44
  • 1
    I reported the issue
    – Nisba
    Commented Jan 10, 2019 at 14:11

In fact, there's a slight difference when you have two superscripts. For instance:


The first one fits better.

  • 1
    Sure, but that's related to ' being the same as ^{\prime}, so if you have foo^{'\dag} your prime symbol is superscripted twice. {\bar{e}_k}'^{\dag} will give identical output as far as my eye can tell, but I agree your input is more elegant. Also fiddling with the my input led me to a double superscript error, which is frankly what I expected to begin with, so using foo^{\prime\dag} is definitely a nice idea here, I think
    – Au101
    Commented Jul 19, 2016 at 7:32
  • 8
    You should type \bar{e}_k'^{\dag} (the braces around \bar{e}_k do nothing).
    – egreg
    Commented Jul 19, 2016 at 13:54

Although ' is a shorthand for ^\prime as noted in answers above, this can get in your way when dealing with multiple superscripts in combination with subscripts:

\pi_{s+r}^{\ast\prime} = 
\pi^{\ast\prime}_{s+r} \ne 
\pi^{\ast}'_{s+r}      \ne 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .