tikz 그림을 그렸는데 를 사용하여 그림의 크기를 조정하면 \begin{tikzpicture}[scale=200/(\hsize-24)]
변환 캔버스 범위 내의 모든 내용이 사라집니다. 누군가 이것을 설명할 수 있나요?
이게 tikz 원본 사진이에요
\documentclass[tikz, border=12]{standalone}
\usepackage{tikz, tkz-euclide, pgfmath, pstricks}
\usetikzlibrary{intersections, decorations.markings, angles,
quotes, calc, arrows, arrows.meta}
\usetkzobj{all}
%
\definecolor{blue}{RGB}{0,51,255}
\definecolor{green}{RGB}{0,153,0}
\definecolor{blue1}{RGB}{174,214,241}
\definecolor{blue}{RGB}{161,207,223}
\definecolor{yellow}{RGB}{255,220,0}
\colorlet{dcolor}{blue}
%
\begin{document}
\begin{tikzpicture}
\pgfgettransformentries{\mya}{\myb}{\myc}{\myd}{\mys}{\myt}
\pgfmathsetmacro{\preserve}{1/\mya}
\begin{scope}[>={Stealth[scale=1.2]} , thick,rotate=0 ]
%
\newcommand\height{10}
%
\newcommand\Ac{-4}
%
\newcommand\Bc{27.46586300953384}
%
\pgfmathsetmacro{\distance}{\Bc+\Ac}
\draw (0,-0.2) node [color=black,fill=white,below] {$Q$};
\draw [fill=black] (\Ac-0.1*\distance,0)--(\Bc+0.1*\distance,0)--(\Bc+0.1*\distance,0.01*\height)--(\Ac-0.1*\distance,0.01*\height)--cycle;
\draw [fill=black] (\Ac-0.1*\distance,\height)--(\Bc+0.1*\distance,\height)--(\Bc+0.1*\distance,1.01*\height)--(\Ac-0.1*\distance,1.01*\height)--cycle;
\draw [black,densely dashed](0,0)--(0,\height);
%
\coordinate (pulleyCenter) at (0,0.9*\height);
%
\pgfmathsetmacro{\pulleyRadius}{0.0375*\height}
\draw (0,0.9*\height-\pulleyRadius) node [color=black,fill=white,below] {$P$};
\draw [line width = 0.2*\distance,line cap=round](0,0.9*\height)--(0,0.995*\height);
\draw [line width = 0.2*\distance]([shift={(0,\height)}]0:-0.025*\height) arc[radius=0.025*\height, start angle=180, end angle= 360];
\pgfmathsetmacro{\ax}{\Bc-0.04*\distance}
\pgfmathsetmacro{\bx}{\Bc+0.04*\distance}
\pgfmathsetmacro{\lowerwidth}{\bx-\ax}
\pgfmathsetmacro{\aby}{0.2+0.01*\height}
\pgfmathsetmacro{\dx}{\Bc-0.08*\distance}
\pgfmathsetmacro{\cx}{\Bc+0.08*\distance}
\pgfmathsetmacro{\upperwidth}{\cx-\dx}
\pgfmathsetmacro{\cartheight}{1.25*\lowerwidth}
\pgfmathsetmacro{\dcy}{\aby+\cartheight}
\coordinate(a) at (\ax,\aby);
\coordinate(b) at (\bx,\aby);
\coordinate(d) at (\dx,\dcy);
\coordinate(c) at (\cx,\dcy);
\pgfmathsetmacro{\adx}{\Bc-0.06*\distance}
\pgfmathsetmacro{\ady}{\aby+0.5*\cartheight}
\coordinate (c1) at (\adx,\ady);
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c1)--++(180:0.01*\Bc) coordinate (e1);
\coordinate (c2) at (\Bc+0.06*\distance,\ady);
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c2)--++(0:0.01*\Bc) coordinate (e2);
\draw [line width = 0.005*\height cm,blue!200,fill=blue](a)--(b)--(c)--(d)--cycle;
\tkzTangent[from with R=e1](pulleyCenter,\pulleyRadius cm) \tkzGetPoints{D1}{D2}
\draw[yellow, line width = 0.010*\height cm,line cap =round](e1)--(D1);
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c1)--(e1);
\draw [line width = 0.005*\height cm,blue!200,fill=blue](a)--(b)--(c)--(d)--cycle;
\pgfmathsetmacro{\wheelax}{0.25*\lowerwidth+\ax}
\pgfmathsetmacro{\wheelbx}{0.75*\lowerwidth+\ax}
\draw[black,fill=black](\wheelax,\aby)circle(\aby-0.011*\height);
\draw[black,fill=gray](\wheelax,\aby)circle(0.75*\aby-0.75*0.011*\height);
\draw[black,fill=black](\wheelbx,\aby)circle(\aby-0.011*\height);
\draw[black,fill=gray](\wheelbx,\aby)circle(0.75*\aby-0.75*0.011*\height);
\draw (\Bc,\ady) node [color=black] {$A$};
\pgfmathsetmacro{\shift}{\Ac-\Bc}
\begin{scope}[transform canvas={xshift=\shift cm}]
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c1)--(e1);
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c2)--(e2);
\coordinate (pulleyCenter) at (-1*\shift,0.9*\height);
\tkzTangent[from with R=e2](pulleyCenter,\pulleyRadius cm) \tkzGetPoints{D1}{D2}
\draw[yellow, line width = 0.01*\height cm,line cap =round](e2)--(D2);
\draw[gray!120,line width = 0.01*\height cm,line cap=round](c2)--(e2);
\draw [line width = 0.005*\height cm,blue!200,fill=blue](a)--(b)--(c)--(d)--cycle;
\draw[black,fill=black](\wheelax,\aby)circle(\aby-0.011*\height);
\draw[black,fill=gray](\wheelax,\aby)circle(0.75*\aby-0.75*0.011*\height);
\draw[black,fill=black](\wheelbx,\aby)circle(\aby-0.011*\height);
\draw[black,fill=gray](\wheelbx,\aby)circle(0.75*\aby-0.75*0.011*\height);
\draw (\Bc,\ady) node [color=black] {$B$};
\draw [gray,fill=gray!50,line width = 0.005*\height cm](pulleyCenter) circle(\pulleyRadius);
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
그리고 이건 사용 후 똑같은 tikz 사진이에요\begin{tikzpicture}[scale=200/(\hsize-24)]
\documentclass[tikz, border=12]{standalone}
\usepackage{tikz, tkz-euclide, pgfmath, pstricks}
\usetikzlibrary{intersections, decorations.markings, angles,
quotes, calc, arrows, arrows.meta}
\usetkzobj{all}
%
\definecolor{blue}{RGB}{0,51,255}
\definecolor{green}{RGB}{0,153,0}
\definecolor{blue1}{RGB}{174,214,241}
\definecolor{blue}{RGB}{161,207,223}
\definecolor{yellow}{RGB}{255,220,0}
\colorlet{dcolor}{blue}
%
\begin{document}
\begin{tikzpicture}[scale=200/(\hsize-24)]
\pgfgettransformentries{\mya}{\myb}{\myc}{\myd}{\mys}{\myt}
\pgfmathsetmacro{\preserve}{1/\mya}
\begin{scope}[>={Stealth[scale=1.2]} , thick,rotate=0 ]
%
\newcommand\height{10}
%
\newcommand\Ac{-4}
%
\newcommand\Bc{27.46586300953384}
%
\pgfmathsetmacro{\distance}{\Bc+\Ac}
\draw (0,-0.2) node [color=black,fill=white,below] {$Q$};
\draw [fill=black] (\Ac-0.1*\distance,0)--(\Bc+0.1*\distance,0)--(\Bc+0.1*\distance,0.01*\height)--(\Ac-0.1*\distance,0.01*\height)--cycle;
\draw [fill=black] (\Ac-0.1*\distance,\height)--(\Bc+0.1*\distance,\height)--(\Bc+0.1*\distance,1.01*\height)--(\Ac-0.1*\distance,1.01*\height)--cycle;
\draw [black,densely dashed](0,0)--(0,\height);
%
\coordinate (pulleyCenter) at (0,0.9*\height);
%
\pgfmathsetmacro{\pulleyRadius}{0.0375*\height}
\draw (0,0.9*\height-\pulleyRadius) node [color=black,fill=white,below] {$P$};
\draw [line width = 0.2*\distance,line cap=round](0,0.9*\height)--(0,0.995*\height);
\draw [line width = 0.2*\distance]([shift={(0,\height)}]0:-0.025*\height) arc[radius=0.025*\height, start angle=180, end angle= 360];
\pgfmathsetmacro{\ax}{\Bc-0.04*\distance}
\pgfmathsetmacro{\bx}{\Bc+0.04*\distance}
\pgfmathsetmacro{\lowerwidth}{\bx-\ax}
\pgfmathsetmacro{\aby}{0.2+0.01*\height}
\pgfmathsetmacro{\dx}{\Bc-0.08*\distance}
\pgfmathsetmacro{\cx}{\Bc+0.08*\distance}
\pgfmathsetmacro{\upperwidth}{\cx-\dx}
\pgfmathsetmacro{\cartheight}{1.25*\lowerwidth}
\pgfmathsetmacro{\dcy}{\aby+\cartheight}
\coordinate(a) at (\ax,\aby);
\coordinate(b) at (\bx,\aby);
\coordinate(d) at (\dx,\dcy);
\coordinate(c) at (\cx,\dcy);
\pgfmathsetmacro{\adx}{\Bc-0.06*\distance}
\pgfmathsetmacro{\ady}{\aby+0.5*\cartheight}
\coordinate (c1) at (\adx,\ady);
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c1)--++(180:0.01*\Bc) coordinate (e1);
\coordinate (c2) at (\Bc+0.06*\distance,\ady);
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c2)--++(0:0.01*\Bc) coordinate (e2);
\draw [line width = 0.005*\height cm,blue!200,fill=blue](a)--(b)--(c)--(d)--cycle;
\tkzTangent[from with R=e1](pulleyCenter,\pulleyRadius cm) \tkzGetPoints{D1}{D2}
\draw[yellow, line width = 0.010*\height cm,line cap =round](e1)--(D1);
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c1)--(e1);
\draw [line width = 0.005*\height cm,blue!200,fill=blue](a)--(b)--(c)--(d)--cycle;
\pgfmathsetmacro{\wheelax}{0.25*\lowerwidth+\ax}
\pgfmathsetmacro{\wheelbx}{0.75*\lowerwidth+\ax}
\draw[black,fill=black](\wheelax,\aby)circle(\aby-0.011*\height);
\draw[black,fill=gray](\wheelax,\aby)circle(0.75*\aby-0.75*0.011*\height);
\draw[black,fill=black](\wheelbx,\aby)circle(\aby-0.011*\height);
\draw[black,fill=gray](\wheelbx,\aby)circle(0.75*\aby-0.75*0.011*\height);
\draw (\Bc,\ady) node [color=black] {$A$};
\pgfmathsetmacro{\shift}{\Ac-\Bc}
\begin{scope}[transform canvas={xshift=\shift cm}]
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c1)--(e1);
\draw [gray!120,line width = 0.01*\height cm,line cap=round](c2)--(e2);
\coordinate (pulleyCenter) at (-1*\shift,0.9*\height);
\tkzTangent[from with R=e2](pulleyCenter,\pulleyRadius cm) \tkzGetPoints{D1}{D2}
\draw[yellow, line width = 0.01*\height cm,line cap =round](e2)--(D2);
\draw[gray!120,line width = 0.01*\height cm,line cap=round](c2)--(e2);
\draw [line width = 0.005*\height cm,blue!200,fill=blue](a)--(b)--(c)--(d)--cycle;
\draw[black,fill=black](\wheelax,\aby)circle(\aby-0.011*\height);
\draw[black,fill=gray](\wheelax,\aby)circle(0.75*\aby-0.75*0.011*\height);
\draw[black,fill=black](\wheelbx,\aby)circle(\aby-0.011*\height);
\draw[black,fill=gray](\wheelbx,\aby)circle(0.75*\aby-0.75*0.011*\height);
\draw (\Bc,\ady) node [color=black] {$B$};
\draw [gray,fill=gray!50,line width = 0.005*\height cm](pulleyCenter) circle(\pulleyRadius);
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}
답변1
tikz 그림의 크기 조정은 변환 캔버스 내부의 xshift에 적용되지 않으므로 변환 캔버스 외부의 이동에 크기 조정을 적용한 다음 캔버스 변환 내부에서 크기 조정된 값을 사용하면 됩니다. 그래서 이걸 사용했어요
\pgfmathsetmacro{\shift}{\Ac-\Bc}
\pgfmathsetmacro{\shifta}{200/(\hsize-24)*\shift}
\begin{scope}[transform canvas={xshift=\shifta cm}]
이것 대신에
\pgfmathsetmacro{\shift}{\Ac-\Bc}
\begin{scope}[transform canvas={xshift=\shift cm}]
나머지 코드는 동일합니다.