2

(Newbie) hi, how do I produce vector (text symbol(s)) with horizontal bar over it? Better, if possible, would be the \rightharpoonup mark above the letter (or word) that is the vector in question.(hope \rightharpoonup is the correct name for it).

I also have some tensor work to include - is there a package specifically for vector/tensor text?

At the moment I've added the bm package and that fine for bold vector symbol - but I prefer the one described above. thank you.

jss
  • 51
  • There is a tensor package indeed. The \rightharpoonup is lazy physicist vector style, in my point of view (I must know -- I am a lazy physicist ;-)) –  Apr 16 '16 at 15:36
  • \overset{\rightharpoonup}{x}? Requires amsmath. – egreg Apr 16 '16 at 15:37
  • @egreg: I wanted to suggest that, but I don’t like the vertical spacing: it places the harpoon too high over the letter, IMHO. – GuM Apr 16 '16 at 15:41
  • Yes, it is a little on the high side - amazing to see the results render so beautifully though - l am only a couple of days into learning tex. OT Am trying several prep systems at the moment - ps I see tikz is a mere ~800 pages :-) – jss Apr 16 '16 at 16:29

3 Answers3

3

Like this?

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[ascii]{inputenc}

\newcommand*{\ttensor}{\mathbin{\overline{\otimes}}}



\begin{document}
Text \( a\ttensor b \) text.
\end{document}

Addendum: I still owe you an answer to the question you actually asked. Christian’s answer is very good, especially because it provides the extensible harpoons you seem to be asking for (when you speak of covering a whole word); but suppose you don’t like the font that the fdsymbol package uses for that, and you want to stick to “Computer Modern harpoons” (those found in positions "28, "29, "2A, and "2B of the cmmi font); with the help of the amsmath package, it isn’t difficult to manifacture the required commands “by hand”:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[ascii]{inputenc}
\usepackage{amsmath}

\makeatletter

\newcommand*\MY@leftharpoonupfill@{%
    \arrowfill@\leftharpoonup\relbar\relbar
}
\newcommand*\MY@rightharpoonupfill@{%
    \arrowfill@\relbar\relbar\rightharpoonup
}
% These are not needed, for now:
% \newcommand*\MY@leftharpoondownfill@{%
%   \arrowfill@\lefttharpoondown\relbar\relbar
% }
% \newcommand*\MY@rightharpoondownfill@{%
%   \arrowfill@\relbar\relbar\rightharpoondown
% }
\newcommand*\overleftharpoon{%
    \mathpalette{\overarrow@\MY@leftharpoonupfill@}%
}
\newcommand*\overrightharpoon{%
    \mathpalette{\overarrow@\MY@rightharpoonupfill@}%
}

\makeatother



\begin{document}

A formula: \(
    \overrightharpoon{x}:=\overrightharpoon{\textit{counter}}
\).  Another formula: \(
    \overleftharpoon{x}:=\overleftharpoon{\textit{counter}}
\).

\end{document}

And here’s the output:

Output of the second code sample


Second addition: On second thought, it occurred to me that perhaps the size of the covering harpoon is too big: it would look better in \scriptstyle size (when the main size is the text size). This requires a bit more effort:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly 
                                 % declare the paper format.

\usepackage[T1]{fontenc}         % Not necessary, but recommended.

\usepackage[ascii]{inputenc}     % Just to check that the source is still pure,
                                 % 7-bit-clean ASCII when you execute it, as it
                                 % was when I wrote it.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath}

\makeatletter

\newcommand*\MY@leftharpoonupfill@{%
    \arrowfill@\leftharpoonup\relbar\relbar
}
\newcommand*\MY@rightharpoonupfill@{%
    \arrowfill@\relbar\relbar\rightharpoonup
}
% These are not needed, for now:
% \newcommand*\MY@leftharpoondownfill@{%
%   \arrowfill@\lefttharpoondown\relbar\relbar
% }
% \newcommand*\MY@rightharpoondownfill@{%
%   \arrowfill@\relbar\relbar\rightharpoondown
% }
\newcommand*\overleftharpoon{%
    \mathpalette{\overarrow@\MY@leftharpoonupfill@}%
}
\newcommand*\overrightharpoon{%
    \mathpalette{\overarrow@\MY@rightharpoonupfill@}%
}

