
¿Alguien podría ayudarme? Realmente no sé qué estoy haciendo con los nuevos entornos. Tengo esto:
%Diagram environment
\newenvironment{diagram}%
{\stepcounter{CountDiag}\vspace*{10pt}%
\begin{center}%
\begin{tikzpicture}}%
{\end{tikzpicture}\vspace*{-5pt}\par Diagram~\theCountDiag%
\end{center}}%
Funciona bien pero me gustaría agregar:
\tkzSetUpCompass[color=blue]
Así que no tengo que incluirlo en todos los diagramas que uso.
\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}
Respuesta1
Simplemente agregue la instrucción en la parte "comienzo".
Sin embargo, haría algunas refactorizaciones.
\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}
Ajuste los espacios para adaptarlos a sus necesidades. Con \addvspace
usted no acumula espacios verticales que podrían ya estar presentes.