1

I am new here at tex.se and looking for some help.

For a project I have to automatically compile some given Latex strings, that I can not change. However I can add some headers or define some new commands.

Does someone know what packages I need to add so this certain lines will compile in that way?

\begin{tikzpicture}[graph]
  \node[graph node] (1) [label=above:\(1\)]{};
  \node[graph node] (2) at ($(1) + (-36:1.5cm)$) [label=right:\(2\)] {};
  \node[graph node] (3) at ($(2) + (-108:1.5cm)$) [label=right:\(3\)] {};
  \node[graph node] (4) [left of=3, label=left:\(4\)] {};
  \node[graph node] (5) at ($(1) + (-144:1.5cm)$) [label=left:\(5\)] {};
  \node[graph node] (6) at ($(2) + (15:2.0cm)$) [label=left:\(6\)] {};
  \node[graph node] (7) [right of=6, label=right:\(7\)] {};
  \node[graph node] (8) [below of=7, label=right:\(8\)] {};
  \node[graph node] (9) [below of=6, label=left:\(9\)] {};

  \path[->]
    (2) edge (1)
        edge (3)
        edge (5)
    (3) edge (1)
        edge[bend left=10] (4)
    (4) edge (1)
        edge[bend left=10] (3)
        edge (5)
    (6) edge[bend left=10] (7)
        edge (8)
        edge (9)
    (7) edge[bend left=10] (6)
        edge (8)
    (9) edge (8);
\end{tikzpicture}

I have already some packages included like:

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{paralist}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage{tkz-graph}
\usetikzlibrary{shapes,arrows}

But I do get this error:

! Package pgfkeys Error: I do not know the key '/tikz/graph' and I am going to ignore it. Perhaps you misspelled it.

Thanks for your help! :)

  • I guess that the problem lies in \begin{tikzpicture}[graph]. Somewhere graph must be defined. Try to compile it without [graph]. – Dr. Manuel Kuehner Aug 13 '17 at 16:49
  • that is somehow the problem. I have to remove all 'graph's in the example in my code, but I think it would be easier not to. Can I somehow implement a dummy definition. And how would I do that? – maltere Aug 13 '17 at 16:55
  • 1
    "Search and Replace"?! (text editor functionality) – Dr. Manuel Kuehner Aug 13 '17 at 16:58
  • The tex-file does get assmbled by a java code, that until now just appends all tex-strings without caring about whats inside. I do now that the strings compile with the source-template, but I do not know how the source-template looks like. Is it that hard to define a dummy "graph" notation? – maltere Aug 13 '17 at 17:05
  • 3
    Creating a dummy graph style can be done by \tikzset{graph/.style={}} before all the tikzpictures. – marsupilam Aug 13 '17 at 17:12
1

enter image description here

Well, this compiles and gives output. Note that the tkzgraph package has its own distinct setup: consult its manual before using it.

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}
  \node (1) [label=above:\(1\)]{};
  \node (2) at ($(1) + (-36:1.5cm)$) [label=right:\(2\)] {};
  \node (3) at ($(2) + (-108:1.5cm)$) [label=right:\(3\)] {};
  \node (4) [left of=3, label=left:\(4\)] {};
  \node (5) at ($(1) + (-144:1.5cm)$) [label=left:\(5\)] {};
  \node (6) at ($(2) + (15:2.0cm)$) [label=left:\(6\)] {};
  \node (7) [right of=6, label=right:\(7\)] {};
  \node (8) [below of=7, label=right:\(8\)] {};
  \node (9) [below of=6, label=left:\(9\)] {};

  \path[->]
    (2) edge (1)
        edge (3)
        edge (5)
    (3) edge (1)
        edge[bend left=10] (4)
    (4) edge (1)
        edge[bend left=10] (3)
        edge (5)
    (6) edge[bend left=10] (7)
        edge (8)
        edge (9)
    (7) edge[bend left=10] (6)
        edge (8)
    (9) edge (8);
\end{tikzpicture}

\end{document}
  • As I told in the comments above I do not want to edit the latex string. So tried marsupilam solution and it worked. But thank you anyway :) – maltere Aug 15 '17 at 11:20

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.