% Support for smaller size arrows:
\newcommand*\@dblsty@mathpalette[2]{%
    % Works like "\mathpalette", but macro passed in #1 must take
    % (at least) three arguments, of which the first _two_ are
    % style selections.
    \mathchoice
        {#1\displaystyle       \scriptstyle       {#2}}%
        {#1\textstyle          \scriptstyle       {#2}}%
        {#1\scriptstyle        \scriptscriptstyle {#2}}%
        {#1\scriptscriptstyle  \scriptscriptstyle {#2}}%
}
\newcommand*\@dblsty@overarrow@[4]{%
    % #1 := stretchable covering arrow
    % #2 := base style
    % #3 := style for covering arrow
    % #4 := base symbol
    \vbox{\ialign{##\crcr
        #1#3\crcr
        \noalign{\nointerlineskip}%
        $\m@th\hfil #2#4\hfil$\crcr
    }}%
}
\newcommand*\smalloverleftharpoon{%
    \@dblsty@mathpalette{\@dblsty@overarrow@\MY@leftharpoonupfill@}%
}
\newcommand*\smalloverrightharpoon{%
    \@dblsty@mathpalette{\@dblsty@overarrow@\MY@rightharpoonupfill@}%
}

\makeatother



\begin{document}

\section{Normal size}

A formula: \(
    \overrightharpoon{x}:=\overrightharpoon{\textit{counter}}
\).  Another formula: \(
    \overleftharpoon{x}:=\overleftharpoon{\textit{counter}}
\).

\section{Smaller size}

A formula: \(
    \smalloverrightharpoon{x}:=\smalloverrightharpoon{\textit{counter}}
\).  Another formula: \(
    \smalloverleftharpoon{x}:=\smalloverleftharpoon{\textit{counter}}
\).

\end{document}

In the output, you can compare the two sizes and choose your preferred one. Be aware, however, that the smaller size is inconsistent with the other uses of “over-arrows” in the amsmath package.

Output of the third code sample


Third addition: It should be noted that (a robust version of) the two commands \overleftharpoon and \overrightharpoon is defined, in exactly the same way as shown above, by the MnSymbol package. On the other hand, as far as I know the “small” variants are genuine new ones.

GuM
  • 21,558
  • @jss: No, I have probably misunderstood your question. If so, I’ll delete my answer. – GuM Apr 16 '16 at 15:27
  • That's useful in itself and certainly related. thanks – jss Apr 16 '16 at 16:23
  • @GustavoMezzetti I'm looking for such a way to typeset vector. Your "smaller size" looks very good for me. But I didn't success, do you know why the bar splits? http://imgur.com/a/tSoCi – Eric May 03 '17 at 05:09
  • @Eric: The extensible harpoon is rendered by juxtapposing as many minus characters as needed to give the desired length, plus a special character for the harpoon tip. (pdf)TeX computes the exact position of all these characters so that they will line up properly, but sometimes the (PDF) previewer misaligns them slightly due to errors in rounding their position to pixels. It is a mere defect of the previewer that should disappear in print. – GuM May 03 '17 at 23:02
  • @Gustavo Mezzetti I see! Thanks for your explanation. And this is the best way(look) to typeset vector symbol that I see in the internet. – Eric May 04 '17 at 12:38
  • @GustavoMezzetti I come back to this question again. I extracted the minus symbol - from txfonts by \DeclareSymbolFont{vvsymbols}{OMS}{txsy}{m}{n} \SetSymbolFont{vvsymbols}{bold}{OMS}{txsy}{bb}{n} \DeclareMathSymbol{-}{\mathbin}{vvsymbols}{0}. And in this case, the bar really splits, even in print. I think this is due to the change of the minus sign which leads to the inconsistency. I tried to modify the code, but I can't figure out the critical part that I should modified. May I ask for your help? :) – Eric May 24 '17 at 15:18
3

You can use the accents package:

\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}

\begin{document}

$\accentset{\rightharpoonup}{x}$

\end{document}

enter image description here

egreg
  • 1,121,712
2

A solution with fdsymbol, using \overrightharpoon:

\documentclass{article}


\usepackage{fdsymbol}


\begin{document}

$\overrightharpoon{A}$
$\overrightharpoon{All}$

\end{document}

enter image description here

There's also the harpoon package and \overrightharp{A} but this does produce weird symbols, in my point of view.

Please have a look on esvect package as well, with provides nice vector arrows as accents.