From 3bcf1e6dc974b0aeeab409786eef794a100f08a0 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 31 Jul 2021 15:20:20 +0300 Subject: [PATCH] started work on modes... Signed-off-by: Alex A. Naanou --- photobook.cls | 130 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 115 insertions(+), 15 deletions(-) diff --git a/photobook.cls b/photobook.cls index df76baf..7be4c1a 100644 --- a/photobook.cls +++ b/photobook.cls @@ -24,6 +24,7 @@ \RequirePackage{calc} \RequirePackage{xargs} +\RequirePackage{ifthen} \RequirePackage{iftex} \RequirePackage{kvoptions} \RequirePackage{etoolbox} @@ -45,6 +46,73 @@ % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % 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... % % see: hyperref's pdfpagelayout for more options... @@ -115,6 +183,14 @@ %---------------------------------------------------------------------- % 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 \newlength\blockwidth \newlength\blockheight @@ -161,19 +237,43 @@ % Commands... \newcommand\RecalculatePageLengths{ - % final page size... - \setlength\blockwidth{ - \ifx\photobook@blockwidth\empty - \dimexpr \paperwidth - \bleed - \innerbleed \relax - \else - \photobook@blockwidth - \fi} - \setlength\blockheight{ - \ifx\photobook@blockheight\empty - \dimexpr \paperheight - 2\bleed \relax - \else - \photobook@blockheight - \fi } + % block size... + \ifnum\blockwidth=0 + % layout: block... + \setlength\blockwidth{ + \ifx\photobook@blockwidth\empty + \dimexpr + \paperwidth + - \bleed + - \innerbleed \relax + \else + \photobook@blockwidth + \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{ + \ifx\photobook@blockheight\empty + \dimexpr \paperheight - 2\bleed \relax + \else + \photobook@blockheight + \fi} \fi % page with bleeds... % NOTE: this is essentially \paperwidth and \paperheight but we do % not rely on them being defined -- photobook settings take @@ -358,8 +458,6 @@ \end{flushright}} -% XXX \blockwidth -% XXX \nudgeimageby % \captionsidebox[offset]{imagebox}{text} % \newcommand\captionsidebox[3][0mm]{ @@ -458,6 +556,8 @@ % \hspace{\dimexpr -(\bleed - \innerbleed) \relax}{\usebox\photobook@imagebox} % - do the same for caption... % 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]{ \sbox{\photobook@imagebox}{ \includegraphics[