Open main menu

Difference between revisions of "Vectors"

(Preliminary description abou the problem of drawing vectors in TeX (a more elaborate description is needed))
 
(Replaced content with "moved to Math/Vectors")
Tag: Replaced
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This short article (being far from complete) is about Math and arrows used for vectors, as in <context>$\overrightarrow{AB}$</context>.
+
moved to [[Math/Vectors]]
 
 
If anyone feels like writing a more extensive article about math arrows in general, you're wellcome to do so.
 
 
 
== Vectors with arrows ==
 
 
 
=== \vec, <context>$\vec{\strut}$</context> ===
 
 
 
The siplest way to write vectors is to use <code>\vec</code>:
 
<context source="yes">
 
$(\vec{\imath}, \vec{\jmath}, \vec{k})$
 
</context>
 
 
 
 
 
However, that solution is not applicable when one needs to use longer arrows, as in:
 
 
 
<context source="yes">
 
$\vec{AB}$
 
</context>
 
 
 
=== \overrightarrow, <context>$\overrightarrow{\strut}$</context> ===
 
 
 
For such cases, the plain format provides another command, \overrightarrow:
 
 
 
<context source="yes">
 
$\overrightarrow{AB}$
 
</context>
 
 
 
 
 
Hovever, again, that command seems to be unsuitable for short letters:
 
<context source="yes">
 
$(\overrightarrow{\imath}, \overrightarrow{\jmath}, \overrightarrow{k})$
 
</context>
 
 
 
which means that one would need to combine both commands at best.
 
 
 
Another nasty property of \overrightarrow is that it doesn't scale down (textstyle, scriptstyle, ...):
 
 
 
<context source="yes">
 
$(X_{Y_{AB}}, X_{Y_{\overrightarrow{AB}}})$
 
</context>
 
 
 
''Wait a minute ... has it really been fixed in ConTeXt when compared to plain TeX ???
 
That's not fair! I cannot demonstrate the problem now! ''
 
-- [[User:Mojca Miklavec|Mojca]] (crying)
 
 
 
Anyway, here's how it looks like in plain TeX:
 
 
 
<context>
 
$(X_{Y_{AB}}, X_{Y_{\displaystyle{\overrightarrow{AB}}}})$
 
</context>
 
 
 
== Vectors with harpoons ==
 
 
 
In some countries vectors are written with harpoons as opposed to arrows. Plain TeX has no support for that, add to that the fact that fonts have no suitable glyphs.
 
 
 
