2

Using the tkz-graph package, I am able to use the \Edges command but not the \Edge command. When I try to use the \Edge command commented out below, I get the following error:

Paragraph ended before \tikz@cc@parse@factor was complete.

The command appears in exactly this format in the tkz-graph manual.

\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc}
%\usepackage[upright]{fourier}
% you can change the line above

\usepackage{tkz-graph}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\thispagestyle{empty}
\begin{document}

\SetVertexNormal[Shape = circle, , LineWidth  = 1pt]
\SetUpEdge[lw  = 1.0pt , color = black ]
\begin{center}
    \begin{tikzpicture}

    \Vertex[ x = 1 , y = -2 ]{$x_1$}
    \Vertex[ x = 3 , y = 0 ]{$x_2$}
    \Vertex[ x = 5 , y = -2 ]{$x_3$}
    \Vertex[ x = 4 , y = -4 ]{$x_4$}

    \tikzset{VertexStyle/.style = {draw , shape = rectangle, line width = 1pt}}
    \Vertex[ x = 8 , y = -2 ]{$S$}
    \Vertex[ x = 2 , y = -4 ]{$T$}

    \tikzset{>=latex} % Set the arrowhead type!
    \tikzset{EdgeStyle/.style = {->, thick, line width = 2pt}}
    \tikzset{LabelStyle/.style = {color = black}}

    %\Edge($S$)($x_2$) % !! FAILS !!
    \Edges($S$,$x_2$) % !! WORKS !!
    \end{tikzpicture}
\end{center}

\end{document}
2
  • Welcome! You do not seem to be using tikz-graph but tkz-graph. I've edited, but could you clarify this? tkz is built on tikz, but it is separate. tikz-graphs is a tag for graphs in the mathematical sense, using TikZ's graph syntax and/or layout algorithms.
    – cfr
    Apr 3, 2017 at 1:51
  • I completely missed the tkz / tikz difference! Yes, I am definitely using tkz-graph, but I had been searching on tikz-graphs. Apr 3, 2017 at 2:12

1 Answer 1

1

Defining a vertex is different than defining the label. The vertex, to my understanding (which isn't authoritative given the documentation is in French) should be text. You are putting the $ signs around it as if you are trying to put the label of the vertex (which is different) into math mode. That's the error but I don't know why it works with \Edges. The label of the vertex is handled by L= in the options for the vertex. See the revised code below.

\documentclass[]{scrartcl}
\usepackage[utf8]{inputenc}
%\usepackage[upright]{fourier}
% you can change the line above
\usepackage{tkz-graph}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\thispagestyle{empty}
\begin{document}

\SetVertexNormal[Shape = circle, , LineWidth  = 1pt]
\SetUpEdge[lw  = 1.0pt , color = black ]
\begin{center}
\begin{tikzpicture}

\Vertex[x=1,y=-2]{$x_1$}
\Vertex[x=3, y=0, L=$x_2$]{A}
\Vertex[x=5 , y = -2 ]{$x_3$}
\Vertex[x=4,y=-4 ]{$x_4$}

\tikzset{VertexStyle/.style = {draw , shape = rectangle, line width = 1pt}}
\Vertex[x=8,y=-2,L=$S$]{S}
\Vertex[x=2,y=-4]{$T$}

\tikzset{>=latex} % Set the arrowhead type!
\tikzset{EdgeStyle/.style = {->, thick, line width = 2pt}}
\tikzset{LabelStyle/.style = {color = black}}

\Edge(S)(A)
%\Edges($S$,$x_2$) % !! WORKS !!
\end{tikzpicture}
\end{center}
\end{document}

Here's the output running in Gummi: enter image description here

Notice that the vertex you were calling $x_2$ is now called A and the label is implemented with L=$x_2$ in the option for the vertex. The section on labels is page 21 in the documentation where a Google Translate for the sentence beginning section 5.1 is "The next option allows you to define a label, this one can be in text mode or in math mode"

2
  • I see now that the node label can be math mode, but the node name/handle cannot be math mode. The error returned by TexStudio was quite unhelpful! Apr 3, 2017 at 2:14
  • @JamesWatson TeXStudio is just the editor. Don't shoot the messenger. It just delivers the post. [Mixed metaphors are sometimes required.]
    – cfr
    Apr 3, 2017 at 2:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .