我试图将两个数字并排放置,但右边的数字应该按一定比例缩放,才能显得比左边的数字大。到目前为止,我的进度是以下代码。我试着看手册,但我看不懂法语。
\documentclass[tikz]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
%Define Points
\tkzDefPoint (0,0){A}
\tkzDefPoint (4,0){B}
\tkzDefPoint (5,1){C}
\tkzDefPoint (3,2){D}
\tkzDrawPolygon[fill=blue!40, very thick](A,B,C,D)
%Label Points
\tkzLabelPoint[left](A){A}
\tkzLabelPoint(B){B}
\tkzLabelPoint(C){C}
\tkzLabelPoint[above](D){D}
%Shift the Points
\tkzDefShiftPoint[A](3 in, 0in){A'}
\tkzDefShiftPoint[B](3 in, 0in){B'}
\tkzDefShiftPoint[C](3 in, 0in){C'}
\tkzDefShiftPoint[D](3 in, 0in){D'}
\tkzDrawPolygon[fill=green!40, very thick,scale=3](A',B',C',D')
\end{tikzpicture}
\end{document}
答案1
您可以在翻译之前缩放点:
\documentclass[tikz]{standalone}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
%Define Points
\tkzDefPoint (0,0){A}
\tkzDefPoint (4,0){B}
\tkzDefPoint (5,1){C}
\tkzDefPoint (3,2){D}
\tkzDrawPolygon[fill=blue!40, very thick](A,B,C,D)
%Label Points
\tkzLabelPoint[left](A){A}
\tkzLabelPoint(B){B}
\tkzLabelPoint(C){C}
\tkzLabelPoint[above](D){D}
%Scale the points about A with ratio 3
\tkzDefPointBy[homothety=center A ratio 3](A)\tkzGetPoint{A};
\tkzDefPointBy[homothety=center A ratio 3](B)\tkzGetPoint{B};
\tkzDefPointBy[homothety=center A ratio 3](C)\tkzGetPoint{C};
\tkzDefPointBy[homothety=center A ratio 3](D)\tkzGetPoint{D};
%Shift the Points
\tkzDefShiftPoint[A](3 in, 0in){A'}
\tkzDefShiftPoint[B](3 in, 0in){B'}
\tkzDefShiftPoint[C](3 in, 0in){C'}
\tkzDefShiftPoint[D](3 in, 0in){D'}
\tkzDrawPolygon[fill=green!40, very thick](A',B',C',D')
\end{tikzpicture}
\end{document}
免责声明:我也不读法语,这是我第一次看tkz-euclide
。我所拥有的似乎有效,但我发现论点结构非常\tkzDefPointBy
奇怪。我建议直接使用tikz
(见cfr 的答案) 类似这样的事情。
答案2
Guho 的答案很好,但还有其他方法:
\documentclass[tikz]{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
%Define Points
\tkzDefPoint (0,0){A}
\tkzDefPoint (4,0){B}
\tkzDefPoint (5,1){C}
\tkzDefPoint (3,2){D}
\tkzDrawPolygon[fill=blue!40, very thick](A,B,C,D)
\end{tikzpicture}
\begin{tikzpicture}[scale=2]
%Define Points
\tkzDefPoint (0,0){A}
\tkzDefPoint (4,0){B}
\tkzDefPoint (5,1){C}
\tkzDefPoint (3,2){D}
\tkzDrawPolygon[fill=green!40, very thick](A,B,C,D)
\end{tikzpicture}
\begin{tikzpicture}
%Define Points
\tkzDefPoint (0,0){A}
\tkzDefPoint (4,0){B}
\tkzDefPoint (5,1){C}
\tkzDefPoint (3,2){D}
\tkzDrawPolygon[fill=blue!40, very thick](A,B,C,D)
\begin{scope}[xshift=5cm,x=2cm,y=2cm]
%Define Points
\tkzDefPoint (0,0){A}
\tkzDefPoint (4,0){B}
\tkzDefPoint (5,1){C}
\tkzDefPoint (3,2){D}
\tkzDrawPolygon[fill=red!40, very thick](A,B,C,D)
\end{scope}
\end{tikzpicture}
\end{document}
答案3
我也不读法语。能举出例子的人会明白一切。但对我来说显然不是。
\documentclass[border=5pt, multi, tikz, italian]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\path [draw, very thick, fill=blue!40] (0,0) \foreach \i/\j/\k in {(0,0)/A/left,(4,0)/B/right,(5,1)/C/right,(3,2)/D/above}
{
-- \i coordinate (\j) node [\k] {\j}
} -- cycle;
\path [draw, very thick, fill=green!40] (3in,0) -- +($3*(B)$) -- +($3*(C)$) -- +($3*(D)$) -- cycle;
\end{tikzpicture}
\end{document}
答案4
这要简单得多元帖子因为您可以将变换应用于整个路径,而不必一次对一个点进行变换。
prologues:=3;outputtemplate:="%j%c.eps";
beginfig(1);
path poly, small_poly, big_poly;
poly = origin -- (4,0) -- (5,1) -- (3,2) -- cycle;
small_poly = poly scaled 30;
big_poly = poly scaled 50 shifted 200 right;
fill small_poly withcolor .6[blue,white];
draw small_poly;
fill big_poly withcolor .6[green,white];
draw big_poly;
label.lft("A", point 0 of small_poly);
label.lrt("B", point 1 of small_poly);
label.rt ("C", point 2 of small_poly);
label.top("D", point 3 of small_poly);
endfig;
end