我想要画出下面的图,它是一个平行四边形和两个全等的正六边形。
\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[portuguese]{babel}
\usepackage{tikz,tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}[scale=0.9]
\tkzInit[xmin=0,xmax=8,ymin=0,ymax=3]
\tkzClip[space=.5]
\tkzDefPoint(0,0){A} \tkzDefPoint(6,0){B}
\tkzDefPoint(7.5,3){C} \tkzDefPoint(1.5,3){D}
\tkzDefPointWith[colinear= at C](B,A)
\tkzDrawPolygon(A,B,C,D)
\end{tikzpicture}
\end{document}
答案1
六边形很好,因为所有角度都是 60 度,这意味着所有边和从中心到角的距离都相同。我称这个距离为\D
。然后主要是计算边和角度的问题。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\newcommand\D{2}
\coordinate (A) at (0,0);
\path (A) ++(0:\D) ++(-60:\D)coordinate (B);
%%
\draw[fill=gray!50] ($(A)+(120:\D)$)
-- ($(A)+(120:\D)+(-120:3*\D)$)
-- ($(B)+(-60:\D)$)
-- ($(B)+(-60:\D)+(60:3*\D)$) -- cycle;
%% Hexagons
\draw[fill=white] (A) +(0:\D) -- +(60:\D) -- +(120:\D) -- +(180:\D) -- +(240:\D) -- +(300:\D) -- cycle;
\draw[fill=white] (B) +(0:\D) -- +(60:\D) -- +(120:\D) -- +(180:\D) -- +(240:\D) -- +(300:\D) -- cycle;
%% Where are A and B?
\draw (A) circle (1pt) node[below]{A};
\draw (B) circle (1pt) node[below]{B};
\end{tikzpicture}
\end{document}