Preamble
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta,positioning}
\usetikzlibrary{math}
\usetikzlibrary{3d}
\usepackage{CJKutf8} %Japanese fonts
\usetikzlibrary{decorations.pathmorphing}
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{arrows.meta,positioning}
\usetikzlibrary{math}
\usetikzlibrary{3d}
\usepackage{CJKutf8}
\usetikzlibrary{decorations.pathmorphing}
Show background grid, show Japanese
\usetikzlibrary{backgrounds}
\makeatletter
\newif\if@showgrid@grid
\newif\if@showgrid@left
\newif\if@showgrid@right
\newif\if@showgrid@below
\newif\if@showgrid@above
\tikzset{%
every show grid/.style={},
show grid/.style={execute at end picture={\@showgrid{grid=true,#1}}},%
show grid/.default={true},
show grid/.cd,
labels/.style={font={\sffamily\small},help lines},
xlabels/.style={},
ylabels/.style={},
keep bb/.code={\useasboundingbox (current bounding box.south west) rectangle (current bounding box.north west);},
true/.style={left,below},
false/.style={left=false,right=false,above=false,below=false,grid=false},
none/.style={left=false,right=false,above=false,below=false},
all/.style={left=true,right=true,above=true,below=true},
grid/.is if=@showgrid@grid,
left/.is if=@showgrid@left,
right/.is if=@showgrid@right,
below/.is if=@showgrid@below,
above/.is if=@showgrid@above,
false,
}
\def\@showgrid#1{%
\begin{scope}[every show grid,show grid/.cd,#1]
\if@showgrid@grid
\begin{pgfonlayer}{background}
\draw [help lines]
(current bounding box.south west) grid
(current bounding box.north east);
%
\pgfpointxy{1}{1}%
\edef\xs{\the\pgf@x}%
\edef\ys{\the\pgf@y}%
\pgfpointanchor{current bounding box}{south west}
\edef\xa{\the\pgf@x}%
\edef\ya{\the\pgf@y}%
\pgfpointanchor{current bounding box}{north east}
\edef\xb{\the\pgf@x}%
\edef\yb{\the\pgf@y}%
\pgfmathtruncatemacro\xbeg{ceil(\xa/\xs)}
\pgfmathtruncatemacro\xend{floor(\xb/\xs)}
\if@showgrid@below
\foreach \X in {\xbeg,...,\xend} {
\node [below,show grid/labels,show grid/xlabels] at (\X,\ya) {\X};
}
\fi
\if@showgrid@above
\foreach \X in {\xbeg,...,\xend} {
\node [above,show grid/labels,show grid/xlabels] at (\X,\yb) {\X};
}
\fi
\pgfmathtruncatemacro\ybeg{ceil(\ya/\ys)}
\pgfmathtruncatemacro\yend{floor(\yb/\ys)}
\if@showgrid@left
\foreach \Y in {\ybeg,...,\yend} {
\node [left,show grid/labels,show grid/ylabels] at (\xa,\Y) {\Y};
}
\fi
\if@showgrid@right
\foreach \Y in {\ybeg,...,\yend} {
\node [right,show grid/labels,show grid/ylabels] at (\xb,\Y) {\Y};
}
\fi
\end{pgfonlayer}
\fi
\end{scope}
}
\makeatother
%\tikzset{showgrid} % would enable it globally
\tikzset{every show grid/.style={show grid/keep bb}}% Keep the original bounding box!
%For showing background grid -- END
\begin{document}
\begin{CJK}{UTF8}{ipxm}
\begin{tikzpicture}[show grid = true]
%Something to draw
\end{tikzpicture}
\end{CJK}
\end{document}
\usetikzlibrary{backgrounds}
\makeatletter
\newif\if@showgrid@grid
\newif\if@showgrid@left
\newif\if@showgrid@right
\newif\if@showgrid@below
\newif\if@showgrid@above
\tikzset{
every show grid/.style={},
show grid/.style={execute at end picture={\@showgrid{grid=true,#1}}},
show grid/.default={true},
show grid/.cd,
labels/.style={font={\sffamily\small},help lines},
xlabels/.style={},
ylabels/.style={},
keep bb/.code={\useasboundingbox (current bounding box.south west) rectangle (current bounding box.north west);},
true/.style={left,below},
false/.style={left=false,right=false,above=false,below=false,grid=false},
none/.style={left=false,right=false,above=false,below=false},
all/.style={left=true,right=true,above=true,below=true},
grid/.is if=@showgrid@grid,
left/.is if=@showgrid@left,
right/.is if=@showgrid@right,
below/.is if=@showgrid@below,
above/.is if=@showgrid@above,
false,
}
\def\@showgrid#1{
\begin{scope}[every show grid,show grid/.cd,#1]
\if@showgrid@grid
\begin{pgfonlayer}{background}
\draw [help lines]
(current bounding box.south west) grid
(current bounding box.north east);
\pgfpointxy{1}{1}
\edef\xs{\the\pgf@x}
\edef\ys{\the\pgf@y}
\pgfpointanchor{current bounding box}{south west}
\edef\xa{\the\pgf@x}
\edef\ya{\the\pgf@y}
\pgfpointanchor{current bounding box}{north east}
\edef\xb{\the\pgf@x}
\edef\yb{\the\pgf@y}
\pgfmathtruncatemacro\xbeg{ceil(\xa/\xs)}
\pgfmathtruncatemacro\xend{floor(\xb/\xs)}
\if@showgrid@below
\foreach \X in {\xbeg,...,\xend} {
\node [below,show grid/labels,show grid/xlabels] at (\X,\ya) {\X};
}
\fi
\if@showgrid@above
\foreach \X in {\xbeg,...,\xend} {
\node [above,show grid/labels,show grid/xlabels] at (\X,\yb) {\X};
}
\fi
\pgfmathtruncatemacro\ybeg{ceil(\ya/\ys)}
\pgfmathtruncatemacro\yend{floor(\yb/\ys)}
\if@showgrid@left
\foreach \Y in {\ybeg,...,\yend} {
\node [left,show grid/labels,show grid/ylabels] at (\xa,\Y) {\Y};
}
\fi
\if@showgrid@right
\foreach \Y in {\ybeg,...,\yend} {
\node [right,show grid/labels,show grid/ylabels] at (\xb,\Y) {\Y};
}
\fi
\end{pgfonlayer}
\fi
\end{scope}
}
\makeatother
\tikzset{every show grid/.style={show grid/keep bb}}
\begin{document}
\begin{CJK}{UTF8}{ipxm}
\begin{tikzpicture}[show grid = true]
\end{tikzpicture}
\end{CJK}
\end{document}
Straight path
\draw (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
\draw (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
Dashed and dotted line
\draw[dashed] (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
\draw[loosely dashed] (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
\draw[densely dashed] (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
\draw[dotted] (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
\draw[dashed] (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
\draw[loosely dashed] (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
\draw[densely dashed] (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
\draw[dotted] (-1.5,0) -- (1.5,0) -- (0,-1.5) -- (0,1.5);
Rectangle
\draw (0,0) rectangle (0.5,0.5);
\draw (0,0) rectangle (0.5,0.5);
Rounded corner rectangle
\draw[rounded corners] (0,0) rectangle (3,2);
\draw[rounded corners=1cm] (0,0) rectangle (3,2);
\draw[rounded corners] (0,0) rectangle (3,2);
\draw[rounded corners=1cm] (0,0) rectangle (3,2);
Curve path
\draw (0,0) .. controls (1,1) and (2,1) .. (2,0);
\draw (0,0) .. controls (1,1) and (2,1) .. (2,0);
Two curves
\draw (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1)
.. controls (0.555,1) and (1,0.555) .. (1,0);
\draw (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1)
.. controls (0.555,1) and (1,0.555) .. (1,0);
Circle
\draw (0,0) circle [radius=10pt];
\draw (0,0) circle [radius=10pt];
ellipse
\draw (0,0) ellipse [x radius=20pt, y radius=10pt];
\draw (0,0) ellipse [x radius=20pt, y radius=10pt];
Arc
\draw (3,0) arc [start angle=0, end angle=30, radius=3];
\draw (3,0) arc [start angle=0, end angle=30, radius=3];
elliptical arc
\draw (0,0) arc [start angle=0, end angle=315, x radius=2cm, y radius=1cm];
\draw (0,0) arc [start angle=0, end angle=315, x radius=2cm, y radius=1cm];
Parabola
\draw (0,0) parabola (-1,-2);
\draw (0,0) parabola (-1,-2);
left and right having different shapes
\draw (0,0) parabola bend (2,8) (5,7);
\draw (0,0) parabola bend (2,8) (5,7);
Sin and Cos
\draw (0,0) sin (2,2);%Always 1/4 period is plotted
\draw (0,0) sin (2,2);
Sin wave of a complete period
\draw (0,0) sin (2,2) cos (4,0) sin (6,-2) cos (8,0);
\draw (0,0) sin (2,2) cos (4,0) sin (6,-2) cos (8,0);
A distorted sin wave
\draw (0,0) sin (1,1) cos (2.5,0) sin (4.5,-1.5) cos (7,0);
\draw (0,0) sin (1,1) cos (2.5,0) sin (4.5,-1.5) cos (7,0);
Grid
\draw[step=2] (0,0) grid (10,10);
\draw[step=2] (0,0) grid (10,10);
Different steps at x and y directions
\draw[xstep=2, ystep=3] (0,0) grid (10,10);
\draw[xstep=2, ystep=3] (0,0) grid (10,10);
Arrow
% Add \usetikzlibrary {arrows.meta} in the preamble
\draw[->] (-1.5,0) -- (1.5,0);
\draw [<-, >=Stealth] (0,0) arc [start angle=180, end angle=30, radius=10pt];
\draw [->>, >=Stealth, very thick] (1,0) -- (1.5cm,10pt) -- (2cm,0pt) -- (2.5cm,10pt);
\draw[->] (-1.5,0) -- (1.5,0);
\draw [<-, >=Stealth] (0,0) arc [start angle=180, end angle=30, radius=10pt];
\draw [->>, >=Stealth, very thick] (1,0) -- (1.5cm,10pt) -- (2cm,0pt) -- (2.5cm,10pt);
Line color and width
\draw[red,very thin] (0,0) rectangle (2,2);
\draw[xstep=2, ystep=3, blue, thick] (0,0) grid (10,10);
\draw[blue, thick] (0,0) ellipse [x radius=2, y radius=1];
\draw[red,very thin] (0,0) rectangle (2,2);
\draw[xstep=2, ystep=3, blue, thick] (0,0) grid (10,10);
\draw[blue, thick] (0,0) ellipse [x radius=2, y radius=1];
Fill and filldraw
% 40% green with 60% white
\fill[green!40!white] (0,0) -- (3,0)
arc [start angle=0, end angle=30, radius=3] -- cycle;
\fill[green!40!white] (0,0) -- (3,0)
arc [start angle=0, end angle=30, radius=3] -- cycle;
Fill and draw the boundary
\filldraw[fill=green!20!white, draw=green!50!black] (0,0) -- (3,0)
arc [start angle=0, end angle=30, radius=3] -- cycle;
\filldraw[fill=green!20!white, draw=green!50!black] (0,0) -- (3,0)
arc [start angle=0, end angle=30, radius=3] -- cycle;
Shade and shadedraw
\shade[top color=yellow,bottom color=black] (0,0) rectangle +(2,1);
\shade[left color=yellow,right color=black] (3,0) rectangle +(2,1);
\shadedraw[inner color=yellow,outer color=black,draw=yellow] (6,0) rectangle +(2,1);
\shade[ball color=green] (9,.5) circle (.5cm);
\shade[top color=yellow,bottom color=black] (0,0) rectangle +(2,1);
\shade[left color=yellow,right color=black] (3,0) rectangle +(2,1);
\shadedraw[inner color=yellow,outer color=black,draw=yellow] (6,0) rectangle +(2,1);
\shade[ball color=green] (9,.5) circle (.5cm);
Coordinates
%(30:2cm) means 2cm in direction 30 degree
\draw[yellow,very thick] (0,0) -- (30:2cm);
\draw[red,very thick] (30:2cm) -- +(0,-0.5);
\draw[blue,very thick] (30:2cm) ++(0,-0.5) -- (0,0);
\draw[green,very thick] (30:1cm) -- ++(120:1) -- (0,0);
\draw[yellow,very thick] (0,0) -- (30:2cm);
\draw[red,very thick] (30:2cm) -- +(0,-0.5);
\draw[blue,very thick] (30:2cm) ++(0,-0.5) -- (0,0);
\draw[green,very thick] (30:1cm) -- ++(120:1) -- (0,0);
Intersections
% Add `\usetikzlibrary{intersections}' after loading tikz in the preamble
\path [name path=line1] (1,0) -- (1,1);
\path [name path=line2] (0,0) -- (30:1.5cm);
\draw [name intersections={of=line1 and line2, by=x}]
[very thick,orange] (1,0) -- (x);
\path [name path=line1] (1,0) -- (1,1);
\path [name path=line2] (0,0) -- (30:1.5cm);
\draw [name intersections={of=line1 and line2, by=x}]
[very thick,orange] (1,0) -- (x);
Loop
\foreach \x in {1,...,10}
\draw (\x,0) circle (0.2*\x cm);
\foreach \x in {1,2,...,5,7,8,...,12}
\draw[red] (\x cm,-0.5) -- (\x cm,0.5);
\foreach \x in {1,...,10}
\draw (\x,0) circle (0.2*\x cm);
\foreach \x in {1,2,...,5,7,8,...,12}
\draw[red] (\x cm,-0.5) -- (\x cm,0.5);
Text
%below, above, left, right, above right, ...
\foreach \x in {-1,0.2,1}
\draw (\x cm,1) -- (\x cm,-1) node[below] {$\x$};
\foreach \x in {2,3.2,4}
\draw[green] (\x cm,1) -- (\x cm,-1) node[fill=blue, draw=red, below=0.5cm] {$\x$};
\foreach \x in {-1,0.2,1}
\draw (\x cm,1) -- (\x cm,-1) node[below] {$\x$};
\foreach \x in {2,3.2,4}
\draw[green] (\x cm,1) -- (\x cm,-1) node[fill=blue, draw=red, below=0.5cm] {$\x$};
Specify the content of some texts
\foreach \x/\xtext in {-1, 0.2/a, 1/b}
\draw (\x cm,1pt) -- (\x cm,-1pt) node[below] {$\xtext$};
\foreach \x/\xtext in {-1, 0.2/a, 1/b}
\draw (\x cm,1pt) -- (\x cm,-1pt) node[below] {$\xtext$};
Text on a line
\draw (0,0) .. controls (6,1) and (9,1) ..
node[near start,sloped,above] {near start}
node {midway}
node[very near end,sloped,below] {very near end} (12,0);
\draw (0,0) .. controls (6,1) and (9,1) ..
node[near start,sloped,above] {near start}
node {midway}
node[very near end,sloped,below] {very near end} (12,0);
Clipping
\clip (1,1) circle (2);%clip command always comes first
\draw[xstep=1, ystep=1.5, blue, thick] (0,0) grid (5,5);
\clip (1,1) circle (2);
\draw[xstep=1, ystep=1.5, blue, thick] (0,0) grid (5,5);
Draw the clipping path
\clip[draw] (1,1) circle (2);
\draw[xstep=1, ystep=1.5, blue, thick] (0,0) grid (5,5);
\clip[draw] (1,1) circle (2);
\draw[xstep=1, ystep=1.5, blue, thick] (0,0) grid (5,5);
\draw[rotate=30] (0,0) ellipse [x radius=20pt, y radius=10pt];
\draw[rotate=30] (0,0) ellipse [x radius=20pt, y radius=10pt];
Shift and scope
\begin{scope}[even odd rule,rounded corners=2pt]
\filldraw[fill=yellow!80!black] (0,0) rectangle (1,1)
[xshift=0.3cm,yshift=0.3cm] (0,0) rectangle (1,1) %cm is necessary otherwise it would be in pt
[rotate=30] (-1,-1) rectangle (2,2);
\end{scope}
\begin{scope}[even odd rule,rounded corners=2pt]
\filldraw[fill=yellow!80!black] (0,0) rectangle (1,1)
[xshift=0.3cm,yshift=0.3cm] (0,0) rectangle (1,1)
[rotate=30] (-1,-1) rectangle (2,2);
\end{scope}
Style
\tikzset{my style/.style={color=blue!10,very thin}}
\begin{document}
\begin{tikzpicture}
\draw [my style, rotate=30] (0,0) ellipse [x radius=2, y radius=1];
\end{tikzpicture}
\end{document}
\tikzset{my style/.style={color=blue!10,very thin}}
\begin{document}
\begin{tikzpicture}
\draw [my style, rotate=30] (0,0) ellipse [x radius=2, y radius=1];
\end{tikzpicture}
\end{document}
Decoration, scope
\tikzmath{\w=1; \h1=0.5; \h2=1.5; \r=0.05; \dis=1;}
\draw[sLine] (0,0) circle (\r);
\draw[sLine] (\r,0) -- ++(\w-\r,0) -- ++(0,-\h1);
\draw[sLine, decorate, decoration={bumps, segment length=0.33cm}] (\w,-\h1) -- ++(0,-\h2);
\draw[sLine] (\w,-\h1-\h2) -- ++(0,-\h1) -- ++(-\w+\r,0);
\draw[sLine] (0,-2*\h1-\h2) circle (\r);
\node[align=center] at (0,-\h1-0.5*\h2) {高\\電\\圧};
\node[left] at (\w,-\h1-0.5*\h2) {$V_1$};
\node[above] at (\w,0) {$n_1$};
\begin{scope}[rotate around={180:(0,-\h1-0.5*\h2)}, xshift=-3cm]
\draw[sLine] (0,0) circle (\r);
\draw[sLine] (\r,0) -- ++(\w-\r,0) -- ++(0,-\h1);
\draw[sLine, decorate, decoration={bumps, segment length=0.33cm}] (\w,-\h1) -- ++(0,-\h2);
\draw[sLine] (\w,-\h1-\h2) -- ++(0,-\h1) -- ++(-\w+\r,0);
\draw[sLine] (0,-2*\h1-\h2) circle (\r);
\end{scope}
\node[align=center] at (2*\w+\dis,-\h1-0.5*\h2) {低\\電\\圧};
\node[right] at (\w+\dis,-\h1-0.5*\h2) {$V_2$};
\node[above] at (\w+\dis,0) {$n_2$};
\tikzmath{\w=1; \h1=0.5; \h2=1.5; \r=0.05; \dis=1;}
\draw[sLine] (0,0) circle (\r);
\draw[sLine] (\r,0) -- ++(\w-\r,0) -- ++(0,-\h1);
\draw[sLine, decorate, decoration={bumps, segment length=0.33cm}] (\w,-\h1) -- ++(0,-\h2);
\draw[sLine] (\w,-\h1-\h2) -- ++(0,-\h1) -- ++(-\w+\r,0);
\draw[sLine] (0,-2*\h1-\h2) circle (\r);
\node[align=center] at (0,-\h1-0.5*\h2) {高\\電\\圧};
\node[left] at (\w,-\h1-0.5*\h2) {$V_1$};
\node[above] at (\w,0) {$n_1$};
\begin{scope}[rotate around={180:(0,-\h1-0.5*\h2)}, xshift=-3cm]
\draw[sLine] (0,0) circle (\r);
\draw[sLine] (\r,0) -- ++(\w-\r,0) -- ++(0,-\h1);
\draw[sLine, decorate, decoration={bumps, segment length=0.33cm}] (\w,-\h1) -- ++(0,-\h2);
\draw[sLine] (\w,-\h1-\h2) -- ++(0,-\h1) -- ++(-\w+\r,0);
\draw[sLine] (0,-2*\h1-\h2) circle (\r);
\end{scope}
\node[align=center] at (2*\w+\dis,-\h1-0.5*\h2) {低\\電\\圧};
\node[right] at (\w+\dis,-\h1-0.5*\h2) {$V_2$};
\node[above] at (\w+\dis,0) {$n_2$};
Curve, intersection
\tikzmath{\xAxisLen=8; \yAxisLen=5; \zeroVal=4.3; \cutVal=5.5; \zeroFreq=7;}
\draw[sAxis] (0,0) -- (\xAxisLen,0);
\draw[sAxis] (0,0) -- (0,\yAxisLen);
\node[below] at (\xAxisLen, 0) {Frequency};
\node[left, align=center] at (0,\yAxisLen) {Output\\(dB)};
\draw[sDash] (0,\zeroVal) -- (0.95*\xAxisLen,\zeroVal);
\draw[sDash, name path=verline] (\cutVal,0) -- (\cutVal,1.1*\zeroVal);
\draw[sCurve, name path=curve] (0,\zeroVal) .. controls (6.5,\zeroVal) and (6.5,4) .. (\zeroFreq,0);
\path[name intersections={of=verline and curve,by={interRight}}];
\coordinate (interLeft) at ($(interRight) +(180:\cutVal)$);
\draw[sDash] (interRight) -- (interLeft) node[left] {--3 dB};
\node[left] at (0,\zeroVal) {0 dB};
\node[below] at (\cutVal,0) {1 MHz};
\draw[sArrow] (\zeroFreq,\yAxisLen) -- node[base right, pos=0, align=center] {Cutoff\\frequency} (\cutVal,1.1*\zeroVal);
\tikzmath{\xAxisLen=8; \yAxisLen=5; \zeroVal=4.3; \cutVal=5.5; \zeroFreq=7;}
\draw[sAxis] (0,0) -- (\xAxisLen,0);
\draw[sAxis] (0,0) -- (0,\yAxisLen);
\node[below] at (\xAxisLen, 0) {Frequency};
\node[left, align=center] at (0,\yAxisLen) {Output\\(dB)};
\draw[sDash] (0,\zeroVal) -- (0.95*\xAxisLen,\zeroVal);
\draw[sDash, name path=verline] (\cutVal,0) -- (\cutVal,1.1*\zeroVal);
\draw[sCurve, name path=curve] (0,\zeroVal) .. controls (6.5,\zeroVal) and (6.5,4) .. (\zeroFreq,0);
\path[name intersections={of=verline and curve,by={interRight}}];
\coordinate (interLeft) at ($(interRight) +(180:\cutVal)$);
\draw[sDash] (interRight) -- (interLeft) node[left] {--3 dB};
\node[left] at (0,\zeroVal) {0 dB};
\node[below] at (\cutVal,0) {1 MHz};
\draw[sArrow] (\zeroFreq,\yAxisLen) -- node[base right, pos=0, align=center] {Cutoff\\frequency} (\cutVal,1.1*\zeroVal);
3D
\tikzmath{\cX=2; \cY=1.7; \cD=0.2;}
% \draw[sAxis] (0,0,0) -- (3,0,0) node [right] {x};
% \draw[sAxis] (0,0,0) -- (0,0,3) node [above] {z};
% \draw[sAxis] (0,0,0) -- (0,3,0) node [above right] {y};
\draw[sCEdge] (0,0,0) -- (\cX,0,0) -- (\cX,\cY,0) -- (0,\cY,0) -- cycle;
\draw[sCEdge, fill=white] (0,0,\cD) -- (\cX,0,\cD) -- (\cX,\cY,\cD) -- (0,\cY,\cD) -- cycle;
\node at (0.5*\cX,0.5*\cY,\cD) {$S$};
\tikzmath{\horiLen=0.4;\arrowLen=0.3;}
\draw[sMeasure] (-0.05,0,0) -- +(-\horiLen,0,0);
\draw[sMeasure, <-, >=Stealth] (-0.5*\horiLen-0.05,0,0) -- +(0,0,-\arrowLen);
\draw[sMeasure] (-0.05,0,\cD) -- +(-\horiLen,0,0);
\draw[sMeasure, <-, >=Stealth] (-0.5*\horiLen-0.05,0,\cD) -- +(0,0,\arrowLen);
\node[left] at (-0.05-\horiLen,0,0.5*\cD) {$d$};
\tikzmath{\wireHeight=0.3;\wireLen=0.5;}
\draw[sWire] (\cX,\cY,\cD) -- ++(0,0,\wireHeight) -- ++(\wireLen,0,0);
\draw[sWire] (\cX,\cY,0) -- ++(0,0,-\wireHeight) -- ++(\wireLen,0,0);
\tikzmath{\circleR=0.05;}
\draw[canvas is xz plane at y=\cY] (\cX+\wireLen+\circleR,-\wireHeight) circle (\circleR);
\draw[canvas is xz plane at y=\cY] (\cX+\wireLen+\circleR,\cD+\wireHeight) circle (\circleR);
\node at (\cX+\wireLen+\circleR, \cY, 0.5*\cD) {$C$};
\tikzmath{\cX=2; \cY=1.7; \cD=0.2;}
\draw[sCEdge] (0,0,0) -- (\cX,0,0) -- (\cX,\cY,0) -- (0,\cY,0) -- cycle;
\draw[sCEdge, fill=white] (0,0,\cD) -- (\cX,0,\cD) -- (\cX,\cY,\cD) -- (0,\cY,\cD) -- cycle;
\node at (0.5*\cX,0.5*\cY,\cD) {$S$};
\tikzmath{\horiLen=0.4;\arrowLen=0.3;}
\draw[sMeasure] (-0.05,0,0) -- +(-\horiLen,0,0);
\draw[sMeasure, <-, >=Stealth] (-0.5*\horiLen-0.05,0,0) -- +(0,0,-\arrowLen);
\draw[sMeasure] (-0.05,0,\cD) -- +(-\horiLen,0,0);
\draw[sMeasure, <-, >=Stealth] (-0.5*\horiLen-0.05,0,\cD) -- +(0,0,\arrowLen);
\node[left] at (-0.05-\horiLen,0,0.5*\cD) {$d$};
\tikzmath{\wireHeight=0.3;\wireLen=0.5;}
\draw[sWire] (\cX,\cY,\cD) -- ++(0,0,\wireHeight) -- ++(\wireLen,0,0);
\draw[sWire] (\cX,\cY,0) -- ++(0,0,-\wireHeight) -- ++(\wireLen,0,0);
\tikzmath{\circleR=0.05;}
\draw[canvas is xz plane at y=\cY] (\cX+\wireLen+\circleR,-\wireHeight) circle (\circleR);
\draw[canvas is xz plane at y=\cY] (\cX+\wireLen+\circleR,\cD+\wireHeight) circle (\circleR);
\node at (\cX+\wireLen+\circleR, \cY, 0.5*\cD) {$C$};