当我尝试使用以下代码绘制扬声器时,我得到一条更宽的中间线:
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1]
\def\w{15pt}
\def\h{6pt}
\node[draw,rectangle,minimum width=\w,minimum height=\h] (base) {};
\draw (base.south west) -- ++(-\w/3,-\h) --
([xshift=\w/3,yshift=-\h]base.south east) --
(base.south east) -- cycle;
\end{tikzpicture}
\end{document}
参见下面的输出:
我知道这可能是通过两次绘制相同的线而引起的,但这有什么问题呢?
答案1
杀死outer sep
为\node
:
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=1]
\def\w{15pt}
\def\h{6pt}
\node[outer sep=0pt,draw,rectangle,minimum width=\w,minimum height=\h] (base) {};
\draw (base.south west) -- ++(-\w/3,-\h) --
([xshift=\w/3,yshift=-\h]base.south east) --
(base.south east) -- cycle;
\end{tikzpicture}
\end{document}