我正在尝试用 tikz 制作折纸模板。我制作了一个 latex 文档,四边边距均为 0.5 厘米。这是我的 tikz 代码:
\documentclass[landscape,a4paper]{article}
\usepackage[top=0.5cm, bottom=0.5cm, left=0.5cm, right=0.5cm]{geometry}
\usepackage{float}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
% \draw (0,0) rectangle (28.7cm,20cm);
\draw (14.45, 4.9) -- (14.6, 17.0);
\draw (14.6, 17.0) -- (26.5, 16.8);
\draw (26.5, 16.8) -- (26.4, 4.7);
\draw (26.4, 4.7) -- (20.43, 4.1);
\draw (20.43, 4.1) -- (14.45, 4.9);
\draw (20.43, 4.1) -- (14.6, 17.0);
\draw (20.43, 4.1) -- (26.5, 16.8);
\draw (14.6, 17) -- (2.7, 17.2);
\draw (2.7, 17.2) -- (2.6, 5.1);
\draw (2.6, 5.1) -- (8.47, 4.3);
\draw (8.47, 4.3) -- (14.45, 4.9);
\draw (8.47, 4.3) -- (2.7, 17.2);
\draw (8.47, 4.3) -- (14.6, 17.0);
\draw (2.6, 5.1) -- (1.3, 5.4);
\draw (1.3, 5.4) -- (1.4, 14.5);
\draw (1.4, 14.5) -- (2.7, 17.2);
\draw (8.47, 4.3) -- (8.7, 0.4);
\draw (8.7, 0.4) -- (10.65, 0.6);
\draw (10.65, 0.6) -- (10.55, 1.5);
\draw (10.55, 1.5) -- (12.99, 1.7);
\draw (12.99, 1.7) -- (13.05, 0.86);
\draw (13.05, 0.86) -- (14.97, 1.1);
\draw (14.97, 1.1) -- (14.45, 4.9);
\draw (14.45, 4.9) -- (17.18, 2.59);
\draw (17.18, 2.59) -- (15.99, 1.95);
\draw (15.99, 1.95) -- (15.97, 1.48);
\draw (15.97, 1.48) -- (20.08, 1.10);
\draw (20.08, 1.10) -- (20.43, 4.1);
\draw (20.43, 4.1) -- (22.56, 1.24);
\draw (22.56, 1.24) -- (22.69, 0.11);
\draw (22.69, 0.11) -- (25.04, 0.44);
\draw (25.04, 0.44) -- (24.93, 1.48);
\draw (24.93, 1.48) -- (26.4, 4.7);
\draw (2.6, 5.1) -- (2.08, 2.06);
\draw (2.08, 2.06) -- (6.1, 1.35);
\draw (6.1, 1.35) -- (6.15, 1.82);
\draw (6.15, 1.82) -- (5.31, 2.77);
\draw (5.31, 2.77) -- (8.47, 4.3);
\node (mid) at (14.6, 17.0);
\node (rh) at (20.48, 18.5);
\node (r) at (26.5, 16.8);
\node (lh) at (8.38, 18.63);
\node (l) at (2.7, 17.2);
\path (mid) edge [out=80,in=145,bend angle=180,looseness=1.45] (rh);
\path (r) edge [out=96,in=35,bend angle=180,looseness=1.4] (rh);
\path (mid) edge [out=100,in=35,bend angle=180,looseness=1.35] (lh);
\path (l) edge [out=86,in=145,bend angle=180,looseness=1.45] (lh);
\end{tikzpicture}
\end{figure}
\end{document}
生成以下页面:
如果你仔细观察,你会发现整个图像似乎都向下移动了。我在 tikz 代码的开头有一个注释掉的矩形,它应该在可打印区域周围放置一个边框。
如果我注释掉最后 4 行(曲线),那么 tikz 图片就在正确的位置。
我并不太担心精确的比例,我真正想要的是它在页面上尽可能大 - 例如,图像的顶部和底部应该接触页面的边缘。
答案1
顶部和底部使用零长度。
\documentclass[landscape,a4paper]{article}
\usepackage[top=0cm, bottom=0cm, left=0.5cm, right=0.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\noindent
\begin{tikzpicture}
\draw (0,0) rectangle (28.7cm,20cm);
\draw (14.45, 4.9) -- (14.6, 17.0);
\draw (14.6, 17.0) -- (26.5, 16.8);
\draw (26.5, 16.8) -- (26.4, 4.7);
\draw (26.4, 4.7) -- (20.43, 4.1);
\draw (20.43, 4.1) -- (14.45, 4.9);
\draw (20.43, 4.1) -- (14.6, 17.0);
\draw (20.43, 4.1) -- (26.5, 16.8);
\draw (14.6, 17) -- (2.7, 17.2);
\draw (2.7, 17.2) -- (2.6, 5.1);
\draw (2.6, 5.1) -- (8.47, 4.3);
\draw (8.47, 4.3) -- (14.45, 4.9);
\draw (8.47, 4.3) -- (2.7, 17.2);
\draw (8.47, 4.3) -- (14.6, 17.0);
\draw (2.6, 5.1) -- (1.3, 5.4);
\draw (1.3, 5.4) -- (1.4, 14.5);
\draw (1.4, 14.5) -- (2.7, 17.2);
\draw (8.47, 4.3) -- (8.7, 0.4);
\draw (8.7, 0.4) -- (10.65, 0.6);
\draw (10.65, 0.6) -- (10.55, 1.5);
\draw (10.55, 1.5) -- (12.99, 1.7);
\draw (12.99, 1.7) -- (13.05, 0.86);
\draw (13.05, 0.86) -- (14.97, 1.1);
\draw (14.97, 1.1) -- (14.45, 4.9);
\draw (14.45, 4.9) -- (17.18, 2.59);
\draw (17.18, 2.59) -- (15.99, 1.95);
\draw (15.99, 1.95) -- (15.97, 1.48);
\draw (15.97, 1.48) -- (20.08, 1.10);
\draw (20.08, 1.10) -- (20.43, 4.1);
\draw (20.43, 4.1) -- (22.56, 1.24);
\draw (22.56, 1.24) -- (22.69, 0.11);
\draw (22.69, 0.11) -- (25.04, 0.44);
\draw (25.04, 0.44) -- (24.93, 1.48);
\draw (24.93, 1.48) -- (26.4, 4.7);
\draw (2.6, 5.1) -- (2.08, 2.06);
\draw (2.08, 2.06) -- (6.1, 1.35);
\draw (6.1, 1.35) -- (6.15, 1.82);
\draw (6.15, 1.82) -- (5.31, 2.77);
\draw (5.31, 2.77) -- (8.47, 4.3);
\node (mid) at (14.6, 17.0){};
\node (rh) at (20.48, 18.5){};
\node (r) at (26.5, 16.8){};
\node (lh) at (8.38, 18.63){};
\node (l) at (2.7, 17.2){};
\path (mid) edge [out=80,in=145,bend angle=180,looseness=1.45] (rh);
\path (r) edge [out=96,in=35,bend angle=180,looseness=1.4] (rh);
\path (mid) edge [out=100,in=35,bend angle=180,looseness=1.35] (lh);
\path (l) edge [out=86,in=145,bend angle=180,looseness=1.45] (lh);
\end{tikzpicture}%
\end{document}
看起来 tikz 有一些尾随空格。但是,这是我的代码的输出: