13

I use a tilde below a letter as a symbol for a vector. Redefining the \vec-command delivers a good output, but subscripts are a pain. I'm using the following code:

\documentclass[10pt,a4paper]{article}
\usepackage{amsmath}
\begin{document}
\renewcommand{\vec}[1]{{\underset{\sim}{#1}}}
$\vec v = \vec{e}_x + 2 \vec{e}_y + 3\vec{e}_z $
\end{document}

This produces the following output:

bad output

The space between the symbol and the tilde is too big and the subscript for the unit vectors is too low.

I'd like this better:

good output

I already tried multiple variations, e.g. {\vec{e}}_x, but the problem persists.

Any ideas?

3 Answers 3

13

You maybe want to use accents:

\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}

\newcommand{\ut}[1]{\underaccent{\tilde}{#1}}
\renewcommand{\vec}[1]{\ut{#1}}

\begin{document}

$\vec v = \vec{e}_x + 2 \vec{e}_y + 3\vec{e}_z $

\end{document}

enter image description here

2
  • 3
    @jaytar On the other hand, there are better ways for denoting vectors, for instance with \mathbf or \bm.
    – egreg
    Aug 29, 2017 at 9:59
  • I guess that depends on personal preference. I also like bold font for vectors, but I have to use the tilde notation. This is especially helpful for tensors of different dimensions, so a one-dimensional tensor is a tilde, a two-dimensional tensor has two tildes etc. This doesn't work for bold as vector notation.
    – jaytar
    Aug 29, 2017 at 10:02
8

A stackengine solution. The underset gap can be adjusted with the 1st argument to \stackengine.

\documentclass[10pt,a4paper]{article}
\usepackage{amsmath,stackengine}
\renewcommand{\vec}[1]{%
  \smash{\ensurestackMath{\stackengine{1pt}{#1}{\scriptscriptstyle\sim}{U}{c}{F}{F}{S}}}
  \vphantom{#1}
}
\begin{document}
$\vec v = \vec{e}_x + 2 \vec{e}_y + 3\vec{e}_z $
\end{document}

enter image description here

6

Try the same using undertilde package.

The code is as follows. It works for me perfectly.

\documentclass[10pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{undertilde}
\begin{document}
$\utilde{v} = \utilde{e}_{x} + 2 \utilde{e}_{y} + 3\utilde{e}_{z}$ 
\end{document}

enter image description here

3
  • 4
    Perfectly may be a bit of a stretch, considering the tilde collides with the subset x.
    – Joey
    Aug 29, 2017 at 13:33
  • I guess {\utilde e}_x would fix that but put the x too low for your taste, so you might want to \smash{...} it
    – Max
    Sep 20, 2022 at 9:03
  • (Then actually the x might be too far, but I see no way to do better with this \utilde which is slightly too wide for a single character. Logically, what you do have is \utilde{e_x}, because the index x does not apply to {\utilde e} but rather the \utilde applies to the vector {e_x} as an entity.
    – Max
    Sep 20, 2022 at 9:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .