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 am trying to add a cross out on an arrow, by placing a node. However I expierience two cases of odd behaviour:

  1. The node that should be a cross out has an arrow
  2. The arrow is affected by the line width set in the crossout shape

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{scopes}

\begin{document}
\begin{tikzpicture}
    { [every to/.style=bend left]
        \draw[-latex] (1,-1.5) to node[draw, red, sloped, cross out, line width=.5ex, minimum width=1.5ex, minimum height=1ex, anchor=center]{} (0, -.25);
        \draw[-latex] (3,-1.5) to (2, -.25);
    }
\end{tikzpicture}

\end{document}

enter image description here Notice the wide arrow tip of the black path and the arrow in the crossout shape. The picture is not quite up to date, but it is necessary to mention that I need bend left, to explain why I can't accept Peters current solution.

How can I get arround this (I am not to familiar with scoping on paths).

share|improve this question
    
There seem to be two problems: 1. The line width setting of the node does affect the arrow tip (which is rightfully dependent of the line width), but it shouldn’t in this case. 2. The cross out shape is not properly defined and needs a simple setting that no arrow tips should be produced (or you do something like every cross out node/.append style={-}). –  Qrrbrbirlbel Jul 7 '13 at 22:09
    
@Qrrbrbirlbel: any idea how to fix the line style issue. And by the way, if the path is dashed the node is drawn dashed as well, so that has to be taken care off as well. –  ted Jul 7 '13 at 22:13
    
Any special reason that you use a to path but not the basic --? –  percusse Jul 7 '13 at 22:47
    
In my mind -- i s a straight line, while to[bend left] gives a curve, as mentioned the picture is outdated, correct me if I am wrong though. –  ted Jul 7 '13 at 23:12

2 Answers 2

up vote 3 down vote accepted

The cross out

The cross out shape defines a foreground path that simply draws two lines:

\foregroundpath{
  % store lower right in xa/ya and upper right in xb/yb
  \southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
  \northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y
  \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@ya}}
  \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@yb}}
  \pgfpathmoveto{\pgfqpoint{\pgf@xa}{\pgf@yb}}
  \pgfpathlineto{\pgfqpoint{\pgf@xb}{\pgf@ya}}
}

It misses any additional settings so it inherits any styles from above.

We need \pgfsetarrows{-} and \pgfsetdash{}{0pt}.

With etoolbox you can easily fix this (without re-defining it entirely) by doing

\usepackage{etoolbox}
\cspreto{pgf@sh@fg@cross out}{\pgfsetarrows{-}\pgfsetdash{}{0pt}}

A TikZ-only (not PGF) but easier way would be to use

\tikzset{every cross out node/.append style={-,solid}}

For the re-sized arrow tip.

It appears that the line width setting for the node (and not for the line as usual) is somehow used in the calculation of the arrow tip size. I don’t have an easy fix for that.

You can do either

\draw[-latex,thin] …

where thin is the default setting (.4pt) or use it in the every path style:

every path/.append style={thin}

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{scopes}
\tikzset{every cross out node/.append style={-, solid}}
%\usepackage{etoolbox}
%\cspreto{pgf@sh@fg@cross out}{%
%  \pgfsetarrows{-}%
%  \pgfsetdash{}{0pt}%
%}
\begin{document}
\begin{tikzpicture}
    { [bend left, dashed, every path/.append style={thin}]
        \draw[-latex] (1,-1.5) to node[draw=red, sloped, cross out, line width=.5ex, minimum width=1.5ex, minimum height=1ex, anchor=center]{} (0, -.25) ;
        \draw[-latex] (3,-1.5) to (2, -.25);
    }
\end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
    
thank you, this solves my issue. would it be worht while filing a bug report, or is there no point to that? –  ted Jul 7 '13 at 22:27
    
@ted Yes, please file a bug report. At least I consider, the bigger arrow tip problem as a bug especially because it is inconsistent with --. That the node inherits path options though wouldn’t be the first time, append after command and path picture do also inherit stuff from its parent path, this probably won’t change so fast. –  Qrrbrbirlbel Jul 8 '13 at 3:01
    
FYI: I filed the report if you would like to add anything to it. I named everything as bug, what they consider bug and feature is up to them this way. –  ted Jul 8 '13 at 9:05
    
FYI: the "bug" has been closed. Here is what Till writes on the bug: The interaction issue was already fixed with bug #134. The arrow tips are no longer shown. The dashing is correct, it is not clear why this graph parameter should not apply to the shape. –  ted Jul 26 '13 at 23:29

A simple solution would be to place the node at the end and use the midway option to position the node, adn the - option to ensure that no additional arrow is added:

enter image description here

Notes:

  • I switched form using to to using -- as I don't see why the to is needed in this case, but also seems to have an issue with node placement via the midway option.

Code:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes}

\begin{document}
\begin{tikzpicture}
    \draw[-latex] (1,-1.5) --  (0, -.25)
        node[draw, midway, -, red, sloped, cross out, line width=.5ex, minimum width=1.5ex, minimum height=1ex, anchor=center]{};
    \draw[-latex] (3,-1.5) -- (2, -.25);
\end{tikzpicture}

\end{document}
share|improve this answer
    
i updated my question, since your solution does not work with to,as you mentioned. –  ted Jul 7 '13 at 19:50

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.