TikZ: 사진 중앙 정렬

TikZ: 사진 중앙 정렬

내 코드는 SR(그래프 발췌 부분의 중앙) 선이 페이지 중앙에 오도록 그림을 정렬하지 못합니다. 위의 텍스트, 그림 아래의 캡션과 페이지 매김을 비교하면 그림이 왼쪽으로 이동한 것이 눈에 띕니다.

\documentclass[12pt, a4paper, oneside]{article}
\usepackage{indentfirst}
\usepackage[margin = 2.5cm]{geometry}
\usepackage{tkz-euclide}
\usepackage{amsmath}
\usepackage{amssymb}
\usetkzobj{all}

\begin{document}

...some text here...

\begin{align*}
    \sec{\varphi}=\frac{|OS|}{|OR|}=\frac{|OS|}{1}=|OS|
& & \cot{\varphi}=\frac{|OU|}{|OT|}=\frac{|OU|}{1}=|OU|
\end{align*}

{\centering

\begin{tikzpicture}[scale=4]

    \def\costhirty{0.8660256}
    \def\secthirty{1.1547}
    \def\sinfifteen{-0.258819}
    \def\cosfifteen{0.9659258}

    \draw[color=gray,dotted,step=1cm] (-0.25,-0.25) grid (2.25,1.25);   

    \draw (\cosfifteen,\sinfifteen) arc (-15:105:1cm);

    \draw[color=gray,dotted] (0,0) -- (30:2.5cm);
    \draw[color=gray,dotted] (30:1cm) -- +(-90:0.75cm);
    \draw[color=gray,dotted] (30:1cm) -- +(90:0.75cm);

    \coordinate (O) at (0, 0);
    \coordinate (P) at (\costhirty, 0);
    \coordinate (Q) at (30:1cm);
    \coordinate (R) at (1, 0);
    \coordinate (S) at (30:\secthirty);
    \coordinate (T) at (0, 1);
    \coordinate (U) at (30:2);

    \draw[thick] (O)--(90:1.25);
    \draw[thick] (O)--(0:2.25);

    \draw[thick] (Q)--(P);
    \draw[thick] (O)--(U)--(T);
    \draw[thick] (R)--(S);

    \tkzLabelPoints[below left](O)
    \tkzLabelPoints[below left](P)
    \tkzLabelPoints[left = 5pt of Q](Q)
    \tkzLabelPoints[below right](R)
    \tkzLabelPoints[below right](S)
    \tkzLabelPoints[above left](T)
    \tkzLabelPoints[above](U)

    \tkzMarkAngle[fill = gray, size=0.3cm, opacity = .3](P,O,Q)
    \tkzLabelAngle[pos = 0.2](P,O,Q){$\varphi$}

    \tkzMarkAngle[fill = gray, size=0.3cm, opacity = .3](T,U,O)
    \tkzLabelAngle[pos = -0.2](O,U,T){$\varphi$}

\end{tikzpicture}

\textit{\scriptsize{Figure 2}}

}

\end{document}

위의 코드는 다음 미리보기를 생성합니다. (이중 빨간색 선은 이후에 추가되었습니다.)

그림

이중 빨간색 선을 통과하는 나머지 콘텐츠와 정렬되도록 SR 선을 중앙에 맞추려면 어떻게 해야 합니까?

답변1

정확한 이유는 모르겠지만 tkz-euclide각도 표시 매크로는 그래픽의 경계 상자 외부에 있는 일부 내부 제어점을 사용해야 합니다.

해결책은 이를 pgfinterruptboundingbox환경 내부에 넣는 것입니다.

\documentclass[12pt, a4paper, oneside]{article}
\usepackage{indentfirst}
\usepackage[margin = 2.5cm]{geometry}
\usepackage{tkz-euclide}
\usepackage{amsmath}
\usepackage{amssymb}
\usetkzobj{all}

\begin{document}

...some text here...

\begin{align*}
    \sec{\varphi}=\frac{|OS|}{|OR|}=\frac{|OS|}{1}=|OS|
& & \cot{\varphi}=\frac{|OU|}{|OT|}=\frac{|OU|}{1}=|OU|
\end{align*}

