Now I use f^{\prime \prime} for double prime. I feel that there should be a better way, but I cannot find how to do it in google or stackexchange. Thanks!
- 259,911
- 34
- 706
- 1,036
- 301
2 Answers
The easiest version of course is just to use $f''(x)$ as egreg mentioned in comments. This is supported by pdfLaTeX and really easy to type.
The prime, double prime, and triple prime have their own unicodes U+2032, U+2033, and U+2034 which you could address with help of the package fontspec via \symbol{"2032}....
This will require Xe- or LuaLaTeX. However, in this case I would recommend the package unicode-math which has all three unicodes wrapped in their own macros. They are easy to type, easy to understand, less bold than the standard version, and have a better (subjectively) kerning to the following parenthesis. The MWE shows the normal and the unicode-math way:
% arara: lualatex
\documentclass{article}
\usepackage{unicode-math}
\begin{document}
\noindent
$f'(x)$\\
$f\prime(x)$\\
$f''(x)$\\
$f\dprime(x)$\\
$f'''(x)$\\
$f\trprime(x)$\\
\end{document}

If you want to stick to pdfLaTeX, you may define your own commands of course. This could look like this:
% arara: pdflatex
\documentclass{article}
\newcommand*{\myprime}{^{\prime}\mkern-1.2mu}
\newcommand*{\mydprime}{^{\prime\prime}\mkern-1.2mu}
\newcommand*{\mytrprime}{^{\prime\prime\prime}\mkern-1.2mu}
\begin{document}
\noindent
$f'(x)$\\
$f\myprime(x)$\\
$f''(x)$\\
$f\mydprime(x)$\\
$f'''(x)$\\
$f\mytrprime(x)$
\end{document}

- 43,807
-
For triple, it is
trprimeortprime? For double, it isdprime, notdbprime! – Sigur Nov 03 '14 at 12:05 -
2@Sigur As shown in my MWE, which compiles.
dprimeandtrprime. The custom macros can be named as you please, of course. And if you think,dbprimeortprimewould be a better choice, you should address that here. – LaRiFaRi Nov 03 '14 at 12:11 -
unicode-mathis supposed to use the correct glyph for multiple primes if they're present in the math font. The fact it doesn't seems like a bug. – egreg Nov 03 '14 at 12:50 -
Thanks! Really helpful! In the end I used f''(x) in pdflatex. As I use lyx, f'(x) and f^\prime(x) look different in lyx, but they look the same in pdf, and f''(x) looks much better than f^{\prime \prime}(x) in pdf. – Yikai Wang Nov 04 '14 at 14:56
You could do the same as in the previous case by using insead of "newcommand" "declaremathoperator" on that place I thing it is little bit more straightforward... this is for example for double prime
\documentclass{article}
\DeclareMathOperator*{\dprime}{\prime \prime}
\begin{document}
$f''(x)$\\
$f^\dprime(x)$
\end{document}
- 303
-
5Welcome to TeX.SX! I'm sorry, but this is the wrong way. Much more simply,
\newcommand{\dprime}{{\prime\prime}}would allow$f^\dprime(x)$. I still think that$f''(x)$is the way to go. – egreg Jan 17 '16 at 16:21 -
\DeclareMathOperatoris not the same as\newcommand; it changes the spacing. – Arun Debray Jan 17 '16 at 16:49
f''(x)will do (any number of apostrophes is allowed. – egreg Nov 03 '14 at 10:31