I have a lot of diagrams with shapes where I draw lines between certain points on the boundary of those shapes. With Tikz I can use nodes to draw shapes, and use anchors like "node.west" to draw lines to points at their boundary.

However, I find it annoying to always set empty brackets {} after the node, as I never have text. Also instead of always having to specify "minimum height" and "minimum width", I would rather have a "size" key with a default value. Last, I haven't found a nice way to define custom node shapes that doesn't involve low level PGF code which I know nothing about.

Up to now, I'm just using commands that draw the desired shapes at Tikz coordinates. But then I don't have the possibility to use anchors, which I would find quite neat.

Is there a Tikz equivalent of a node, which isn't designed for putting text, but just shapes? Or is there another solution that is similar to what I want?


There is the key node contents that specifically allows you to drop the empty braces, {}. A minor pitfall is that this key needs to come after the name of the node.

\begin{tikzpicture}[circle only/.style={circle,draw,inner sep=2pt,node contents={}}]
 \path node (P) [circle only] ;
 %\path node[circle only] (P)  ; % does not work
 \draw (P.north west) -- ++ (-1,1);

enter image description here

For somewhat more advanced options look up the definition of vertex that ships with tikz-feynman.

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.