# A Tunisian flag on Tikz using a macro “m-grams”

I tried to represent the flag of my country. I typed this code. But I believe that the position of stars, circles, ... is not so respected. In addition I have a left margin "white band" I want to eliminate it, but without result.

Please can you help me get the correct code.

%A tunisian flag
%Author: Fethi GHARIANI
%using Tom Bombadil code in http://tex.stackexchange.com/questions/58903/how-to-draw-star-in-tikz-background who uses a macro for drawing stars as well as "n-grams"
\documentclass[fontsize=14pt]{scrartcl}
\usepackage[norsk,francais]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

% inner radius, outer radius, tips, rot angle, options étoile
\newcommand{\tstar}[5]{
\pgfmathsetmacro{\starangle}{360/#3}
\draw[#5] (#4:#1)
\foreach \x in {1,...,#3}
{ -- (#4+\x*\starangle-\starangle/2:#2) -- (#4+\x*\starangle:#1)
}
-- cycle;
}

\newcommand{\ngram}[4]{% outer radius, tips, rot angle, options
\pgfmathsetmacro{\starangle}{360/#2}
}

\definecolor{rec}{rgb}{1,0,0}
\definecolor{cir}{rgb}{1,1,1}
\definecolor{hon}{rgb}{1,0,0}
\definecolor{sta}{rgb}{1,1,1}

\begin{document}
\begin{tikzpicture}
\fill[rec] rectangle (24cm,16cm);
\fill[cir] (12,8) circle (4cm);
\fill[hon] (12,8) circle (3cm);
\fill[sta] (12.8,8) circle (2.4cm);
\ngram{1.5}{5}{72}{red,thick,fill=red,xshift=13.2cm,yshift=8cm};
\end{tikzpicture}
\end{document}

-
–  Peter Grill Jan 18 '13 at 8:09
The stripe one the left can be eliminated via adding a \noindent as the first line after \begin{document}. As far as the location of the starts and circles it should just be a matter of tweaking the coordinates to your liking. But comparing to this flag, the positioning and size look pretty good. I can't see what you positioning needs to be changed. –  Peter Grill Jan 18 '13 at 8:10
@Peter Grill. thank you very much, It works for the margin. –  Fethi G. Jan 18 '13 at 8:16
On the size and position, please see for example, dc444.4shared.com/img/px48cTom/s7/Dimension_flagTunisia.png –  Fethi G. Jan 18 '13 at 8:23
With xshift=12.8cm (instead of 13.2cm), the star is located in the center of the inner circle... –  Paul Gaborit Jan 18 '13 at 8:27

No n-grams code is required. Standard star node shape can do.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\definecolor{red}{RGB}{206,17,38}
\noindent\begin{tikzpicture}
% Use wikipedia's dimensions
\fill[red] rectangle (12, 8);
\fill[white] (6,4) circle (2);
\fill[red] (6,4) circle (1.5);
\fill[white] (6.4,4) circle (1.2);
\node[star,fill=red, minimum size=1.8cm, rotate=90, star point ratio=2.617,inner sep=0pt] at (6.4,4) {};
% Star point ratio is GoldenRatio^2 (1.618^2)
\end{tikzpicture}
\end{document}


Dimensions were taken from the reglamentary specification after 1999 law. This specification says nothing about the star shape and rotation, but it is safe to assume that it is a regular pentagram and that the flag has a horizontal symmetry axe, which completes the required information.

# Update

There is the pre-1999 version:

In this case I wrote a code more complex, in order to show a different technique. All elements in the flag are tikz nodes, and the styles define their size and position. Also all dimensions are relative to \flagwidth which can be changed at will.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{shapes.geometric}

\definecolor{red}{RGB}{206,17,38}
\def\flagwidth{6cm}
\tikzset{
flag/.style = {
fill=red,
minimum width=\flagwidth,
minimum height=2/3*\flagwidth,
inner sep = 0pt,
},
inner circle/.style = {
fill = white,
minimum size=1/3*\flagwidth,
circle,
inner sep = 0pt,
},
crescent/.style = {
fill = red,
minimum size = 2/9*\flagwidth,
circle,
inner sep = 0pt,
after node path = {node[moon] {}},
},
moon/.style = {
fill = white,
xshift= 1/45*\flagwidth,
minimum size = 1/5*\flagwidth,
inner sep = 0pt,
circle,
},
inner star/.style = {
fill = red,
star,
inner sep = 0pt,
xshift= 1/30*\flagwidth,
minimum size=4/27*\flagwidth,
rotate=90,
star point ratio=2.617,
}
}

\noindent\begin{tikzpicture}%[scale=0.01]
% Use pre 1999 dimensions
% http://en.wikipedia.org/wiki/File:Mesures_drapeau_Tunisie_avant_1999.svg
\draw node[flag] {}
node[inner circle]  {}
node[crescent] {}
node[inner star] {};
\end{tikzpicture}
\end{document}

-
Thank you, I thought of this question. "How to change this code." –  Fethi G. Jan 18 '13 at 9:42
@FethiG. You are right, I didn't answer directly your question, sorry. But I thought you could be interested in a simpler a more compact solution. And, anyway, I "changed your code" didn't I? :-) –  JLDiaz Jan 18 '13 at 10:38
not at all, I think to ask how to change this code, because, I believe that is very long. The reglamentary specification after 1999 law, changes the position of the 3rd circle, but I don't like it. Thank's. –  Fethi G. Jan 18 '13 at 10:54
Really, I thank you very much. I'm a biginner in Latex and Tikz, but I understand. –  Fethi G. Jan 18 '13 at 11:57
The red color should be {206,17,38} (RGB) (fr.wikipedia.org/wiki/Drapeau_de_la_Tunisie#Description). –  Paul Gaborit Jan 18 '13 at 14:02

Here is Turkish Flag:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\definecolor{red}{RGB}{227, 10, 23}
\noindent\begin{tikzpicture}
% Use wikipedia's dimensions
\fill[red] rectangle (12, 8);%G=8, L=12, L=1.5 G
\fill[white] (4,4) circle (2);
\fill[red] (4.5,4) circle (1.6);
\node[star,fill=white, minimum size=2cm, rotate=90, star point ratio=2.617,inner sep=0pt] at (6.83333333333,4) {};
\end{tikzpicture}
\end{document}


-
Welcome to TeX.SX! –  Papiro Jun 26 '13 at 0:00
Welcome to TeX.SX! –  mafp Jun 26 '13 at 0:01
Welcome to TeX.SX! –  In PSTricks we trust Jun 26 '13 at 2:45