% \iffalse meta-comment
%
% Copyright (C) 2015 by Tibor Tomacs
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% 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.2 or later is part of all distributions of LaTeX
% version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{bookcover.dtx}
\newcommand{\eifiledate}{2016/05/01}
\newcommand{\eifilever}{v1.1}
%</driver>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{bookcover}[2016/05/01 v1.1 class for book covers and dust jackets]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[paperwidth=210mm,paperheight=295mm,textwidth=160mm,top=25mm,bottom=25mm,outer=25mm]{geometry}
\usepackage[unicode,pdfstartview=FitH,bookmarksnumbered,pdfborder={0 0 0},colorlinks,linktocpage,allcolors=blue]{hyperref}
\usepackage[english]{babel}
\usepackage{xcolor,graphicx,listings,calc,multirow}
\lstset{
literate={ü}{{\"u}}1{ó}{{\'o}}1{é}{{\'e}}1{á}{{\'a}}1{Á}{{\'A}}1,
basicstyle=\color{example}\small\ttfamily,
columns=fullflexible,
comment=[l][\ttfamily\color{black}]{\%}}
\colorlet{newcommand}{red!50!black}
\colorlet{example}{blue!50!black}
\colorlet{layer}{green!50!black}

\begin{document}
    \DocInput{./bookcover.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{1406}
%
% \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           \~}
%
% \GetFileInfo{bookcover.cls}
%
% \title{Class for book covers and dust jackets\\
%        \textsf{bookcover.cls}\\
%        {\large\eifilever\ (\eifiledate)}}
% \author{Tibor Tómács\\{\normalsize\href{mailto:tomacs@ektf.hu}{\texttt{tomacs@ektf.hu}}}}
% \date{}
% \maketitle
%
% \tableofcontents
%
% \section{Book cover parts and sizes}
% In the following picture we can see a typical dust jacket. Its main parts are back flap, back, spine, front and front flap. 
% Typographically, a book cover is a dust jacket without flaps, the only difference is that the book cover is a fixed part of the book, whereas the dust jacket is removable.
% \begin{center}
% \includegraphics[height=40mm]{figures/cover}
% \end{center}
% When we prepare a cover for printing, some marks are needed to know where to trim or fold the paper. These marks determine a special area of the sheet, which is called ``bleed'' (see the next figure). The background will be expanded onto the bleed, taking account of slight inaccuracy when trimming.
% \begin{center}
% \includegraphics{figures/coverscheme}
% \end{center}
%
% \subsection{Sizes}\label{subsec:sizes}
% We have to give the following sizes to prepare a cover: \texttt{coverwidth}, \texttt{coverheight}, \texttt{spinewidth}, \texttt{flapwidth}, \texttt{marklength}, \texttt{bleedwidth}.
% \begin{center}
% \includegraphics{figures/sizes}
% \end{center}
%
% \subsection{Trimmed version}\label{subsec:trimmed}
% After trimming we get the following result:
% \begin{center}
% \includegraphics{figures/result}
% \end{center}
%
% \subsection{Background parts}\label{subsec:background}
% Important: The bleed is a part of the background!
%
% \medskip\noindent
% In case |flapwidth>0mm| 
% \begin{center}
% \includegraphics{figures/background1}\\[4mm]
% \includegraphics{figures/background2}\\[4mm]
% \includegraphics{figures/background3}
% \end{center}
% In case |flapwidth=0mm| 
% \begin{center}
% \includegraphics{figures/background4}\\[4mm]
% \includegraphics{figures/background5}
% \end{center}
%
% \subsection{Foreground parts}\label{subsec:foreground}
% Important: The bleed is not part of the foreground!
%
% \medskip\noindent
% In case |flapwidth>0mm| 
% \begin{center}
% \includegraphics{figures/foreground1}
% \end{center}
% In case |flapwidth=0mm| 
% \begin{center}
% \includegraphics{figures/foreground2}
% \end{center}
%
% \section{Description}
%
% \subsection{Loading class}
% The class \texttt{bookcover} requires the services of the class \texttt{article} and the following packages:
% \texttt{kvoptions}, \texttt{geometry}, \texttt{graphicx}, \texttt{calc}, \texttt{xcolor}, \texttt{ifthen}, \texttt{tikz}, \texttt{eso-pic}, \texttt{textpos}.
%
% \bigskip\noindent
% Load the class as usual, with
%
% \medskip\noindent
% {\color{newcommand}|\documentclass|\oarg{options}|{bookcover}|}
%
% \begin{center}
% \begin{tabular}{@{}l@{\hspace*{-30mm}}r@{}} 
% \textbf{book cover size options} (see Subsection \ref{subsec:sizes}) & \textbf{default values}\\ 
% \hline  
% \texttt{coverwidth=}\meta{length}  & \texttt{170mm}\\ 
% \texttt{coverheight=}\meta{length} & \texttt{240mm}\\
% \texttt{spinewidth=}\meta{length}  &   \texttt{5mm}\\
% \texttt{flapwidth=}\meta{length}   &   \texttt{0mm}\\
% \texttt{marklength=}\meta{length}  &  \texttt{10mm}\\
% \texttt{bleedwidth=}\meta{length}  &   \texttt{5mm}\\
% &\\
% \textbf{other options}&\\ 
% \hline  
% \texttt{markthick=}\meta{length}   & Thickness of marks (default value: \texttt{0.4pt}).\\
% \texttt{markcolor=}\meta{color}    & Color of marks (default value: \texttt{red}).\\
% \texttt{10pt}                      & Normal font size is 10\,pt (default).\\
% \texttt{11pt}                      & Normal font size is 11\,pt.\\
% \texttt{12pt}                      & Normal font size is 12\,pt.\\
% \texttt{grid}                      & Grid for checking sizes.\\
% \texttt{bgtikznodes}               & See Subsubsection \ref{subsubsec:bgtikz}.\\
% \texttt{bgtikzclip}                & See Subsubsection \ref{subsubsec:bgtikz}.\\
% \texttt{trimmed}                   & It shows trimmed version (see Subsection \ref{subsec:trimmed}).
% \end{tabular} 
% \end{center}
% \bigskip\noindent\emph{Example:}
%\color{example}
%\begin{verbatim}
%\documentclass[flapwidth=50mm,spinewidth=15mm]{bookcover}
%\end{verbatim}
%\color{black}
%
% \subsection{Commands}
% This class defines two commands: 
%
% \medskip\noindent
% {\color{newcommand}|\setbookcover|\marg{main layer}\marg{part}\marg{content}}
%
% \medskip\noindent 
% \meta{main layer} (see the following subsubsections)\\ 
% \hspace*{10mm}\texttt{bgcolor}, \texttt{bgpic}, \texttt{bgtikz}, \texttt{fgfirst}, \texttt{fgsecond}
%
% \medskip\noindent The \meta{part} and the \meta{content} depend on the \meta{main layer} (see the following subsubsections).
%
% \medskip\noindent 
% {\color{newcommand}|\makebookcover|}
%
% \subsubsection{Background colors}
% {\color{newcommand}|\setbookcover{bgcolor}|\marg{background part}\marg{colors}}
%
% \medskip\noindent 
% \meta{background part} (see Subsection \ref{subsec:background})\\ 
% \hspace*{10mm}\texttt{back}, \texttt{front}, \texttt{spine}, \texttt{front flap}, \texttt{back flap}, \texttt{whole without flaps}, \texttt{whole}
%
% \medskip\noindent 
% \meta{colors} (options of command |\fill| of package \texttt{tikz})\\ 
% \hspace*{10mm}|color=|\meta{color name} (See \meta{color name} in the package \texttt{xcolor}.)\\ 
% \hspace*{10mm}|top color=|\meta{color name}\\ 
% \hspace*{10mm}|bottom color=|\meta{color name}\\ 
% \hspace*{10mm}|middle color=|\meta{color name}\\ 
% \hspace*{10mm}|inner color=|\meta{color name}\\ 
% \hspace*{10mm}|outer color=|\meta{color name}\\ 
% \hspace*{10mm}|ball color=|\meta{color name}\\ 
% \hspace*{10mm}|shading angle=|\meta{degrees} (This rotates the shading by the given angle.)
%
% \bigskip\noindent\emph{Example:}
%\color{example}
%\begin{verbatim}
%\setbookcover{bgcolor}{whole without flaps}{
%    top color=white, bottom color=blue!50!black, shading angle=60}
%\end{verbatim}
%\color{black}
%
% \subsubsection{Background pictures}
% {\color{newcommand}|\setbookcover{bgpic}|\marg{background part}\marg{picture file}}
%
% \medskip\noindent 
% \meta{background part} (see Subsection \ref{subsec:background})\\ 
% \hspace*{10mm}\texttt{back}, \texttt{front}, \texttt{spine}, \texttt{front flap}, \texttt{back flap}, \texttt{whole without flaps}, \texttt{whole}
%
% \medskip\noindent The picture will be rescaled according to the sizes of the current background part.
%
% \bigskip\noindent\emph{Example:}
%\color{example}
%\begin{verbatim}
%\setbookcover{bgpic}{front flap}{fig.png}
%\end{verbatim}
%\color{black}
%
% \subsubsection{Background Ti\emph{k}Z figures}\label{subsubsec:bgtikz}
% {\color{newcommand}|\setbookcover{bgtikz}|\marg{background part}\marg{tikz code}}
%
% \medskip\noindent 
% \meta{background part} (see Subsection \ref{subsec:background})\\ 
% \hspace*{10mm}\texttt{back}, \texttt{front}, \texttt{spine}, \texttt{front flap}, \texttt{back flap}, \texttt{whole without flaps}, \texttt{whole}
%
% \medskip\noindent
% The Ti\emph{k}Z figure will be placed to the upper left corner of the current background part, without resizeing.
%
% \bigskip\noindent\emph{Example:}
%\color{example}
%\begin{verbatim}
%\setbookcover{bgtikz}{back}{
%    \fill[blue] (0mm,250mm)--(100mm,250mm)--(100mm,245mm)--(0mm,110mm)--cycle;
%    \fill[yellow] (5mm,5mm)--(175mm,245mm)--(175mm,0mm)--(5mm,0mm)--cycle;}
%\end{verbatim}
%\color{black}
%
% \medskip\noindent
% Using the option \texttt{bgtikznodes} of the document class:
% \begin{itemize}
% \item the origin moves to the lower left corner of the current background part;
% \item two nodes come into being: \texttt{\color{newcommand}current part} and \texttt{\color{newcommand}current trimmed part}. (Thank Zunbeltz Izaola for the idea.)
% \end{itemize}
%
% \bigskip\noindent\emph{Example:}
%\color{example}
%\begin{verbatim}
%\setbookcover{bgtikz}{whole}{
%    \draw[blue] (current part.south west) rectangle (current part.north east);
%    \fill[gray](current trimmed part.south east) rectangle (current trimmed part.north west);
%    \fill[green] (0,0) circle [radius=2mm];}
%\setbookcover{bgtikz}{spine}{
%    \fill[orange] (current part.center) circle [radius=8mm];}
%\end{verbatim}
%\color{black}
% \begin{center}
% \includegraphics{figures/bgtikznodes}
% \end{center}
% The option \texttt{bgtikzclip} of the document class works like \texttt{bgtikznodes}, but it clips the current part. For example, the result of the previous code with option \texttt{bgtikzclip}:
% \begin{center}
% \includegraphics{figures/bgtikzclip}
% \end{center}
%
% \subsubsection{First foreground}
% {\color{newcommand}|\setbookcover{fgfirst}|\marg{foreground part}\marg{content}}
%
% \medskip\noindent 
% \meta{foreground part} (see Subsection \ref{subsec:foreground})\\ 
% \hspace*{10mm}\texttt{back}, \texttt{front}, \texttt{spine}, \texttt{front flap}, \texttt{back flap},\\ 
% \hspace*{10mm}\texttt{above front}, \texttt{below front}, \texttt{above back}, \texttt{below back}
%
% \medskip\noindent The first foreground is the top layer of the book cover (see Subsection \ref{subsec:layers}).
%
% \bigskip\noindent\emph{Example:}
%\color{example}
%\begin{verbatim}
%\setbookcover{fgfirst}{spine}{
%    \vfill
%    \begin{center}
%        \rotatebox[origin=c]{90}{\bfseries Annales Mathematicae et Informaticae}
%    \end{center}
%    \vfill}
%\end{verbatim}
%\color{black}
%
% \subsubsection{Second foreground}
% {\color{newcommand}|\setbookcover{fgsecond}|\marg{foreground part}\marg{content}}
%
% \medskip\noindent 
% \meta{foreground part} (see Subsection \ref{subsec:foreground})\\ 
% \hspace*{10mm}\texttt{back}, \texttt{front}, \texttt{spine}, \texttt{front flap}, \texttt{back flap}
%
% \medskip\noindent The second foreground is under the first foreground (see Subsection \ref{subsec:layers}).
%
% \bigskip\noindent\emph{Example:} 
% The following code puts a picture behind the `TEXT' on the front cover:
%\color{example}
%\begin{verbatim}
%\setbookcover{fgsecond}{front}{
%    \vfill
%    \begin{center}
%        \includegraphics[width=80mm]{pic.png}
%    \end{center}
%    \vfill}
%\setbookcover{fgfirst}{front}{
%    \vfill
%    \begin{center}
%        TEXT
%    \end{center}
%    \vfill}
%\end{verbatim}
%\color{black}
%
% \subsubsection{Making book cover}
% {\color{newcommand}|\makebookcover|}
%
% \medskip\noindent 
% This command makes the book cover by using contents of background and foreground. 
%
% \subsection{Layers}\label{subsec:layers}
% In the following table we can see the hierarchy of the layers:
%
% \bigskip
% \begin{center}
% \begin{tabular}{@{}ll@{}c@{}}
% \cline{1-2} 
%  \multirow{2}*{|fgfirst|}  & |above front|, |below front|, |above back|, |below back|& \color{layer}\emph{top layer}\\
%                            & |back|, |front|, |spine|, |front flap|, |back flap|     &\color{layer}$\uparrow$\\ 
% \cline{1-2}
% |fgsecond| & |back|, |front|, |spine|, |front flap|, |back flap|&\color{layer}$\uparrow$\\
% \cline{1-2}
% & |back|, |front|, |spine|, |front flap|, |back flap| &\color{layer}$\uparrow$\\
% |bgtikz| &  |whole without flaps| &\color{layer}$\uparrow$\\ 
% & |whole| &\color{layer}$\uparrow$\\
% \cline{1-2}
% & |back|, |front|, |spine|, |front flap|, |back flap| &\color{layer}$\uparrow$\\
% |bgpic| &  |whole without flaps| &\color{layer}$\uparrow$\\ 
% & |whole| &\color{layer}$\uparrow$\\
% \cline{1-2}
% & |back|, |front|, |spine|, |front flap|, |back flap| &\color{layer}$\uparrow$\\
% |bgcolor| &  |whole without flaps| &\color{layer}$\uparrow$\\ 
% & |whole| & \color{layer}\emph{bottom layer}\\
% \cline{1-2}
% \end{tabular} 
% \end{center}
% \bigskip\noindent For example, in case
%\color{example}
%\begin{verbatim}
%\setbookcover{bgpic}{whole}{fig1.jpg}
%\setbookcover{bgpic}{front}{fig2.jpg}
%\setbookcover{fgsecond}{front}{fig3.jpg}
%\setbookcover{fgfirst}{front}{TEXT}
%\end{verbatim}
%\color{black}
%the \texttt{TEXT} is above the \texttt{fig3.jpg}, the \texttt{fig3.jpg} is above the \texttt{fig2.jpg} and the \texttt{fig2.jpg} is above the \texttt{fig1.jpg}.
%
% \section{Examples}
% \subsection{A dust jacket}
% \lstinputlisting{example1.tex}
% \subsection*{The result:}
% \begin{center}
% \setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.4pt}
% \fcolorbox{black!50}{white}{\includegraphics[width=\textwidth-.8pt]{example1}}
% \end{center}
%
% \subsection{A two-sided book cover}
% The outside and the inside are edited in the same document.
% \lstinputlisting{example2.tex}
% \subsection*{The result:}
% \begin{center}
% \setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.4pt}
% \fcolorbox{black!50}{white}{\includegraphics[page=1,width=\textwidth-.8pt]{example2}}\\[4mm]
% \fcolorbox{black!50}{white}{\includegraphics[page=2,width=\textwidth-.8pt]{example2}}
% \end{center}
%
% \subsection{Drawing bar code by pst-barcode package}
%
%{\color{example}
%\begin{verbatim}
%\documentclass{bookcover}
%\usepackage{pst-barcode}
%\begin{document}
%    \setbookcover{fgfirst}{back}{
%        \vfill
%        \centering
%        \begin{pspicture}(1in,1.5in)
%            \psbarcode{1787-6117}{includetext height=1 width=1.5}{issn}
%        \end{pspicture}
%        \vspace{5mm}
%        }
%    \makebookcover
%\end{document}
%\end{verbatim}}
%
% \noindent We can compile this file by \texttt{latex.exe} only. If you want to use another compiler, then choose the following way:
%
%{\color{example}
%\begin{verbatim}
%\documentclass{bookcover}
%
%\usepackage{filecontents}
%\begin{filecontents*}{bar.tex}
%    \documentclass{article}
%    \usepackage{pst-barcode}
%    \pagestyle{empty}
%    \begin{document}
%        \begin{pspicture}(1in,1.5in)
%            \psbarcode{1787-6117}{includetext height=1 width=1.5}{issn}
%        \end{pspicture}
%    \end{document}
%\end{filecontents*}
%
%\immediate\write18{
%    latex bar.tex && 
%    dvips bar.dvi && 
%    ps2pdf bar.ps && 
%    pdfcrop -hires bar.pdf barcode.pdf}
%
%\begin{document}
%    \setbookcover{fgfirst}{back}{
%        \vfill
%        \centering
%        \includegraphics{barcode}
%        \vspace{5mm}
%        }
%    \makebookcover
%\end{document}
%\end{verbatim}}
%
% \noindent The command to compile this file is the following:
%\begin{verbatim}
%pdflatex -shell-escape filename
%\end{verbatim}
% or
%\begin{verbatim}
%xelatex -shell-escape filename
%\end{verbatim}
% or
%\begin{verbatim}
%lualatex -shell-escape filename
%\end{verbatim}
%
% \subsection*{The result:}
% \begin{center}
% \setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.4pt}
% \fcolorbox{black!50}{white}{\includegraphics[width=\textwidth-.8pt]{figures/example-barcode}}
% \end{center}
%
% \StopEventually{}
%
% \section{Implementation}
% 
%    \begin{macrocode}
%%
%% OPTIONS
\RequirePackage{kvoptions}
\SetupKeyvalOptions{family=bookcover,prefix=bookcover@}
\DeclareVoidOption{10pt}{\PassOptionsToClass{10pt}{article}}
\DeclareVoidOption{11pt}{\PassOptionsToClass{11pt}{article}}
\DeclareVoidOption{12pt}{\PassOptionsToClass{12pt}{article}}
\DeclareVoidOption{grid}{\PassOptionsToPackage{grid}{eso-pic}}
\DeclareStringOption[170mm]{coverwidth}
\DeclareStringOption[240mm]{coverheight}
\DeclareStringOption[5mm]{spinewidth}
\DeclareStringOption[0mm]{flapwidth}
\DeclareStringOption[10mm]{marklength}
\DeclareStringOption[.4pt]{markthick}
\DeclareStringOption[5mm]{bleedwidth}
\DeclareStringOption[red]{markcolor}
\DeclareBoolOption[false]{trimmed}
\DeclareBoolOption[false]{bgtikznodes}
\DeclareBoolOption[false]{bgtikzclip}
\ProcessKeyvalOptions{bookcover}

%% LOADING CLASS
\LoadClass{article}

%% LOADING PACKAGES
\RequirePackage{geometry,graphicx,calc,xcolor,ifthen,tikz,eso-pic}
\RequirePackage[absolute]{textpos}

%% PAGE STYLE
\pagestyle{empty}

%% USER LENGTHS
\newlength{\coverwidth}
\newlength{\coverheight}
\newlength{\spinewidth}
\newlength{\flapwidth}
\newlength{\marklength}
\newlength{\markthick}
\newlength{\bleedwidth}

%% INTERNAL LENGTHS
\newlength{\bookcover@xpos@}
\newlength{\bookcover@ypos@}
\newlength{\bookcover@partwidth@}
\newlength{\bookcover@partheight@}
\newlength{\bookcover@bgtikz@trimmed@part@width@minus}
\newlength{\bookcover@bgtikz@trimmed@part@push@right}

%% USER LENGTHS SETTING
\setlength{\coverwidth}{\bookcover@coverwidth}
\setlength{\coverheight}{\bookcover@coverheight}
\setlength{\spinewidth}{\bookcover@spinewidth}
\setlength{\flapwidth}{\bookcover@flapwidth}
\setlength{\marklength}{\bookcover@marklength}
\setlength{\markthick}{\bookcover@markthick}
\setlength{\bleedwidth}{\bookcover@bleedwidth}
\setlength{\paperwidth}{2\marklength+2\bleedwidth+2\coverwidth+2\flapwidth+\spinewidth}
\setlength{\paperheight}{2\marklength+2\bleedwidth+\coverheight}
\setlength{\parindent}{0pt}

%% IF GRID
\ifESO@grid
    \setlength{\markthick}{2pt}
    \def\bookcover@markcolor{red}\fi

%% COMMANDS FOR INTERNAL LENGTHS SETTING
\def\bookcover@xpos#1{\setlength{\bookcover@xpos@}{#1}}
\def\bookcover@ypos#1{\setlength{\bookcover@ypos@}{#1}}
\def\bookcover@partwidth#1{\setlength{\bookcover@partwidth@}{#1}}
\def\bookcover@partheight#1{\setlength{\bookcover@partheight@}{#1}}
\def\bookcover@bgtikz@trimmed@part@param#1#2{%
    \setlength{\bookcover@bgtikz@trimmed@part@width@minus}{#1}%
    \setlength{\bookcover@bgtikz@trimmed@part@push@right}{#2}}

%% MACROS FOR OUTPUTS OF PARTS
%% bgcolor
\def\bookcover@bgcolor#1{
    \begin{textblock*}{\bookcover@partwidth@}(\bookcover@xpos@,\bookcover@ypos@)
        \tikz\expandafter\fill#1 (0,0) rectangle (\bookcover@partwidth@,\bookcover@partheight@);
    \end{textblock*}}
%% bgpic
\def\bookcover@bgpic#1{
    \begin{textblock*}{\bookcover@partwidth@}(\bookcover@xpos@,\bookcover@ypos@)
        \includegraphics[width=\bookcover@partwidth@,height=\bookcover@partheight@]{#1}
    \end{textblock*}}
%% bgtikz
\def\bookcover@bgtikz#1{
    \begin{textblock*}{\bookcover@partwidth@}(\bookcover@xpos@,\bookcover@ypos@)
        \ifbookcover@bgtikzclip\bookcover@bgtikznodestrue\fi
        \ifbookcover@bgtikznodes
            \begin{tikzpicture}[overlay,yshift=-\bookcover@partheight@]
            \begin{scope}[transparent,line width=0pt]
                \pgfset{minimum width=\bookcover@partwidth@,minimum height=\bookcover@partheight@}
                \pgfnode{rectangle}{south west}{}{current part}{\pgfusepath{draw}}
                \pgfset{minimum width=\bookcover@partwidth@-\bookcover@bgtikz@trimmed@part@width@minus,
                        minimum height=\bookcover@partheight@-2\bleedwidth}
                \pgftransformshift{\pgfpoint{\bookcover@bgtikz@trimmed@part@push@right}{\bleedwidth}}
                \pgfnode{rectangle}{south west}{}{current trimmed part}{\pgfusepath{draw}}
            \end{scope}
            \ifbookcover@bgtikzclip
                \clip (current part.south west) rectangle (current part.north east);\fi
        \else\begin{tikzpicture}\fi
            #1
        \end{tikzpicture}
    \end{textblock*}}
%% fg
\def\bookcover@fg#1{
    \begin{textblock*}{\bookcover@partwidth@}(\bookcover@xpos@,\bookcover@ypos@)
        \parbox[t][\bookcover@partheight@][t]{\bookcover@partwidth@}{#1}
    \end{textblock*}}
%% remark
\def\bookcover@remark#1{
    \begin{textblock*}{\bookcover@partwidth@}(\bookcover@xpos@,\bookcover@ypos@)
        \parbox[t][\bookcover@partheight@][c]{\bookcover@partwidth@}
            {\centering#1\par}
    \end{textblock*}}

%% MACROS FOR MARKS
%% vertical mark
\def\bookcover@vmark{
    \begin{textblock*}{\bookcover@partwidth@}(\bookcover@xpos@,\bookcover@ypos@)
        {\color{\bookcover@markcolor}\rule[0pt]{\markthick}{\marklength}}
    \end{textblock*}}
%% horizontal mark
\def\bookcover@hmark{
    \begin{textblock*}{\bookcover@partwidth@}(\bookcover@xpos@,\bookcover@ypos@)
        {\color{\bookcover@markcolor}\rule[0pt]{\marklength}{\markthick}}
    \end{textblock*}}

%% MACRO FOR TRIMMING
\def\bookcover@trimming{
    \begin{textblock*}{\paperwidth}(0mm,0mm)
        \begin{tikzpicture}
            \begin{scope}[color=white]
                \fill(0,0)--
                     (\paperwidth,0)--
                     (\paperwidth,\marklength+\bleedwidth)--
                     (0,\marklength+\bleedwidth)--cycle;
                \fill(0,\paperheight)--
                     (\paperwidth,\paperheight)--
                     (\paperwidth,\paperheight-\marklength-\bleedwidth)--
                     (0,\paperheight-\marklength-\bleedwidth)--cycle;
                \fill(0,0)--
                     (\marklength+\bleedwidth,0)--
                     (\marklength+\bleedwidth,\paperheight)--
                     (0,\paperheight)--cycle;
                \fill(\paperwidth-\marklength-\bleedwidth,0)--
                     (\paperwidth,0)--
                     (\paperwidth,\paperheight)--
                     (\paperwidth-\marklength-\bleedwidth,\paperheight)--cycle;
            \end{scope}
            \draw[color=\bookcover@markcolor,line width=\markthick]
                 (\marklength+\bleedwidth,\marklength+\bleedwidth)--
                 (\paperwidth-\marklength-\bleedwidth,\marklength+\bleedwidth)--
                 (\paperwidth-\marklength-\bleedwidth,\paperheight-\marklength-\bleedwidth)--
                 (\marklength+\bleedwidth,\paperheight-\marklength-\bleedwidth)--cycle;
        \end{tikzpicture}
    \end{textblock*}
    \bookcover@ypos{\bleedwidth}
    \bookcover@partwidth{\markthick}
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth-.5\markthick}
        \bookcover@vmark
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
        \bookcover@vmark\fi
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth-.5\markthick}
    \bookcover@vmark
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth-.5\markthick}
    \bookcover@vmark
    \bookcover@ypos{\paperheight-\marklength-\bleedwidth}
    \bookcover@partwidth{\markthick}
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth-.5\markthick}
        \bookcover@vmark
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
        \bookcover@vmark\fi
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth-.5\markthick}
    \bookcover@vmark
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth-.5\markthick}
    \bookcover@vmark}

%% RESET DATAS
\def\bookcover@reset{
    \def\bookcover@bgcolor@whole{}
    \def\bookcover@bgcolor@wholewf{}
    \def\bookcover@bgcolor@back{}
    \def\bookcover@bgcolor@front{}
    \def\bookcover@bgcolor@backflap{}
    \def\bookcover@bgcolor@frontflap{}
    \def\bookcover@bgcolor@spine{}
    \def\bookcover@bgpic@whole{}
    \def\bookcover@bgpic@wholewf{}
    \def\bookcover@bgpic@back{}
    \def\bookcover@bgpic@front{}
    \def\bookcover@bgpic@backflap{}
    \def\bookcover@bgpic@frontflap{}
    \def\bookcover@bgpic@spine{}
    \def\bookcover@bgtikz@whole{}
    \def\bookcover@bgtikz@wholewf{}
    \def\bookcover@bgtikz@back{}
    \def\bookcover@bgtikz@front{}
    \def\bookcover@bgtikz@backflap{}
    \def\bookcover@bgtikz@frontflap{}
    \def\bookcover@bgtikz@spine{}
    \def\bookcover@fgfirst@back{}
    \def\bookcover@fgfirst@front{}
    \def\bookcover@fgfirst@spine{}
    \def\bookcover@fgfirst@backflap{}
    \def\bookcover@fgfirst@frontflap{}
    \def\bookcover@fgfirst@abovefront{}
    \def\bookcover@fgfirst@belowfront{}
    \def\bookcover@fgfirst@aboveback{}
    \def\bookcover@fgfirst@belowback{}
    \def\bookcover@fgsecond@back{}
    \def\bookcover@fgsecond@front{}
    \def\bookcover@fgsecond@spine{}
    \def\bookcover@fgsecond@backflap{}
    \def\bookcover@fgsecond@frontflap{}}
\bookcover@reset    
    
%% SETBOOKCOVER    
\long\def\setbookcover#1#2#3{
    \ifthenelse{\equal{#1}{bgcolor}}{
        \ifthenelse{\equal{#2}{whole}}{\def\bookcover@bgcolor@whole{[#3]}}{}
        \ifthenelse{\equal{#2}{whole without flaps}}{\def\bookcover@bgcolor@wholewf{[#3]}}{}
        \ifthenelse{\equal{#2}{back}}{\def\bookcover@bgcolor@back{[#3]}}{}
        \ifthenelse{\equal{#2}{front}}{\def\bookcover@bgcolor@front{[#3]}}{}
        \ifthenelse{\equal{#2}{back flap}}{\def\bookcover@bgcolor@backflap{[#3]}}{}
        \ifthenelse{\equal{#2}{front flap}}{\def\bookcover@bgcolor@frontflap{[#3]}}{}
        \ifthenelse{\equal{#2}{spine}}{\def\bookcover@bgcolor@spine{[#3]}}{}}{}
    \ifthenelse{\equal{#1}{bgpic}}{    
        \ifthenelse{\equal{#2}{whole}}{\def\bookcover@bgpic@whole{#3}}{}
        \ifthenelse{\equal{#2}{whole without flaps}}{\def\bookcover@bgpic@wholewf{#3}}{}
        \ifthenelse{\equal{#2}{back}}{\def\bookcover@bgpic@back{#3}}{}
        \ifthenelse{\equal{#2}{front}}{\def\bookcover@bgpic@front{#3}}{}
        \ifthenelse{\equal{#2}{back flap}}{\def\bookcover@bgpic@backflap{#3}}{}
        \ifthenelse{\equal{#2}{front flap}}{\def\bookcover@bgpic@frontflap{#3}}{}
        \ifthenelse{\equal{#2}{spine}}{\def\bookcover@bgpic@spine{#3}}{}}{}    
    \ifthenelse{\equal{#1}{bgtikz}}{    
        \ifthenelse{\equal{#2}{whole}}{\def\bookcover@bgtikz@whole{#3}}{}
        \ifthenelse{\equal{#2}{whole without flaps}}{\def\bookcover@bgtikz@wholewf{#3}}{}
        \ifthenelse{\equal{#2}{back}}{\def\bookcover@bgtikz@back{#3}}{}
        \ifthenelse{\equal{#2}{front}}{\def\bookcover@bgtikz@front{#3}}{}
        \ifthenelse{\equal{#2}{back flap}}{\def\bookcover@bgtikz@backflap{#3}}{}
        \ifthenelse{\equal{#2}{front flap}}{\def\bookcover@bgtikz@frontflap{#3}}{}
        \ifthenelse{\equal{#2}{spine}}{\def\bookcover@bgtikz@spine{#3}}{}}{}     
    \ifthenelse{\equal{#1}{fgfirst}}{    
        \ifthenelse{\equal{#2}{back}}{\def\bookcover@fgfirst@back{#3}}{}
        \ifthenelse{\equal{#2}{front}}{\def\bookcover@fgfirst@front{#3}}{}
        \ifthenelse{\equal{#2}{spine}}{\def\bookcover@fgfirst@spine{#3}}{}
        \ifthenelse{\equal{#2}{back flap}}{\def\bookcover@fgfirst@backflap{#3}}{}
        \ifthenelse{\equal{#2}{front flap}}{\def\bookcover@fgfirst@frontflap{#3}}{}
        \ifthenelse{\equal{#2}{remark}}{\def\bookcover@fgfirst@abovefront{#3}}{}% for version 1.0
        \ifthenelse{\equal{#2}{above front}}{\def\bookcover@fgfirst@abovefront{#3}}{}
        \ifthenelse{\equal{#2}{below front}}{\def\bookcover@fgfirst@belowfront{#3}}{}
        \ifthenelse{\equal{#2}{above back}}{\def\bookcover@fgfirst@aboveback{#3}}{}
        \ifthenelse{\equal{#2}{below back}}{\def\bookcover@fgfirst@belowback{#3}}{}}{}    
    \ifthenelse{\equal{#1}{fgsecond}}{    
        \ifthenelse{\equal{#2}{back}}{\def\bookcover@fgsecond@back{#3}}{}
        \ifthenelse{\equal{#2}{front}}{\def\bookcover@fgsecond@front{#3}}{}
        \ifthenelse{\equal{#2}{spine}}{\def\bookcover@fgsecond@spine{#3}}{}
        \ifthenelse{\equal{#2}{back flap}}{\def\bookcover@fgsecond@backflap{#3}}{}
        \ifthenelse{\equal{#2}{front flap}}{\def\bookcover@fgsecond@frontflap{#3}}{}}{}}

%% MAKEBOOKCOVER  
\def\makebookcover{
%% background parameters
\bookcover@ypos{\marklength}
\bookcover@partheight{\coverheight+2\bleedwidth}
%% {bgcolor}{whole}
\ifx\bookcover@bgcolor@whole\@empty\else
    \bookcover@xpos{\marklength}
    \bookcover@partwidth{2\coverwidth+2\bleedwidth+2\flapwidth+\spinewidth}
    \bookcover@bgcolor{\bookcover@bgcolor@whole}\fi
%% {bgcolor}{whole without flaps}
\ifx\bookcover@bgcolor@wholewf\@empty\else
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{2\coverwidth+\spinewidth}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{2\coverwidth+2\bleedwidth+\spinewidth}\fi
    \bookcover@bgcolor{\bookcover@bgcolor@wholewf}\fi
%% {bgcolor}{back flap}
\ifx\bookcover@bgcolor@backflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength}
    \bookcover@partwidth{\flapwidth+\bleedwidth}
    \bookcover@bgcolor{\bookcover@bgcolor@backflap}\fi\fi
%% {bgcolor}{back}
\ifx\bookcover@bgcolor@back\@empty\else
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{\coverwidth}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{\coverwidth+\bleedwidth}\fi
    \bookcover@bgcolor{\bookcover@bgcolor@back}\fi
%% {bgcolor}{spine}
\ifx\bookcover@bgcolor@spine\@empty\else
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\spinewidth}
    \bookcover@bgcolor{\bookcover@bgcolor@spine}\fi
%% {bgcolor}{front}
\ifx\bookcover@bgcolor@front\@empty\else
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
        \bookcover@partwidth{\coverwidth}
    \else
        \bookcover@xpos{\marklength+\bleedwidth+\coverwidth+\spinewidth}
        \bookcover@partwidth{\coverwidth+\bleedwidth}\fi
    \bookcover@bgcolor{\bookcover@bgcolor@front}\fi
%% {bgcolor}{front flap}
\ifx\bookcover@bgcolor@frontflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth}
    \bookcover@partwidth{\flapwidth+\bleedwidth}
    \bookcover@bgcolor{\bookcover@bgcolor@frontflap}\fi\fi
%% {bgpic}{whole}
\ifx\bookcover@bgpic@whole\@empty\else
    \bookcover@xpos{\marklength}
    \bookcover@partwidth{2\coverwidth+2\bleedwidth+2\flapwidth+\spinewidth}
    \bookcover@bgpic{\bookcover@bgpic@whole}\fi
%% {bgpic}{whole without flaps}
\ifx\bookcover@bgpic@wholewf\@empty\else
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{2\coverwidth+\spinewidth}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{2\coverwidth+2\bleedwidth+\spinewidth}\fi
    \bookcover@bgpic{\bookcover@bgpic@wholewf}\fi
%% {bgpic}{back flap}
\ifx\bookcover@bgpic@backflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength}
    \bookcover@partwidth{\flapwidth+\bleedwidth}
    \bookcover@bgpic{\bookcover@bgpic@backflap}\fi\fi
%% {bgpic}{back}
\ifx\bookcover@bgpic@back\@empty\else
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{\coverwidth}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{\coverwidth+\bleedwidth}\fi
    \bookcover@bgpic{\bookcover@bgpic@back}\fi
%% {bgpic}{spine}
\ifx\bookcover@bgpic@spine\@empty\else
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\spinewidth}
    \bookcover@bgpic{\bookcover@bgpic@spine}\fi
%% {bgpic}{front}
\ifx\bookcover@bgpic@front\@empty\else
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
        \bookcover@partwidth{\coverwidth}
    \else
        \bookcover@xpos{\marklength+\bleedwidth+\coverwidth+\spinewidth}
        \bookcover@partwidth{\coverwidth+\bleedwidth}\fi
    \bookcover@bgpic{\bookcover@bgpic@front}\fi
%% {bgpic}{front flap}
\ifx\bookcover@bgpic@frontflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth}
    \bookcover@partwidth{\flapwidth+\bleedwidth}
    \bookcover@bgpic{\bookcover@bgpic@frontflap}\fi\fi
%% {bgtikz}{whole}
\ifx\bookcover@bgtikz@whole\@empty\else
    \bookcover@xpos{\marklength}
    \bookcover@partwidth{2\coverwidth+2\bleedwidth+2\flapwidth+\spinewidth}
    \bookcover@bgtikz@trimmed@part@param{2\bleedwidth}{\bleedwidth}
    \bookcover@bgtikz{\bookcover@bgtikz@whole}\fi
%% {bgtikz}{whole without flaps}
\ifx\bookcover@bgtikz@wholewf\@empty\else
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{2\coverwidth+\spinewidth}
        \bookcover@bgtikz@trimmed@part@param{0pt}{0pt}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{2\coverwidth+2\bleedwidth+\spinewidth}
        \bookcover@bgtikz@trimmed@part@param{2\bleedwidth}{\bleedwidth}\fi
    \bookcover@bgtikz{\bookcover@bgtikz@wholewf}\fi
%% {bgtikz}{back flap}
\ifx\bookcover@bgtikz@backflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength}
    \bookcover@partwidth{\flapwidth+\bleedwidth}
    \bookcover@bgtikz@trimmed@part@param{\bleedwidth}{\bleedwidth}
    \bookcover@bgtikz{\bookcover@bgtikz@backflap}\fi\fi
%% {bgtikz}{back}
\ifx\bookcover@bgtikz@back\@empty\else
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{\coverwidth}
        \bookcover@bgtikz@trimmed@part@param{0pt}{0pt}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{\coverwidth+\bleedwidth}
        \bookcover@bgtikz@trimmed@part@param{\bleedwidth}{\bleedwidth}\fi
    \bookcover@bgtikz{\bookcover@bgtikz@back}\fi
%% {bgtikz}{spine}
\ifx\bookcover@bgtikz@spine\@empty\else
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\spinewidth}
    \bookcover@bgtikz@trimmed@part@param{0pt}{0pt}
    \bookcover@bgtikz{\bookcover@bgtikz@spine}\fi
%% {bgtikz}{front}
\ifx\bookcover@bgtikz@front\@empty\else
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
        \bookcover@partwidth{\coverwidth}
        \bookcover@bgtikz@trimmed@part@param{0pt}{0pt}
    \else
        \bookcover@xpos{\marklength+\bleedwidth+\coverwidth+\spinewidth}
        \bookcover@partwidth{\coverwidth+\bleedwidth}
        \bookcover@bgtikz@trimmed@part@param{\bleedwidth}{0pt}\fi
    \bookcover@bgtikz{\bookcover@bgtikz@front}\fi
%% {bgtikz}{front flap}
\ifx\bookcover@bgtikz@frontflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth}
    \bookcover@partwidth{\flapwidth+\bleedwidth}
    \bookcover@bgtikz@trimmed@part@param{\bleedwidth}{0pt}
    \bookcover@bgtikz{\bookcover@bgtikz@frontflap}\fi\fi
%% foreground parameters
\bookcover@ypos{\marklength+\bleedwidth}
\bookcover@partheight{\coverheight}
%% {fgsecond}{back flap}
\ifx\bookcover@fgsecond@backflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth}
    \bookcover@partwidth{\flapwidth}
    \bookcover@fg{\bookcover@fgsecond@backflap}\fi\fi
%% {fgsecond}{back}
\ifx\bookcover@fgsecond@back\@empty\else
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
    \bookcover@partwidth{\coverwidth}
    \bookcover@fg{\bookcover@fgsecond@back}\fi
%% {fgsecond}{spine}
\ifx\bookcover@fgsecond@spine\@empty\else
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\spinewidth}
    \bookcover@fg{\bookcover@fgsecond@spine}\fi
%% {fgsecond}{front}
\ifx\bookcover@fgsecond@front\@empty\else
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
    \bookcover@partwidth{\coverwidth}
    \bookcover@fg{\bookcover@fgsecond@front}\fi
%% {fgsecond}{front flap}
\ifx\bookcover@fgsecond@frontflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth}
    \bookcover@partwidth{\flapwidth}
    \bookcover@fg{\bookcover@fgsecond@frontflap}\fi\fi
%% {fgfirst}{back flap}
\ifx\bookcover@fgfirst@backflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth}
    \bookcover@partwidth{\flapwidth}
    \bookcover@fg{\bookcover@fgfirst@backflap}\fi\fi
%% {fgfirst}{back}
\ifx\bookcover@fgfirst@back\@empty\else
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
    \bookcover@partwidth{\coverwidth}
    \bookcover@fg{\bookcover@fgfirst@back}\fi
%% {fgfirst}{spine}
\ifx\bookcover@fgfirst@spine\@empty\else
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\spinewidth}
    \bookcover@fg{\bookcover@fgfirst@spine}\fi
%% {fgfirst}{front}
\ifx\bookcover@fgfirst@front\@empty\else
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
    \bookcover@partwidth{\coverwidth}
    \bookcover@fg{\bookcover@fgfirst@front}\fi
%% {fgfirst}{front flap}
\ifx\bookcover@fgfirst@frontflap\@empty\else\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth}
    \bookcover@partwidth{\flapwidth}
    \bookcover@fg{\bookcover@fgfirst@frontflap}\fi\fi
%% {fgfirst}{above front} = {fgfirst}{remark} in version 1.0
\ifx\bookcover@fgfirst@abovefront\@empty\else\ifdim\marklength>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
    \bookcover@ypos{0mm}
    \bookcover@partwidth{\coverwidth}
    \bookcover@partheight{\marklength}
    \bookcover@remark{\bookcover@fgfirst@abovefront}\fi\fi
%% {fgfirst}{below front}
\ifx\bookcover@fgfirst@belowfront\@empty\else\ifdim\marklength>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
    \bookcover@ypos{\marklength+2\bleedwidth+\coverheight}
    \bookcover@partwidth{\coverwidth}
    \bookcover@partheight{\marklength}
    \bookcover@remark{\bookcover@fgfirst@belowfront}\fi\fi
%% {fgfirst}{above back}
\ifx\bookcover@fgfirst@aboveback\@empty\else\ifdim\marklength>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
    \bookcover@ypos{0mm}
    \bookcover@partwidth{\coverwidth}
    \bookcover@partheight{\marklength}
    \bookcover@remark{\bookcover@fgfirst@aboveback}\fi\fi    
%% {fgfirst}{below back}
\ifx\bookcover@fgfirst@belowback\@empty\else\ifdim\marklength>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
    \bookcover@ypos{\marklength+2\bleedwidth+\coverheight}
    \bookcover@partwidth{\coverwidth}
    \bookcover@partheight{\marklength}
    \bookcover@remark{\bookcover@fgfirst@belowback}\fi\fi  
%% mark top parameters
\bookcover@ypos{0mm}
\bookcover@partwidth{\markthick}
%% mark top 1
\bookcover@xpos{\marklength+\bleedwidth-.5\markthick}
\bookcover@vmark
%% mark top 2
\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth-.5\markthick}
    \bookcover@vmark\fi
%% mark top 3
\bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth-.5\markthick}
\bookcover@vmark
%% mark top 4
\bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth-.5\markthick}
\bookcover@vmark
%% mark top 5
\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
    \bookcover@vmark\fi
%% mark top 6
\bookcover@xpos{\marklength+\bleedwidth+2\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
\bookcover@vmark
%% mark bottom parameters
\bookcover@ypos{\paperheight-\marklength}
\bookcover@partwidth{\markthick}
%% mark bottom 1
\bookcover@xpos{\marklength+\bleedwidth-.5\markthick}
\bookcover@vmark
%% mark bottom 2
\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth-.5\markthick}
    \bookcover@vmark\fi
%% mark bottom 3
\bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth-.5\markthick}
\bookcover@vmark
%% mark bottom 4
\bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth-.5\markthick}
\bookcover@vmark
%% mark bottom 5
\ifdim\flapwidth>0mm
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
    \bookcover@vmark\fi
%% mark bottom 6
\bookcover@xpos{\marklength+\bleedwidth+2\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
\bookcover@vmark
%% mark left parameters
\bookcover@xpos{0mm}
\bookcover@partwidth{\marklength}
%% mark left 1
\bookcover@ypos{\marklength+\bleedwidth-.5\markthick}
\bookcover@hmark
%% mark left 2
\bookcover@ypos{\marklength+\bleedwidth+\coverheight-.5\markthick}
\bookcover@hmark
%% mark right parameters
\bookcover@xpos{\paperwidth-\marklength}
\bookcover@partwidth{\marklength}
%% mark right 1
\bookcover@ypos{\marklength+\bleedwidth-.5\markthick}
\bookcover@hmark
%% mark right 2
\bookcover@ypos{\marklength+\bleedwidth+\coverheight-.5\markthick}
\bookcover@hmark
%% trimming
\ifbookcover@trimmed
    \bookcover@trimming\fi
%% new book cover
\mbox{}
\newpage
\bookcover@reset}
%    \end{macrocode}
% \Finale
\endinput
