2

I am trying to get tikz to draw some arrows for me and I keep getting the following error message:

Package pgfkeys Error: I do not know the key '/tikz/line' and I am going to ignore it. Perhaps you misspelled it. \path [line] (

When I try using a test document, everything works well but it does not work in my intended document.

\begin{tikzpicture}[node distance = 5cm, auto]
    \node [startstop] (ba) {Block A};
    \node [startstop, right of=ba] (bb) {Block B};
    \path [line] (ba) -- (bb);
\end{tikzpicture}

Here is the rough structure of my document:

%Some other packages used here
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}


\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm,
    minimum height=1cm,text centered, draw=black, fill=red!30]
%% Edit Begin %%
\tikzstyle{line} = [draw, -latex']
%% Edit End %%

%% Some matter here

\begin{tikzpicture}[node distance = 5cm, auto]
    \node [startstop] (ba) {Block A};
    \node [startstop, right of=ba] (bb) {Block B};
    %% Works
    %% \path [line] (ba) -- (bb);
    %% Does not work
    \draw [arrow] (ba) -- (bb);
\end{tikzpicture}

%% More matter
\end{document}

Is there something silly that I am missing here?

When I compile the document, I do see the blocks but not the arrows and I have looked into almost all the posts about similar issues on the internet and the issue is typically not using the right \usetikzlibrary commands.

In my case, I am using all the right libraries but I still keep getting this cryptic error message.

Please help.

--- Edit ---

Added the tikzstyle definition for "line".

When I try to use the inbuilt arrow, I get a similar error message:

Package pgfkeys Error: I do not know the key '/tikz/arrow' and I am going to ignore it. Perhaps you misspelled it. \draw [arrow]

For now, I can proceed using the "line" that I am defining but would be nice to know why the \draw [arrow] does not work.

  • 1
    You don't have any style called line. At least it's not present in the code you showed to us. – Ignasi Mar 17 '16 at 19:11
  • 1
    I'm pretty sure [arrow] isn't a predefined style either, which is why you're getting the exact same error. – Arun Debray Mar 17 '16 at 23:06
5

The error occurs because there is no default line style for TikZ, even in the libraries you're using. Thus, if you want to use it in your code, you must define it with \tikzstyle. If you adapted your code from a question such as this one, then you should add to your preamble something like \tikzstyle{line}=[draw], which will allow you to use line in your code as follows:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\tikzstyle{line}=[draw] % here
\begin{document}

\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm,
    minimum height=1cm,text centered, draw=black, fill=red!30]

\begin{tikzpicture}[node distance = 5cm, auto]
    \node [startstop] (ba) {Block A};
    \node [startstop, right of=ba] (bb) {Block B};
    \path [line] (ba) -- (bb);
\end{tikzpicture}
\end{document}

This will draw a line between the two nodes. If you prefer a different style, you can change the \tikzstyle definition.

  • Thanks a lot for your feedback! I have updated the question. After defining the tikzstyle, I am able to draw the arrows as required but I still get an error message while using \draw [arrow]. Would like to know whats up with that one...I have used tikz in the past also but never faced this kind of an issue... – sanjay Mar 17 '16 at 19:30
  • 1
    Have you added \tikzstyle{arrow}=[draw, -latex] to your preamble? – Arun Debray Mar 17 '16 at 20:04
3

I had this same problem.

Using: \draw [->] (ba) -- (bb); rather than \draw [arrow] (ba) -- (bb); fixed it for me.

I am only a beginner in LaTeX so sorry if this is not applicable to you!. I am using MacOS X 10.9.5 and compiling on TeXshop via the built in button.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.