I'm trying to produce an arrow similar to $\nrightarrow $ only with the smaller line being vertical rather than horizontal. I went over the big list of latex symbols several times and could not find it. Any help would be appreciated (I'm using xypic, so extended codes are fine if xypic supports them).
[Tex/LaTex] code for arrow with a short vertical line in the middle of the shaft
arrows
Related Solutions
The decorations
library can be used to all kinds of stuff like this. Unfortunately it is slightly verbose.
\usetikzlibrary{decorations.markings}
\begin{scope}[very thick,decoration={
markings,
mark=at position 0.5 with {\arrow{>}}}
]
\draw[postaction={decorate}] (-4,0)--(4,0);
\draw[postaction={decorate}] (4,0)--(4,2);
\draw[postaction={decorate}] (4,2)--(-4,2);
\draw[postaction={decorate}] (-4,2)--(-4,0);
\end{scope}
As noticed, the markings
mechanism puts the arrow in the selected position
taking as reference its arrowhead. The following example demonstrates it clearly:
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.markings,plotmarks}
\begin{document}
\begin{tikzpicture}[
middlearrow/.style 2 args={
decoration={
markings,
mark=at position 0.5 with {\arrow{triangle 45}, \node[#1] {#2};}
},
postaction={decorate}
},
my mark/.style={
decoration={
markings,
mark=at position 0.5 with{\color{red}\pgfuseplotmark{x}},
},
postaction=decorate,
}
]
\draw[middlearrow={below}{+},my mark] (0,0) -- (1,0);
\draw[middlearrow={below}{+},my mark] (0,-1) -- (2,-1);
\draw[middlearrow={below}{+},my mark] (0,-2) -- (4,-2);
\end{tikzpicture}
\end{document}
What to do then? Steven showed one possibility. The same approach can be taken, easily, using only TikZ options, specifically xshift
:
\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.markings,plotmarks}
\begin{document}
\begin{tikzpicture}[
middlearrow/.style 2 args={
decoration={
markings,
mark=at position 0.5 with {\arrow[xshift=3.333pt]{triangle 45}, \node[#1] {#2};}
},
postaction={decorate}
},
]
\draw[middlearrow={below}{+}] (0,0) -- (1,0);
\draw[middlearrow={below}{+}] (0,-1) -- (2,-1);
\draw[middlearrow={below}{+}] (0,-2) -- (4,-2);
\end{tikzpicture}
\end{document}
The "magic number" seems to be correct. To be really precise, one should go in pgflibraryarrows.code.tex
file and compute the exact width of triangle 45
arrow.
This solution does not prevent errors while changing line width.
Best Answer
Something like the following?
To fine-tune the position of the vertical bar along the shaft of the arrow, either decrease or increase the arguments of both
\mkern
directives by the same amounts; just make sure that the arguments sum to-9mu
.