Math & ScienceExtended Vector Arrow

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Extended Vector Arrow

Post by ghostanime2001 »

How do you put an arrow above a vector as in vector AB or vector ABC? I have used \vec but this command works for only single letter vectors but what about multiple character vectors?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

tommytex
Posts: 39
Joined: Wed Jan 23, 2013 10:04 pm

Extended Vector Arrow

Post by tommytex »

hi (:

Use this.

Code: Select all

\documentclass[12pt]{article}

\begin{document}
$$\overrightarrow{ABC}$$
$$\overrightarrow{ABCDEFG}$$
\end{document}
or the package esvect

greez tommy ;)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Extended Vector Arrow

Post by localghost »

tommytex wrote:[…] Use this.

Code: Select all

\documentclass[12pt]{article}

\begin{document}
$$\overrightarrow{ABC}$$
$$\overrightarrow{ABCDEFG}$$
\end{document}
[…]
Never ever use $$ … $$ for unnumbered equations (look here for the reason).


Thorsten
User avatar
tommytex
Posts: 39
Joined: Wed Jan 23, 2013 10:04 pm

Re: Extended Vector Arrow

Post by tommytex »

sorrry thorsten :(

i hoope i can give a better answer next time :?

tommy
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Extended Vector Arrow

Post by ghostanime2001 »

the problem with \overrightarrow is that the arrow touches the top borders of the letters. Are there packages to customize vector arrows ?
Last edited by cgnieder on Tue Apr 09, 2013 9:44 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Extended Vector Arrow

Post by cgnieder »

ghostanime2001 wrote:the problem with \overrightarrow is that the arrow touches the top borders of the letters.
This depends on the font you're using:

Code: Select all

\documentclass[margin=.75cm]{standalone}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\begin{document}
$\overrightarrow{AB}$
\end{document}
ora1.png
ora1.png (2.06 KiB) Viewed 89423 times

Code: Select all

\documentclass[margin=.75cm]{standalone}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage{amsmath}
\usepackage[libertine]{newtxmath}
\begin{document}
$\overrightarrow{AB}$
\end{document}
ora2.png
ora2.png (1.82 KiB) Viewed 89423 times

Code: Select all

\documentclass[margin=.75cm]{standalone}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{MnSymbol}
\begin{document}
$\overrightarrow{AB}$
\end{document}
ora3.png
ora3.png (1.84 KiB) Viewed 89423 times
Regards
site moderator & package author
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: Extended Vector Arrow

Post by ghostanime2001 »

can the arrow be moved just a little bit upward ?
User avatar
tommytex
Posts: 39
Joined: Wed Jan 23, 2013 10:04 pm

Extended Vector Arrow

Post by tommytex »

actually i looked it up and found some nice usage of "esvect" where it works indeed.... using a command called \vv

unfortunately, the page is in german but i think you can get its meaning anyway

see http://www.latex-pfeile.de/ you will have to scroll down a bit
Attachments
a_esvect_vec_vvv.jpg
a_esvect_vec_vvv.jpg (2.51 KiB) Viewed 89424 times
f_esvect_vec_vvv.jpg
f_esvect_vec_vvv.jpg (2.52 KiB) Viewed 89424 times
ghostanime2001
Posts: 402
Joined: Fri May 20, 2011 9:41 am

Re: Extended Vector Arrow

Post by ghostanime2001 »

that's what I wanted to use but if only it can be moved up a little, what is the full command for \vv ? like I know it has to be made up from other commands, so maybe there's a parameter for height and if that could be changed the height of the arrow could also be changed.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Extended Vector Arrow

Post by cgnieder »

ghostanime2001 wrote:what is the full command for \vv ?

That actually doesn't tell you much, except that it has a starred variant:

Code: Select all

\def\vv{\@ifstar{\vvstar}{\vecteur}}
\vvstar calls itself \vecteur which in turn calls ... The code of esvect.sty is only 32 lines long, you could look it up yourself.
ghostanime2001 wrote:maybe there's a parameter for height and if that could be changed the height of the arrow could also be changed.
The macro that actually places the arrow over the letters is the following:

Code: Select all

\def\overvect@#1#2#3{\vbox{\ialign{##\crcr%
 \noalign{\kern-.7pt\nointerlineskip}#1#2\crcr%
 \noalign{\kern-.3pt\nointerlineskip}$\m@th\hfil#2#3\hfil$\crcr}}}
It actually moves the arrow closer to the letters by -.3pt. Changing this value shifts the arrow vertically, so you can play until you find something you like:

Code: Select all

\documentclass[margin=5pt]{standalone}
\usepackage{esvect}
\begin{document}

% original:
$\vv{AB}$

% changed definition:
\makeatletter
\def\overvect@#1#2#3{\vbox{\ialign{##\crcr%
 \noalign{\kern-.7pt\nointerlineskip}#1#2\crcr%
 \noalign{\kern3pt\nointerlineskip}$\m@th\hfil#2#3\hfil$\crcr}}}
\makeatother

$\vv{AB}$

\end{document}
vect.png
vect.png (3.71 KiB) Viewed 89412 times
Regards
site moderator & package author
Post Reply