Compilateur LaTeX en ligne
www.cpierquet.fr
fichiers/test/nutriscore.tex
↓ télécharger
\documentclass{article}
\usepackage[margin=8mm]{geometry}
\usepackage{tikz}
\usepackage{listofitems}
% -------------------------------------------------------
% Définition des variables
\pgfmathsetmacro{\stripwidth}{2.4}
\pgfmathsetmacro{\width}{5*\stripwidth}
\pgfmathsetmacro{\height}{\width/3}
\pgfmathsetmacro{\margin}{0.3}
% Définition des couleurs
\definecolor{couleur1}{RGB}{45,126,67}
\definecolor{couleur2}{RGB}{151,186,56}
\definecolor{couleur3}{RGB}{240,202,13}
\definecolor{couleur4}{RGB}{213,123,26}
\definecolor{couleur5}{RGB}{197,52,25}
% Définition des formes
\def\nutriShape{
	(0,0) rectangle (\width,\height)
}
\def\scoreShape{
	(0,0) rectangle (\stripwidth+2*\margin,\height+2*\margin)
}
\tikzset{
	nodeStyle/.style={
		pos=0.5,
		white,
		opacity=0.5
	}
}
% Définition des commandes
\newcommand\score[2][nutri-score]{
	\begin{tikzpicture}[font=\fontfamily{qag}]
		\begin{scope}
			\clip[rounded corners = 10mm] \nutriShape;
			\fill[couleur1] (0,0) rectangle ++(\stripwidth,\height) node[nodeStyle]{\fontsize{60}{40}\selectfont \textbf{A}};
			\fill[couleur2] (\stripwidth,0) rectangle ++(\stripwidth,\height) node[nodeStyle]{\fontsize{60}{40}\selectfont \textbf{B}};
			\fill[couleur3] (2*\stripwidth,0) rectangle ++(\stripwidth,\height) node[nodeStyle]{\fontsize{60}{40}\selectfont \textbf{C}};
			\fill[couleur4] (3*\stripwidth,0) rectangle ++(\stripwidth,\height) node[nodeStyle]{\fontsize{60}{40}\selectfont \textbf{D}};
			\fill[couleur5] (4*\stripwidth,0) rectangle ++(\stripwidth,\height) node[nodeStyle]{\fontsize{60}{40}\selectfont \textbf{E}};
		\end{scope}
		\fill[rounded corners = 12mm, line width=2mm, draw=white, fill=couleur#2, xshift=(-1*\margin+(#2-1)*\stripwidth)*1cm, yshift=(-1*\margin)*1cm] \scoreShape node[pos=0.5, white]{\fontsize{60}{40}\selectfont \textbf{\letterList[#2]}};
		\node[right, lightgray] at (\margin,1.2*\height) {\fontsize{30}{20}\selectfont \uppercase{\textbf{#1}}};
	\end{tikzpicture}
}
% -------------------------------------------------------
\readlist\letterList{A,B,C,D,E}
\begin{document}
	\score[Géométrie]{5}
\end{document}