summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/bookcover/bookcover.dtx
blob: b9ab7e69ccded3cd3c85c7831df9359ce00f8933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
% \iffalse meta-comment
%
% Copyright (C) 2015-2020 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}{2020/11/12}
\newcommand{\eifilever}{v2.4}
%</driver>
%<class>
%<class>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<class>\ProvidesClass{bookcover}[2020/11/12 v2.4 class for book covers and dust jackets]
%
%<*driver>
\documentclass{ltxdoc}
\OnlyDescription
\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,colorlinks,allcolors=teal]{hyperref}
\usepackage[english]{babel}
\usepackage{xcolor,graphicx,listings,calc,multirow,array,pdfpages}

\colorlet{command}{blue!80!black}
\colorlet{example}{black}
\colorlet{layer}{purple}
\colorlet{param}{green!50!black}

\lstnewenvironment{examplelst}{\lstset{
    gobble=2,
    belowskip=5mm,
    basicstyle=\color{example}\small\ttfamily,
    backgroundcolor=\color{black!10},
    columns=fullflexible,
    keepspaces}}{}

\lstnewenvironment{commandlst}{\lstset{
    literate={<}{{$\langle$}}1{>}{{$\rangle$}}1,
    delim=[is][\color{param}\normalfont\itshape\small]{!}{!},
    gobble=2,
    basicstyle=\color{command}\ttfamily,
    backgroundcolor=\color{white},
    columns=fullflexible,
    keepspaces}}{}

