3

The following code

\documentclass[varwidth, margin = 1cm]{standalone}
\begin{document}
apostrophe '\\
apostrophe  as a Unicode character 2032 `^^^^2032\\ %requires xelatex                                                                                                                                         
apostrophe in math mode $'$
\end{document}

gives the result

enter image description here As one can see the apostrophe in free form, as a Unicode character 2032 and in math mode appears in different ways.

How can I produce an apostrophe similar to the one in math mode in a free text without using the awkward step of going into math mode?

  • Do you mean something like \newcommand{\apostrophe}{{\quotefont'}}? Display real apostrophe in parts of a document – Bobyandbob Oct 27 '17 at 21:34
  • It's a prime (Unicode U+2032) but most text fonts for pdftex do not have both a curly and straight right quote – David Carlisle Oct 27 '17 at 21:35
  • 1
    \newcommand\textprime{\ensuremath{'}} – egreg Oct 27 '17 at 21:40
  • Routine in LuaLaTeX or XeTeX, where you can directly use Unicode with Open Type fonts, thanks to fontspec. Many Open Type fonts, including some available via TeX, have the prime symbol. Then, as David noted, ^^^^2032 places the character without need for math mode. Or you can simply paste it in from a character map. – user139954 Oct 27 '17 at 21:40
  • 1
    @Viesturs Unicode entry only works if your document uses utf-8 encoding. I specifically think of LuaLaTeX and XeTeX (I do not know how it works if it works, in pdflatex). To enter a character at Unicode hex PQRS (where PQRS is 0 to lowercase f) type `^^^^PQRS. Alternatively, find the character in a Unicode character map, copy and paste into your document. – user139954 Oct 28 '17 at 1:52
4

If you want to use pdflatex:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{newunicodechar}

\newcommand{\textprime}{\ensuremath{'}}
\newunicodechar{′}{\textprime}

\begin{document}

Arnol′d

$f'(x)$

\end{document}

enter image description here

Don't use in math mode, unless it's for a single prime.

For XeLaTeX or LuaLaTeX:

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}

\setmainfont{Libertinus Serif}

\newcommand{\safeprime}{\ensuremath{'}}
\newunicodechar{′}{%
  \iffontchar\font`′′\else\safeprime\fi
}

\begin{document}

Arnol′d

\end{document}

The usage of \newunicodechar is a safety measure in case the font doesn't have the glyph corresponding to U+2032 PRIME.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.