我想要一条从红点开始的线。为什么它们之间有间隙?我使用以下代码。
\begin{tikzpicture}
\draw[help lines] (0,0) grid (10,10);
\draw[very thick,rotate around={45:(2.3,5)}] (2.3,5) rectangle ++(4,0.3) ++(0,-0.15) node (p) {};
\fill[red] (p) circle (2pt);
\draw (p)--++(225:6);
\end{tikzpicture}
谢谢你!
答案1
间隙是由于节点命令inner sep
的默认值造成的,即。设置将消除间隙并将节点减小到最小尺寸。\node
(p)
.3333em
inner sep=0pt
\documentclass[10pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (10,10);
\draw[very thick,rotate around={45:(2.3,5)}] (2.3,5) rectangle ++(4,0.3) ++(0,-0.15) node[inner sep=0pt,outer sep=0pt] (p) {};
\fill[red] (p) circle (2pt);
\draw (p)--++(225:6);
\end{tikzpicture}
\end{document}
答案2
或者
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[help lines] (0,0) grid (10,10);
\draw[very thick,rotate around={45:(2.3,5)}] (2.3,5) rectangle ++(4,0.3) ++(0,-0.15) coordinate (p);
\draw (p)--++(225:6);
\fill[red] (p) circle (2pt);
\end{tikzpicture}
\end{document}
gab 是由˙inner sep
节点引起的(默认值为 3pt)。实际上有两种可能性:
- 减少
inner sep
节点,或 - 相反,节点使用坐标,正如我上面建议的那样