2

I found this beautiful code online which draws a saturation block that can be used e.g. in circuitikz. Here is a MWE.

\documentclass[border=0pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage[siunitx,europeanresistors]{circuitikz}

\tikzset{% saturation block/.style={% draw, path picture={ % Get the width and height of the path picture node \pgfpointdiff{\pgfpointanchor{path picture bounding box}{north east}}% {\pgfpointanchor{path picture bounding box}{south west}} \pgfgetlastxy\x\y % Scale the x and y vectors so that the range % -1 to 1 is slightly shorter than the size of the node \tikzset{x=\x.4, y=\y.4} % % Draw annotation \draw (-1,0) -- (1,0) (0,-1) -- (0,1); \draw (-1,-.7) -- (-.7,-.7) -- (.7,.7) -- (1,.7); } } }

\begin{document} \begin{circuitikz} \draw (0,0) node[saturation block, minimum size=1cm] (sat1) {}; \end{circuitikz} \end{document}

enter image description here

How can I modify this code such that the border (and only the border) of this block is dashed?

snuff
  • 79

1 Answers1

3

If you use dashed for the node, this is inherited by the internal drawing. You can override it by using solid.

\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\usepackage[siunitx,europeanresistors]{circuitikz}

\tikzset{% saturation block/.style={% draw, path picture={ % Get the width and height of the path picture node \pgfpointdiff{\pgfpointanchor{path picture bounding box}{north east}}% {\pgfpointanchor{path picture bounding box}{south west}} \pgfgetlastxy\x\y % Scale the x and y vectors so that the range % -1 to 1 is slightly shorter than the size of the node \tikzset{x=\x.4, y=\y.4} % % Draw annotation \draw[solid] (-1,0) -- (1,0) (0,-1) -- (0,1); \draw[solid] (-1,-.7) -- (-.7,-.7) -- (.7,.7) -- (1,.7); } } }

\begin{document} \begin{circuitikz} \draw (0,0) node[saturation block, densely dashed, minimum size=1cm] (sat1) {}; \end{circuitikz} \end{document}

enter image description here

(With densely dashed the output is better in my opinion).

Rmano
  • 40,848
  • 3
  • 64
  • 125