How to typeset a primed vector

I write a vector with an arrow above the letter using \vec{p} and sometimes the vector needs to be primed using ' (or ^{\prime}, equivalently).

However, neither

\vec{p}'


nor

\vec{p'}


looks satisfactory (first option: prime dash overlaps with vector arrow, second option: arrow looks misplaced).

How would one write a primed vector?

• If you're happy to use boldface for a vector, I would recommend \renewcommand\vec\mathbf in the pre-amble, and \vec{p}' in the document. – Niel de Beaudrap Jun 19 '13 at 16:15
• I'd hope to stick with the arrow notation. So far, the best I got is \vec{p}^{\, \prime}, but it still doesn't look right. Maybe I'm overthinking this... Possibly decreasing the size of the prime would be an option, while increasing the spacing. – Bernd Jun 19 '13 at 16:19
• I think that \vec{p}^{\,\prime} looks alright myself; but I suppose it depends on precisely what you want to achieve with it. Do beware overthinking it though. – Niel de Beaudrap Jun 19 '13 at 16:26

Priming a vector denoted with the arrow is, as you discovered, not a really good thing to do. You want to prime the letter, not the whole construction.

\documentclass{article}
\newcommand{\pvec}[1]{\vec{#1}\mkern2mu\vphantom{#1}}

\begin{document}
$\vec{p}+\pvec{p}'=\pvec{p}''$
\end{document}


Adding a small amount of space in the first option should make it better:

{\vec{p}\,}'

• Yes, that's what I am currently doing (see my comment above). It still doesn't look perfect to me, but better indeed. – Bernd Jun 19 '13 at 16:25

There's a problem I don't get to understand. And it's the fact that if there are multiple atoms inside a \vec it gets recolocated. I comment a little bit here.

Disclaimer: this is not fully correct (because, for instance, the prime gets recolocated), but the fact that sometimes \vec{{}<something>} looks better than \vec{<something>} annoys me.

A possible solution is:

\let\originalvec\vec
\renewcommand*\vec[1]{\originalvec{\kern0pt #1}}


If that's not enough, you can mix it with egreg's answer

 \newcommand*\pvec[1]{\vec{#1}\mkern1mu\vphantom{#1}}


Full compilable example

\documentclass{scrartcl}

\let\originalvec\vec
\renewcommand\vec[1]{\originalvec{\kern0pt #1}}
\newcommand*\pvec[1]{\vec{#1}\mkern2mu\vphantom{#1}}

\begin{document}
$\vec p + \pvec p' = \pvec p''$

$\vec h = \vec r \times \vec v = \vec r \times \pvec r'$
\end{document}


• Appendix G of The TeXbook, rule 12 ( the rule for Acc atoms) will explain you the special treatment that nuclei consisting of a single character receive: the accent may be shifted right a bit (depending on information contained in the kerning tables associated with the \skewchar of the font of the nucleus) and, more importantly, the superscript and the subscript are positioned before the accent is superimposed. Sorry, I cannot explain better in so few keystrokes... – GuM Jul 1 '15 at 15:56

In this period I have tried various solutions but I am not very convinced and satisfied. I insert some test:

\documentclass{article}
\usepackage{amsmath,amssymb,amsfonts,amsthm}
\usepackage{stackengine}
\usepackage{tcolorbox}

\newcommand\barbelow[1]{\stackunder[1.2pt]{$#1$}{\rule{.8ex}{.075ex}}}
\newcommand\barbon[1]{\stackon[0.5pt]{$#1$}{\rule{.9ex}{.1ex}}}
\newcommand\barbons[1]{\stackon[0.5pt]{$#1$}{\rule{.9ex}{.1ex}}\mkern2mu\vphantom{#1}}
\newcommand\bvec[1]{\barbon{\vec{u}}}

%%----------------------------------------------------------------
%https://tex.stackexchange.com/questions/120029/how-to-typeset-a-primed-vector/253157#253157

\let\originalvec\vec
\renewcommand\vec[1]{\originalvec{\kern0pt #1}}
\newcommand*\pvec[1]{\vec{#1}\mkern2mu\vphantom{#1}}
%%----------------------------------------------------------------
\newcommand\barbona[1]{\stackon[1.2pt]{$#1$}{\rule{.9ex}{.1ex}}}
\newcommand\barbonb[1]{\stackon[1pt]{$#1$}{\rule{.9ex}{.1ex}}}
\newcommand\barbonc[1]{\stackon[0.8pt]{$#1$}{\rule{.9ex}{.1ex}}}
\newcommand\barbond[1]{\stackon[0.5pt]{$#1$}{\rule{.9ex}{.1ex}}}
%%----------------------------------------------------------------
\newcommand\barbonsa[1]{\stackon[1.2pt]{$#1$}{\rule{.9ex}{.1ex}}\mkern2mu\vphantom{#1}}
\newcommand\barbonsb[1]{\stackon[1pt]{$#1$}{\rule{.9ex}{.1ex}}\mkern2mu\vphantom{#1}}
\newcommand\barbonsc[1]{\stackon[0.8pt]{$#1$}{\rule{.9ex}{.1ex}}\mkern2mu\vphantom{#1}}
\newcommand\barbonsd[1]{\stackon[0.5pt]{$#1$}{\rule{.9ex}{.1ex}}\mkern2mu\vphantom{#1}}

\begin{document}

\begin{equation*}
\centering
\begin{cases}
\bar{\vec{u}} - \barbon{\vec{u}}\\
\bar{u}' - \barbon{u}'\\
\bar{\vec{u}}' - \barbon{\vec{u}}' - \barbon{\pvec{u}}' - \tcbox[tcbox raise base]{$\barbons{\vec{u}}'$}\\
\bar{C} - \barbon{C}\\
\bvec{u}\\
\pvec{a}+\pvec{b}+\pvec{t}+\pvec{u}\\
\barbon{\pvec{a}}+\barbon{\pvec{b}}+\barbon{\pvec{t}}+\barbon{\pvec{u}}\\
\end{cases}
\end{equation*}

\begin{center}
\begin{minipage}{.50\textwidth}
\begin{equation*}
\centering
\begin{cases}
\tcbox[tcbox raise base]{$\bar{u}$}\\
\tcbox[tcbox raise base]{$\barbona{\vec{u}}'$}\\
\tcbox[tcbox raise base]{$\barbonb{\vec{u}}'$}\\
\tcbox[tcbox raise base]{$\barbonc{\pvec{u}}'$}\\
\tcbox[tcbox raise base]{$\barbond{\pvec{u}}'$}\\
\end{cases}
\end{equation*}
\end{minipage}\hfill
\begin{minipage}{.50\textwidth}
\begin{equation*}
\centering
\begin{cases}
\tcbox[tcbox raise base]{$\bar{u}$}\\
\tcbox[tcbox raise base]{$\barbonsa{\vec{u}}'$}\\
\tcbox[tcbox raise base]{$\barbonsb{\vec{u}}'$}\\
\tcbox[tcbox raise base]{$\barbonsc{\vec{u}}'$}\\
\tcbox[tcbox raise base]{$\barbonsd{\vec{u}}'$}\\
\end{cases}
\end{equation*}
\end{minipage}
\end{center}
\end{document}


Someone raised this old (but good) question, so I might as well mention an alternative. You can use ISO-style bold italic vectors instead of an arrow.

In PDFLaTeX, you can do this with the isomath package.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amssymb, isomath, bm}

\pagestyle{empty}

\begin{document}
$a \cdot \vectorsym{p}' \times \vectorsym{p}''$
\end{document}


In LuaLaTeX or XeLaTeX, you would use unicode-math.

\documentclass{article}
\usepackage{unicode-math}

\pagestyle{empty}

\newcommand\vectorsym[1]{\symbfit{#1}}

\begin{document}
$a \cdot \vectorsym{p}' \times \vectorsym{p}''$
\end{document}


If you want a bolder prime symbol to match the vector symbol, you can define

\newcommand\boldprime{\boldsymbol{'}}


For this to work in unicode-math, you must load a math font that comes in bold, or \setmathfont with .[version=bold].