Prime in text mode
If you really want the math prime symbol you may simply use $'$
or $\prime$
, or if you want to use it in text and math mode \ensuremath{'}
or \ensuremath{\prime}
, e.g.:
\documentclass{article}
\newcommand*{\everymodeprime}{\ensuremath{\prime}}
\begin{document}
Prime in text mode: \everymodeprime
Prime in math mode: $\everymodeprime$
\end{document}
I've used \prime
instead of '
to avoid typo mistakes.
\ensuremath
does only switch to math mode, if math mode it not already active. So it is often useful to define commands, that uses math mode commands and should work in text and math mode.
The flexisym
package offers \textprime
which can be directly used in math or in text mode:
\documentclass{article}
\usepackage{flexisym}
\begin{document}
a\textprime
$a\textprime$
\end{document}
I don't think there's a \prime
character in text mode. If you want an upright single quote, you can use \textquotesingle
defined in the textcomp
package; alternatively if you actually want a prime, then you can just use $'$
in text mode.