[Tex/LaTex] Drawing a flag in LaTeX Tikz

htmltikz-pgf

Here is my code:

\documentclass[tikz]{standalone}
\usetikzlibrary{shapes,snakes}
\usepackage[html]{xcolor} 

\definecolor{rot}{HTML}{e40303}
\definecolor{xorange}{HTML}{ff8c00}
\definecolor{gelb}{HTML}{ffed00}
\definecolor{gruen}{HTML}{008026}
\definecolor{blau}{HTML}{004dff}
\definecolor{lilla}{HTML}{750787}


\begin{document}


\begin{tikzpicture}[x=0.026458cm,y=0.026458cm]
\fill[fill=rot](0,0)rectangle(750,70);
\fill[fill=xorange](0,0)rectangle(750,140);
\fill[fill=gelb](0,0)rectangle(750,210);
\fill[fill=gruen](0,0)rectangle(750,280);
\fill[fill=blau](0,0)rectangle(750,350);
\fill[fill=lilla](0,0)rectangle(750,420);
\end{tikzpicture}

\end{document}

I don't know why it doesn't do what I wanted it to do. Hopefully some of you can help?

Regenbogenflagge

Kind regards!

Best Answer

Some comments :

  1. xcolor is loaded by tikz, so don't reload it again,
  2. use capitals in color numbers,
  3. your last rectangle overlap the previous ones,
  4. you can make it shorter using foreach.

Here is the code :

\documentclass[tikz]{standalone}

\definecolor{rot}{HTML}{E40303}
\definecolor{xorange}{HTML}{FF8C00}
\definecolor{gelb}{HTML}{FFED00}
\definecolor{gruen}{HTML}{008026}
\definecolor{blau}{HTML}{004DFF}
\definecolor{lilla}{HTML}{750787}

\begin{document}
  \begin{tikzpicture}[x=0.026458cm,y=0.026458cm]
    \foreach[count=\i] \col in {lilla,blau,gruen,gelb,xorange,rot}
      \fill[\col] (0,70*\i) rectangle +(750,70);
  \end{tikzpicture}
\end{document}

enter image description here