새로운 환경에 인수 삽입

새로운 환경에 인수 삽입

누구든지 나를 도와줄 수 있습니까? 나는 새로운 환경에서 내가 무엇을 하고 있는지 잘 모르겠습니다. 나는 이것을 가지고있다:

 %Diagram environment
 \newenvironment{diagram}%
 {\stepcounter{CountDiag}\vspace*{10pt}%

 \begin{center}%
     \begin{tikzpicture}}%
         {\end{tikzpicture}\vspace*{-5pt}\par Diagram~\theCountDiag%
 \end{center}}%

잘 작동하지만 다음을 추가하고 싶습니다.

  \tkzSetUpCompass[color=blue]

따라서 사용하는 모든 다이어그램에 이를 넣을 필요는 없습니다.

 \documentclass{article}
 \usepackage{tkz-euclide}

 %Diagram environment
 \newenvironment{diagram}%
 {\stepcounter{CountDiag}\vspace*{10pt}%

 \begin{center}%
 \begin{tikzpicture}}%
    {\end{tikzpicture}\vspace*{-5pt}\par Diagram~\theCountDiag%
 \end{center}}%

 \newcounter{CountDiag}\counterwithin*{CountDiag}{section}%

 \begin{document}

 \begin{diagram}
 \tkzDefPoint(0,0){A}
 \tkzDefPoint(3,0){B}
    \tkzDrawCircle[blue](A,B)

    \tkzDrawPoints(A,B)
    \tkzLabelPoints(A,B)
    
    \tkzDrawSegment[red](A,B)
 \end{diagram}
 \end{document}

답변1

"시작" 부분에 명령을 추가하기만 하면 됩니다.

그래도 리팩토링을 좀 할게요.

\documentclass{article}
\usepackage{tkz-euclide}

\usepackage{lipsum}

%Diagram environment
\newenvironment{diagram}
 {%
  \par\addvspace{10pt}%
  \centering
  \stepcounter{CountDiag}
  \tkzSetUpCompass[color=blue]
  \begin{tikzpicture}
}{%
  \end{tikzpicture}\par\nopagebreak
  \vspace{5pt}
  Diagram~\theCountDiag\par
  \addvspace{10pt}
}
\newcounter{CountDiag}\counterwithin*{CountDiag}{section}%

\begin{document}

\lipsum[1][1-4]

\begin{diagram}
  \tkzDefPoint(0,0){A}
  \tkzDefPoint(3,0){B}
  \tkzDrawCircle[blue](A,B)
  \tkzDrawPoints(A,B)
  \tkzLabelPoints(A,B)
  \tkzDrawSegment[red](A,B)
\end{diagram}

\lipsum[2]

\end{document}

필요에 맞게 간격을 조정하세요. \addvspace이미 존재할 수 있는 수직 간격을 누적하지 않습니다 .

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

관련 정보