
만약 내가한다면
\draw (1,1) circle (1pt)
1pt
tikz는 직경이 에 있는 작은 원을 그립니다 (1,1)
.
cross
다음과 같은 경로를 어떻게 정의할 수 있습니까?
\draw (1,1) cross (1pt)
직경이 있는 작은 십자가를 그립니다 1pt
(원처럼 크기 조절 가능)?
답변1
cross
에 해당하는 명령은 circle
존재하지 않지만 라이브러리 의 노드를 TiKZ
사용할 수 있습니다 . 이런 종류의 노드는 노드의 텍스트 위에 교차를 추가하지만 원하는 대로 적용하기가 쉽습니다.cross out
shapes.misc
\tikzset{cross/.style={cross out, draw,
minimum size=2*(#1-\pgflinewidth),
inner sep=0pt, outer sep=0pt}}
반경=1pt인 원을 그리 므로 circle (1pt)
전체 크기는 2pt가 되며 cross
노드의 크기는 minimum size=2*(#1-\pgflinewidth)
및 로 정의 inner
되고 outer
간격은 로 고정됩니다 0pt
.
교차 각도가 원하는 각도가 아닐 경우 rotate
옵션으로 변경할 수 있습니다. 다음으로 몇 가지 예가 있습니다. 또한 circles
원과 십자가의 크기가 동일하다는 것을 보여주기 위해 그 위에 배치했습니다 .
\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{shapes.misc}
\tikzset{cross/.style={cross out, draw=black, minimum size=2*(#1-\pgflinewidth), inner sep=0pt, outer sep=0pt},
%default radius will be 1pt.
cross/.default={1pt}}
\begin{document}
\begin{tikzpicture}[]
\draw (0,0) circle (1pt);
\draw (.5,0) node[cross,rotate=10] {};
\draw (.5,0) circle (1pt);
\draw (0,.5) circle (1pt);
\draw (0,.5) node[cross,red] {};
\draw (.5,.5) node[cross,rotate=30] {};
\draw (0.25,.25) circle (2pt);
\draw (0.25,.25) node[cross=2pt,rotate=45,green]{};
\end{tikzpicture}
\end{document}
답변2
다음을 사용하는 대체 솔루션 pic
:
\documentclass[]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\tikzset{
cross/.pic = {
\draw[rotate = 45] (-#1,0) -- (#1,0);
\draw[rotate = 45] (0,-#1) -- (0, #1);
}
}
\begin{document}
\begin{tikzpicture}
\draw (0,0) circle (1pt);
\path (.5,0) pic[rotate = 10] {cross=1pt};
\draw (.5,0) circle (1pt);
\draw (0,.5) circle (1pt);
\path (0,.5) pic[red] {cross=1pt};
\draw (.5,.5) pic[rotate = 30] {cross=1pt};
\draw (0.25,.25) circle (2pt);
\draw (0.25,.25) pic[rotate=45,green] {cross=2pt};
\end{tikzpicture}
\end{document}
답변3
해당 위치에 "x"를 쓸 수 있습니다.
\draw (1,1) node {x};
그런 다음 다음과 같이 글꼴 크기를 사용하여 크기를 조정할 수 있습니다.
\draw (1,1) node {\Huge x};
'x'의 중심은 실제로 주어진 좌표에 정확하게 배치됩니다.