[Tex/LaTex] How to write doubleprime in latex

symbols

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!

Best Answer

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}

enter image description here


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}

enter image description here

Related Question