1

This is the complied result of my code:enter image description here And this is my code:

\documentclass{article}
\usepackage{tikz}
\usepackage{ctex}

\begin{document}
\usetikzlibrary{shapes.geometric,arrows,positioning}
\flushleft
\begin{tikzpicture}[level1/.style={regular polygon, regular polygon sides=3,fill=orange,draw=black, minimum width=3cm, minimum height=2cm},level2/.style={rectangle, rounded corners, fill=purple, minimum width=3cm, minimum height=2cm},level3/.style={trapezium,trapezium angle=70,fill=blue,draw=black,minimum height=1.3cm}]
\tikzset{trapezium stretches=true}
\node(a1)[level1]{雅思一对一精品教程(推荐)};
\node(b1)[level2,below=1cm of a1,xshift=-5cm]{雅思口语提升班};
\node(b2)[level2,right=of b1]{雅思听力提升班};
\node(b3)[level2,right=of b2]{雅思阅读提升班};
\node(b4)[level2, right=of b3]{雅思写作提升班};
\node(c1)[level3,below=of b1]{夯实基础:雅思语法讲解};
\node(c2)[level3,right =  of c1]{夯实基础:雅思发音讲解};
\node(c3)[level3,right= of c2]{夯实基础: 雅思词汇讲解};
\end{tikzpicture}
\end{document}

As you can see, the picture is ugly and nonsymetrical. I am looking for some way to make it more symetrical. I guess I could math it out and calculate the xshift I need, but this is not what I am looking for. Is there an easier way that let tikz automatically align nodes?

jxhyc
  • 1,121

1 Answers1

1

Let me first apologize for not being able to use your characters. However, the answer to the question is: yes, e.g. with a matrix of nodes. BTW, you can set the node distance, then you do no longer have to say below=1cm.

\documentclass[tikz,border=3mm]{standalone}
% please put the libraries in the preamble
\usetikzlibrary{shapes.geometric,positioning,matrix}
\begin{document}
\begin{tikzpicture}[level1/.style={regular polygon, regular polygon sides=3,
fill=orange,draw=black, minimum width=3cm, minimum height=2cm},
level2/.style={rectangle, rounded corners, fill=purple, minimum width=3cm, 
minimum height=2cm},level3/.style={trapezium,trapezium angle=70,fill=blue,
draw=black,minimum height=1.3cm},node distance=1cm]
\tikzset{trapezium stretches=true}
\node(a1)[level1]{AAAAAAAAA(AA)};
\node[matrix of nodes,below=of a1,inner sep=0pt,nodes={level2,anchor=center},column sep=1cm] (b)
 {AAAAAAA & AAAAAAA & AAAAAAA & AAAAAAA \\};
\node[matrix of nodes,below=of b,inner sep=0pt,nodes={level3,anchor=center},column sep=1cm] (c)
{AAAA:AAAAAA & AAAA: AAAAAA & AAAA: AAAAAA\\};
\end{tikzpicture}
\end{document}

enter image description here