我使用以下 Latex 脚本
\documentclass{article}
\usepackage{tikz,xcolor}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\filldraw[fill=gray!40!white, draw=black] (0,0) rectangle (4,2);
\node[black](dot) at (2,1) {\textbullet};
\node[below=0cm of dot] {\small{$x_a = (2,1)$}};
\end{tikzpicture}
\end{document}
要得到:
有没有办法添加角坐标?例如,我想在左下角看到 (0,0)。
答案1
当然。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\filldraw[fill=gray!40!white, draw=black] (0,0)
node[black,label={[font=\small]below:$x_0 = (0,0)$}](dot0){\textbullet}
rectangle (4,2)
node[black,midway,label={[font=\small]below:$x_a = (2,1)$}](dot){\textbullet};
\end{tikzpicture}
\end{document}
或者
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[bullet/.style={node contents={\textbullet},
label={[font=\small]below:#1}}]
\filldraw[fill=gray!40!white, draw=black] (0,0)
node[bullet={$x_0=(0,0)$}]
rectangle (4,2) node[midway,bullet={$x_a=(2,1)$}];
\end{tikzpicture}
\end{document}
答案2
PSTricks 解决方案仅用于娱乐目的!
\documentclass[pstricks,12pt,border=12pt]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}(-1,-1)(4,2)
\psframe[fillstyle=solid,fillcolor=lightgray](0,0)(4,2)
\pstGeonode[PosAngle={-90},PointName={{x_0=(0,0)},{x_a=(2,1)}}](0,0){O}(2,1){A}
\end{pspicture}
\end{document}