この tikz コードで円の位置をシフトする方法

この tikz コードで円の位置をシフトする方法

このコードでは、見出しと円の間のスペースを減らしたいです。また、このコードをより効率的にするための提案も必要です。

\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ライブラリbackgrounds、、を追加してfit、MWE を次のように書き直しましたpositioningscopes

\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よりも、中央揃えにしたいです。alignedgathered

ご覧のとおり、画像のピボットは円です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}

関連情報