2

I need to draw a lot of arrows with both the -> and -Latex option. I need a shorthand (preferably one character) for the -Latex option. If I use \tikzset{>={Latex}} it redefines all arrowhead which I do not want. I tried using something like \tikzset{]={Latex}} but it gave me the error

Package pgfkeys Error: I do not know the key '/tikz/]', to which you passed 'Latex', and I am going to ignore it. Perhaps you misspelled it. \tikzset{]={Latex}}

Obviously using something like \tikzset{b>={Latex}} also does not work.

One option is to use \pgfarrowsdeclare and draw the arrow from scratch. Firstly, I am not sure I can do it and secondly, it is an overkill.

Is there a way out? Can I use a very short command like -X to achieve -Latex effect but without changing all the arrows?

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
magguu
  • 917
  • 4
  • 10
  • Maybe this example could help you: https://tex.stackexchange.com/a/54797/101651. Otherwise, you can define two styles and use one or the other when needed. – CarLaTeX Aug 03 '17 at 03:48
  • Actually the same diagram uses several -> as well as -Latex arrows. Can I still try switching styles? – magguu Aug 03 '17 at 03:52
  • You didn't provide the actual code that yields the error, so it is difficult to suggest any solution. Also, you are looking for >=latex not -Latex. – CroCo Aug 03 '17 at 04:08
  • There is no complicated code here. Just \tikzset{]={Latex}} in the preamble and \draw[dashed,-]] (A) -- (D); between the tikzpicture environment, of course after defining A and D. I was actually looking for -Latex so that it can be scaled. but even scalable `-latex will do. – magguu Aug 03 '17 at 07:26

2 Answers2

7

If you are using (or can use) the latest version of PGF then the .tip handler is pretty useful:

\documentclass[tikz,border=5]{standalone}
\begin{document}
\begin{tikzpicture}[X/.tip={latex}]
  \draw [->, red]   (0,0) -- (1,1);
  \draw [-X, green] (0,1) -- (1,0);
\end{tikzpicture}
\end{document}

enter image description here

Mark Wibrow
  • 70,437
  • This solution worked perfect. I guess X/.style and -latex is the old version of PGF. I used this command based on your suggestion:

    \tikzset{ -X/.tip={Latex[length=3mm]} } in the preamble and it worked perfect.

    – magguu Aug 03 '17 at 07:33
3

This will work just fine.

\documentclass[border={10}]{standalone}
\usepackage{tikz}

\tikzset{%
    -X/.style={->,>=latex}
}

\begin{document}
\begin{tikzpicture}
\draw[-X] (0,0) -- (1,0);
\draw  (0,1) -- (1,1);
\end{tikzpicture}
\end{document}
CroCo
  • 5,902