更新

更新

我想要制作由 4 个五边形组成的下一个图形。

在此处输入图片描述

我只能用两个,而且它们之间还有空隙。我甚至无法对两个五边形进行反射来得到所需的图形。

\documentclass[a4paper]{article}

\usepackage[brazil]{babel}

\usepackage{graphicx}

\usepackage{tikz}

\begin{document}

 \begin{center}

\begin{figure}[!htb]

  \begin{tikzpicture}

        \draw[ultra thick,rotate=18] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;

  \end{tikzpicture}

 \end{figure}

\begin{figure}[!htb]

   \begin{tikzpicture}
        \draw[ultra thick,rotate around={198:(-0.80,0.58)}] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;

  \end{tikzpicture}

  \end{figure}

\end{center}

\end{document}

在此处输入图片描述

答案1

您可以绘制同一个多个形状tikzpicture

\documentclass[a4paper]{article}

\usepackage[brazil]{babel}

\usepackage{graphicx}

\usepackage{tikz}

\begin{document}

 \begin{center}

\begin{figure}[!htb]

  \begin{tikzpicture}

        \draw[ultra thick,rotate=18] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;
        \begin{scope}[yshift=-3.22cm]
        \draw[ultra thick,rotate=198] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;
                \end{scope}
                \begin{scope}[xshift=3.8cm]
                        \draw[ultra thick,rotate=18] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;
                        \begin{scope}[yshift=-3.22cm]
                        \draw[ultra thick,rotate=198] (0:2) -- (72:2) -- (144:2) -- (216:2) -- (288:2) -- cycle;
                                \end{scope}
                \end{scope}
  \end{tikzpicture}

  \end{figure}

\end{center}

\end{document}

为了使事情变得简单,你可以使用预定义的五边形:

\documentclass[a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

\begin{figure}[!htb]
\begin{tikzpicture}[every node/.append style={regular polygon, regular polygon sides=5, minimum size=4cm, draw,ultra thick}]
    \node at (0,0) {};
    \node at (3.8,0) {};    
    \node[rotate=180] at (0,-3.22) {};  
    \node[rotate=180] at (3.8,-3.22) {};        
\end{tikzpicture} 
\end{figure}

\end{document} 

在此处输入图片描述

题外话:请注意,将浮动figure环境放置在非浮动center环境中并没有多大意义。

答案2

与@samcarter 的回答类似,但使用命名节点——避免计算距离。我的座右铭:让 TikZ 来完成这项工作!

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{shapes.geometric}
%% The size can easily altered by changing the minimum size
\tikzset{pgon/.style={regular polygon,regular polygon sides=5,minimum size=1in,draw,ultra thick,outer sep=0pt}}

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{shapes.geometric}

\tikzset{pgon/.style={regular polygon,regular polygon sides=5,minimum size=1.5in,draw,ultra thick,outer sep=0pt}}

\begin{document}

\tikz{%
    \node[pgon] (S) at (0,0) {S};
    \node[pgon,anchor=corner 2] (A) at (S.corner 5) {A};
    \node[pgon,rotate=180,anchor=corner 4] (B) at (S.corner 3) {B};
    \node[pgon,rotate=180,anchor=corner 4] (C) at (A.corner 3) {C};
    \draw[fill=purple!50,line join=bevel,ultra thick] (S.corner 5) --
            (A.corner 3) -- 
            (C.corner 5) -- 
            (S.corner 4) -- cycle;
}

\end{document}

更新

我稍微修改了代码,这样彩色形状的顶部和底部就不会出现斜接问题。同时更新了输出。

五角大楼图

答案3

这看起来像一个代码高尔夫挑战;)

\documentclass[tikz,border=7pt]{standalone}
\usetikzlibrary{shapes.geometric}
\begin{document}
  \tikz
    \path[fill=violet](1,1.17557)foreach~in{1,-1}{[scale=~]foreach~in{1,-1}{[yscale=~]
      --(1,1.17557)node[regular polygon,regular polygon sides=5,
      inner sep=17.11435,draw,fill=white,transform shape,yshift=-9.24486]{}}};
\end{document}

在此处输入图片描述

计算

  • 1cm = 28.452755906694 pt
  • x = 1 cm
  • y = (cos(pi/5)+cos(2*pi/5))/sin(2*pi/5) = 1.1755705045849463 cm
  • inner sep = cos(pi/5)/sqrt(2)/sin(2*pi/5)*28.452755906694 = 17.114359850473026 pt
  • yshift = -cos(2*pi/5)/sin(2*pi/5)*28.452755906694 = -9.244860806192047 pt

相关内容