5

I'd like to define a style in tikz with 2 squares in each other. However if I use \draw multiple times, it only ever draws the last one:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows}
\begin{document}
\tikzstyle{square} = [draw, rectangle,minimum height=4em, minimum width=4em,
    draw, rectangle,minimum height=2em, minimum width=2em]
\end{document}

I'm trying to draw this divisor symbol:

enter image description here

4

Basically, you can't nest nodes in TikZ. There are provision for modifying the "border path", though, but they are quite complex. In this case I would go with a normal node but using a double line for the border.

This in principle should work (you are using a deprecated library and the deprecated \tikzstyle command; I changed it. Moreover, never use pgfplots without setting a compatibility level; I removed it).

I say in principle because it wreaks havoc with some viewer antialiasing (evince is ok, okular shows only some of the sides in some zoom...).

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{shapes.geometric,arrows.meta}% arrows is depreacted
\begin{document}
\tikzset{dsquare/.style={regular polygon, regular polygon sides=4,
    minimum width=4em, draw, double, double distance=1mm, line width=0.6pt},
}
\begin{tikzpicture}[]
    \draw node[dsquare] {test};
\end{tikzpicture}
\end{document}

enter image description here

1
  • 1
    Awesome, thanks! I'm just starting with tikz and that really helped
    – caesar
    Sep 17 at 8:51

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.