我正在尝试制作一个正方形来演示反射和旋转的工作原理,因此我希望正方形的每个内部顶点都标有数字。
答案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
}