1

Feeding latex or pdflatex with

\documentclass{article} \usepackage{newtxmath} \begin{document} \(\mathit{\vec{var}}\) \end{document} 

results in

var

without any arrow and without any warning on the console. (One has to look into the log to see “Missing character: There is no ® in font cmti10!” and wonder what ® means 🙂.) Of course, the problem can be circumvented by dropping \usepackage{newtxmath} or exchanging the order of calling \vec and \mathit. However, since the calls to the two macros may be hidden inside other macros (and for my larger, non-minimal LaTeX sources, they are indeed hidden inside other macros), it would be better to solve the problem already on the level of the preamble or in the NewTX package or by patching it in such a way that the user's main document needn't be changed. Any idea how to do this? I informed the NewTX maintainer. (However, he didn't reply within two months, so whoever wishes to ping him, please feel free…)

PS. For xelatex/lualatex and TeX Gyre Termes (Math), cf. \mathit{\vec{…}} silently swallows up the vector when using xelatex/lualatex, unicode-math, and TeX Gyre Termes (Math) .

PPS. The best workaround so far is given by Vincent's answer http://tex.stackexchange.com/a/643761 .

3
  • Why \mathit{\vec{var}}? It should be \vec{\mathit{var}}. Commented May 11, 2022 at 8:01
  • @egreg mathit and vec come from the internals of two commands. The outer command (that reduces to mathit in my question) tries to interpret the argument as a term variable and typeset it as such a variable, regardless of how many letters it has and whether it has any dashes, underscores or accents. The inner command (that reduces to vec in my question) typesets the argument as a vector. So, semantically, \mathit{\vec{foo}} says that the vector foo is to be typeset as a term variable (in the context of some formula). Commented May 14, 2022 at 1:06
  • @egreg The other way round, \vec{\mathit{foo}} would mean: typeset the variable foo as a vector or typeset the application of the overrightarrow operation (which is defined in the book I typeset) to the variable foo. The semantic meaning is different. In fact, semantically, I have both: (1) typeset a vector as a term variable (rather than, e.g., as a term constant, or as an n-ary operation, or as a sort name) and (2) apply the overrightarrow operation (whatever it means) to a term variable. Commented May 14, 2022 at 1:15

1 Answer 1

2

I'm not sure how you could get \vec to forget the italic shape, but a workaround would be to use newtxmath's \vv command instead of \vec. It's another command to add an arrow above other symbols, but its length adapts to the argument (see section 19.4 of the documentation for more details).

\documentclass[11pt]{article} \usepackage{newtxmath} \begin{document} \(\mathit{\vv{var}}\) \end{document} 
6
  • That's right, \vv works; I forgot to mention this. That would be yet another workaround, perhaps, the best one for latex/pdflatex with NewTX. Commented May 11, 2022 at 0:54
  • @GeekestGeek and if you're also happy with how \vv looks on a single symbol, you could add \let\vec\vv in the preamble. This way, you shouldn't have to change anything else in the document to see the arrows appear everywhere. Commented May 11, 2022 at 0:58
  • I'm also unsure what you mean by getting “\vec to forget the italic shape”. Commented May 11, 2022 at 1:07
  • I remember having preferred \vec to \vv for my large book months ago for some reason. I'd have to re-check. In any case, this would be a partial solution, if at all, because I have more or less the same question for UTF-8 engines. Of course, \ifluatex and \ifxetex exist, but they add up to the hassle. Fixing NewTX would be cleaner. Commented May 11, 2022 at 1:08
  • @GeekestGeek From my understanding, what happens is that when writing \mathit{\vec{var}}, LaTeX tries to write the letters "var" with the arrow above, all in italic font. However, it doesn't find the arrow in the italic font. This is what I meant by "getting \vec to forget the italic shape": in the end you just want for \mathit{\vec{var}} to write "var" in italic font and add an arrow in normal font. Commented May 11, 2022 at 1:27

You must log in to answer this question.