Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
3  
Why not just \dot\vec{x}}? –  Werner Jan 29 '13 at 20:33
add comment

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:

result


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:

result

Zoom for letter a:

zoom

share|improve this answer
    
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? –  Manuel Jan 29 '13 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. –  Danie Els Jan 30 '13 at 1:47
    
@DanieEls, ok then. I hope someone develops an optimized package in the future. –  Manuel Jan 30 '13 at 13:00
add comment

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} puts text 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.

share|improve this answer
3  
Can you please explain why you did it so? I'm sure that there are several readers not knowing what \hght or \raisebox is ... –  Kurt Jan 29 '13 at 21:20
1  
Ok. Editing answer. –  Eddy_Em Jan 30 '13 at 4:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.