
이 코드에서는 제목과 원 사이의 공간을 줄이고 싶습니다. 또한 이 코드를 보다 효율적으로 만들려면 몇 가지 제안이 필요합니다.
\documentclass{article} \usepackage{tikz} \usetikzlibrary{angles,quotes}
\def\myrad{3cm}% radius of the circle \def\myang{60}% angle for the arc
\begin{document}
\def\myrad{1.5cm}% radius of the circle
\def\myang{45}% angle for the arc
\begin{tikzpicture}
% the origin
\coordinate (O) at (0,0);
% the box for deterministic part
\draw [fill=blue!05!white,dashed] (-4,-4) rectangle (4,4);
\draw [draw=none,node font=\LARGE] (-4,3) rectangle (4,4) node[midway]
{Deterministic};
% the circle and the dot at the origin
\draw (O) node[circle,inner sep=1.5pt,fill] {};
\draw [black!25,thick] circle [radius=\myrad];
% the ``\theta'' arc
\draw (\myrad,0) coordinate (xcoord) --
node[midway,below] {$r=1$} (O) --
(\myang:\myrad) coordinate (slcoord)
pic [draw,thick,->,>=stealth,angle radius=1cm,"$\theta$"] {angle = xcoord--O--slcoord};
% the outer ``s'' arc
\draw (\myrad,0) arc[start angle=0,end angle=\myang,radius=\myrad] {};
\node[draw=none,text width=4cm, font=\Large,align=center] at (0.25,-3){$0\leq \boldsymbol{\theta} \leq \pi/4$\vspace{2mm}$x=\cos(\theta_i)$\\$y=\sin(\theta_i)$};
\end{document}
답변1
MWE에 몇 가지 오류가 있습니다.
- 패키지가 누락
amsmat
되었거나mathtools
- 없어진
\end{tikzpicture}
tikz
라이브러리를 추가하여 MWE 를 backgrounds
다음 과 같이 다시 작성했습니다 .fit
positioning
scopes
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{angles, backgrounds, fit, quotes, positioning, scopes}
\begin{document}
\begin{center}
\begin{tikzpicture}[
node distance = 5mm,
my angle/.style = {draw, thick, -stealth,
angle radius=1cm,"$\theta$"}
]
\def\myrad{1.5cm}% radius of the circle
\def\myang{45}% angle for the arc
% the origin
\node (C) [circle,draw=red, minimum size=2*\myrad] {};
\node [circle, inner sep=1pt, fill] {};
% angle
\draw[thick]
(C.center) -- node[below] {$r=1$} (0:\myrad) coordinate (A)
arc (0:45:1.5) coordinate (B)
-- cycle;
\draw pic [my angle] {angle = A--C--B};
% box for deterministic part
\node (D) [above=of C, font=\Large] {Deterministic};
% math
\node (E) [below=of C, font=\Large] {%
$\begin{aligned}
0 & \boldsymbol{\theta} \leq \pi/4 \\
x & = \cos(\theta_i) \\
y & =\sin(\theta_i)
\end{aligned}$};
% background rectangle
\scoped[on background layer]
\node [draw, dashed, fill=gray!20, inner xsep=11mm,
fit=(C) (D) (E)] {};
\end{tikzpicture}
\end{center}
\end{document}
이제 이미지 요소의 모든 위치가 상대적이므로 노드 간 거리( 기준 node distance
)와 이미지 요소의 크기를 중앙에서 제어할 수 있습니다. 위 코드는 아마도 MWE보다 약간 짧을 것입니다.
\theta
왜 방정식 에 굵은 글씨로 표시되어 있고 이미지에는 표시되어 있지 않은지 명확하지 않습니다 . 제 생각에는 방정식에서 제거해야 한다고 생각합니다 boldsymbol
. 방정식은 이제 amsmath
( mathtools
) 환경 에 있습니다 aligned
. 나는 방정식에서 앰퍼샌드를 제거하고 aligned
로 바꾸는 것 보다 중앙에 위치하는 것을 더 좋아합니다 gathered
.
보시다시피 이미지의 피벗은 원입니다 C
. 이를 기준으로 원 "잘라내기"와 각도가 그려지고 그 위에는 이미지 제목이 있고 아래에는 방정식이 있습니다. 배경 직사각형이 진짜예요배경마지막으로 그려집니다.
부록: 원과 각도 영역에 색상을 추가했습니다. 나는 당신이 올바르게 이해했기를 바랍니다 :)
\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{angles, backgrounds, fit, quotes, positioning, scopes}
\begin{document}
\begin{center}
\begin{tikzpicture}[
node distance = 5mm,
my angle/.style = {draw, thick, -stealth,
angle radius=1cm,"$\theta$"}
]
\def\myrad{1.5cm}% radius of the circle
\def\myang{45}% angle for the arc
% the origin
\node (C) [circle, draw=red, fill=red!10, minimum size=2*\myrad] {};% added fill, color is red!10. you can change color according to your taste/wish
\node [circle, inner sep=1pt, fill] {};
% angle
\draw[thick, fill=white] % added fill, color is white. you can change color according to your taste/wish
(C.center) -- node[below] {$r=1$} (0:\myrad) coordinate (A)
arc (0:45:1.5) coordinate (B)
-- cycle;
\draw pic [my angle] {angle = A--C--B};
% box for deterministic part
\node (D) [above=of C, font=\Large] {Deterministic};
% math
\node (E) [below=of C, font=\Large] {%
$\begin{aligned}
0 & \leq \boldsymbol{\theta} \leq \pi/4 \\
x & = \cos(\theta_i) \\
y & = \sin(\theta_i)
\end{aligned}$};
% background rectangle
\scoped[on background layer]
\node [draw, dashed, fill=blue!10, inner xsep=11mm,
fit=(C) (D) (E)] {};
\end{tikzpicture}
\end{center}
\end{document}