答案1
是的。一种选择是使用pic
s。
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\tikzset{
pics/.cd,
vector out/.style={
code={
\draw[#1] (0,0) circle (1) (45:1) -- (225:1) (135:1) -- (315:1);
}%end code
}%end style
}%end tikzset
\tikzset{
pics/.cd,
vector in/.style={
code={
\draw[#1] (0,0) circle (1);
\fill[#1] (0,0) circle (.1);
}%end code
}%end style
}%end tikzset
\begin{tikzpicture}%
\path (0,0) pic {vector out={line width=1.5pt}} (3,0) pic {vector in={line
width=1.5pt}};
\end{tikzpicture}
\end{document}
编辑:具有相对线宽:
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\tikzset{
pics/.cd,
vector out/.style args={#1/#2}{
code={
\draw[#1] (0,0) circle (1);
\draw[#2] (45:1) -- (225:1) (135:1) -- (315:1);
}%end code
}%end style
}%end tikzset
\tikzset{
pics/vector in/.style args={#1/#2/#3}{
code={
\draw[line width=#1] (0,0) circle (1);
\fill[#2] (0,0) circle (#3);
}%end code
}%end style
}%end tikzset
\begin{tikzpicture}%
\path (0,0) pic {vector out={line width=3pt/line width=2pt}} (3,0)
pic {vector in=1.5pt/blue/.2};
\end{tikzpicture}
\end{document}
答案2
Apath picture
是另一种选择,或者说是灵活性较差的 plonking \odot
and \otimes
in选项node contents
。
\documentclass[12pt,twoside]{article}
\usepackage{tikz}
\tikzset{
odot/.style={
circle,
inner sep=0pt,
node contents={$\odot$},
scale=2
},
otimes/.style={
circle,
inner sep=0pt,
node contents={$\otimes$},
scale=2
},
circ/.style={
circle,
draw,
minimum size=5mm,
inner sep=0
},
odot2/.style={
circ,
path picture={\fill circle[radius=2pt];}
},
otimes2/.style={
circ,
path picture={
\draw (path picture bounding box.45) -- (path picture bounding box.225);
\draw (path picture bounding box.135) -- (path picture bounding box.315);
}
}
}
\begin{document}
\begin{tikzpicture}
\node [odot,name=o1];
\node [otimes,name=o2,at={(1,0)}];
\node [odot2] at (2,0) {};
\node [otimes2] at (3,0) {};
\end{tikzpicture}
\end{document}