I would like to combine, somehow, \vec{x}
and \dot{x}
so that I get an x with a vector arrow over it and a dot over that. Any suggestions?
2 Answers
How about the obvious, i.e. $\dot{\vec{a}}$
? Spacing is a little off... which could be fixed by using the esvect
package (for vectors in general) and using:
\documentclass{minimal}
\usepackage{esvect}
\begin{document}
$\dot{\vv{a}}$
\end{document}
Result using first solution is on left hand side, using esvect
is on right hand side:
UPDATE:
I added a little solution of my own which has good spacing and uses the normal latex
vector arrow [but requires the accents
package]. This can be obtained using the command \DotVec
(no need for an additional \vec
; code:
\usepackage{accents}
\newcommand*{\DotVec}[1]{%
\accentset{\mbox{\hspace{0.25ex}.}}{\ensuremath{\vec{#1}}}}
I created a document for comparing my solution, the "plain" latex
solution and @Eddy_Em's [I hope that's okay?] solution. Code is:
\documentclass{minimal}
%% solution using esvect
\usepackage{esvect}
%% required for looping all letters
\usepackage{pgffor}
%% my solution using the accents package
\usepackage{accents}
\newcommand*{\DotVec}[1]{%
\accentset{\mbox{\hspace{0.25ex}.}}{\ensuremath{\vec{#1}}}}
%% this is Eddy_Em's solution
\newsavebox{\hght}
\def\dotvec#1{\savebox{\hght}{$\vec{#1}$}\dot{\raisebox{0pt}[.8\ht\hght]{$\vec{#1}$}}}
%% this is used for a little extra vertical space in the below listing
\def\vSpacer{\vrule height 15pt width 0pt}
\begin{document}
\noindent
Order is:
\begin{verbatim*}
\dot{\vec{a}} \dot{\vv{a}} \dotvec{a} \DotVec{a}
\end{verbatim*}
For roman alphabet:\\[5pt]
\par\noindent
\foreach \l in {a,...,z} {%
\vSpacer $\dot{\vec{\l}} \; \dot{\vv{\l}} \; \dotvec{\l} \; \DotVec{\l},\quad$
}
\par\noindent
\foreach \l in {A,...,Z} {%
\vSpacer $\dot{\vec{\l}} \; \dot{\vv{\l}} \; \dotvec{\l} \; \DotVec{\l},\quad$
}
\end{document}
Resulting document:
Zoom for letter a
:
-
esvect
vectors adjust their size pretty well. But if the argument is only one letter, I would like them to be even shorter (as short as the usual\vec{a}
, for example). Is there an easy way of tweaking it that way?– ManuelCommented Jan 29, 2013 at 21:55 -
@Manual: No, esvect is a replacement for the
\overrightarrow
command, which in turn is build up from\relbar
and\rightarrow
. Therefor the shortest version is\rightarrow
. Commented Jan 30, 2013 at 1:47 -
@DanieEls, ok then. I hope someone develops an optimized package in the future.– ManuelCommented Jan 30, 2013 at 13:00
I did it so:
\newsavebox{\hght}
\def\dotvec#1{\savebox{\hght}{$\vec{#1}$}\dot{\raisebox{0pt}[.8\ht\hght]{$\vec{#1}$}}}
Some explanations:
\newsavebox{\boxname}
defines a "saving-box" — a box which can contain anything for some preprocessing (for example every page before output is placed to\box255
);\savebox{\boxname}{text}
putstext
into box\boxname
, we put there our vector;- then we need to add a dot to it (
\dot
), but to avoid a large space between dot and vector we "reduce" height of our vector by 20% (\raisebox
not only "raise" its contents but also can change its height and depth).
Here we've used \savebox
only to measure height of vector, but instead of vector itself in \raisebox
argument we can write \usebox{\hght}
. It could be more quickly because latex won't need to process this box again — it will simply use a ready box.
-
4Can you please explain why you did it so? I'm sure that there are several readers not knowing what
\hght
or\raisebox
is ...– MenschCommented Jan 29, 2013 at 21:20 -
2
\dot\vec{x}}
?