\lstdefinestyle{examplefile}{
    literate={ü}{{\"u}}1{ó}{{\'o}}1{é}{{\'e}}1{á}{{\'a}}1{Á}{{\'A}}1,
    belowskip=5mm,
    basicstyle=\color{example}\small\ttfamily,
    backgroundcolor=\color{black!10},
    columns=fullflexible,
    keepspaces,
    comment=[l][\ttfamily\color{black!50}]{\%}}

\newcommand{\commandinline}{\lstinline[
    literate={<}{{$\langle$}}1{>}{{$\rangle$}}1,
    delim={[is][\color{param}\normalfont\itshape\small]{!}{!}},
    basicstyle=\color{command}\ttfamily,
    columns=fullflexible,
    keepspaces]}

\flushbottom

\def\meta#1{{\color{param}\normalfont\itshape\small$\langle$#1$\rangle$}}

\def\example{\colorbox{command}{\footnotesize\sffamily\bfseries\color{white}EXAMPLE}}

\def\BookCover{{\def\sfdefault{ugq}\sffamily\bfseries
    \color{gray}\mbox{}\lower.15ex\hbox{[B}ook%
    \color{orange}\lower.15ex\hbox{C}over\lower.15ex\hbox{]}}}

\begin{document}
    \DocInput{./bookcover.dtx}
\end{document}
%</driver>
% \fi
%
% \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{{\Huge\BookCover\\[5mm]}
%        Class for book covers and dust jackets\\[2mm]
%        \textsf{bookcover.cls}\\
%        {\large\eifilever\ (\eifiledate)}}
% \author{Tibor Tómács\\{\normalsize\href{mailto:tomacs.tibor@uni-eszterhazy.hu}{\texttt{tomacs.tibor@uni-eszterhazy.hu}}}}
% \date{}
% \maketitle
%
% \section{Introduction}
% In the following picture we can see a typical dust jacket. Its 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{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 green area in 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}
% We get the following result after trimming:
% \begin{center}
% \includegraphics{figures/result}
% \end{center}
%
% \section{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{ifthen}, \texttt{tikz}, \texttt{fgruler}.
%
% \medskip\noindent
% Load the class as usual, with
% \begin{commandlst}
% \documentclass[!<options>!]{bookcover}
% \end{commandlst}
%
% \begin{center}
% \begin{tabular}{@{}l@{}l@{\hspace{-13mm}}r@{}}
% \textbf{option}                        & \textbf{description}  & \textbf{default value}\\
% \hline
% \commandinline|coverwidth=!<length>!|  & \multirow{6}*{\hspace{-1mm}$\left.\hbox{\rule[-11mm]{0pt}{22mm}}\right\}$ See the next figure}& \texttt{170mm}\\
% \commandinline|coverheight=!<length>!| & & \texttt{240mm}\\
% \commandinline|spinewidth=!<length>!|  & &   \texttt{5mm}\\
% \commandinline|flapwidth=!<length>!|   & &   \texttt{0mm}\\
% \commandinline|marklength=!<length>!|  & &  \texttt{10mm}\\
% \commandinline|bleedwidth=!<length>!|  & &   \texttt{5mm}\\
% \commandinline|markthick=!<length>!|   & Thickness of marks & \texttt{0.4pt}\\
% \commandinline|markcolor=!<color>!|    & Color of marks     &   \texttt{red}\\
% \commandinline|10pt|                   & \multirow{3}*{\hspace{-1mm}$\left.\hbox{\rule[-4mm]{0pt}{8mm}}\right\}$ Normal font size (default: \texttt{10pt})}&\\
% \commandinline|11pt|                   & &\\
% \commandinline|12pt|                   & &\\
% \commandinline|trimmed|                & It shows trimmed version&\texttt{false}\\
% \hline
% \end{tabular}
% \end{center}
% \begin{center}
% \includegraphics{figures/sizes}
% \end{center}
%
% \noindent\example
% \begin{examplelst}
% \documentclass[flapwidth=50mm,spinewidth=15mm]{bookcover}
% \end{examplelst}
%
% \section{Creating book cover}\label{sec:mainmethod}
% \subsection{Commands}
% Use \commandinline{bookcover} environment to make a new book cover. In this environment, you can create a component of the book cover by the following command:
% \begin{commandlst}
% \bookcovercomponent{!<component type>!}{!<part>!}{!<content>!}
% \end{commandlst}
% \meta{component type} See Subsection \ref{subsec:componenttypes}.
%
% \medskip\noindent
% \meta{part} See Subsection \ref{subsec:parts-main-method} or Section~\ref{sec:illustration-parts}.
%
% \medskip\noindent
% \meta{content} It depends on the \meta{component type}. See Subsection \ref{subsec:componenttypes}.
%
% \medskip\noindent
% Every |\bookcovercomponent| generates a layer on the sheet. The first one generates the bottom layer and the last one generates the top layer.
%
% \bigskip\noindent\example
% \begin{examplelst}
% \begin{bookcover}
%     \bookcovercomponent{color}{bg whole}{color=blue}
%     \bookcovercomponent{normal}{front}{
%         \vspace{5cm}
%         \begin{center}
%             \bfseries\huge Book title
%         \end{center}}
% \end{bookcover}
% \end{examplelst}
%
% \subsection{Parts}\label{subsec:parts-main-method}
% Important: The background parts are expanded onto the bleed, taking account of slight inaccuracy when trimming!
% \subsubsection{One-piece background parts}
% \commandinline{bg back flap}, \commandinline{bg back}, \commandinline{bg spine}, \commandinline{bg front}, \commandinline{bg front flap}
%
% \begin{center}
% \textbf{With flaps}\\*[0pt]
% \includegraphics{figures/bg1}
% \end{center}
% \begin{center}
% \textbf{Without flaps}\\*[0pt]
% \includegraphics{figures/bg4}
% \end{center}
%
% \subsubsection{One-piece foreground parts}
% \commandinline{back flap}, \commandinline{back}, \commandinline{spine}, \commandinline{front}, \commandinline{front flap}, \commandinline{above back}, \commandinline{above front}, \commandinline{below back}, \commandinline{below front}
%
% \begin{center}
% \textbf{With flaps}\\*[0pt]
% \includegraphics{figures/foreground1}
% \end{center}
% \begin{center}
% \textbf{Without flaps}\\*[0pt]
% \includegraphics{figures/foreground2}
% \end{center}
%
% \subsubsection{Combined parts}
% The following combined parts are defined. You can see illustrations in the Section~\ref{sec:illustration-parts}.
% \begin{center}
% \begin{tabular}{@{}>{\color{command}\ttfamily}l@{\hspace{1cm}}>{\color{command}\ttfamily}l@{}}
% {\rmfamily\bfseries\textcolor{black}{background}}&{\rmfamily\bfseries\textcolor{black}{foreground}}\\
% \hline
% bg back and flap            & back and flap\\
% bg back and spine           & back and spine\\
% bg front and spine          & front and spine\\
% bg front and flap           & front and flap\\
% bg back and flap and spine  & back and flap and spine\\
% bg front and flap and spine & front and flap and spine\\
% bg whole without front flap & whole without front flap\\
% bg whole without back flap  & whole without back flap\\
% bg whole without flaps      & whole without flaps\\
% bg whole                    & whole\\
% whole page                  &
% \end{tabular}
% \end{center}
%
% \subsection{Component types}\label{subsec:componenttypes}
% The following component types are defined: \commandinline{color}, \commandinline{picture}, \commandinline{tikz}, \commandinline{tikz clip}, \commandinline{normal}, \commandinline{center}, \commandinline{ruler}.
% \subsubsection[color]{Component type: \texttt{color}}
% \begin{commandlst}
% \bookcovercomponent{color}{!<part>!}{!<colors>!}
% \end{commandlst}
% It determines the color of the part.
%
% \medskip\noindent
% \meta{colors} The options of the |\fill| in the \texttt{tikz} package:\label{page:color}\\
% \indent\commandinline{color=!<color name>!} See \meta{color name} in the \texttt{xcolor} package.\\
% \indent\commandinline{top color=!<color name>!}\\
% \indent\commandinline{bottom color=!<color name>!}\\
% \indent\commandinline{middle color=!<color name>!}\\
% \indent\commandinline{inner color=!<color name>!}\\
% \indent\commandinline{outer color=!<color name>!}\\
% \indent\commandinline{ball color=!<color name>!}\\
% \indent\commandinline{shading angle=!<degree>!} It rotates the shading by the given angle.
%
% \pagebreak\bigskip\noindent\example
% \begin{examplelst}
% \begin{bookcover}
%     \bookcovercomponent{color}{bg whole without flaps}{
%         top color=white, bottom color=blue!50!black, shading angle=60}
% \end{bookcover}
% \end{examplelst}
%
% \subsubsection[picture]{Component type: \texttt{picture}}
% \begin{commandlst}
% \bookcovercomponent{picture}{!<part>!}{!<picture file>!}
% \end{commandlst}
% The picture will be rescaled according to the sizes of the \meta{part}.
%
% \bigskip\noindent\example
% \begin{examplelst}
% \begin{bookcover}
%     \bookcovercomponent{picture}{bg front flap}{fig.png}
% \end{bookcover}
% \end{examplelst}
%
% \subsubsection[tikz]{Component type: \texttt{tikz}}
% \begin{commandlst}
% \bookcovercomponent{tikz}{!<part>!}{!<tikz code>!}
% \end{commandlst}
% The origin of the Ti\emph{k}Z figure is the lower left corner of the \meta{part}. Two rectangle nodes come into being: \commandinline{part} and \commandinline{trimmed part}. (Thanks to Zunbeltz Izaola for the idea.)
%
% \bigskip\noindent\example
% \begin{examplelst}
% \begin{bookcover}
% \bookcovercomponent{tikz}{bg whole}{
%     \fill[yellow] (part.south west) rectangle (part.north east);
%     \fill[gray] (trimmed part.south east) rectangle (trimmed part.north west);
%     \draw[green] (0,0) circle [radius=10mm];}
% \bookcovercomponent{tikz}{bg spine}{
%     \fill[orange] (part.center) circle [radius=8mm];}
% \end{bookcover}
% \end{examplelst}
% \begin{center}
% \setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.4pt}
% \fcolorbox{black!50}{white}{\includegraphics{figures/tikz}}
% \end{center}
%
% \subsubsection[tikz clip]{Component type: \texttt{tikz clip}}
% \begin{commandlst}
% \bookcovercomponent{tikz clip}{!<part>!}{!<tikz code>!}
% \end{commandlst}
% It works the same as the \texttt{tikz} component type, but it clips the \meta{part}.
%
% \bigskip\noindent\example
% \begin{examplelst}
% \begin{bookcover}
% \bookcovercomponent{tikz clip}{bg whole}{
%     \fill[yellow] (part.south west) rectangle (part.north east);
%     \fill[gray] (trimmed part.south east) rectangle (trimmed part.north west);
%     \draw[green] (0,0) circle [radius=10mm];}
% \bookcovercomponent{tikz clip}{bg spine}{
%     \fill[orange] (part.center) circle [radius=8mm];}
% \end{bookcover}
% \end{examplelst}
% \begin{center}
% \setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.4pt}
% \fcolorbox{black!50}{white}{\includegraphics{figures/tikzclip}}
% \end{center}
%
% \subsubsection[normal]{Component type: \texttt{normal}}
% \begin{commandlst}
% \bookcovercomponent{normal}{!<part>!}{!<content>!}
% \end{commandlst}
% In this case, the \meta{content} is not specific. You can choose it as text or picture etc.
%
% \bigskip\noindent\example
% \begin{examplelst}
% \begin{bookcover}
%     \bookcovercomponent{normal}{front}{
%         \vspace{5cm}
%         \begin{center}
%             {\bfseries\huge Book title}\\[5mm]
%             \includegraphics[width=6cm]{fig.png}
%         \end{center}}
% \end{bookcover}
% \end{examplelst}
%
% \subsubsection[center]{Component type: \texttt{center}}
% \begin{commandlst}
% \bookcovercomponent{center}{!<part>!}{!<content>!}
% \end{commandlst}
% It works the same as the \texttt{normal} component type, but the position of the content is the center of the part (horizontally and vertically).
%
% \bigskip\noindent\example
% \begin{examplelst}
% \begin{bookcover}
%     \bookcovercomponent{center}{above front}{
%         \color{blue}Remark above front}
%     \bookcovercomponent{center}{spine}{
%         \rotatebox[origin=c]{90}{\bfseries\Large Book title}}
% \end{bookcover}
% \end{examplelst}
%
% \subsubsection[ruler]{Component type: \texttt{ruler}}
% Use the \texttt{ruler} component type to check the sizes of the part.
% \begin{commandlst}
% \bookcovercomponent{ruler}{!<part>!}{\setruler[!<unit>!]{!<coordsys>!}{!<shift x>!}{!<shift y>!}{!<color>!}}
% \end{commandlst}
% \meta{unit} The ruler unit:\\
% \indent\commandinline{cm} Metric ruler (centimeter). Default value.\\
% \indent\commandinline{in} English ruler (inch).
%
% \medskip\noindent
% \meta{coordsys} The type of the coordinate system:\\
% \indent\commandinline{upper left } The origin is the upper left corner of the part.\\
% \indent\commandinline{upper right} The origin is the upper right corner of the part.\\
% \indent\commandinline{lower left } The origin is the lower left corner of the part.\\
% \indent\commandinline{lower right} The origin is the lower right corner of the part.
%
% \medskip\noindent
% \meta{shift x},\meta{shift y} Moving the origin of the ruler to the vector (\meta{shift x},\meta{shift y}).
%
% \medskip\noindent
% \meta{color} The color of the ruler.
%
% \pagebreak\bigskip\noindent\example
% \begin{examplelst}
% \begin{bookcover}
%    \bookcovercomponent{ruler}{back}{\setruler{upper left}{0cm}{0cm}{blue}}
%    \bookcovercomponent{ruler}{back}{\setruler{upper left}{2cm}{1cm}{black}}
%    \bookcovercomponent{ruler}{front}{\setruler{lower right}{0cm}{0cm}{green}}
%    \bookcovercomponent{ruler}{front}{\setruler{lower right}{2cm}{1cm}{gray}}
% \end{bookcover}
% \end{examplelst}
% \begin{center}
% \setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.4pt}
% \fcolorbox{black!50}{white}{\includegraphics{figures/ruler}}
% \end{center}
%
% \subsection{Defining component type}
% You can define a new component type, redefine or rename a defined component type with the following commands:
% \begin{commandlst}
% \newbookcovercomponenttype{!<new component type name>!}{!<formatting>!}
% \renewbookcovercomponenttype{!<defined component type name>!}{!<formatting>!}
% \newnamebookcovercomponenttype{!<new component type name>!}{!<defined component type name>!}
% \end{commandlst}
% You can use the following length commands in \meta{formatting}:
%
% \medskip\noindent
% \commandinline{\partwidth  } Width of the part.\\
% \commandinline{\partheight } Height of the part.
%
% \bigskip\noindent
% You have to referrence the content as \verb|#1|. 
%
% \bigskip\noindent\example
% \begin{examplelst}
% \documentclass[spinewidth=1cm]{bookcover}
% \newbookcovercomponenttype{center rotate}{
%     \parbox[t][\partheight][c]{\partwidth}{
%         \begin{center}
%             \rotatebox[origin=c]{90}{#1}
%         \end{center}}}
% \begin{document}
% \begin{bookcover}
%      \bookcovercomponent{center rotate}{spine}{Author -- Book title}
% \end{bookcover}
% \end{document}
% \end{examplelst}
%
% \subsection{Defining part}
% You can define a new part, redefine or rename a defined part with the following commands:
% \begin{commandlst}
% \newbookcoverpart{!<new part name>!}{!<setting>!}
% \renewbookcoverpart{!<defined part name>!}{!<setting>!}
% \newnamebookcoverpart{!<new part name>!}{!<defined part name>!}
% \end{commandlst}
% In \meta{setting} you have to set the new part sizes, the coordinates of its upper left corner (the origin is the upper left corner of the printed box), and the parameters of the \texttt{trimmed part} rectangle node in \texttt{tikz} and \texttt{tikz clip} component types. For this purpose, use the following commands:
% \begin{commandlst}
% \setpartposx{!<coord x>!}
% \setpartposy{!<coord y>!}
% \setpartwidth{!<width>!}
% \setpartheight{!<height>!}
% \settrimmedpart{!<width minus>!}{!<height minus>!}{!<shift x>!}{!<shift y>!}
% \end{commandlst}
%
%\begin{center}
%\includegraphics{./figures/newpart}
%\end{center}
%
% \noindent To give the previous lengths, you can use the following length commands:
%
% \medskip\noindent
% \commandinline{\marklength \bleedwidth \flapwidth \coverwidth \spinewidth \coverheight}
%
% \bigskip\noindent\example
% \begin{examplelst}
% \documentclass[flapwidth=3cm]{bookcover}
% \newbookcoverpart{bg half front}{
%     \setpartposx{\marklength+\bleedwidth+\flapwidth+\spinewidth+1.5\coverwidth}
%     \setpartposy{\marklength}
%     \setpartheight{\coverheight+2\bleedwidth}
%     \ifdim\flapwidth>0mm
%         \setpartwidth{.5\coverwidth}
%         \settrimmedpart{0pt}{2\bleedwidth}{0pt}{\bleedwidth}
%     \else
%         \setpartwidth{.5\coverwidth+\bleedwidth}
%         \settrimmedpart{\bleedwidth}{2\bleedwidth}{0pt}{\bleedwidth}\fi}
% \begin{document}
% \begin{bookcover}
% \bookcovercomponent{tikz}{bg half front}{
%     \fill[blue] (part.south west) rectangle (part.north east);
%     \fill[green] (trimmed part.south west) rectangle (trimmed part.north east);}
% \end{bookcover}
% \end{document}
% \end{examplelst}
%
% \includepdfset{nup=2x5,delta=4mm 4mm,noautoscale,frame}
% \includepdf[pages=1-10,pagecommand={\section{Illustration of the predefined parts}\label{sec:illustration-parts}\subsection{Background parts (cover width flaps)}}]{figures/parts.pdf}
% \includepdf[pages=11-16,pagecommand={}]{figures/parts.pdf}
% \includepdf[pages=36-42,pagecommand={\subsection{Background parts (cover widthout flaps)}}]{figures/parts.pdf}
% \includepdf[pages=17-26,pagecommand={\subsection{Foreground parts (cover width flaps)}}]{figures/parts.pdf}
% \includepdf[pages=27-35,pagecommand={}]{figures/parts.pdf}
% \includepdf[pages=43-52,pagecommand={\subsection{Foreground parts (cover widthout flaps)}}]{figures/parts.pdf}
%
% \newpage\section{Full examples}
% \subsection{A dust jacket}
% \lstinputlisting[style=examplefile]{bookcover-example1.tex}
% \begin{center}
% \setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.4pt}
% \fcolorbox{black!50}{white}{\includegraphics[width=\textwidth-.8pt]{bookcover-example1}}\label{page:example1}
% \end{center}
%
% \subsection{A two-sided book cover}
% \lstinputlisting[style=examplefile]{bookcover-example2.tex}
% \begin{center}
% \setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.4pt}%
% \fcolorbox{black!50}{white}{\includegraphics[page=1,width=\textwidth-.8pt]{bookcover-example2}}\\[5mm]
% \fcolorbox{black!50}{white}{\includegraphics[page=2,width=\textwidth-.8pt]{bookcover-example2}}
% \end{center}
%
% \newpage\subsection{Barcode}
% \begin{examplelst}
% \documentclass{bookcover}
% \usepackage{pst-barcode}
% \begin{document}
% \begin{bookcover} 
%     \bookcovercomponent{normal}{back}{
%         \vfill
%         \centering
%         \begin{pspicture}(1.5in,1in)
%             \psbarcode{1787-6117}{includetext height=1 width=1.5}{issn}
%         \end{pspicture}
%         \vspace{5mm}}
% \end{bookcover}
% \end{document}
% \end{examplelst}
%
% \noindent You can compile this file with \texttt{latex} or \texttt{xelatex}. Using \texttt{pdflatex} or \texttt{lualatex}, write the following code into the preamble:
% \begin{examplelst}
% \usepackage[pdfcrop={-hires}]{auto-pst-pdf}
% \end{examplelst}
% In this case, the \texttt{pdflatex} or \texttt{lualatex} must be called with the \texttt{-shell-escape} option.
%
% \bigskip
% \begin{center}
% \setlength{\fboxsep}{0pt}\setlength{\fboxrule}{.4pt}
% \fcolorbox{black!50}{white}{\includegraphics[width=\textwidth-.8pt]{figures/barcode}}
% \end{center}
%
% \StopEventually{}
%
%    \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}}
\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}
\ProcessKeyvalOptions{bookcover}

