LaTeX forum ⇒ 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

Postby ghostanime2001 » Tue Apr 09, 2013 8:19 pm

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 2021:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
tommytex
Posts: 39
Joined: Wed Jan 23, 2013 10:04 pm

Extended Vector Arrow

Postby tommytex » Tue Apr 09, 2013 8:48 pm

hi (:

Use this.
\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

Postby localghost » Tue Apr 09, 2013 8:55 pm

tommytex wrote:[…] Use this.
\documentclass[12pt]{article}

\begin{document}
$$\overrightarrow{ABC}$$
$$\overrightarrow{ABCDEFG}$$
\end{document}

[…]

Never ever use $$ … $$ for unnumbered equations (look here for the reason).


Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

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

Re: Extended Vector Arrow

Postby tommytex » Tue Apr 09, 2013 9:06 pm

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

Postby ghostanime2001 » Tue Apr 09, 2013 9:15 pm

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: 2001
Joined: Sat Apr 16, 2011 7:27 pm

Extended Vector Arrow

Postby cgnieder » Tue Apr 09, 2013 9:52 pm

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:

\documentclass[margin=.75cm]{standalone}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\begin{document}
$\overrightarrow{AB}$
\end{document}


ora1.png
ora1.png (2.06 KiB) Viewed 72797 times


\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 72797 times


\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 72797 times


Regards
site moderator & package author

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

Re: Extended Vector Arrow

Postby ghostanime2001 » Tue Apr 09, 2013 10:02 pm

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

Postby tommytex » Tue Apr 09, 2013 10:47 pm

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 72798 times
f_esvect_vec_vvv.jpg
f_esvect_vec_vvv.jpg (2.52 KiB) Viewed 72798 times

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

Re: Extended Vector Arrow

Postby ghostanime2001 » Wed Apr 10, 2013 12:45 am

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: 2001
Joined: Sat Apr 16, 2011 7:27 pm

Extended Vector Arrow

Postby cgnieder » Wed Apr 10, 2013 11:19 pm

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

That actually doesn't tell you much, except that it has a starred variant:
\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:
\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:

\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 72786 times


Regards
site moderator & package author


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 5 guests