4

I'm trying to use the TikZ graph library to draw graphs, but I'm having trouble figuring out how to draw graphs without text on the nodes. Here's a MWE.

\documentclass{article}
\usepackage{amsthm, amsfonts, ae}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{circular}

\begin{document}

\begin{tikzpicture}
  [baseline=-1mm,
   field/.style={circle,fill=black, minimum size=2mm},
   wall/.style={rectangle,draw=black, fill=white, minimum size=2mm}]
  \graph [simple necklace layout, nodes={field},horizontal=C to B] {
    A[wall] -- B -- C -- A,
  };
\end{tikzpicture}

\end{document}

What I would like is for the nodes of the graph to not have A, B, and C rendered as text on each node, but for them to simply have no text at all. This seems simple but I've not found a way to do it yet looking through the TikZ manual.

1
  • Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This is especially important for tikz as there are numerous libraries. Commented Jan 22, 2021 at 17:39

1 Answer 1

3

You can use the as key for this, which is documented on page 282 (in section 19.3.4 Syntax of Node Specifications) of the manual for version 3.1.8b. This key lets you set the text of the node separately from the node names, and if you want all the nodes to be empty, add as= to the nodes={...}, i.e.:

enter image description here

\documentclass{article}
\usepackage{amsthm, amsfonts, ae}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing}
\usegdlibrary{circular}

\begin{document}

\begin{tikzpicture}
  [baseline=-1mm,
   field/.style={circle,fill=black, minimum size=2mm},
   wall/.style={rectangle,draw=black, fill=white, minimum size=2mm}]
  \graph [simple necklace layout,
          nodes={field,as=}, % <-- added as= here
          horizontal=C to B] {
    A[wall] -- B -- C -- A,
  };
\end{tikzpicture}

\end{document}
1
  • 2
    Instead of \graph[nodes={as=}] one can also use the more readable \graph[empty nodes].
    – DerWeh
    Commented Sep 30, 2021 at 14:25

You must log in to answer this question.

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