在绘制物理图时,我们经常需要描绘一个垂直于绘图平面的矢量。如果要画进去,我们可以用 $\otimes$ 来画,对我来说这已经足够好了。但我能找到的最好的外箭头符号是 $\bigodot$,看起来不太好看。内部填充的圆圈似乎太小了。相反,我可以在 tikz 中使用类似
\fill [color=black] (-3, 0) circle(0.1);
\draw [color=black, thick] (-3, 0) circle(0.25);
但我认为它太冗长了。
代码如下:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary {positioning}
\usepgfmodule{decorations}
\usetikzlibrary{calc,fadings,decorations.pathreplacing, arrows}
\usetikzlibrary{decorations.markings}
\usepackage{bm} %boldfaced math symbols
\begin{document}
\begin{tikzpicture}[scale=0.6, decoration={
markings,
mark=at position 0.5 with {\arrow{latex}}}]
\def\x{2.5}
\def\X{7.6}
\def\y{-1}
\def\Y{1}
\draw[blue] (.5, 0.4*\y)--(18.5, 0.4*\y);
\draw[blue] (.5, 0.4*\Y)--(18.5, 0.4*\Y);
\foreach \x in {1,..., 18} {
\draw [blue] (\x, 0) node {$\bm\bigodot$};
}
% Amperiana intermediaria
\draw[color=red, postaction={decorate}] (\X, \Y)--(\x, \Y) ;
\draw[color=red, postaction={decorate}] (\x, \y)--(\X, \y);
\draw[red, postaction={decorate}] (\X, \y)--(\X, \Y) node[below right]
{$c$};
\draw[red, postaction={decorate}] (\x, \Y) -- (\x, \y);
\draw[ <->] (\x, 1.3*\Y) -- (\X, 1.3*\Y) node[midway, above] {$\ell$};
\draw[blue] (10, 0.7) node {$\vec\kappa$};
\draw[red, -latex] (11, 2.0) -- (10, 2) node [above] {$\vec B$};
\draw[red, -latex] (10, -2.0) -- (11, -2) node [above] {$-\vec B$};
\draw[red, -latex] (17, 1.0) --++ (1, 0) node [below] {$x$};
\draw[red, -latex] (17, 1.0) --++ (0, 1) node [left] {$y$};
\filldraw[white] (17, 1.0) circle (0.2) node[red] {\small$\bm\bigodot$};
\draw[red] (17, 1.0) node[left=0.1] {$z$};
\end{tikzpicture}
\end{document}
有没有$\bigodot$的简单替代品?
答案1
tikz 的pic
工作方式与节点非常相似。因此,你可以像这样定义自己的图片:
\tikzset{fieldout/.pic={
\fill circle(0.1);
\draw [thick] circle(0.25);
}
}
并在代码中的任何位置使用它,类似于使用节点的方式。
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary {positioning}
\usepgfmodule{decorations}
\usetikzlibrary{calc,fadings,decorations.pathreplacing, arrows}
\usetikzlibrary{decorations.markings}
\usepackage{bm} %boldfaced math symbols
\tikzset{fieldout/.pic={
\fill circle(0.1);
\draw [thick] circle(0.25);
}
}
\begin{document}
\begin{tikzpicture}[scale=0.6, decoration={
markings,
mark=at position 0.5 with {\arrow{latex}}}]
\def\x{2.5}
\def\X{7.6}
\def\y{-1}
\def\Y{1}
\draw[blue] (.5, 0.4*\y)--(18.5, 0.4*\y);
\draw[blue] (.5, 0.4*\Y)--(18.5, 0.4*\Y);
\foreach \x in {1,..., 18} {
%\draw [blue] (\x, 0) node {$\bm\bigodot$};
\pic [scale=.7,blue] at (\x, 0) {fieldout};
}
% Amperiana intermediaria
\draw[color=red, postaction={decorate}] (\X, \Y)--(\x, \Y) ;
\draw[color=red, postaction={decorate}] (\x, \y)--(\X, \y);
\draw[red, postaction={decorate}] (\X, \y)--(\X, \Y) node[below right]
{$c$};
\draw[red, postaction={decorate}] (\x, \Y) -- (\x, \y);
\draw[ <->] (\x, 1.3*\Y) -- (\X, 1.3*\Y) node[midway, above] {$\ell$};
\draw[blue] (10, 0.7) node {$\vec\kappa$};
\draw[red, -latex] (11, 2.0) -- (10, 2) node [above] {$\vec B$};
\draw[red, -latex] (10, -2.0) -- (11, -2) node [above] {$-\vec B$};
\draw[red, -latex] (17, 1.0) --++ (1, 0) node [below] {$x$};
\draw[red, -latex] (17, 1.0) --++ (0, 1) node [left] {$y$};
%\filldraw[white] (17, 1.0) circle (0.2) node[red] {\small$\bm\bigodot$};
\pic [scale=.7,red] at (17, 1.0) {fieldout};
\draw[red] (17, 1.0) node[left=0.1] {$z$};
\end{tikzpicture}
\end{document}