![如何简化节点?](https://linux22.com/image/345495/%E5%A6%82%E4%BD%95%E7%AE%80%E5%8C%96%E8%8A%82%E7%82%B9%EF%BC%9F.png)
我正在尝试绘制一个带有标签的正方形,但我认为节点可以简化。
\begin{tikzpicture}
\draw (0,0) -- (4,0) -- (4,4) -- (0,4) -- cycle;
\draw (2,0) -- (4,2) -- (2,4) -- (0,2) -- cycle;
\node[below left] at (0,0) {A};
\node[above left] at (0,4) {B};
\node[above right] at (4,4) {C};
\node[below right] at (4,0) {D};
\node[above] at (1,4) {b};
\node[above] at (3,4) {c};
\node[right] at (4,3) {b};
\node[right] at (4,1) {c};
\node[below] at (3,0) {b};
\node[below] at (1,0) {c};
\node[left] at (0,1) {b};
\node[left] at (0,3) {c};
\node[left] at (1,1) {a};
\node[left] at (1,3) {a};
\node[right] at (3,1) {a};
\node[right] at (3,3) {a};
\end{tikzpicture}
答案1
我猜你看上去可能像这样:
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{quotes}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node[below left] {A} to ["b"] (0,2) to ["c"]
(0,4) node[above left] {B} to ["b"] (2,4) to ["c"]
(4,4) node[above right] {C} to ["b"] (4,2) to ["c"]
(4,0) node[below right] {D} to ["b"] (2,0) to ["c"] cycle;
\draw (2,0) to ["$a$" ']
(4,2) to ["$a$" ']
(2,4) to ["$a$" ']
(0,2) to ["$a$" '] cycle;
\end{tikzpicture}
\end{document}
其结果与您的代码相同: