I am trying to redefine \v command (wedge above character) to do what \vec does in mathmode and preserve \v in a command called, say \hac. This code works perfect

line 1: š č ř

line 2: \hac{s} \hac{c} \hac{r} \v{s} \v{c} \v{r}

(line 1 does not print ''š č ř'' as it does not recognize the characters). However, when I add


into the preamble, the first line prints ''s c r'' with a \vec over them. I do not understand where this behaviour is coming from and how to fix it. (Line 2 is always correct, first ''s c r'' is with a wedge and the second is with a \vec). Can anyone please explain?

Alternative way to achieve what I am trying to achieve is to find out syntax of the \v command. I did this using \showcmd in show2e package, finding ''> \v=macro: ->\OT1-cmd \v \OT1\v . \v '', but do not understand the syntax.

Thank you, J

  • 3
    š is defined in cp1250 encoding to be \v s so if you redefine \v you redefine š. Jul 28, 2014 at 14:03
  • 3
    Welcome to TeX.SX! You have discovered why redefining commands, especially those for accents, is dangerous. ;-)
    – egreg
    Jul 28, 2014 at 14:03

2 Answers 2


š is defined in cp1250 encoding (and other encodings) to be \v s so if you redefine \v you redefine š. Redefining a core LaTeX command like \v is unlikely to be worth the effort, it makes your document fragments incompatible with every other LaTeX setup unless you redefine all of LaTeX's accent and encoding support not to use \v.


You can just redefine \v to be \vec in math mode, but stay the original \v in text mode. That way you don't have the portability problems the others mentioned.

You can achieve this as follows (do this in the preamble):

  • This is fantastic, thank you. Could you explain how it works? I've never seen the command \TextOrMath before. Also, it seems that it does not work if \vec is replaced with a more complex expression.
    – pglpm
    May 29, 2020 at 7:07
  • 1
    \TextOrMath does different things depending on the current mode. So, \TextOrMath{textmode}{mathmode} would print textmode in text mode, and math mode in math mode. Any arguments afterwards get passed on, so with the above definitions, \v a would expand to \textv a which is equal to the original \v a which becomes ǎ, whereas $\v a$ would expand to $\vec a$ which becomes a⃗.
    – Marian
    Sep 3, 2020 at 18:09
  • 1
    It does not work with more complex expressions, because normally you would have to put braces around the arguments. You can omit them if, and only if, the argument is just one character or command. I did use this short form above, because each argument is just one command. You just have to use \TextOrMath{\textv}{your more complex expression}.
    – Marian
    Sep 3, 2020 at 18:14

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.