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'm looking for variations of the symbol \relbar, or any other horizontal line that is about as along as a standard-length arrow.

In particular, I'd like to be able to add arrowheads, as in \leftarrow, \rightarrow, \leftrightarrow.

I also wish to be able to add vertical bars, as in \leftfootline from the MnSymbol package.

Symbols for all of the above exist, but the problem is being able to add them in any combination. For instance, a rightarrow with a vertical bar on the right hand side. This yields 16 possible symbols in total.

Ideas, anyone?

share|improve this question
    
Maybe I don't understand your question but isn't a \relbar with an arrowhead the same as a \rightarrow/\leftarrow? And adding vertical bars yields the \mapsto/\mapsfrom symbols? And vertical bars without the heads is \vdash/\dashv... –  elemakil Feb 1 '13 at 14:14
    
\relbar is just a minus sign treated as a binary relation symbol, but it should never be used alone, as it is "smashed", so it has no height. –  egreg Feb 1 '13 at 14:21
    
@elemakil Well yes but they're aren't all from the same "set". They look different. Also, some combinations are missing. Like what about right arrow with a vertical line on the right hand side? –  user18921 Feb 1 '13 at 14:24
    
@user18921 with some resizing for the ..dash.. macros they look pretty consistent I'd say... but I must admit there's no vertical bar on the same side as the arrowhead. Btw. now I do understand how your count yielded 16... ;) But I must agree with @egreg, \relbar is not meant to be used for what you're trying to achieve, maybe think about using TikZ for creating those symbols. –  elemakil Feb 1 '13 at 14:30
1  
TikZ has a learning curve similar to basketball cockeyed.com/lessons/learning_curve/learning_curve.php –  Yiannis Lazarides Feb 1 '13 at 16:25
show 2 more comments

2 Answers

up vote 4 down vote accepted

One can use TikZ; this is a prototype with a perhaps convenient syntax where the argument to \erelbar consists of two digits (0, 1, 2, or 3):

  • 0 stands for no arrowhead
  • 1 stands for a normal arrowhead
  • 2 stands for a bar
  • 3 stands for both bar and arrowhead

The first digit refers to the left side, the second one to the right side.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}

\makeatletter
\newcommand\@erelb@r[1]{%
  \mathrel{\tikz[baseline=-.5ex]\draw[#1] (0,0)--(0.3,0);}
}
% 0 is for nothing
% 1 is for arrowhead
% 2 is for bar
% 3 is for both
\newcommand{\erelbar}[1]{\@erelbar#1}
\def\@erelbar#1#2{%
  \ifcase\numexpr#1*4+#2\relax
    \@erelb@r{-}\or     % 00
    \@erelb@r{->}\or    % 01
    \@erelb@r{-|}\or    % 02
    \@erelb@r{->|}\or   % 03
    \@erelb@r{<-}\or    % 10
    \@erelb@r{<->}\or   % 11
    \@erelb@r{<-|}\or   % 12
    \@erelb@r{<->}\or   % 13
    \@erelb@r{|-}\or    % 20
    \@erelb@r{|->}\or   % 21
    \@erelb@r{|-|}\or   % 22
    \@erelb@r{|<->|}\or % 23
    \@erelb@r{|<-}\or   % 30
    \@erelb@r{|<->}\or  % 31
    \@erelb@r{|<-|}\or  % 32
    \@erelb@r{|<->|}    % 33
  \else
    \@wrong
  \fi
}
\makeatother
\begin{document}

$a\erelbar{11}b$

$\begin{array}{cccc}
\erelbar{00} & \erelbar{10} & \erelbar{20} & \erelbar{30} \\
\erelbar{01} & \erelbar{11} & \erelbar{21} & \erelbar{31} \\
\erelbar{02} & \erelbar{12} & \erelbar{22} & \erelbar{32} \\
\erelbar{03} & \erelbar{13} & \erelbar{23} & \erelbar{33} \\
\end{array}$
\end{document}

enter image description here

share|improve this answer
    
This is neat! I must start learning TikZ! One thing though, the resulting arrows have a different size than the arrows created by LaTeX's \...arrow commands. They have correct length but are about the half height. –  elemakil Feb 1 '13 at 21:27
    
@elemakil I too. ;-) –  egreg Feb 1 '13 at 21:29
add comment

I'm no expert in using TikZ (which I guess offers by far more tools for creating new symbols), thus I present you my very own \mapsto command as an example how one can combine existing LaTeX symbols. First the MWE:

\documentclass{minimal}

\usepackage{graphicx}

\newcommand\mymapsto{\mathrel{\ooalign{$\rightarrow$\cr%
  \kern-.15ex\raise.275ex\hbox{\scalebox{1}[0.522]{$\mid$}}\cr}}}

\begin{document}
    $\mymapsto$
\end{document}  

and the resulting symbol:

result

obviously the vertical bar is longer than for the original \mapsto but from what you said I assumed that you intend the vertical bars to share the height of the arrowhead.

Now take another look at the MWE, in the definition of the \mymapsto command I superimposed a \rightarrow with a \mid (using \ooalign see this answer for a quick course on \ooalign). Obviously there's a lot of work required when determining the correct dimensions of \kern and \raise, however, using my code as basis you should be able to construct the 15 remaining symbols yourself [don't forget \rotatebox, it will be useful!]. I'd like to stress that you should use the units em or ex when constructing a symbol because when doing so the symbols will remain correct for different fontsizes (or so I'm told).

In constract to using TikZ this solution might be a little less time-consuming, but you won't learn something new in the process I guess...

share|improve this answer
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.