# How to write doubleprime in latex

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!

• Welcome to TeX.SX! f''(x) will do (any number of apostrophes is allowed. – egreg Nov 3 '14 at 10:31

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}


• For triple, it is trprime or tprime? For double, it is dprime, not dbprime! – Sigur Nov 3 '14 at 12:05
• @Sigur As shown in my MWE, which compiles. dprime and trprime. The custom macros can be named as you please, of course. And if you think, dbprime or tprime would be a better choice, you should address that here. – LaRiFaRi Nov 3 '14 at 12:11
• unicode-math is 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 3 '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 4 '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}

• Welcome 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
• \DeclareMathOperator is not the same as \newcommand; it changes the spacing. – Arun Debray Jan 17 '16 at 16:49