我试图将两个节点放置在网格上的特定点附近,这看起来很简单但是当我尝试时:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{calc}
\begin{tikzpicture}[scale=1.5]
\tikzset{microphone/.style={black,circle,draw,fill=gray,pos=0.75,scale=0.5,inner sep=2pt}};
\coordinate (centre_of_array) at (4,1);
\coordinate (bottom_left) at (0,0);
\coordinate (top_right) at (7,5);
\draw [dotted, draw=black, fill=white] (bottom_left) grid (top_right);
\draw [ultra thick, draw=black] (bottom_left) rectangle (top_right);
\node[microphone, label=below:$x_1$, left of=centre_of_array] (x1) {};
\node[microphone, label=below:$x_2$,right of=centre_of_array] (x2) {};
\end{tikzpicture}
\end{document}
我得到以下信息:
这看起来很简单,但在这里搜索后,我找不到任何人发布过类似的内容,为什么“麦克风”没有放在网格上位置 (4,1) 的两侧?我遗漏了什么吗?
非常感谢。
答案1
你已经在你的microphone
风格中定义了一个位置。如果你把它去掉,你就会得到你想要的。
% arara: pdflatex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc, positioning}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\tikzset{microphone/.style={black,circle,draw,fill=gray,scale=0.5,inner sep=2pt}};
\coordinate (centre_of_array) at (4,1);
\coordinate (bottom_left) at (0,0);
\coordinate (top_right) at (7,5);
\draw [dotted, draw=black, fill=white] (bottom_left) grid (top_right);
\draw [ultra thick, draw=black] (bottom_left) rectangle (top_right);
\node[microphone, label=below:$x_1$, left = of centre_of_array] (x1) {};
\node[microphone, label=below:$x_2$, right = of centre_of_array] (x2) {};
\end{tikzpicture}
\end{document}