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:
\documentclass{article}
\begin{document}
\[ f^\prime (x)=y \]
\[ f' (x)=y \]
\end{document}
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityTL;DR: '
is a shorthand for ^{\prime}
.
'
is defined in latex.ltx
as active math character:
\def\active@math@prime{^\bgroup\prim@s}
{\catcode`\'=\active \global\let'\active@math@prime}
\def\prim@s{%
\prime\futurelet\@let@token\pr@m@s}
\def\pr@m@s{%
\ifx'\@let@token
\expandafter\pr@@@s
\else
\ifx^\@let@token
\expandafter\expandafter\expandafter\pr@@@t
\else
\egroup
\fi
\fi}
\def\pr@@@s#1{\prim@s}
\def\pr@@@t#1#2{#2\egroup}
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
str='$$F^\prime$$'
text(0,0,str,'Interpreter','latex')
to print $F'$ at location $(0,0)$. Using $F'$ in the code however becomes problematic.
'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.
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.
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.
In fact, there's a slight difference when you have two superscripts. For instance:
{\bar{e}_k}^{\prime\dag}
{\bar{e}_k}^{'\dag}
The first one fits better.
'
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
\bar{e}_k'^{\dag}
(the braces around \bar{e}_k
do nothing).
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
\pi_{s+r}^{\ast}'
$f^\prime$
; it's just more awkward to type than$f'$
and the result is exactly the same.^\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)}$
.