% \iffalse meta-comment
%
% Copyright (C) 2013 by Sven Harder
% -----------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, 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.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{xcookybooky}
%<package> [2013/03/10 v1.2 Easy typesetting (potentially long) recipes with pictures]
%<config>\ProvidesFile{xcookybooky.cfg}
%<config> [2011/12/29 v1.0 'xcookybooky' configuration]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc} 
\usepackage{lmodern}
\usepackage{xcookybooky}
\usepackage{units}
\usepackage{pdfpages}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\addtolength{\textheight}{-1.5cm}
\addtolength{\oddsidemargin}{0.5cm}
\setcounter{IndexColumns}{2}
\setcounter{GlossaryColumns}{2}
\usepackage{hyperref}
\hypersetup{%
    pdfauthor = {Sven Harder},
    pdftitle = {xcookybooky documentation},
    colorlinks = {true},
    linkcolor = {blue},
    urlcolor = {blue},
    citecolor = {blue},
    filecolor = {blue}
}
\begin{document}
    \DocInput{xcookybooky.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{666}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v1.0}{2011/12/29}{Initial version}
% \changes{v1.1}{2012/04/06}{Load the non-free package 'emerald' per option. Possibility to change the picture width independently from the text columns}
% \changes{v1.2}{2013/03/10}{Better way for displaying the ingredients (tabularx). Thanks to Bartosz Dziubaczyk for developing.}
%
% \GetFileInfo{xcookybooky.sty}
%
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ ,\"}
% \DoNotIndex{\@ne}
% \DoNotIndex{\advance,\begingroup,\catcode,\closein}
% \DoNotIndex{\closeout,\day,\def,\edef,\else,\empty,\endgroup}
% \DoNotIndex{\begin,\end,\equal,\if,\fi,\ifthenelse,\setcounter,\value,\ifx,\ifnum}
% \DoNotIndex{\RequirePackage}
% \DoNotIndex{\savekeys,\define,\setkeys,\define@key}
%
% \title{The \textsf{xcookybooky} package\thanks{This document
% corresponds to \textsf{xcookybooky}~\fileversion,
% dated \filedate.}}
% \author{Sven Harder \\ \texttt{sven\_one1@gmx.de}}
%
% \maketitle
%
% \begin{abstract}
% This package is made for typesetting recipes. You simply enter ingredients, preparation steps and get a beautiful recipe page. It is also possible to enter 2 pictures, which are displayes above the name of the recipe. Another option is to write a hint, which is displayed at the bottom.
% \end{abstract}
%
% \vspace{3em}
%
% \PrintChanges
%
% \newpage
% \tableofcontents
% \newpage
%
% \section{Introduction}
%
% When I was looking for template for recipes, I found the cookybooky package by Jürgen Gilg (http://www.ctan.org/tex-archive/macros/latex/contrib/cookybooky).
% It looks very good, but I was unable to compile it correctly (e.g. I haven't got the Lucida fonts). Also there are some packages which have to be downloaded by hand, because there are not available at CTAN. Other handicaps are the missing possibility to create a PDF-file directly and a recipe cannot be longer than a single page.
% So decided to take a look at the code. Step by step I replaced all critical parts. Finally it is now possible to write recipes much easier (at least in my opinion).
% 
% \section{Comparison between xcookybooky and cookybooky}
% 
% There is no compatibility between xcookybooky and cookybooky, even the name is associating it. The reason for the naming is nearly similar design.
%
% A comparison between \texttt{xcookybooky} and \texttt{cookybooky} is shown in table \ref{tbl:comparison}.
% \begin{table}[htbp]
%    \centering
%    \begin{tabular}{rll}
%        \textbf{Characteristic} & \textbf{xcookybooky} & \textbf{cookybooky}\\
%        Maximum recipe length & unlimited & 1 page\\
%        Support missing pictures & yes & no\\
%        Transparent background graphic & not part of package (see section \ref{sec:background}) & yes\\
%        Main Layout & wraptable & minipages\\
%        Support twoside option & only changing pictures above & full\\
%        Generate recipe & environment & macro\\
%    \end{tabular}
%     \caption{Comparison between xcookybooky and cookybooky}
%     \label{tbl:comparison}
% \end{table}
% \newpage
%
% \section{Usage}
% First I want to explain the most important macros. After this you should be able to insert recipes. Afterwards some macros are shown, which allows you to modify the design (e.g. colors, headlines).
%
% \DescribeEnv{recipe}
% This the environment to insert recipes. Each recipe is included in a single enviroment. It is necessary to enter the name of the recipe. It is possible to insert also the recipetime, the portions, the calory content and the source (where you get this recipe).
% 
% Example:
% \begin{verbatim}
% \begin{recipe}[
%     preparationtime = 30 min,
%     bakingtime = 1 hour,
%     bakingtemperature = \unit[225]{°C},
%     portion = 4 portions,
%     calory = 4 kj,
%     source = My neighbour Sarah
% ]{Currywurst}
% ...
% \end{recipe}
% \end{verbatim}
%
% \DescribeMacro{\graph}
% It is possible to set 2 pictures by the macro \texttt{graph}. They are displayed above the other content. If no pictures are set, the space is used by the other content.
% The \texttt{big} picture should be bigger than the \texttt{small} picture ;) but it also possible to modify this behaviour.
% The reason for this is that the widths of the pictures are predefined by the command \texttt{setRecipeLengths}.
%
% Example (simple):
% \begin{verbatim}
% \graph{
%     small = strawberry,
%     big = strawberrycake
% }
% \end{verbatim}
%
% Another possibility is shown in the following example. It is recommended if you only want to change the widths of the pictures for one recipe.
% \textbf{Note:} These values are one only used for one recipe.
%
% Example (extended):
% \begin{verbatim}
% \graph{
%     small = strawberry,
%     smallpicturewidth = 0.3\textwidth,
%     big = strawberrycake,
%     bigpicturewidth = 0.6\textwidth,
% }
% \end{verbatim}
%
% \DescribeMacro{\ingredients}
% Here the ingredients of your recipe are set. They should be entered by number (unit) \& ingredient. If the unit is a SI-Unit, it looks better if you use the \texttt{units} package instead of a blank.
% Since the version 1.2 there is only one possibility to enter ingredients, which is shown in the example. Note that a overlong ingredient will automatically create a line break.
%
% Example:
% \begin{verbatim}
% \ingredients{
%     2 Tafeln & dunkle Schokolade (über \unit[70]{\%})\\
%     3        & Eier\\
%     \unit[200]{ml} & Sahne\\
%     \unit[40]{g} & Zucker\\
%     \unit[50]{g} & Butter
% }
% \end{verbatim}
%
% In the versions up to 1.1 there was also a method to enter ingredients with three columns. Due to the substitution of \texttt{tabular} with \texttt{tabularx} I decided that the three columns method is no longer supported, because it would mean a lot of work. This method has also the drawback it needs more space and in my opinion it also looks ugly.
% If you are using the three columns solution there are two options:
% \begin{enumerate}
%   \item Use the version 1.1 of thsi package
%   \item Redefine the concerning command in your latex file or in the configuration file 
% \end{enumerate}
% 
% \DescribeMacro{\preparation}
% The preparation steps are inserted by this macro. Every step is written after \texttt{step} command. This is necessarry for the numeration.
%
% Example:
% \begin{verbatim}
% \preparation{
%     \step This is the first step for cooking a brilliant meal.
%     \step The second step follows...
%     \step and so on
%     \step Enjoy your meal! 
% }
% \end{verbatim}
%
% \DescribeMacro{\portion}
% This macro is intented as an interface for an equal formating of portions entries. For this it can be easily modified. You just have to renew this command.
%
% \DescribeMacro{\bakingtemperature}
% This macro allows you to enter some bakingtemperatures. If you do not like the order of the temperatures you can change them by redefining the command. The temperatures are inserted as key/value pairs as known from the \texttt{xkeyval} package.
%
% Example (an entry in options of an recipe):
% \begin{verbatim}
% \begin{recipe}
% [
%     bakingtemperature={\protect\bakingtemperature{fanoven=\unit[230]{°C},
%         topbottomheat=\unit[195]{°C}, topheat=\unit[195]{°C}, bottomheat, gasstove=Stufe 2}}
% ]{Currywurst}
% \end{recipe}
% \end{verbatim}
%
% \subsection{Modify design}
% The following macros can be used outside the recipe environment to choose your personal color etc.
%
% \DescribeMacro{\setRecipeColors}
% If you want to change the default colors, you can use \texttt{setRecipeColors}. The colors are set by <key~=~value> as known by the \texttt{xkeyval} package. The names of colors can be found in table \ref{tbl:colormanagement}. New colors can be easiliy defined by the \texttt{xcolor} package as shown the example below.
% \begin{table}[htbp]
%     \centering
%     \begin{tabular}{rcl}
%         \textbf{key}& \textbf{default value} & \textbf{description}\\
%         recipename & green & recipe name\\
%         ing    & gray    & ingredients (text)\\
%         inghead & gray & headline of the ingredients\\
%         prep    & black    & preparation (text)\\
%         prephead & black & headline of the preparation\\
%         hint    & red    & hint (text)\\
%         hinthead & red    & headline of the hint\\
%         hintline & red & lines leftside the hint text (cross)\\
%         numeration & red & numeration of the preparation steps\\ 
%     \end{tabular}
%     \caption{Color Management}
%     \label{tbl:colormanagement}
% \end{table}
% 
% \begin{samepage}
% Example:
% \begin{verbatim}
% \definecolor{webgreen}{rgb}{0,.5,0}
%
% \setRecipeColors{
%     recipename = webgreen,
%     ing = blue,
%     numeration = black,    
% }
% \end{verbatim}
% \end{samepage}
%
% \DescribeMacro{\setRecipeLengths}
% By using the command \texttt{setRecipeLengths} it is possible to change the (default) values for the picture widths and the text column width.
% 
% Example:
% \begin{verbatim}
% \setRecipeLengths{
%     preparationwidth = 0.60\textwidth,
%     ingredientswidth = 0.35\textwidth,
%     pictureheight = 6cm,
%     bigpicturewidth = 0.6\textwidth,
%     smallpicturewidth = 0.35\textwidth
% }
% \end{verbatim}
%
% \DescribeMacro{\setRecipeSizes}
% The macro \texttt{setRecipeSizes} enables you to modify the fontsize of many parts of the recipe. The sizes are inserted by <key~=~value> (\texttt{xkeyval}).
%
% Example (these are the default values):
% \begin{samepage}
% \begin{verbatim}
% \setRecipeSizes{
%     recipename = \fontsize{25pt}{30pt},
%     ing = \normalsize,
%     inghead = \normalsize,
%     prep = \normalsize,
%     prephead = \normalsize,
%     hint = \normalsize,
%     hinthead = \Large
% }
% \end{verbatim}
% \end{samepage}
%
% \DescribeMacro{\setRecipenameFont}
% The name of recipe is displayed with a handwritten font by default. In my opinion it looks much better than a standard font. But if you want to change it you can use this macro. A well-arranged list of fonts can be found at \texttt{http://www.tug.dk/FontCatalogue/}. The other parameters are fontencoding, fontseries and fontshape. The size is changed by \texttt{setRecipeSizes}.
%
% Example (some fonts you could try out, requires option \texttt{handwritten}):
% \begin{verbatim}
% \setRecipenameFont{
%     % pbsi
%     % fau
%     % fwb
%     % fjd    % default when using the option handwritten
%     cmr      % default
% }{T1}{m}{n}
% \end{verbatim}
%
% \subsection{Translation}
% \DescribeMacro{\setHeadlines}
% \texttt{setHeadlines} allows to modify the default headlines. This is also needed for translations (The default values are german, sorry).
% The headlines are also inserted in <key~=~value> form.
%
% Example (a possible english translation):
% \begin{verbatim}
% \setHeadlines{
%     inghead = Ingredients,
%     prephead = Preparation,
%     hinthead = Hint,
%     calory = energy content,
%     continuationhead = Continuation,
%     continuationfoot = Continuation on next page
% }
% \end{verbatim}
%
%
% \subsection{Options}
% \label{sec:options}
% This package provides three options which are explained in the following.
% \begin{samepage}
% \begin{itemize}
%     \item \textbf{handwritten} This option requires the non-free package \texttt{emerald} and can only be used if your are not using TeX Live.
%     \item \textbf{nowarnings} This options tries to eliminate all nasty warnings. Only important and interesting warnings are logged. This is in my opinion a good choice because the package \texttt{wrapfigure} generates a lot of warnings, see section \ref{sec:knownissues}.
%     \item \textbf{myconfig} If you are using this package often or want to keep your main file 'clean' you can define your modfications in the configuration file. If you submit this option the file will be loaded otherwise \textbf{not}.
% \end{itemize}
% \end{samepage}
%
% \subsection{Background graphic}
% \label{sec:background}
% Inside this package there is only the option to set a background picture using the \texttt{setBackgroundPicture} macro. 
% For creating transparent backgrounds I recommand \textbf{Inkscape}\footnote{http://inkscape.org/}. You just have to import a picture and reduce the opacity of the picture (I prefer \unit[22]{\%}).
% The possible options for the orientation are: default, pagecenter, textcenter or stockcenter. To modify these orientations you have the possibility to change it manually by setting the \texttt{x} and \texttt{y} option (as shown below).
%
% Example:
% \begin{verbatim}
% \setBackgroundPicture
% [%
%     x = 2cm,
%     y = -1cm,
%     width=\paperwidth-3cm,
%     height,
%     orientation=pagecenter
% ]{pic/bg_transparent} % filepath
% \end{verbatim} 
%
% \newpage
% \IfFileExists{example/example.pdf}
% {
% \section{Example}
% \begin{minipage}{\textheight}
% \includepdf[pages={2}, scale=0.86]{example/example.pdf}
% \end{minipage}
% \newpage
% }{}
%
% \section{Troubleshooting}
% \subsection{MiKTeX}
% If you have problems with the used fonts (e.g. \texttt{cookingsymbols}) it might be necessary to refresh the database of MiKTeX.
%
% \subsection{TeX Live}
% If you are using this distribution you may should not use the option \texttt{handwritten}, because this option load the font package \texttt{emerald}.
% This package is non-free and therefore not available in TeX Live.
%
% \section{Bugs}
% If you found a bug, which is not described in the following section, feel free to write me an email. It can be found at the titlepage.
%
% \subsection{Known issues}
% \label{sec:knownissues}
% The \texttt{wrapfig} package has some problems with enumerations and the \texttt{lettrine} package. This is the reason, why some warnings are generated by compiling (the example), if do not use the package option \textbf{nowarnings}. But nevertheless the results look quite well, so I decided to ignore this issue.
% By using \texttt{wrapfig} it is not possible to switch ingredients and preparation (the result looks really ugly). This is the reason, why the layout is not changed when setting the \texttt{twoside} option in the document class. I also tried \texttt{parcolumns} and \texttt{parallel}, but the results were disappointing. If you want to use this feature, you have to use \texttt{cookybooky}.
%
% Another limitation is the length of the ingredients. The maximum length is one page, because the \texttt{wrapfigure} package does not work with \texttt{longtable}. As a result no pagebreak in the ingredients is possible.
% \StopEventually{\PrintIndex}
%
% \section{Implementation}
% Let's have a look at the implementation.
%
% \subsection{Options}
% You can use the option \texttt{myconfig} to load your personal configuration (file). See section \ref{sec:configuration}
%    \begin{macrocode}
%<*package>
\newif\ifHandwrittenFont@required
\HandwrittenFont@requiredfalse
\DeclareOption{handwritten}
{% displays the recipename in a handwitten font
    \HandwrittenFont@requiredtrue           
    \AtEndOfPackage{
        \setRecipeSizes{recipename = \fontsize{25pt}{30pt}}
        \setRecipenameFont{fjd}{T1}{m}{n}
    }
}
\DeclareOption{nowarnings}
{% tries to eliminate nasty warnings
    \AtEndOfPackage{
        \def\WF@conflict{}
        %\def\@fancywarning#1{}
    }
}
\DeclareOption{myconfig}
{% load personal configuration
    \AtEndOfPackage{
        \InputIfFileExists{xcookybooky.cfg}
        {\PackageInfo{xcookybooky}{inputting 'xcookybooky.cfg'}}
        {\PackageWarning{xcookybooky}{cannot find the configuration file 'xcookybooky.cfg'}}
    }
}
\ProcessOptions\relax

%    \end{macrocode}
%
% \subsection{Required Packages}
%  All needed packages are available at CTAN and as far as I know no general driver limitation are given.
%    \begin{macrocode}
\RequirePackage{tikz}                        % for creating the lines for the hint
\RequirePackage{graphicx}
\RequirePackage{xcolor}
\RequirePackage[clock, misc, weather]{ifsym} % Symbolpackage e.g. \Interval, \Wecker etc
\RequirePackage{cookingsymbols}              % Cookings symbols e.g. \Oven, \Dish etc
\ifHandwrittenFont@required
    \RequirePackage{emerald}                 % Handwritten Fonts
\fi
\RequirePackage{wrapfig}                     % To wrap the tabular with the ingredients

\RequirePackage{ifthen}
\RequirePackage{xkeyval}
\RequirePackage{lettrine}                    % numbering the preparation steps
\RequirePackage{fancyhdr}
\RequirePackage{units}
\RequirePackage{eso-pic}                     % for background pictures
\RequirePackage{picture}                     % for modfifying the position of the bg pictures
\RequirePackage{tabularx}                    % line breaks in tabular

%    \end{macrocode}
%
% \subsection{Page Layout}
% This will set up the page. It is optimized for the documentclass \texttt{article}. If you use a other package you probably have to modify this.
%
% \textbf{Note:} I tried to use the KOMA class \texttt{scrartcl}, but unfortunately some strange effects occured.
%    \begin{macrocode}
\setlength{\parindent}{0cm}
\setlength{\parskip}{2ex plus 0.5ex}

\setlength{\textwidth}{15.5cm}
\setlength{\textheight}{24.0cm}
\setlength{\topmargin}{-0.8cm}
\setlength{\headheight}{14pt} %0cm
\setlength{\headsep}{1cm}
\setlength{\topskip}{0cm}
\setlength{\footskip}{1.4cm}
\setlength{\evensidemargin}{-0.5cm}
\setlength{\oddsidemargin}{0.5cm}
\setlength{\voffset}{0cm}
\setlength{\hoffset}{0cm}
\setcounter{secnumdepth}{2} % subsubsections not numbered
\setcounter{tocdepth}{3}    % subsubsections in the .toc file

%    \end{macrocode}
%
% \begin{macro}{\recipesection}
% The macro \texttt{recipesection} allows to modify the entry in the table of contents.
% \textbf{Note:} If you modify the macro you may change the two upper lines as well.
%    \begin{macrocode}
\newcommand*{\recipesection}[2][]
{%
    \subsubsection[#1]{#2}
}

%    \end{macrocode}
% \end{macro}
%
% \subsection{Color Management}
% Below the (default) colors are defined using the \texttt{xkeyval} package.
%    \begin{macrocode}
\define@key{colorManagement}{recipename}[green]{\def\xcb@color@recipename{#1}}
\define@key{colorManagement}{ing}[gray]{\def\xcb@color@ing{#1}}
\define@key{colorManagement}{inghead}[gray]{\def\xcb@color@inghead{#1}}
\define@key{colorManagement}{prep}[black]{\def\xcb@color@prep{#1}}
\define@key{colorManagement}{prephead}[black]{\def\xcb@color@prephead{#1}}
\define@key{colorManagement}{hint}[black]{\def\xcb@color@hint{#1}}
\define@key{colorManagement}{hinthead}[red]{\def\xcb@color@hinthead{#1}}
\define@key{colorManagement}{hintline}[red]{\def\xcb@color@hintline{#1}}
\define@key{colorManagement}{numeration}[red]{\def\xcb@color@numeration{#1}}
\savekeys{colorManagement}
{%
    recipename,   % color of recipename
    ing,          % color of ingredients (text)
    inghead,      % color of headline of ingredients
    prep,         % color of preparation (text)
    prephead,     % color of headline of preparation
    hint,         % color of hint (text)
    hinthead,     % color of headline of hint
    hintline,     % color of lines of hint
    numeration    % color of numeration (preparation)
}

%    \end{macrocode}
%
% \begin{macro}{\setRecipeColors}
% The parameter are set in the form "key~=~value" as known by the \texttt{xkeyval} package.
%    \begin{macrocode}
\newcommand*{\setRecipeColors}[1]
{%
    \setkeys{colorManagement}{#1}
}

%    \end{macrocode}
% \end{macro}
%
% This is the initialisation of all required recipe colors.
%    \begin{macrocode}
\setRecipeColors
{% initialisation
    recipename,
    ing,
    inghead,
    prep,
    prephead,
    hint,
    hinthead,
    hintline,
    numeration
}

%    \end{macrocode}
% \subsection{Size Management}
% Below the (default) sizes are definded.
%    \begin{macrocode}
\define@key{sizeManagement}{recipename}[\fontsize{25pt}{30pt}]{\def\xcb@fontsize@recipename{#1}}
\define@key{sizeManagement}{ing}[\normalsize]{\def\xcb@fontsize@ing{#1}}
\define@key{sizeManagement}{inghead}[\normalsize]{\def\xcb@fontsize@inghead{#1}}
\define@key{sizeManagement}{prep}[\normalsize]{\def\xcb@fontsize@prep{#1}}
\define@key{sizeManagement}{prephead}[\normalsize]{\def\xcb@fontsize@prephead{#1}}
\define@key{sizeManagement}{hint}[\normalsize]{\def\xcb@fontsize@hint{#1}}
\define@key{sizeManagement}{hinthead}[\Large]{\def\xcb@fontsize@hinthead{#1}}
\savekeys{sizeManagement}
{
    recipename,
    ing,
    inghead,
    prep,
    prephead,
    hint,
    hinthead
}

%    \end{macrocode}
%
% \begin{macro}{\setRecipeSizes}
% The parameter are set in the form "key~=~value" as known by the \texttt{xkeyval} package.
%    \begin{macrocode}
\newcommand*{\setRecipeSizes}[1]
{
    \setkeys{sizeManagement}{#1}
}

%    \end{macrocode}
% \end{macro}
% This is the initialisation of all required recipe sizes.
%    \begin{macrocode}
\setRecipeSizes
{% initialisation
    recipename,
    ing,
    inghead,
    prep,
    prephead,
    hint,
    hinthead
}

%    \end{macrocode}
%
% \begin{macro}{\setRecipenameFont}
% This macro sets the font for the name of the recipe. You have to insert the fontfamily, fontencoding, fontseries and fontshape. The size is set by the \texttt{sizeManagement}
%    \begin{macrocode}
%% Handwritten fonts: hlce, pbsi, hlcw, fjd, fau
%% Other fonts: fwb
\newcommand*{\setRecipenameFont}[4]
{% sets the font for the recipename
    \def\xcb@font@recipename
    {
        \fontfamily{#1}
        \fontencoding{#2}
        \fontseries{#3} %x1
        \fontshape{#4}
        \xcb@fontsize@recipename
        \selectfont
    }
}
%    \end{macrocode}
% \end{macro}
%
% This is the initialisation of the font for the recipename. The default is Computer Modern, because it is available on every \LaTeX{} distribution.
%    \begin{macrocode}
\setRecipenameFont{cmr}{T1}{b}{n}

%    \end{macrocode}
%
% We need a counter for the numeration of the preparation steps.
%    \begin{macrocode}
\newcounter{step}
\setcounter{step}{0}
%    \end{macrocode}
%
% Set the color of the numeration of preparation steps.
%    \begin{macrocode}
\renewcommand{\LettrineFontHook}
{%
    \color{\xcb@color@numeration}
}

%    \end{macrocode} 
%
%
% \begin{macro}{\step}
% The command is used for numbering the steps of preparation. Take a look at the \texttt{lettrine} package for details.
%    \begin{macrocode}
\newcommand{\step}
{%
    \lettrine
    [%
        lines=2,
        lhang=0,          % space into margin, value between 0 and 1
        loversize=0.15,   % enlarges the height of the capital
        slope=0em,
        findent=1em,      % gap between capital and intended text
        nindent=0em       % shifts all intended lines, begining with the second line
    ]{\stepcounter{step}\thestep}{}%
}

%    \end{macrocode}
% \end{macro}
%
%
%    \begin{macrocode}
\define@key{headlines}{inghead}[Zutaten]{
    \def\xcb@name@inghead{\textcolor{\xcb@color@inghead}{\textbf{\xcb@fontsize@inghead{#1}}\ }}
}
\define@key{headlines}{prephead}[Zubereitung]{
    \def\xcb@name@prephead{\textcolor{\xcb@color@prephead}{\textbf{\xcb@fontsize@prephead{#1}}\ }}
}
\define@key{headlines}{hinthead}[Tipp:]{
    \def\xcb@name@hinthead{\textcolor{\xcb@color@hinthead}{\xcb@fontsize@hinthead{#1}}}
}
\define@key{headlines}{continuationhead}[Fortsetzung]{\def\xcb@name@continuationhead{#1}}
\define@key{headlines}{continuationfoot}[Fortsetzung auf n\"achster Seite]{\def\xcb@name@continuationfoot{#1}}
\define@key{headlines}{preparationtime}[\fontsize{14.5pt}{10pt}\Gloves]{\def\xcb@name@preparationtime{#1}}
\define@key{headlines}{bakingtime}[\fontsize{14.5pt}{10pt}\Oven]{\def\xcb@name@bakingtime{#1}}
\define@key{headlines}{bakingtemperature}[\Thermo{4}]{\def\xcb@name@bakingtemperature{#1}}
\define@key{headlines}{portion}[\fontsize{14.5pt}{10pt}\Dish]{\def\xcb@name@portion{#1}}
\define@key{headlines}{portionvalue}[Personen]{\def\xcb@name@portionvalue{#1}}
\define@key{headlines}{calory}[Brennwert]{\def\xcb@name@calory{#1}}
\define@key{headlines}{source}[\PaperPortrait]{\def\xcb@name@source{#1}}
\savekeys{headlines}
{
    inghead,
    prephead,
    hinthead,
    continuationhead,
    continuationfoot,
    preparationtime,
    bakingtime,
    bakingtemperature,
    portion,
    portionvalue,
    calory,
    source
}
%    \end{macrocode}
%
% \begin{macro}{\setHeadlines}
% This allows you to modify the headlines for the recipe parts. This also needed for translations (The default values are german, sorry). The parameter are set in the form "key~=~value" as known by the \texttt{xkeyval} package.
%    \begin{macrocode}
\newcommand*{\setHeadlines}[1]
{%
    \setkeys{headlines}{#1}
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\setHeadlines
{% initialisation
    inghead,
    prephead,
    hinthead,
    continuationhead,
    continuationfoot,
    preparationtime,
    bakingtime,
    bakingtemperature,
    portion,
    portionvalue,
    calory,
    source
}

%    \end{macrocode}
% The values xcb@bigpicturewidth and xcb@smallpicturewidth are the default values.
% They can be changed with the \texttt{graph} command.
%    \begin{macrocode}
\define@key{recipelengths}{preparationwidth}[0.60\textwidth]{\def\xcb@preparationwidth{#1}}
\define@key{recipelengths}{ingredientswidth}[0.35\textwidth]{\def\xcb@ingredientswidth{#1}}
\define@key{recipelengths}{pictureheight}[6cm]{\def\xcb@pictureheight{#1}}
\define@key{recipelengths}{bigpicturewidth}[0.60\textwidth]{\def\xcb@bigpicturewidth{#1}}
\define@key{recipelengths}{smallpicturewidth}[0.35\textwidth]{\def\xcb@smallpicturewidth{#1}}
\savekeys{recipelengths}
{
    preparationwidth,
    ingredientswidth,
    pictureheight,
    bigpicturewidth,
    smallpicturewidth
}

%    \end{macrocode}
%
% \begin{macro}{\setRecipeLengths}
% This command allows to modify most sizes of the recipe. The \texttt{pictureheight} is the height of the two pictures above the text.
%    \begin{macrocode}
\newcommand*{\setRecipeLengths}[1]
{%
    \setkeys{recipelengths}{#1}
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\setRecipeLengths
{% initialisation
    preparationwidth,
    ingredientswidth,
    pictureheight,
    bigpicturewidth,
    smallpicturewidth
}

%    \end{macrocode}
%    \begin{macrocode}
\define@key{picture}{small}[]{
    \def\xcb@picture@small{
        \ifthenelse{\equal{#1}{}}
        {% not set => not shown
        }
        {
            \vspace{-0.6cm}
            \includegraphics[width=\linewidth, height = \xcb@pictureheight, keepaspectratio]{#1}
        }
    }
}
\define@key{picture}{smallpicturewidth}[]{\def\xcb@picture@smallwidth{#1}}
\define@key{picture}{bigpicturewidth}[]{\def\xcb@picture@bigwidth{#1}}
\define@key{picture}{big}[]{
    \def\xcb@picture@big{
        \ifthenelse{\equal{#1}{}}
        {% not set => not shown
        }
        {
            \vspace{-0.6cm}
            \includegraphics[width=\linewidth, height = \xcb@pictureheight, keepaspectratio]{#1}
        }
    }
}

\define@key{recipe}{preparationtime}[]{\def\xcb@preparationtime{#1}}
\define@key{recipe}{bakingtime}[]{\def\xcb@bakingtime{#1}}
\define@key{recipe}{bakingtemperature}[]{\def\xcb@bakingtemperature{#1}}
\define@key{recipe}{portion}[]{\def\xcb@portion{#1}}
\define@key{recipe}{calory}[]{\def\xcb@calory{#1}}
\define@key{recipe}{source}[]{\def\xcb@source{#1}}

%    \end{macrocode}
%
% \begin{macro}{\portion}
% This macro is for inserting the portions correctly. By renewing this command you can easiliy define your own design for the portions.
%    \begin{macrocode}
\newcommand*{\portion}[2][\xcb@name@portionvalue]{\unit[#2]{#1}}

%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\bakingtemperature}
% This macro is used for inserting different bakingtemperatures. Only entered temperatures are displayed (with a symbol from \texttt{cookingsymbols} package). You can change the order of the temperatures by renew this command.
%    \begin{macrocode}
\define@key{bakingtemperature}{fanoven}[]{\def\xcb@bakingtemperature@fanoven{#1}}
\define@key{bakingtemperature}{topbottomheat}[]{\def\xcb@bakingtemperature@topbottomheat{#1}}
\define@key{bakingtemperature}{topheat}[]{\def\xcb@bakingtemperature@topheat{#1}}
\define@key{bakingtemperature}{bottomheat}[]{\def\xcb@bakingtemperature@bottomheat{#1}}
\define@key{bakingtemperature}{gasstove}[]{\def\xcb@bakingtemperature@gasstove{#1}}

\newboolean{xcb@bakingtemperature@firstentry}
\newcommand*{\bakingtemperature}[1]
{%
    \setboolean{xcb@bakingtemperature@firstentry}{true}%
    \setkeys{bakingtemperature}{fanoven, topbottomheat, topheat, bottomheat, gasstove}%
    \setkeys{bakingtemperature}{#1}%

    \ifthenelse{\equal{\xcb@bakingtemperature@fanoven}{}}%
    {}%
    {%
        \xcb@bakingtemperature@fanoven \ {\fontsize{14.5pt}{10pt}\Fanoven}%
        \setboolean{xcb@bakingtemperature@firstentry}{false}%
    }%
    \ifthenelse{\equal{\xcb@bakingtemperature@topbottomheat}{}}%
    {}%
    {%
        \ifthenelse{\boolean{xcb@bakingtemperature@firstentry}}{\setboolean{xcb@bakingtemperature@firstentry}{false}}{, }%
        \xcb@bakingtemperature@topbottomheat \ {\fontsize{14.5pt}{10pt}\Topbottomheat}%
    }%
    \ifthenelse{\equal{\xcb@bakingtemperature@topheat}{}}%
    {}%
    {%
        \ifthenelse{\boolean{xcb@bakingtemperature@firstentry}}{\setboolean{xcb@bakingtemperature@firstentry}{false}}{, }%
        \xcb@bakingtemperature@topheat \ {\fontsize{14.5pt}{10pt}\Topheat}%
    }%
    \ifthenelse{\equal{\xcb@bakingtemperature@bottomheat}{}}%
    {}%
    {%
        \ifthenelse{\boolean{xcb@bakingtemperature@firstentry}}{\setboolean{xcb@bakingtemperature@firstentry}{false}}{, }%
        \xcb@bakingtemperature@bottomheat \ {\fontsize{14.5pt}{10pt}\Bottomheat}%
    }%
    \ifthenelse{\equal{\xcb@bakingtemperature@gasstove}{}}%
    {}%
    {%
        \ifthenelse{\boolean{xcb@bakingtemperature@firstentry}}{\setboolean{xcb@bakingtemperature@firstentry}{false}}{, }%
        \xcb@bakingtemperature@gasstove \ {\fontsize{14.5pt}{10pt}\Gasstove}%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Recipe Environment}
% \begin{environment}{recipe}
% This the environment for inserting recipes. Inside you define your ingredients, preparation, pictures (graph) and maybe a hint.
% The commands \texttt{xcb@cmd@myrecipeoverview} and \texttt{xcb@cmd@wrapfill} are intended for internal use only.
%    \begin{macrocode}
\newenvironment{recipe}[2][]
{
    %% macros
    \newcommand*{\graph}[1]
    {%
        \setkeys{picture}{##1}
    }

    \newcommand*{\ingredients}[1]
    {%
        \def\xcb@ingredients
        {%
            \vspace{-1em}    % same height of ingredients and preparation
            \xcb@name@inghead
            %\\[4pt]
            \\[1em]
            \xcb@fontsize@ing\color{\xcb@color@ing}
            \begin{tabularx}{\xcb@ingredientswidth}{rX}
                ##1
            \end{tabularx}
        }
    }
    
    \newcommand*{\preparation}[1]
    {%
        \def\xcb@preparation
        {%
            \xcb@name@prephead
            %\\[4pt]
            \xcb@fontsize@prep\color{\xcb@color@prep}##1
        }
        \setcounter{step}{0}
    }
    
    \newcommand*{\hint}[1]
    {%
        \def\xcb@hint
        {%
            \pagebreak[1]    % begin here a new page, if the space is small
            \begin{tikzpicture}[line width = 1.5pt, \xcb@color@hintline]
                \useasboundingbox (0,0) -- ++(right:3.5cm) -- ++(up:3mm) -- ++(left:3.5cm) -- cycle;
                \draw (-3mm, 0mm) -- ++(right:3.5cm);
                \draw (0, 3mm) -- ++(down:2.4cm);
            \end{tikzpicture}
            
            \nopagebreak

            \begingroup      % a group for the hint
                \leftskip1em
                \xcb@name@hinthead
                \nopagebreak
    
                \itshape\textcolor{\xcb@color@hint}{\xcb@fontsize@hint{##1}}
                \par
            \endgroup
        }
    }
    
    \newcommand{\xcb@cmd@recipeoverview}
    {
        \begin{tabular}{rl}
            \ifthenelse{\equal{\xcb@preparationtime}{}}
            {% not set => not shown
            }
            {
                \xcb@name@preparationtime & \xcb@preparationtime\\
            }
            \ifthenelse{\equal{\xcb@bakingtime}{}}
            {% not set => not shown
            }
            {
                \xcb@name@bakingtime & \xcb@bakingtime\ifthenelse{\equal{\xcb@bakingtemperature}{}}
                {
                    \\
                }
                {,\hspace{1em} \xcb@name@bakingtemperature \hspace{1ex} \xcb@bakingtemperature\\
                }
            }
            \ifthenelse{\equal{\xcb@portion}{}}
            {% not set => not shown
            }
            {
                \xcb@name@portion & \xcb@portion\\
            }
            \ifthenelse{\equal{\xcb@calory}{}}
            {% not set => not shown
            }
            {
                \xcb@name@calory & \xcb@calory\\
            }
            \ifthenelse{\equal{\xcb@source}{}}
            {% not set => not shown
            }
            {
                \xcb@name@source & \xcb@source
            }
        \end{tabular}
    }

%    \end{macrocode}
% The following command is needed, if more ingredients than preparation (steps) are inserted. In this case the \texttt{wrapfigure} package behaves in a strange way. The result is that the hint is also floating around the ingredients, although the "box" is already closed. This command repairs this effect.
% It is taken from http://mizine.de/latex/wrapfigure-austricksen/
%    \begin{macrocode}    
    \newcommand\xcb@cmd@wrapfill
    {%
        \par
        \ifx\parshape\WF@fudgeparshape
        \nobreak
        \vskip-\baselineskip
        \vskip\c@WF@wrappedlines\baselineskip
        \allowbreak
        \WFclear
        \fi
    }
    %% end of macros
    
    
    % initialisation
    \setkeys{recipe}{preparationtime, bakingtime, bakingtemperature, portion, calory, source}
    \setkeys{picture}{small, big, smallpicturewidth=\xcb@smallpicturewidth, bigpicturewidth=\xcb@bigpicturewidth} % load the default values
    \ingredients{}
    \preparation{}
    \def\xcb@hint{}
    
    \def\xcb@recipename{#2}
    \setkeys{recipe}{#1}  % reading the optional parameters
    
    \setcounter{xcb@newpagefoot}{1}
    \setcounter{xcb@newpagehead}{\value{page}}
}
{% this part is executed at \end{recipe}
%% FIRST BLOCK
    \if@twoside
        \ifodd\arabic{page}
            \begin{minipage}[T]{\xcb@picture@bigwidth}
                \xcb@picture@big
            \end{minipage}
            \hfill
            \begin{minipage}[T]{\xcb@picture@smallwidth}
                \xcb@picture@small
            \end{minipage}
        \else
            \begin{minipage}[T]{\xcb@picture@smallwidth}
                \xcb@picture@small
            \end{minipage}
            \hfill
            \begin{minipage}[T]{\xcb@picture@bigwidth}
                \xcb@picture@big
            \end{minipage}
        \fi
    \else
        \begin{minipage}[T]{\xcb@picture@bigwidth}
            \xcb@picture@big
        \end{minipage}
        \hfill
        \begin{minipage}[T]{\xcb@picture@smallwidth}
            \xcb@picture@small
        \end{minipage}
    \fi

%% SECOND BLOCK
    \recipesection[\normalsize\xcb@recipename]%
    {\hspace{-1em}\textcolor{\xcb@color@recipename}{\xcb@font@recipename\xcb@recipename}}
    \xcb@cmd@recipeoverview

%% THIRD BLOCK
    \begin{wraptable}{r}{\xcb@ingredientswidth}
    {
        \xcb@ingredients
    }
    \end{wraptable}
    \xcb@preparation

    \vfill

    \xcb@cmd@wrapfill
    \xcb@hint
    \setcounter{xcb@newpagefoot}{0}
}

%    \end{macrocode}
% \end{environment}
%
% \subsection{Header and Footer}
%    \begin{macrocode}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]
{%
    \markright{\MakeUppercase{\thesection.\ #1}}
}
\renewcommand{\headrulewidth}
{%
    0.5pt
}
\fancyhf{}
\if@twoside
    \fancyfoot[LE,RO]{\textbf{\thepage}}
    \fancyhead[LE,RO]{\rightmark}
\else
    \fancyfoot[R]{\textbf{\thepage}}
    \fancyhead[R]{\rightmark}
\fi
\fancyhead[C]{\@newpagehint{head}}
\fancyfoot[C]{\@newpagehint{foot}}

%    \end{macrocode}
% Below the counter for the header and the footer are defined and initialised.
%    \begin{macrocode}
\newcounter{xcb@newpagehead}
\setcounter{xcb@newpagehead}{0}
\newcounter{xcb@newpagefoot}
\setcounter{xcb@newpagefoot}{0}
%    \end{macrocode}
% \begin{macro}{\@newpagehint}
% This macro is used to create a hint in the head or foot of the page, that the recipe is longer than one page.
%    \begin{macrocode}
\newcommand*{\@newpagehint}[1]
{
    \ifthenelse{\equal{#1}{head}}
    {
        \ifnum \value{xcb@newpagehead} < \value{page}
            \ifnum \value{xcb@newpagehead} > 0
                \xcb@name@continuationhead
            \fi
        \fi
    }
    {
        \ifthenelse{\value{xcb@newpagefoot} > 0}
        {
            \xcb@name@continuationfoot
        }
        {% if no message at the bottom is set, there is no need for a message on the next page
            \setcounter{xcb@newpagehead}{0}
        }
    }
}

%    \end{macrocode}
% \end{macro}
%
% \subsection{Background Picture}
%    \begin{macrocode}
\define@key{background}{width}[\linewidth]{\def\xcb@background@width{#1}}
\define@key{background}{height}[\paperheight]{\def\xcb@background@height{#1}}
\define@key{background}{x}[0cm]{\def\xcb@background@x{#1}}
\define@key{background}{y}[0cm]{\def\xcb@background@y{#1}}
\define@key{background}{orientation}[default]{\def\xcb@background@orientation{#1}}
\savekeys{background}
{%
    width,
    height,
    x,
    y,
    orientation
}

%    \end{macrocode}
% \begin{macro}{\setBackgroundPicture}
% This macro is intended to set easily a (transparent) background. The command uses the \texttt{eso-pic} package. If the implemented options are not satisfying you, you may take a look at the documentation of \texttt{eso-pic} when redefining this command.
%    \begin{macrocode}
\newcommand*{\setBackgroundPicture}[2][]
{%
    \ClearShipoutPictureBG
    \setkeys{background}{width, height, x, y, orientation} % initialisation
    \setkeys{background}{#1}
    \AddToShipoutPicture
    {%
        \ifthenelse{\equal{\xcb@background@orientation}{default}}
        {% default
            \put(\xcb@background@x, \xcb@background@y)
            {%
                \parbox[b][\xcb@background@height]{\xcb@background@width}
                {%
                    \vfill
                    \includegraphics[width=\xcb@background@width, height=\xcb@background@height, keepaspectratio]{#2}%
                    \vfill
                }
            }
        }
        {%
            \ifthenelse{\equal{\xcb@background@orientation}{pagecenter}}
            {% pagecenter
                \AtPageCenter{%
                    \makebox(\xcb@background@x, \xcb@background@y)[c]
                    {%
                        \includegraphics[width=\xcb@background@width, height=\xcb@background@height, keepaspectratio]{#2}
                    }
                }
            }
            {%
                \ifthenelse{\equal{\xcb@background@orientation}{textcenter}}
                {% textcenter
                    \AtTextCenter{%
                        \makebox(\xcb@background@x, \xcb@background@y)[c]
                        {%
                            \includegraphics[width=\xcb@background@width, height=\xcb@background@height, keepaspectratio]{#2}
                        }
                    }
                }
                {%
                    \ifthenelse{\equal{\xcb@background@orientation}{stockcenter}}
                    {% stockcenter
                        \AtStockCenter{%
                            \makebox(\xcb@background@x, \xcb@background@y)[c]
                            {%
                                \includegraphics[width=\xcb@background@width, height=\xcb@background@height, keepaspectratio]{#2}
                            }
                        }
                    }
                    {% error message
                        \PackageError{xcookybooky}
                        {There is no '\xcb@background@orientation' option for background picture orientation available!}
                        {The possible options are: default, pagecenter, textcenter or stockcenter}
                    }
                }
            }
        }
        
    }
}
%</package>
%    \end{macrocode}
% \end{macro}
%
% \subsection{Configuration file}
% \label{sec:configuration}
% This file is intended to change the design central. The most important commands are already written down. You have to submit the option \texttt{myconfig}, if you want to load the configuration file.
%    \begin{macrocode} 
%<*config>
%% Change Layout
\setRecipeColors
{%
    recipename,
    ing,
    inghead,
    prep,
    prephead,
    hint,
    hinthead,
    hintline,
    numeration
}

\setRecipeSizes
{%
    recipename,
    ing,
    inghead,
    prep,
    prephead,
    hint,
    hinthead
}

\setRecipeLengths
{%
    preparationwidth,
    ingredientswidth,
    pictureheight
}

\setRecipenameFont{fjd}{T1}{m}{n}


%% Translation
\setHeadlines
{%
    inghead,
    prephead,
    hinthead,
    continuationhead,
    continuationfoot,
    preparationtime,
    bakingtime,
    bakingtemperature,
    portion,
    portionvalue,
    calory,
    source
}
%</config>
%    \end{macrocode}
%
% \Finale
\endinput