{\centering

\begin{tikzpicture}[scale=4]

    \def\costhirty{0.8660256}
    \def\secthirty{1.1547}
    \def\sinfifteen{-0.258819}
    \def\cosfifteen{0.9659258}

    \draw[color=gray,dotted,step=1cm] (-0.25,-0.25) grid (2.25,1.25);   

    \draw (\cosfifteen,\sinfifteen) arc (-15:105:1cm);

    \draw[color=gray,dotted] (0,0) -- (30:2.5cm);
    \draw[color=gray,dotted] (30:1cm) -- +(-90:0.75cm);
    \draw[color=gray,dotted] (30:1cm) -- +(90:0.75cm);

    \coordinate (O) at (0, 0);
    \coordinate (P) at (\costhirty, 0);
    \coordinate (Q) at (30:1cm);
    \coordinate (R) at (1, 0);
    \coordinate (S) at (30:\secthirty);
    \coordinate (T) at (0, 1);
    \coordinate (U) at (30:2);

    \draw[thick] (O)--(90:1.25);
    \draw[thick] (O)--(0:2.25);

    \draw[thick] (Q)--(P);
    \draw[thick] (O)--(U)--(T);
    \draw[thick] (R)--(S);

    \tkzLabelPoints[below left](O)
    \tkzLabelPoints[below left](P)
    \tkzLabelPoints[left = 5pt of Q](Q)
    \tkzLabelPoints[below right](R)
    \tkzLabelPoints[below right](S)
    \tkzLabelPoints[above left](T)
    \tkzLabelPoints[above](U)
    \begin{pgfinterruptboundingbox}
        \tkzMarkAngle[fill = gray, size=0.3cm, opacity = .3](P,O,Q)
        \tkzLabelAngle[pos = 0.2](P,O,Q){$\varphi$}
        \tkzMarkAngle[fill = gray, size=0.3cm, opacity = .3](T,U,O)
        \tkzLabelAngle[pos = -0.2](O,U,T){$\varphi$}
    \end{pgfinterruptboundingbox}
\end{tikzpicture}

\textit{\scriptsize{Figure 2}}

}

\end{document}

여기에 이미지 설명을 입력하세요


예제를 약간 축소하면 테스트를 위한 일부 "계측"을 통해 문제가 더 명확하게 표시됩니다.

\documentclass{article}
\usepackage{tkz-euclide}
\usepackage{amsmath}
\usetkzobj{all}

\begin{document}

...some text here... \hrulefill

\begin{align*}
    \sec{\varphi}=\frac{|OS|}{|OR|}=\frac{|OS|}{1}=|OS|
& & \cot{\varphi}=\frac{|OU|}{|OT|}=\frac{|OU|}{1}=|OU|
\end{align*}

{\centering

\begin{tikzpicture}[scale=4]
    \coordinate (O) at (0, 0);
    \coordinate (P) at ({cos(30)}, 0);
    \coordinate (Q) at (30:1cm);
    \coordinate (R) at (1, 0);
    \coordinate (S) at (30:{sec(30)});
    \coordinate (T) at (0, 1);
    \coordinate (U) at (30:2);

    \draw[thick] (Q)--(P);
    \draw[thick] (O)--(U)--(T);
    \draw[thick] (R)--(S);

    \node[red] at (current bounding box.south) {$\vert$};
    \begin{pgfinterruptboundingbox}
        \tkzMarkAngle[fill = gray, size=0.3cm, opacity = .3](P,O,Q)
        \tkzLabelAngle[pos = 0.2](P,O,Q){$\varphi$}
        \tkzMarkAngle[fill = gray, size=0.3cm, opacity = .3](T,U,O)
        \tkzLabelAngle[pos = -0.2](O,U,T){$\varphi$}
    \end{pgfinterruptboundingbox}
    \node[blue] at (current bounding box.south) {$\vert$};
\end{tikzpicture}

$\vert$

}

\end{document}

여기에 이미지 설명을 입력하세요

pgfinterruptboundingbox환경에 따라 세 가지 가 모두 어떻게 \vert정렬되는지 확인하세요. 이 환경을 주석 처리하면 각도 표시 매크로에 의해 경계 상자에 발생한 정렬 불량이 표시됩니다.

관련 정보