{{todo|clean the code (some might be in the core already), describe Aditya's macros}}
 
 
 
<context>
 
\unprotect
 
 
 
\def\mtharrowfill#1#2#3#4#5#6#7#8% AM: Added #8 (for displaystyle)
 
{$\mathsurround 0pt
 
  \thickmuskip0mu\medmuskip\thickmuskip\thinmuskip\thickmuskip
 
  \relax#8#5%
 
  \mkern-#1mu
 
  \cleaders\hbox{$#8\mkern -#2mu#6\mkern -#3mu$}\hfill
 
  \mkern-#4mu#7$}
 
 
 
%D Now we need to make sure that the extensible arrows do not get
 
%D %D affected. So...
 
 
 
\def\domthxarr#1#2#3#4#5% hm, looks like we do a double mathrel
 
{\begingroup
 
  \def\mtharrfactor{1}%
 
  \def\mtharrextra {0}%
 
  \processaction[#1] % will be sped up
 
    [  \v!none=>\def\mtharrfactor{0},
 
      \v!small=>\def\mtharrextra{10},
 
    \v!medium=>\def\mtharrextra{15},
 
        \v!big=>\def\mtharrextra{20},
 
    \v!normal=>,
 
    \v!default=>,
 
    \v!unknown=>\doifnumberelse{#1}{\def\mtharrextra{#1}}\donothing]%
 
  \mathsurround\zeropoint
 
  \muskip0=\thirdoffourarguments  #2mu
 
  \muskip2=\fourthoffourarguments #2mu
 
  \muskip4=\firstoffourarguments  #2mu
 
  \muskip6=\secondoffourarguments #2mu
 
  \muskip0=\mtharrfactor\muskip0 \advance\muskip0 \mtharrextra mu
 
  \muskip2=\mtharrfactor\muskip2 \advance\muskip2 \mtharrextra mu
 
  \setbox0\hbox{$\scriptstyle
 
                \mkern\muskip4\relax
 
                \mkern\muskip0\relax
 
                #5\relax
 
                \mkern\muskip2\relax
 
                \mkern\muskip6\relax
 
                $}%
 
  \setbox4\hbox{#3\displaystyle}% AM: Added displaystyle
 
  \dimen0\wd0
 
  \ifdim\wd4>\dimen0 \dimen0\wd4 \fi
 
  \setbox2\hbox{$\scriptstyle
 
                \mkern\muskip4\relax
 
                \mkern\muskip0\relax
 
                #4\relax
 
                \mkern\muskip2\relax
 
                \mkern\muskip6\relax
 
                $}%
 
  \ifdim\wd2>\dimen0 \dimen0\wd2 \fi
 
  \setbox4\hbox to \dimen0{#3\displaystyle}% AM: added dislaystyle
 
  \mathrel{\mathop{\hbox to
 
\dimen0{\hss\copy4\hss}}\limits^{\box0}_{\box2}}
 
  \endgroup}
 
 
 
\let\domthxarrsingle\domthxarr
 
 
 
%D Now, for defining overarrows.
 
 
 
\def\definemathoverarrow
 
{\dotripleargument\dodefinemathoverarrow}
 
 
 
\def\dodefinemathoverarrow[#1][#2][#3]%
 
{\ifthirdargument
 
  \setvalue{#1}{\dohandlemathoverarrow[#2][#3]}%
 
  \else
 
  \setvalue{#1}{\dohandlemathoverarrow[\zeropoint][#2]}%
 
  \fi}
 
 
 
\def\dohandlemathoverarrow[#1][#2]%
 
{\mathpalette{\dodohanglemathoverarrow{#1}{#2}}}
 
 
 
% Note: math-pln has \kern-\onepoint, amsmath does not. I keep the
 
% % kern amount as an option. This is useful with overharpoons.
 
 
 
\def\dodohanglemathoverarrow#1#2#3#4%
 
{\vbox{\ialign{##\crcr
 
  #2#3\crcr
 
  \noalign{\kern#1\nointerlineskip}
 
  $\m@th\hfil#3#4\hfil$\crcr}}}
 
 
 
\protect
 
 
 
\definemathoverarrow  [overleftarrow]      [\leftarrowfill]
 
\definemathoverarrow  [overrightarrow]      [\rightarrowfill]
 
\definemathoverarrow  [overleftrightarrow]  [\leftrightarrowfill]
 
 
 
 
 
%$\overleftarrow{A}$ $\overleftarrow{ABC}$
 
%$a_{\overleftarrow{A}}$ $b_{\overleftarrow{ABC}}$
 
%
 
%$\overleftrightarrow{A}$ $\overleftrightarrow{ABC}$
 
%
 
%$a_{\overleftrightarrow{A}}$ $b_{\overleftrightarrow{ABC}}$
 
 
 
\definemathoverarrow [overtwoheadrightarrow]      [\twoheadrightarrowfill]
 
\definemathoverarrow [overtwoheadleftarrow]      [\twoheadleftarrowfill]
 
\definemathoverarrow [overrightharpoondown] [1pt] [\rightharpoondownfill]
 
\definemathoverarrow [overrightharpoonup]        [\rightharpoonupfill]
 
\definemathoverarrow [overleftharpoondown]  [1pt] [\leftharpoondownfill]
 
\definemathoverarrow [overleftharpoonup]          [\leftharpoonupfill]
 
 
 
 
 
\def\definemathshortarrow
 
  {\dotripleargument\dodefinemathshortarrow}
 
 
 
\def\dodefinemathshortarrow[#1][#2][#3]%
 
  {\ifthirdargument
 
      \setvalue{#1}{\dohandlemathshortarrow[#2][#3]}%
 
    \else
 
      \setvalue{#1}{\dohandlemathshortarrow[\zeropoint][#2]}%
 
    \fi}
 
 
 
\def\dohandlemathshortarrow[#1][#2]%
 
  {\mathpalette{\dodohandlemathshortarrow{#1}{#2}}}
 
 
 
\def\dodohandlemathshortarrow#1#2#3#4%
 
  {\setbox0\hbox{$\m@th#3#4$}%
 
  \vbox{\ialign{##\crcr
 
  \mirror{\clip[width=\wd0]{\mirror{$\m@th#2#3$}}}\crcr
 
  \noalign{\kern#1\nointerlineskip}%
 
  $\m@th\hfil#3#4\hfil$\crcr}}}
 
 
 
\definemathshortarrow  [shortoverrightharpoonup]
 
                      [\rightharpoonup]
 
 
 
\let\myvec\shortoverrightharpoonup
 
$(\myvec{\imath},\myvec{\jmath},\myvec{k})$ or $\myvec{\nabla}$, $\myvec{\sigma}$, $\myvec{r}$ or $\displaystyle{A^{\myvec{ABCD}}}$
 
</context>
 
 
 
=== \overrightharpoonup, <context>$\rightharpoonup$</context> ===
 
 
 
{{todo|compare sizes of different arrows}}
 
 
 
== Antykwa Toruńska ==
 
 
 
{{todo|Jacko and Janusz have added some extra glyphs - explore, describe the problem & solution and draw}}
 
 
 
\mathchardef\minusleft="32C9
 
\mathchardef\minusright="32CA
 
\mathchardef\minusc="32C8
 
 
 
== See also ==
 
 
 
This is a [[My Way]] about a related topic:
 
* [http://dl.contextgarden.net/myway/matharrows.pdf Extensible Arrows in ConTeXt] by Aditya Mahajan
 
 
 
 
 
[[Category:Math]]
 

Latest revision as of 19:59, 12 May 2024

moved to Math/Vectors