여기서 minimum width=αx
x는 tikzpicture 환경에 지정된 x 좌표 벡터의 길이입니다(예: ) \begin{tikzpicture}[x=0.1cm,y=2.5ex]
. 이것이 가능한가?
답변1
에서 제안한대로이 답변, 다음 예와 같이 변수를 정의하여 x 및 y 축척과 노드 스타일을 설정할 수 있습니다.
\documentclass{article}
\usepackage{tikz}
\newcommand{\unitx}{1cm}
\newcommand{\unity}{1cm}
\tikzset{%
box/.style 2 args = {%
rectangle,
draw,
minimum width = #1*\unitx,
minimum height = #2*\unity
},
every tikzpicture/.append style = {
x = \unitx,
y = \unity
}
}
\begin{document}
\begin{tikzpicture}
\node[box={2}{3}] at (0, 0) {Hello};
\end{tikzpicture}
\renewcommand{\unitx}{5cm}
\renewcommand{\unity}{3cm}
\begin{tikzpicture}
\node[box={2}{3}] at (0, 0) {Hello};
\end{tikzpicture}
\end{document}
이를 통해 모든 환경에 대해 x
지정된 규모를 적용 하고 이 규모를 기반으로 직사각형 노드에 대한 스타일을 정의합니다 .y
tikzpicture
minimum width
minimum height
배율은 문서의 어느 곳에서나 재정의하여 배율을 변경할 수 있는 \unitx
및 변수에 저장됩니다.\unity
크기 조정을 전역적으로 적용하지 않으려면 다음 예와 같이 명령 every tikzpicture
인수를 제거하고 로컬로 크기 조정을 적용하십시오.\tikzset
\documentclass{standalone}
\usepackage{tikz}
\newcommand{\unitx}{2cm}
\newcommand{\unity}{1cm}
\tikzset{%
box/.style 2 args = {%
rectangle,
draw,
minimum width = #1*\unitx,
minimum height = #2*\unity
}
}
\begin{document}
\begin{tikzpicture}[x = \unitx, y = \unity]
\node[box={2}{3}] at (0, 0) {Hello};
\end{tikzpicture}
\end{document}