%% CLASS AND PACKAGES

\LoadClass{article}
\RequirePackage{geometry,graphicx,calc,ifthen,tikz}
\RequirePackage[nonefgrulers]{fgruler}

%% PAGE STYLE

\pagestyle{empty}

%% NEW IF

\newif\if@inbookcoverenv

%% USER LENGTHS

\newlength{\coverwidth}
\newlength{\coverheight}
\newlength{\spinewidth}
\newlength{\flapwidth}
\newlength{\marklength}
\newlength{\markthick}
\newlength{\bleedwidth}

%% INTERNAL LENGTHS

\newlength{\bookcover@templength@}
\newlength{\bookcover@xpos@}
\newlength{\bookcover@ypos@}
\newlength{\bookcover@partwidth@}
\newlength{\bookcover@partheight@}
\newlength{\bookcover@tikz@trimmed@part@width@minus}
\newlength{\bookcover@tikz@trimmed@part@height@minus}
\newlength{\bookcover@tikz@trimmed@part@push@right}
\newlength{\bookcover@tikz@trimmed@part@push@up}
\newlength{\bookcover@rulerwidth@}
\newlength{\bookcover@rulerheight@}
\let\partheight\bookcover@partheight@
\let\partwidth\bookcover@partwidth@

%% 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}

