我需要制作这个图。但我已经完成了一部分,没有完全完成,仍然缺少一些部分。这是我需要得到的(但失败了) 这是我的代码,它部分完成了工作。但之后我似乎没有任何想法。
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[ultra thick,cyan] (0,0) \foreach \k in {0,...,8} { let \n1={-2*mod(\k,2) + 1.0} in -- ++(0,\n1) -- ++(1,0)};
\draw[densely dashed,cyan] (3,0) -- + (0,1.5) (5,0) -- + (0,1.5);
\draw[<->] (3,1.3) -- node[above] {$\Lambda$} + (2,0);
\draw[red] (1,1.5) node[above] {$z =0$} + (0,1.);
\draw[red] (8,1.5) node[above] {$z = L$} + (0,1.);
\draw[red] (10,0) node[right] {$x = -a$};
\draw[red] (10,1) node[right] {$x = 0$};
\draw[red] (10,-2) node[right] {$x = -t$};
\draw[ultra thick, cyan] (9,1) -- + (1,0);
\draw[ultra thick, cyan] (0,-2) -- + (10,0);
\draw[densely dashed, cyan] (8,0) -- + (2,0);
\draw[densely dashed,cyan] (1,0) -- + (0,1.5);
\draw[densely dashed,cyan] (8,0) -- + (0,1.5);
\end{tikzpicture}
\end{document}
答案1
对已编辑问题的回答
这只是使用与我对原始问题的命名和引用节点的回答相同的原理,并添加了positioning
库。
\documentclass[border=10pt]{standalone}
\usepackage{tikz,amssymb}
\usetikzlibrary{calc,positioning}
\begin{document}
\begin{tikzpicture}
\draw [ultra thick, draw=cyan] (0,0) coordinate (o) \foreach \k in {0,...,8} { let \n1={-2*mod(\k,2) + 1.0} in -- ++(0,\n1) -- ++(1,0) coordinate (p\k)} -- ++(1,0) node [above=10pt,midway] {$n_1$} node (n2) [below=10pt,midway] {$n_2$} node (p9) [right, red] {$x=0$};
\draw [densely dashed, draw=cyan] (3,0) -- + (0,1.5) (5,0) -- + (0,1.5) (o -| p7) -- (o -| p9.west) node (a) [right, red] {$x=-\alpha$} (a -| n2) node (n3) [below=10pt] {$n_3$};
\draw[<->] (3,1.3) -- node (l) [above] {$\Lambda$} + (2,0);
\node at (l |- n3) {Guiding layer};
\draw[red] (1,1.5) node[above] {$z =0$} + (0,1.);
\draw[red] (8,1.5) node[above] {$z = L$} + (0,1.);
\draw[red] (10,-2) node (t) [right] {$x = -t$};
\path (t -| l) node [below=10pt] {Substrate layer};
\draw[densely dashed,cyan] (1,0) -- + (0,1.5);
\draw[densely dashed,cyan] (8,0) -- + (0,1.5);
\draw[ultra thick, cyan] (0,-2) -- + (10,0);
\end{tikzpicture}
\end{document}
原始问题的答案
像这样?如果我理解正确的话,这会增加你在评论中提到的造成困难的两个步骤。
\documentclass[border=10pt]{standalone}
\usepackage{tikz,amssymb}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw [ultra thick, draw=cyan] (0,0) coordinate (o) \foreach \k in {0,...,8} { let \n1={-2*mod(\k,2) + 1.0} in -- ++(0,\n1) -- ++(1,0) coordinate (p\k)} -- ++(2,0) node (p9) [right] {$x=0$};
\draw [densely dashed, draw=cyan] (3,0) -- + (0,1.5) (5,0) -- + (0,1.5) (o -| p7) -- (o -| p9.west) node [right] {$x=\varnothing$};
\draw[<->] (3,1.3) -- node[above] {$\Lambda$} + (2,0);
\draw[red] (1,1.5) node[above] {$z =0$} + (0,1.);
\draw[red] (8,1.5) node[above] {$z = L$} + (0,1.);
\draw[densely dashed,cyan] (1,0) -- + (0,1.5);
\draw[densely dashed,cyan] (8,0) -- + (0,1.5);
\end{tikzpicture}
\end{document}
这只是通过命名坐标和节点来实现的,以便以后可以使用它们而无需指定它们的实际坐标。