started work on modes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-07-31 15:20:20 +03:00
parent aa7467030e
commit 3bcf1e6dc9

View File

@ -24,6 +24,7 @@
\RequirePackage{calc} \RequirePackage{calc}
\RequirePackage{xargs} \RequirePackage{xargs}
\RequirePackage{ifthen}
\RequirePackage{iftex} \RequirePackage{iftex}
\RequirePackage{kvoptions} \RequirePackage{kvoptions}
\RequirePackage{etoolbox} \RequirePackage{etoolbox}
@ -45,6 +46,73 @@
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% options... % options...
% mode...
%
% - block (default):
%
% blockwidth
% <--------------->
%
% +---------------+
% | |
% | |
% | |
% | |
% +---------------+
%
%
% - endpaper:
%
% blockwidth 2x
% <------------------------------->
%
% +---------------+---------------+
% | . |
% | . |
% | . |
% | . |
% +---------------+---------------+
%
%
% - endpaper:
%
% blockwidth blockwidth
% <---------------> <--------------->
%
% +---------------++---++---------------+
% | .. .. |
% | .. .. |
% | .. .. |
% | .. .. |
% +---------------++---++---------------+
% . .
% ^. .^ spine fold
% . .
% <---> spinewidth
%
%
% XXX how dow we separate \blockwidth and \paperwidth and still allow
% the user to use all the macros??
% ...implement separate cover templates???
% the obvious way is just set \blockwidth to the new size, but this
% will not help orient the layout correctly...
% XXX do we need to implement cover fold over???
% XXX fold/cut marks???
% XXX write all the dimensions to the comment...
% XXX not implemented yet...
\DeclareStringOption[block]{layoutmode}[block]
\@DeclareLiteralOptionTo{layoutmode}{block}
\@DeclareLiteralOptionTo{layoutmode}{endpaper}
\@DeclareLiteralOptionTo{layoutmode}{cover}
% spine width and spine fold...
%
% NOTE: this is only used when layoutmode=cover
\DeclareStringOption[0]{spinewidth}[0]
\DeclareStringOption[0]{spinefold}[0]
% pdf layout... % pdf layout...
% %
% see: hyperref's pdfpagelayout for more options... % see: hyperref's pdfpagelayout for more options...
@ -115,6 +183,14 @@
%---------------------------------------------------------------------- %----------------------------------------------------------------------
% Globals... % Globals...
\edef\layoutmode{\photobook@layoutmode}
\newlength\spinewidth
\setlength\spinewidth{\photobook@spinewidth}
\newlength\spinefold
\setlength\spinefold{\photobook@spinefold}
% NOTE: page and bleed block sizes are set via \RecalculatePageLengths % NOTE: page and bleed block sizes are set via \RecalculatePageLengths
\newlength\blockwidth \newlength\blockwidth
\newlength\blockheight \newlength\blockheight
@ -161,19 +237,43 @@
% Commands... % Commands...
\newcommand\RecalculatePageLengths{ \newcommand\RecalculatePageLengths{
% final page size... % block size...
\ifnum\blockwidth=0
% layout: block...
\setlength\blockwidth{ \setlength\blockwidth{
\ifx\photobook@blockwidth\empty \ifx\photobook@blockwidth\empty
\dimexpr \paperwidth - \bleed - \innerbleed \relax \dimexpr
\paperwidth
- \bleed
- \innerbleed \relax
\else \else
\photobook@blockwidth \photobook@blockwidth
\fi} \fi}
% XXX EXPERIMENTAL...
% XXX not yet sure how to go about this -- should we update \blockwidth
% or should we define a new length and let some templates
% use one and some use the other???
% ...I'm leaning towards the second...
% layout: cover...
\ifdefstring{\layoutmode}{cover}{
\setlength\blockwidth{
\dimexpr
2\blockwidth
+ 2\spinefold
+ \spinewidth \relax } }{}
% layout: endpaper...
\ifdefstring{\layoutmode}{endpaper}{
\setlength\blockwidth{
2\blockwidth } }{}
\fi
\ifnum\blockheight=0
\setlength\blockheight{ \setlength\blockheight{
\ifx\photobook@blockheight\empty \ifx\photobook@blockheight\empty
\dimexpr \paperheight - 2\bleed \relax \dimexpr \paperheight - 2\bleed \relax
\else \else
\photobook@blockheight \photobook@blockheight
\fi } \fi} \fi
% page with bleeds... % page with bleeds...
% NOTE: this is essentially \paperwidth and \paperheight but we do % NOTE: this is essentially \paperwidth and \paperheight but we do
% not rely on them being defined -- photobook settings take % not rely on them being defined -- photobook settings take
@ -358,8 +458,6 @@
\end{flushright}} \end{flushright}}
% XXX \blockwidth
% XXX \nudgeimageby
% \captionsidebox[offset]{imagebox}{text} % \captionsidebox[offset]{imagebox}{text}
% %
\newcommand\captionsidebox[3][0mm]{ \newcommand\captionsidebox[3][0mm]{
@ -458,6 +556,8 @@
% \hspace{\dimexpr -(\bleed - \innerbleed) \relax}{\usebox\photobook@imagebox} % \hspace{\dimexpr -(\bleed - \innerbleed) \relax}{\usebox\photobook@imagebox}
% - do the same for caption... % - do the same for caption...
% XXX BUG: vertical alignment falls apart if page head is changed... % XXX BUG: vertical alignment falls apart if page head is changed...
% XXX replace \ifthenelse\isodd .. with etoolbox equivalent....
% ...this is the only dependency on \RequirePackage{ifthen}
\newcommand\imagepagefitWH[4]{ \newcommand\imagepagefitWH[4]{
\sbox{\photobook@imagebox}{ \sbox{\photobook@imagebox}{
\includegraphics[ \includegraphics[