%%  --------------------------------------------------------------  %%
%%  -------------------- cuisine.sty package ---------------------  %%
%%               a package written by Baptiste Le Roi               %%
%%                                                                  %%
%%  Package / style modified from livrerecettes.sty of Alexis Flesh %%
%%                                                                  %%
%%         modified from cookybooky.dtx package from J. Gilg        %%
%%                                                                  %%
%%  ------- Copyright (C) 2009,2021 by Gilg, Flesj, Le Roi -------  %%
%%  gilg@acrotex.net, alexis.flesch@gmail.com, leroi.bwh@gmail.com  %%
%%                                                                  %%
%%    This work may be distributed and/or modified under the        %%
%%    conditions of the LaTeX Project Public License (LPPL),        %%
%%    either version 1.3 of this license or (at your option)        %%
%%    any later version.                                            %%
%%    The latest version of this license is in                      %%
%%                                                                  %%
%%          http://www.latex-project.org/lppl.txt                   %%
%%                                                                  %%
%%    and version 1.3 or later is part of all distributions of      %%
%%    LaTeX version 2005/12/01 or later.                            %%
%%                                                                  %%
%%  --------------------------------------------------------------  %%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cuisine}
\RequirePackage{xkeyval}
\RequirePackage{marvosym}
%\RequirePackage{showframe}

% Geometry of the book
\RequirePackage[paperheight=21cm,paperwidth=14.8cm,margin=1cm,heightrounded]{geometry}%showframe

%glossary of the recipes
\RequirePackage{imakeidx}

% Links in the book
\RequirePackage[hidelinks,colorlinks=false]{hyperref}

% Colors
\RequirePackage{xcolor} % Required for specifying colors by name
\definecolor{ocre}{RGB}{164,16,52}  %{243,102,25} % Define the red color used for highlighting throughout the book

% Headers
\RequirePackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\normalsize\bfseries\ #1}{}} % Chapter text font settings
\fancyhf{} \renewcommand{\headrulewidth}{0pt}
%\fancyfoot[LE]{\bfseries\thepage} % Font setting for the page number in the foot
%\fancyfoot[RO]{\huge\bfseries\textcolor{white}{ \rightmark}} %% Font setting for the page number in the foot
% remove the page number on chapter pages
\makeatletter
\let\ps@plain\ps@empty
\makeatother


% Pictures and graphic content
\RequirePackage{graphicx} % Required for including pictures
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored
\RequirePackage{wrapfig} % To wrap the tabular with the ingredients
\RequirePackage{floatrow}
\RequirePackage{tikz} % Required for drawing custom shapes
\RequirePackage{eso-pic} % for background pictures
\RequirePackage{transparent} % for transparency

