Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to the Power Users community on Codidact!

Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.

Post History

60%
+1 −0
Q&A How can I reuse a set of nodes in Tikz?

I have a graph in TikZ which I would like to use multiple times, with variations. As a simple example, say I have the following set of nodes \begin{tikzpicture} \node (a) at (0, 0) [circle,draw...

0 answers  ·  posted 6mo ago by Moshi‭

Question latex tikz
#1: Initial revision by user avatar Moshi‭ · 2024-06-11T04:44:17Z (6 months ago)
How can I reuse a set of nodes in Tikz?
I have a graph in TikZ which I would like to use multiple times, with variations. As a simple example, say I have the following set of nodes

```tex
\begin{tikzpicture}
  \node (a) at (0, 0) [circle,draw] {a};
  \node (b) at (1, 0) [circle,draw] {b};
  \node (c) at (1, 1) [circle,draw] {c};
\end{tikzpicture}
```

In the first graph, I'd like to simply draw edges from a to b, b to c, and c to a. In the second graph, I'd like to do the same thing, but with some bold edges, and maybe an additional node. And so on.

Instead of copying this multiple times, is there an easy way to reuse a set of nodes in each graph?

In addition, it would be good if it worked with the graph drawing algorithms, since simply copy-pastes results in slightly different computed positions even with the same random seed, so I'd like to generate the node positions once and reuse them.