![如何制作一个正方形并在每个角上标记数字?](https://linux22.com/image/306248/%E5%A6%82%E4%BD%95%E5%88%B6%E4%BD%9C%E4%B8%80%E4%B8%AA%E6%AD%A3%E6%96%B9%E5%BD%A2%E5%B9%B6%E5%9C%A8%E6%AF%8F%E4%B8%AA%E8%A7%92%E4%B8%8A%E6%A0%87%E8%AE%B0%E6%95%B0%E5%AD%97%EF%BC%9F.png)
我正在尝试制作一个正方形来演示反射和旋转的工作原理,因此我希望正方形的每个内部顶点都标有数字。
答案1
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (0,2) -- (2,2) -- (2,0) -- (0,0);
\node[above right] at (0,0) {1};
\node[below right] at (0,2) {2};
\node[below left] at (2,2) {3};
\node[above left] at (2,0) {4};
\end{tikzpicture}
\end{document}
答案2
一种自动且简单的适应方法(遵循@Benjamin McKay 的想法)
\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[blue,draw=red,thick,minimum width=2cm,minimum height=2cm] (rect) at (0,0) {$\times$};
\foreach \anc/\n in {south west/1,north west/2,north east/3,south east/4}{
\node[anchor=\anc] at (rect.\anc) {\n};
}
\end{tikzpicture}
\end{document}
答案3
最标准的 LaTeX(不是 TeX ;-))图形解决方案:picture
环境。因此没有加载任何包。
\documentclass[12pt]{scrartcl}
\begin{document}
\setlength{\unitlength}{4cm}
\begin{picture}(1,1)
\put(0,0){\framebox(1,1)[t]{}}
\put(0.01,0.01){1}
\put(0.99,0.01){\makebox(0,0)[br]{2}}
\put(0.99,0.99){\makebox(0,0)[tr]{3}}
\put(0.01,0.99){\makebox(0,0)[tl]{4}}
\end{picture}
\end{document}
答案4
仅基于 TeX 原语的解决方案(没有 TikZ、Metapost、Lua 等):
\def\hboxlab#1#2{\hbox to2cm{\vrule height4mm depth1mm \kern1mm #1\hfil #2\kern1mm\vrule}}
\vbox{\offinterlineskip\hrule
\hboxlab 43
\hbox to2cm{\vrule height1cm \hfil\vrule}
\hboxlab 12
\hrule
}