% Fonts
\RequirePackage{lettrine}
\RequirePackage{polyglossia}
\setdefaultlanguage{english}
\usepackage{fontspec}
\setmainfont{Comic Neue}
%\renewcommand{\familydefault}{\sfdefault} %Schriftart Sans-Serif
%\RequirePackage[defaultfam,tabular,lining,alternates]{montserrat} %% Option 'defaultfam'
%% only if the base font of the document is to be sans serif
\renewcommand*\oldstylenums[1]{\oldstylenums{#1}} %wenn Montserrat nicht verwendet
%\renewcommand*\oldstylenums[1]{{\fontfamily{Montserrat-TOsF}\selectfont #1}}

% the name of the TOC
\addto\captionsfrench{% Replace "english" with the language you use
  \renewcommand{\contentsname}%
    {Inhalte}%
}

% lists
\RequirePackage{enumitem}

\usepackage{paracol}%f. Seitenumbrüche in minipage

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                       Elements of the recipe                                                  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%Counter of recipe
%\newcounter{numrecette}\setcounter{numrecette}{0}

\RequirePackage[compact]{titlesec}
\titleformat{\section}
        {\color{ocre}\normalfont\Huge\bfseries}
       {\color{ocre}\thesection}{1em}{}
\renewcommand{\thesection}{}
\titleformat{\chapter}[display]
  {\normalfont\bfseries}{}{0pt}{\Huge}

% Name of the recipe
\newcommand*{\recipename}[1]
    {
        \newpage 
        \section{#1}
        \index{#1}}
%\addcontentsline{toc}{section}{#1}}
%%        \stepcounter{numrecette}
%        \textcolor{ocre}{{\Huge \textbf{#1\hfill}}} 
%    \vspace{1em}    
    




% Icons and text
\newcommand{\preptime}[1]{\includegraphics[height=15pt]{Pictures/ico/chef.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\cooktime}[1]{\includegraphics[height=15pt]{Pictures/ico/pot.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\baketime}[1]{\includegraphics[height=15pt]{Pictures/ico/oven.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\servings}[1]{\includegraphics[height=15pt]{Pictures/ico/plate.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\cooltime}[1]{\includegraphics[height=15pt]{Pictures/ico/fridge.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\robot}[1]{\includegraphics[height=15pt]{Pictures/ico/robot.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\marinade}[1]{\includegraphics[height=15pt]{Pictures/ico/marinade.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\kcal}[1]{\includegraphics[height=15pt]{Pictures/ico/kcal.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\KH}[1]{\includegraphics[height=15pt]{Pictures/ico/KH.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\protein}[1]{\includegraphics[height=15pt]{Pictures/ico/protein.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\fett}[1]{\includegraphics[height=15pt]{Pictures/ico/fett.png}{\raisebox{3pt}{ #1\hspace{1em}}}}
\newcommand{\oberunter}[1]{\includegraphics[height=15pt]{Pictures/ico/oberunter.png}{\raisebox{3pt}{ #1\hspace{1em}}}}

% icon from https://www.flaticon.com/fr/auteurs/those-icons


% Ingredients
\RequirePackage{wrapfig}                     % To wrap the tabular with the ingredients
\RequirePackage{units}
\RequirePackage{tabulary}                    % line breaks in tabular

\usepackage{tabularx}
% Neue Spaltenart: T = minimal flexible Breite
\newcolumntype{T}{>{\raggedleft\arraybackslash}p{1.8cm}}

\setlength{\columnsep}{2em} % Abstand zwischen Spalten
\columnratio{0.65}           % linke Spalte 60%, rechte 40%

\newcommand{\recipe}[3]{
    \vspace{2em}
    \begin{paracol}{2}
        \flushcolumns    % <-- sorgt für gleiche Startpositionen
        %Zutaten
        \begin{leftcolumn}
            \textbf{Zutaten}\\[1em]
            \begin{tabularx}{\linewidth}{@{}T X@{}}
                #1
            \end{tabularx}
        \end{leftcolumn}
        %Notizen
        \begin{rightcolumn}
            \textbf{Notizen}\\[1em]
                #2
        \end{rightcolumn}
    \end{paracol}
    \vspace{3em}
    %Zubereitung
    \textbf{Zubereitung}
    \begin{enumerate}[label=\color{ocre}\theenumi, font=\bfseries]
        #3
    \end{enumerate}
}


% The photo of the recipe
\newcommand{\photo}[1]{
    \newpage
    \vfill{ \transparent{0} :)}
    \AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{#1}}
}

\newcommand*{\info}[1]
    {\vfill
        \begin{tikzpicture}[overlay]
            \draw[line width=1.5pt,color=ocre] (-.2,0) -- (3,0);
            \draw[line width=1.5pt,color=ocre] (0,.2) -- (0,-1);
            %\draw[color=red] (0.2,-.5) node[right] {\Large Astuce :};
        \end{tikzpicture}
        
        \vspace{1em}
        \hspace{1em}\begin{minipage}{.915\textwidth}%
            \itshape#1
        \end{minipage}
    }

% Hilfsbefehl zum Setzen eines Bildes auf einer Seite
\newcommand{\SetPageImage}[1]{%
    \begin{tikzpicture}[remember picture,overlay]
        \node[anchor=north east, xshift=-0.2cm, yshift=-0.2cm] 
            at (current page.north east) {\includegraphics[height=1.75cm]{#1}};
    \end{tikzpicture}%
}

\endinput