%% PAGE DIMENSIONS SETTING

\geometry{%
    margin=0pt,
    paperwidth=2\marklength+2\bleedwidth+2\coverwidth+2\flapwidth+\spinewidth,
    paperheight=2\marklength+2\bleedwidth+\coverheight}

%% NO PARAGRAPH INDENTATION

\setlength{\parindent}{0pt}

%% 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@tikz@trimmed@part@param#1#2#3#4{%
    \setlength{\bookcover@tikz@trimmed@part@width@minus}{#1}%
    \setlength{\bookcover@tikz@trimmed@part@height@minus}{#2}%
    \setlength{\bookcover@tikz@trimmed@part@push@right}{#3}%
    \setlength{\bookcover@tikz@trimmed@part@push@up}{#4}}
\let\setpartposx\bookcover@xpos
\let\setpartposy\bookcover@ypos
\let\setpartwidth\bookcover@partwidth
\let\setpartheight\bookcover@partheight
\let\settrimmedpart\bookcover@tikz@trimmed@part@param

%% POSBOX

\newcommand{\bookcover@posbox}[4]{%
    \setlength{\bookcover@templength@}{#3}%
    \put(#2,-\bookcover@templength@){\parbox[b][0pt][t]{#1}{#4}}}

%% MARKS

\def\bookcover@vmark{%
    \bookcover@posbox{\bookcover@partwidth@}{\bookcover@xpos@}{\bookcover@ypos@}{%
        {\color{\bookcover@markcolor}\rule[0pt]{\markthick}{\marklength}}}}

\def\bookcover@hmark{%
    \bookcover@posbox{\bookcover@partwidth@}{\bookcover@xpos@}{\bookcover@ypos@}{%
        {\color{\bookcover@markcolor}\rule[0pt]{\marklength}{\markthick}}}}

\def\bookcover@marks{
    \bookcover@ypos{0mm}
    \bookcover@partwidth{\markthick}
    \bookcover@xpos{\marklength+\bleedwidth-.5\markthick}
    \bookcover@vmark
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth-.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
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
        \bookcover@vmark\fi
    \bookcover@xpos{\marklength+\bleedwidth+2\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
    \bookcover@vmark
    \bookcover@ypos{\paperheight-\marklength}
    \bookcover@partwidth{\markthick}
    \bookcover@xpos{\marklength+\bleedwidth-.5\markthick}
    \bookcover@vmark
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth-.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
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
        \bookcover@vmark\fi
    \bookcover@xpos{\marklength+\bleedwidth+2\flapwidth+2\coverwidth+\spinewidth-.5\markthick}
    \bookcover@vmark
    \bookcover@xpos{0mm}
    \bookcover@partwidth{\marklength}
    \bookcover@ypos{\marklength+\bleedwidth-.5\markthick}
    \bookcover@hmark
    \bookcover@ypos{\marklength+\bleedwidth+\coverheight-.5\markthick}
    \bookcover@hmark
    \bookcover@xpos{\paperwidth-\marklength}
    \bookcover@partwidth{\marklength}
    \bookcover@ypos{\marklength+\bleedwidth-.5\markthick}
    \bookcover@hmark
    \bookcover@ypos{\marklength+\bleedwidth+\coverheight-.5\markthick}
    \bookcover@hmark}

%% TRIMMING

\def\bookcover@trimming{%
    \bookcover@posbox{\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}}
    \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}

%% BOOKCOVER ENVIRONMENT

\def\bookcover{%
    \@inbookcoverenvtrue%
    \newpage%
    \begin{picture}(\paperwidth,\paperheight)(0,-\paperheight)}

\def\endbookcover{%
    \bookcover@marks%
    \ifbookcover@trimmed\bookcover@trimming\fi%
    \end{picture}%
    \@inbookcoverenvfalse}

%% BOOKCOVER COMPONENT

\long\def\bookcovercomponent#1#2#3{
    \if@inbookcoverenv\else
        \@latexerr{\string\bookcovercomponent\space is not in 'bookcover' environment.}{}\fi
    \bookcover@xpos{0pt}
    \bookcover@ypos{0pt}
    \bookcover@partwidth{0pt}
    \bookcover@partheight{0pt}
    \bookcover@tikz@trimmed@part@param{0pt}{0pt}{0pt}{0pt}
    \@ifundefined{bookcover@part@param@#2}{\@latexerr{Part '#2' undefined.}{}}{
        \@ifundefined{bookcover@componenttype@#1}{\@latexerr{Component type '#1' undefined.}{}}{
            \ifx\@empty#3\else
                \csname bookcover@part@param@#2\endcsname
                \ifdim\bookcover@partwidth@>0mm
                    \ifdim\bookcover@partheight@>0mm
                        \csname bookcover@componenttype@#1\endcsname{#3}\fi\fi\fi}}}

%% NEW BOOKCOVER PART

\def\newbookcoverpart#1#2{
    \@ifundefined{bookcover@part@param@#1}{
        \expandafter\def\csname bookcover@part@param@#1\endcsname{#2}}
    {\@latexerr{Part '#1' already defined.}{}}}

%% RENEW BOOKCOVER PART

\def\renewbookcoverpart#1#2{
    \@ifundefined{bookcover@part@param@#1}{\@latexerr{Part '#1' undefined.}{}}{
        \expandafter\def\csname bookcover@part@param@#1\endcsname{#2}}}

%% NEW NAME BOOKCOVER PART

\def\newnamebookcoverpart#1#2{
    \@ifundefined{bookcover@part@param@#1}{
        \@ifundefined{bookcover@part@param@#2}{\@latexerr{Part '#2' undefined.}{}}{
            \expandafter\def\csname bookcover@part@param@#1\endcsname{%
                \csname bookcover@part@param@#2\endcsname}}}
    {\@latexerr{Part '#1' already defined.}{}}}

%% NEW BOOKCOVER COMPONENT TYPE

\def\newbookcovercomponenttype#1#2{%
    \@ifundefined{bookcover@componenttype@#1}{%
        \long\expandafter\def\csname bookcover@componenttype@#1\endcsname##1{%
        \bookcover@posbox{\bookcover@partwidth@}{\bookcover@xpos@}{\bookcover@ypos@}{#2}}}
    {\@latexerr{Component type '#1' already defined.}{}}}

%% RENEW BOOKCOVER COMPONENT TYPE

\def\renewbookcovercomponenttype#1#2{%
    \@ifundefined{bookcover@componenttype@#1}{\@latex@error{Component type '#1' undefined.}{}}{%
        \long\expandafter\def\csname bookcover@componenttype@#1\endcsname##1{%
        \bookcover@posbox{\bookcover@partwidth@}{\bookcover@xpos@}{\bookcover@ypos@}{#2}}}}

%% NEW NAME BOOKCOVER COMPONENT TYPE

\def\newnamebookcovercomponenttype#1#2{
    \@ifundefined{bookcover@componenttype@#1}{
        \@ifundefined{bookcover@componenttype@#2}{\@latexerr{Component type '#2' undefined.}{}}{
            \expandafter\def\csname bookcover@componenttype@#1\endcsname{%
                \csname bookcover@componenttype@#2\endcsname}}}
    {\@latexerr{Component type '#1' already defined.}{}}}

%% COMPONENT TYPES

\newbookcovercomponenttype{color}{
    \tikz\fill[#1] (0,0) rectangle (\bookcover@partwidth@,\bookcover@partheight@);}

\newbookcovercomponenttype{picture}{
    \includegraphics[width=\bookcover@partwidth@,height=\bookcover@partheight@]{#1}}

\newbookcovercomponenttype{tikz}{
    \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}{}{part}{\pgfusepath{draw}}
        \pgfset{minimum width=\bookcover@partwidth@-\bookcover@tikz@trimmed@part@width@minus,
                minimum height=\bookcover@partheight@-\bookcover@tikz@trimmed@part@height@minus}
        \pgftransformshift{\pgfpoint{\bookcover@tikz@trimmed@part@push@right}
                                    {\bookcover@tikz@trimmed@part@push@up}}
        \pgfnode{rectangle}{south west}{}{trimmed part}{\pgfusepath{draw}}
    \end{scope}
    #1
    \end{tikzpicture}}

\newbookcovercomponenttype{tikz clip}{
    \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}{}{part}{\pgfusepath{draw}}
        \pgfset{minimum width=\bookcover@partwidth@-\bookcover@tikz@trimmed@part@width@minus,
                minimum height=\bookcover@partheight@-\bookcover@tikz@trimmed@part@height@minus}
        \pgftransformshift{\pgfpoint{\bookcover@tikz@trimmed@part@push@right}
                                    {\bookcover@tikz@trimmed@part@push@up}}
        \pgfnode{rectangle}{south west}{}{trimmed part}{\pgfusepath{draw}}
    \end{scope}
    \clip (part.south west) rectangle (part.north east);
    #1
    \end{tikzpicture}}

\newbookcovercomponenttype{normal}{
    \parbox[t][\bookcover@partheight@][t]{\bookcover@partwidth@}{#1}}

\newbookcovercomponenttype{center}{
    \parbox[t][\bookcover@partheight@][c]{\bookcover@partwidth@}{\begin{center}#1\end{center}}}

\newbookcovercomponenttype{ruler}{
    \parbox[t][\bookcover@partheight@][t]{\bookcover@partwidth@}{#1}}
\newcommand{\setruler}[5][cm]{%
    \rulernorotatenum%
    \rulerparams{}{}{#5}{}{}%
    \setlength{\bookcover@rulerwidth@}{\bookcover@partwidth@-#3}%
    \setlength{\bookcover@rulerheight@}{\bookcover@partheight@-#4}%
    \ifthenelse{\equal{#2}{upper left}}{%
        \vspace{#4}%
        \hspace{#3}%
        \squareruler[#1]{upperleft}{\bookcover@rulerwidth@}{\bookcover@rulerheight@}}{}%
    \ifthenelse{\equal{#2}{upper right}}{%
        \vspace{#4}%
        \squareruler[#1]{upperright}{\bookcover@rulerwidth@}{\bookcover@rulerheight@}}{}%
    \ifthenelse{\equal{#2}{lower left}}{%
        \hspace{#3}%
        \squareruler[#1]{lowerleft}{\bookcover@rulerwidth@}{\bookcover@rulerheight@}}{}%
    \ifthenelse{\equal{#2}{lower right}}{%
        \squareruler[#1]{lowerright}{\bookcover@rulerwidth@}{\bookcover@rulerheight@}}{}}

%% BOOKCOVER PARTS

\newbookcoverpart{bg back flap}{
    \ifdim\flapwidth>0mm
        \bookcover@ypos{\marklength}
        \bookcover@partheight{\coverheight+2\bleedwidth}
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{\flapwidth+\bleedwidth}
        \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}\fi}

\newbookcoverpart{bg back}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{\coverwidth}
        \bookcover@tikz@trimmed@part@param{0pt}{2\bleedwidth}{0pt}{\bleedwidth}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{\coverwidth+\bleedwidth}
        \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}\fi}

\newbookcoverpart{bg spine}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\spinewidth}
    \bookcover@tikz@trimmed@part@param{0pt}{2\bleedwidth}{0pt}{\bleedwidth}}

\newbookcoverpart{bg front}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
    \ifdim\flapwidth>0mm
        \bookcover@partwidth{\coverwidth}
        \bookcover@tikz@trimmed@part@param{0pt}{2\bleedwidth}{0pt}{\bleedwidth}
    \else
        \bookcover@partwidth{\coverwidth+\bleedwidth}
        \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{0pt}{\bleedwidth}\fi}

\newbookcoverpart{bg front flap}{
    \ifdim\flapwidth>0mm
        \bookcover@ypos{\marklength}
        \bookcover@partheight{\coverheight+2\bleedwidth}
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth}
        \bookcover@partwidth{\flapwidth+\bleedwidth}
        \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{0pt}{\bleedwidth}\fi}

\newbookcoverpart{bg back and flap}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \bookcover@xpos{\marklength}
    \bookcover@partwidth{\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}}

\newbookcoverpart{bg back and spine}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{\coverwidth+\spinewidth}
        \bookcover@tikz@trimmed@part@param{0pt}{2\bleedwidth}{0pt}{\bleedwidth}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{\coverwidth+\bleedwidth+\spinewidth}
        \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}\fi}

\newbookcoverpart{bg front and spine}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \ifdim\flapwidth>0mm
        \bookcover@partwidth{\coverwidth+\spinewidth}
        \bookcover@tikz@trimmed@part@param{0pt}{2\bleedwidth}{0pt}{\bleedwidth}
    \else
        \bookcover@partwidth{\coverwidth+\spinewidth+\bleedwidth}
        \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{0pt}{\bleedwidth}\fi}

\newbookcoverpart{bg front and flap}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
    \bookcover@partwidth{\coverwidth+\flapwidth+\bleedwidth}
    \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{0pt}{\bleedwidth}}

\newbookcoverpart{bg back and flap and spine}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \bookcover@xpos{\marklength}
    \bookcover@partwidth{\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
    \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}}

\newbookcoverpart{bg whole without flaps}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{2\coverwidth+\spinewidth}
        \bookcover@tikz@trimmed@part@param{0pt}{2\bleedwidth}{0pt}{\bleedwidth}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{2\coverwidth+2\bleedwidth+\spinewidth}
        \bookcover@tikz@trimmed@part@param{2\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}\fi}

\newbookcoverpart{bg front and flap and spine}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\coverwidth+\flapwidth+\bleedwidth+\spinewidth}
    \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{0pt}{\bleedwidth}}

\newbookcoverpart{bg whole without front flap}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \bookcover@xpos{\marklength}
    \ifdim\flapwidth>0mm
        \bookcover@partwidth{2\coverwidth+\flapwidth+\bleedwidth+\spinewidth}
        \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}
    \else
        \bookcover@partwidth{2\coverwidth+2\bleedwidth+\spinewidth}
        \bookcover@tikz@trimmed@part@param{2\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}\fi}

\newbookcoverpart{bg whole without back flap}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \ifdim\flapwidth>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@partwidth{2\coverwidth+\flapwidth+\bleedwidth+\spinewidth}
        \bookcover@tikz@trimmed@part@param{\bleedwidth}{2\bleedwidth}{0mm}{\bleedwidth}
    \else
        \bookcover@xpos{\marklength}
        \bookcover@partwidth{2\coverwidth+2\bleedwidth+\spinewidth}
        \bookcover@tikz@trimmed@part@param{2\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}\fi}

\newbookcoverpart{bg whole}{
    \bookcover@ypos{\marklength}
    \bookcover@partheight{\coverheight+2\bleedwidth}
    \bookcover@xpos{\marklength}
    \bookcover@partwidth{2\coverwidth+2\bleedwidth+2\flapwidth+\spinewidth}
    \bookcover@tikz@trimmed@part@param{2\bleedwidth}{2\bleedwidth}{\bleedwidth}{\bleedwidth}}

\newbookcoverpart{whole page}{
    \bookcover@partheight{\paperheight}
    \bookcover@partwidth{\paperwidth}}

\newbookcoverpart{back flap}{
    \ifdim\flapwidth>0mm
        \bookcover@ypos{\marklength+\bleedwidth}
        \bookcover@partheight{\coverheight}
        \bookcover@xpos{\marklength+\bleedwidth}
        \bookcover@partwidth{\flapwidth}\fi}

\newbookcoverpart{back}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
    \bookcover@partwidth{\coverwidth}}

\newbookcoverpart{spine}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\spinewidth}}

\newbookcoverpart{front}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
    \bookcover@partwidth{\coverwidth}}

\newbookcoverpart{front flap}{
    \ifdim\flapwidth>0mm
        \bookcover@ypos{\marklength+\bleedwidth}
        \bookcover@partheight{\coverheight}
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+2\coverwidth+\spinewidth}
        \bookcover@partwidth{\flapwidth}\fi}

\newbookcoverpart{above front}{
    \ifdim\marklength>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
        \bookcover@ypos{0mm}
        \bookcover@partwidth{\coverwidth}
        \bookcover@partheight{\marklength}\fi}

\newbookcoverpart{below front}{
    \ifdim\marklength>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
        \bookcover@ypos{\marklength+2\bleedwidth+\coverheight}
        \bookcover@partwidth{\coverwidth}
        \bookcover@partheight{\marklength}\fi}

\newbookcoverpart{above back}{
    \ifdim\marklength>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@ypos{0mm}
        \bookcover@partwidth{\coverwidth}
        \bookcover@partheight{\marklength}\fi}

\newbookcoverpart{below back}{
    \ifdim\marklength>0mm
        \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
        \bookcover@ypos{\marklength+2\bleedwidth+\coverheight}
        \bookcover@partwidth{\coverwidth}
        \bookcover@partheight{\marklength}\fi}

\newbookcoverpart{back and flap}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@xpos{\marklength+\bleedwidth}
    \bookcover@partwidth{\flapwidth+\coverwidth}
    \bookcover@partheight{\coverheight}}

\newbookcoverpart{back and spine}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
    \bookcover@partwidth{\coverwidth+\spinewidth}}

\newbookcoverpart{front and spine}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\coverwidth+\spinewidth}}

\newbookcoverpart{front and flap}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth+\spinewidth}
    \bookcover@partwidth{\coverwidth+\flapwidth}}

\newbookcoverpart{back and flap and spine}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@xpos{\marklength+\bleedwidth}
    \bookcover@partwidth{\flapwidth+\coverwidth+\spinewidth}
    \bookcover@partheight{\coverheight}}

\newbookcoverpart{whole without flaps}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
    \bookcover@partwidth{2\coverwidth+\spinewidth}}

\newbookcoverpart{front and flap and spine}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth+\coverwidth}
    \bookcover@partwidth{\coverwidth+\flapwidth+\spinewidth}}

\newbookcoverpart{whole without front flap}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth}
    \bookcover@partwidth{2\coverwidth+\flapwidth+\spinewidth}}

\newbookcoverpart{whole without back flap}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth+\flapwidth}
    \bookcover@partwidth{2\coverwidth+\flapwidth+\spinewidth}}

\newbookcoverpart{whole}{
    \bookcover@ypos{\marklength+\bleedwidth}
    \bookcover@partheight{\coverheight}
    \bookcover@xpos{\marklength+\bleedwidth}
    \bookcover@partwidth{2\coverwidth+2\flapwidth+\spinewidth}}

%    \end{macrocode}
% \Finale
\endinput