8

My code:

\documentclass[]{article}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{graphs}
\begin{document}
    \pagenumbering{gobble}
    \begin{tikzpicture}
        \graph [nodes={draw, circle}, clockwise, radius=.75cm, empty nodes, n=8] {
            subgraph C_n [name=inner] <->[shorten <=1pt, shorten >=1pt]
            subgraph C_n [name=outer]
        };
    \end{tikzpicture}
\end{document}

produces the following figure:

enter image description here

instead of the intended figure:

enter image description here

Why could this be?

4
  • 3
    Right, that's peculiar, as your code is a straight copy from ch. 19 in the pgfmanual. I tried the subgraph example above it, which doesn't work either, while the simple abcd graph does work. I.e. once subgraph is involved, it's "mad".
    – MS-SPO
    Commented Oct 6, 2022 at 11:12
  • 1
    You should load \usetikzlibrary{graphs.standard}. In don't know why this is not stated in the manual. Commented Oct 6, 2022 at 12:27
  • 1
    @JasperHabicht good catch. There is a cryptic warning if you don't add that library... Package pgf Warning: Returning node center instead of a point on node border. Did you specify a point identical to the center of node ``subgraph C_n''? on input line 12.
    – Rmano
    Commented Oct 6, 2022 at 12:30
  • 1
    I just opened a git issue. Commented Oct 6, 2022 at 12:36

1 Answer 1

9

There seems to be a mistake in the manual, since the libraray graphs.standard is needed for this to work:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs.standard}

\begin{document}
    \begin{tikzpicture}
        \graph [nodes={draw, circle}, clockwise, radius=.75cm, empty nodes, n=8] {
            subgraph C_n [name=inner] <->[shorten <=1pt, shorten >=1pt]
            subgraph C_n [name=outer]
        };
    \end{tikzpicture}
\end{document}

enter image description here

1
  • It seems that this is not the only case where the libraries stated in the example are not sufficient. The issue is known and currently being addressed by the package maintainers. Commented Oct 13, 2022 at 8:19

You must log in to answer this question.

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