5

So basically I need to put a vector symbol (\vec) on an upright letter for which I use \mathrm in math mode. For example:

\vec{\mathrm{E}}

While Katex seems to get the alignment right on all the letters:

Katex

My pdfTeX version doesn't do so well (using the same code):

pdflatex

Clearly the vector symbol is positioned such that it would be aligned if the letters were in italic mode.

Which leads me to the following question:

  • How can I get the vector symbol aligned with the upright math letter using pdfTeX?

pdfTeX version

$ pdflatex --version
pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian)
kpathsea version 6.2.1

Document setup

\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

Complete example

\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
 \vec{\mathrm{A}}\;\vec{\mathrm{B}}\;\vec{\mathrm{C}}\;\vec{\mathrm{D}}\;\vec{\mathrm{E}}\;\vec{\mathrm{F}}\;\vec{\mathrm{G}}\;\vec{\mathrm{H}}\;\vec{\mathrm{I}}\;\vec{\mathrm{J}}\;\vec{\mathrm{K}}\;\vec{\mathrm{L}}\;\vec{\mathrm{M}}\;\vec{\mathrm{N}}\;\vec{\mathrm{O}}\;\vec{\mathrm{P}}\;\vec{\mathrm{Q}}\;\vec{\mathrm{R}}\;\vec{\mathrm{S}}\;\vec{\mathrm{T}}\;\vec{\mathrm{U}}\;\vec{\mathrm{V}}\;\vec{\mathrm{W}}\;\vec{\mathrm{X}}\;\vec{\mathrm{Y}}\;\vec{\mathrm{Z}}
\end{equation*}

\end{document}
  • Show a complete minimal example, not only some snippets - this makes it much easier to test. – Ulrike Fischer Feb 4 at 8:49
  • 2
    The glyph used for the \vec accent is indeed tailored for best results with italic letters, as the shape of the arrow itself shows. Katex is not a TeX engine, so it can't be used for comparison. Beware that \textrm is the wrong command in that context, use \mathrm. – egreg Feb 4 at 8:50
  • \vec{{}<letter>} try adding the empty group (or a \kern0pt) inside the argument of \vec. – Manuel Feb 4 at 8:52
  • 2
    try \vv{\textrm{E}} from the esvect package – Hafid Boukhoulda Feb 4 at 8:56
  • @UlrikeFischer I assumed the Document setup would already contain all the necessary information. Anyway I've added the complete code that produces the posted screenshot. – a_guest Feb 4 at 16:36
4

Before (\vec) and after (\upvec):

\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\newcommand\upvec[1]{\!\vec{\,\mathrm{#1}}}
\begin{document}
\begin{equation*}
\vec{\mathrm{A}}\;\vec{\mathrm{B}}\;\vec{\mathrm{C}}\;\vec{\mathrm{D}}\;
\vec{\mathrm{E}}\;\vec{\mathrm{F}}\;\vec{\mathrm{G}}\;\vec{\mathrm{H}}\;
\vec{\mathrm{I}}\;\vec{\mathrm{J}}\;\vec{\mathrm{K}}\;\vec{\mathrm{L}}\;
\vec{\mathrm{M}}\;\vec{\mathrm{N}}\;\vec{\mathrm{O}}\;\vec{\mathrm{P}}\;
\vec{\mathrm{Q}}\;\vec{\mathrm{R}}\;\vec{\mathrm{S}}\;\vec{\mathrm{T}}\;
\vec{\mathrm{U}}\;\vec{\mathrm{V}}\;\vec{\mathrm{W}}\;\vec{\mathrm{X}}\;
\vec{\mathrm{Y}}\;\vec{\mathrm{Z}}
\end{equation*}

\begin{equation*}
\upvec A\;\upvec B\;\upvec C\;\upvec D\;\upvec E\;\upvec F\;\upvec G\;
\upvec H\;\upvec I\;\upvec J\;\upvec K\;\upvec L\;\upvec M\;\upvec N\;
\upvec O\;\upvec P\;\upvec Q\;\upvec R\;\upvec S\;\upvec T\;\upvec U\;
\upvec V\;\upvec W\;\upvec X\;\upvec Y\;\upvec Z
\;\upvec{a}
\end{equation*}

\[
\vec A\upvec B f = \upvec D \vec E g
\]
\end{document}

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.