moving mostly done + refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-07-30 14:21:53 +03:00
parent dbf667836b
commit 16074180b5

View File

@ -60,11 +60,11 @@
% . +---------------------------------------+ . v . . --- % . +---------------------------------------+ . v . . ---
% . | ^ . = . % . | ^ . = .
% . | . . . . . . | . . = . ^ % . | . . . . . . | . . = . ^
% . |<-- pagewidth ------------------------>= . | % . |<-- blockwidth ------------------------>= . |
% . | . | . . = . | % . | . | . . = . |
% . | | . = . textheight % . | | . = . textheight
% . | . | . . = . | % . | . | . . = . |
% . | pageheight . = . | % . | blockheight . = . |
% . | . | . . = . | % . | . | . . = . |
% . | | <---> bindingoffset | % . | | <---> bindingoffset |
% . | . . . . . . | . . = . v % . | . . . . . . | . . = . v
@ -77,15 +77,15 @@
% ^ binding line % ^ binding line
% %
% NOTE: innerbleed defaults to bleed... % NOTE: innerbleed defaults to bleed...
% NOTE: if pagewidth/pageheight are set they will force recalculations % NOTE: if blockwidth/blockheight are set they will force recalculations
% and overriding of the paperwidth/paperheight if they were changed % and overriding of the paperwidth/paperheight if they were changed
% by the user code anywhere between \documentclass[..]{photobook} % by the user code anywhere between \documentclass[..]{photobook}
% and \begin{document}... % and \begin{document}...
\DeclareStringOption[5mm]{bleed}[5mm] \DeclareStringOption[5mm]{bleed}[5mm]
\DeclareStringOption{innerbleed} \DeclareStringOption{innerbleed}
% XXX do we need to rename these??? (used by lualatex??) % XXX do we need to rename these??? (used by lualatex??)
\DeclareStringOption{pagewidth} \DeclareStringOption{blockwidth}
\DeclareStringOption{pageheight} \DeclareStringOption{blockheight}
\DeclareStringOption[0]{bindingoffset}[10mm] \DeclareStringOption[0]{bindingoffset}[10mm]
% Image block size relative to text block... % Image block size relative to text block...
@ -110,8 +110,8 @@
% Globals... % Globals...
% NOTE: page and bleed block sizes are set via \RecalculatePageLengths % NOTE: page and bleed block sizes are set via \RecalculatePageLengths
\newlength\pagewidth \newlength\blockwidth
\newlength\pageheight \newlength\blockheight
% NOTE: these are equivalent to \paperwidth and \paperheight but are % NOTE: these are equivalent to \paperwidth and \paperheight but are
% independent of them... % independent of them...
\newlength\bleedblockwidth \newlength\bleedblockwidth
@ -156,27 +156,27 @@
\newcommand\RecalculatePageLengths{ \newcommand\RecalculatePageLengths{
% final page size... % final page size...
\setlength\pagewidth{ \setlength\blockwidth{
\ifx\photobook@pagewidth\empty \ifx\photobook@blockwidth\empty
\dimexpr \paperwidth - \bleed - \innerbleed \relax \dimexpr \paperwidth - \bleed - \innerbleed \relax
\else \else
\photobook@pagewidth \photobook@blockwidth
\fi} \fi}
\setlength\pageheight{ \setlength\blockheight{
\ifx\photobook@pageheight\empty \ifx\photobook@blockheight\empty
\dimexpr \paperheight - 2\bleed \relax \dimexpr \paperheight - 2\bleed \relax
\else \else
\photobook@pageheight \photobook@blockheight
\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
% priority over \paperwidth and \paperwidth... % priority over \paperwidth and \paperwidth...
\setlength\bleedblockwidth{\dimexpr \setlength\bleedblockwidth{\dimexpr
\bleed + \pagewidth + \innerbleed \bleed + \blockwidth + \innerbleed
\relax} \relax}
\setlength\bleedblockheight{\dimexpr \setlength\bleedblockheight{\dimexpr
2\bleed + \pageheight 2\bleed + \blockheight
\relax} } \relax} }
@ -323,7 +323,7 @@
\end{flushright}} \end{flushright}}
% XXX \pagewidth % XXX \blockwidth
% XXX \nudgeimageby % XXX \nudgeimageby
% \captionsidebox[offset]{imagebox}{text} % \captionsidebox[offset]{imagebox}{text}
% %
@ -332,10 +332,10 @@
% caption-image distance... % caption-image distance...
-1em -1em
-\clearimage -\clearimage
+\pagewidth +\blockwidth
-(\wd#2 - #1) -(\wd#2 - #1)
+(\nudgeimageby) +(\nudgeimageby)
-(0.5\pagewidth - 0.5\textwidth) \relax} -(0.5\blockwidth - 0.5\textwidth) \relax}
{ \captionsize #3 } { \captionsize #3 }
\end{minipage}} \end{minipage}}
@ -494,7 +494,7 @@
% XXX % XXX
% XXX \OFFSETFIX % XXX captions wrong...
% \imagepagefit[clearence]{caption}{image} % \imagepagefit[clearence]{caption}{image}
% %
% +---------------+ % +---------------+
@ -510,37 +510,31 @@
% +---------------+ % +---------------+
% %
% NOTE: this is like \imagepage but will fit an image into page... % NOTE: this is like \imagepage but will fit an image into page...
% XXX captions untested...
\newcommand\imagepagefit[3][\clearimage]{ \newcommand\imagepagefit[3][\clearimage]{
\sbox{\photobook@imagebox}{ \sbox{\photobook@imagebox}{
\includegraphics[ \includegraphics[
keepaspectratio, keepaspectratio,
width=\dimexpr \pagewidth - ((#1) * 2) \relax, width=\dimexpr \blockwidth - ((#1) * 2) \relax,
height=\dimexpr \pageheight - ((#1) * 2) \relax]{#3} } height=\dimexpr \blockheight - ((#1) * 2) \relax]{#3} }
%\clearpage %\clearpage
\null \null
\captionboxright[-#1]{\photobook@imagebox}{#2} % XXX misaligned...
\captionboxright{\photobook@imagebox}{#2}
\ShipoutPicture{ \ShipoutPicture{
\AtPageLowerLeft{ \AtPageLowerLeft{
\hspace*{\dimexpr \hspace*{\dimexpr
+0.5\pagewidth +0.5\blockwidth
-0.5\wd\photobook@imagebox -0.5\wd\photobook@imagebox
-\bleed
% XXX
-0.5\OFFSETFIX
\relax}{ \relax}{
% XXX this is not correct...
\raisebox{\dimexpr \raisebox{\dimexpr
+0.5\pageheight +0.5\blockheight
-0.5\ht\photobook@imagebox -0.5\ht\photobook@imagebox
%+#1
%-\bleed
\relax}{ \relax}{
\usebox\photobook@imagebox } } } } \usebox\photobook@imagebox } } } }
\newpage } \newpage }
% XXX % XXX does not work...
% XXX \OFFSETFIX % XXX \OFFSETFIX
% \imagepagefill[clearence]{caption}{image} % \imagepagefill[clearence]{caption}{image}
% %
@ -563,16 +557,16 @@
\sbox{\photobook@imagebox}{ \sbox{\photobook@imagebox}{
\includegraphics[ \includegraphics[
keepaspectratio, keepaspectratio,
width=\dimexpr \pagewidth - ((#1) * 2) \relax, width=\dimexpr \blockwidth - ((#1) * 2) \relax,
% XXX make this use the minumum dimention and not width... % XXX make this use the minumum dimention and not width...
%height=\dimexpr \pageheight - ((#1) * 2) \relax %height=\dimexpr \blockheight - ((#1) * 2) \relax
]{#3} } ]{#3} }
\clearpage \clearpage
\captionboxright[-#1]{\photobook@imagebox}{#2} \captionboxright[-#1]{\photobook@imagebox}{#2}
\ShipoutPicture{ \ShipoutPicture{
\AtPageLowerLeft{ \AtPageLowerLeft{
\hspace*{\dimexpr \hspace*{\dimexpr
+0.5\pagewidth +0.5\blockwidth
-0.5\wd\photobook@imagebox -0.5\wd\photobook@imagebox
-\bleed -\bleed
% XXX % XXX
@ -606,7 +600,7 @@
\sbox{\photobook@imagebox}{ \sbox{\photobook@imagebox}{
\includegraphics[ \includegraphics[
keepaspectratio, keepaspectratio,
height=\dimexpr \pageheight - ((#1) * 2) \relax]{#3} } height=\dimexpr \blockheight - ((#1) * 2) \relax]{#3} }
\clearpage \clearpage
\captionboxright[-#1]{\photobook@imagebox}{#2} \captionboxright[-#1]{\photobook@imagebox}{#2}
\ShipoutPicture{ \ShipoutPicture{
@ -637,14 +631,14 @@
\sbox{\photobook@imagebox}{ \sbox{\photobook@imagebox}{
\includegraphics[ \includegraphics[
keepaspectratio, keepaspectratio,
height=\dimexpr \pageheight - ((#1) * 2) \relax]{#3} } height=\dimexpr \blockheight - ((#1) * 2) \relax]{#3} }
\clearpage \clearpage
\captionboxleft[-#1]{\photobook@imagebox}{#2} \captionboxleft[-#1]{\photobook@imagebox}{#2}
\ShipoutPicture{ \ShipoutPicture{
\AtPageLowerLeft{ \AtPageLowerLeft{
\hspace*{\dimexpr \hspace*{\dimexpr
-#1 -#1
+\pagewidth +\blockwidth
-\wd\photobook@imagebox \relax}{ -\wd\photobook@imagebox \relax}{
\raisebox{\dimexpr #1 + \bleed \relax}{ \raisebox{\dimexpr #1 + \bleed \relax}{
\usebox\photobook@imagebox } } } } \usebox\photobook@imagebox } } } }
@ -655,7 +649,370 @@
%---------------------------------------------------------------------- %----------------------------------------------------------------------
% Spread Templates... % Spread Templates...
\newlength{\photobook@tmpnudgeimageby}
\newlength{\photobook@tmpvnudgeimageby}
\newlength{\photobook@tmpvgrowimageby}
\newlength{\nudgeimageby}
\setlength{\nudgeimageby}{0mm}
\newlength{\vnudgeimageby}
\setlength{\vnudgeimageby}{0mm}
\newlength{\vgrowimageby}
\setlength{\vgrowimageby}{0mm}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% nudgeimage{amount}
%
% NOTE: in addition to spread commands below this is also used by
% \captionsidebox
\newcommand\nudgeimage[1]{%
\setlength{\nudgeimageby}{#1}}
% vnudgeimage{amount}
%
% offset image vertically within bleeds.
%
% NOTE: this should not be used in conjunction with \vgrowimage{..} and
% should not exceed 1/2 of the amount given to \vgrowimage{..}
\newcommand\vnudgeimage[1]{%
\setlength{\vnudgeimageby}{#1}}
% vgrowimage{amount}
%
% This will effectively add to 1/2 amount to top bleed and the same to
% bottom bleed.
\newcommand\vgrowimage[1]{%
\setlength{\vgrowimageby}{#1}}
% resetnudgeimage
%
% NOTE: when working with shipout place this after \newpage as when
% placed before this will reset the \nudgeimageby BEFORE the image
% placing commands have a chance to execute.
% XXX rename
\newcommand\resetnudgeimage{%
\setlength{\vgrowimageby}{0mm}%
\setlength{\vnudgeimageby}{0mm}%
\setlength{\nudgeimageby}{0mm}}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% XXX
% portraitspreadbleedleft[clearence]{caption}{image}
%
% +---------------+---------------+
% | |. .| |
% | | . . | |
% | | . . | |
% | | . . | |
% | | image | |
% | | . . | |
% | | . . | |
% | | . . | |
% | |. .| c |
% +---------------+---------------+
%
\newcommand\portraitspreadbleedleft[3][\clearimage]{
\cleartoleftpage
% style the caption...
\null
\vfill
\begin{flushright}
#2%
\end{flushright}
\newpage
% XXX add \bleed
\portraitimagepageleft[#1]{}{#3} }
% XXX
% portraitspreadbleedright[clearence]{caption}{image}
%
% +---------------+---------------+
% | |. .| |
% | | . . | |
% | | . . | |
% | | . . | |
% | | image | |
% | | . . | |
% | | . . | |
% | | . . | |
% | c |. .| |
% +---------------+---------------+
%
\newcommand\portraitspreadbleedright[3][\clearimage]{
\cleartoleftpage
% style the caption...
% XXX add \bleed
\portraitimagepageright[#1]{}{#3}
\null
\vfill
\begin{flushleft}
#2%
\end{flushleft}
\newpage }
% XXX
% XXX \OFFSETFIX
% imagespreadleft[clearence]{caption}{image}
%
% Image spread aligned left (with bleed)...
%
% +---------------+---------------+
% | . . . | |
% | . . . | |
% | . . . | |
% | . .. | |
% | image | |
% | . .. | |
% | . . . | |
% | . . . | |
% | . . . | c |
% +---------------+---------------+
%
%
% XXX might be a good idea to do a version of this with min/max width of
% the caption block...
\newcommand\imagespreadleft[3][\clearimage]{
\sbox{\imagebox}{
\includegraphics[
keepaspectratio,
height=\dimexpr \blockheight - ((#1) * 2) + \vgrowimageby \relax]{#3} }
% left page...
% XXX BUG: this in some cases creates an extra empty spread before this...
% ...appears to be a problem where we have a tweak.tex
%\cleartoleftpage
\null
\ShipoutPicture{
\AtPageLowerLeft{
\hspace*{\dimexpr
\OFFSETFIX
-(\nudgeimageby)
+#1
+\bleed
\relax}{
\raisebox{\dimexpr
#1
+ \bleed
- 0.5\vgrowimageby
- \vnudgeimageby
\relax}{
\usebox\imagebox } } } }
\newpage
% right page...
\captionboxright[\blockwidth]{\imagebox}{#2}
\ShipoutPicture{
\AtPageLowerLeft{
\hspace*{\dimexpr
\OFFSETFIX
-(\nudgeimageby)
+#1
-\blockwidth
+\innerbleed
\relax}{
\raisebox{\dimexpr
#1
+ \bleed
- 0.5\vgrowimageby
- \vnudgeimageby
\relax}{
\usebox\imagebox } } } }
\newpage
\resetnudgeimage }
% XXX
% imagespreadright[clearence]{caption}{image}
%
% Image spread aligned right (with bleed)...
%
% +---------------+---------------+
% | | . . . |
% | | . . . |
% | | . . . |
% | | .. . |
% | | image |
% | | .. . |
% | | . . . |
% | | . . . |
% | c | . . . |
% +---------------+---------------+
%
\newcommand\imagespreadright[3][\clearimage]{
\sbox{\imagebox}{
\includegraphics[
keepaspectratio,
height=\dimexpr \blockheight - ((#1) * 2) + \vgrowimageby \relax]{#3} }
% left page...
%\cleartoleftpage
\null
\captionboxleft[\blockwidth]{\imagebox}{#2}
\ShipoutPicture{
\AtPageLowerLeft{
\hspace*{\dimexpr
-#1
+(\nudgeimageby)
+2\blockwidth
+\bleed
-\wd\imagebox \relax}{
\raisebox{\dimexpr
#1 + \bleed
- 0.5\vgrowimageby - \vnudgeimageby \relax}{
\usebox\imagebox } } } }
\newpage
% right page...
\null
\ShipoutPicture{
\AtPageLowerLeft{
\hspace*{\dimexpr
-#1
+(\nudgeimageby)
+\blockwidth
+\innerbleed
-\wd\imagebox \relax}{
\raisebox{\dimexpr
#1 + \bleed
- 0.5\vgrowimageby - \vnudgeimageby \relax}{
\usebox\imagebox } } } }
\newpage
\resetnudgeimage }
% XXX
% XXX \OFFSETFIX
% imageleftspreadfullbleed[vertical-offset]{caption}{image}
%
% Image spread with full bleed...
%
% +---------------+
% | . .
% | . .
% | . .
% | . .
% | ima
% | . .
% | . .
% | . .
% | . c .
% +---------------+
%
\newcommand\imageleftspreadfullbleed[3][0mm]{
\sbox{\imagebox}{
\includegraphics[
keepaspectratio,
width=\dimexpr
2\blockwidth - 2\clearimage + \vgrowimageby \relax]{#3} }
\clearpage
\null
\vfill
\begin{flushright}
#2
\end{flushright}
\ShipoutPicture{
\AtPageCenter{
\hspace{\dimexpr
\OFFSETFIX
-(\nudgeimageby)
+\clearimage
-0.5\blockwidth \relax}{
\raisebox{\dimexpr
(#1)
+\clearimage
-(0.5\blockheight
+(0.5\ht\imagebox - 0.5\blockheight))
- 0.5\vgrowimageby - \vnudgeimageby \relax}{
\usebox\imagebox } } } }
\newpage
\resetnudgeimage }
% XXX
% XXX \OFFSETFIX
% imagerightspreadfullbleed[vertical-offset]{caption}{image}
%
% Image spread with full bleed...
%
% +---------------+
% . . |
% . . |
% . . |
% . . |
% age |
% . . |
% . . |
% . . |
% . . c |
% +---------------+
%
\newcommand\imagerightspreadfullbleed[3][0mm]{
\sbox{\imagebox}{
\includegraphics[
keepaspectratio,
width=\dimexpr
2\blockwidth - 2\clearimage + \vgrowimageby \relax]{#3} }
\clearpage
\null
\vfill
% XXX for some reason the last line here is a bit off...
% XXX do we need to restrict caption width here??? ...0.5\textwidth??
% XXX make caption sizing a bit more flexible...
\begin{flushright}
\captionsize #2
\end{flushright}
\ShipoutPicture{
\AtPageCenter{
\hspace{\dimexpr
\OFFSETFIX
-(\nudgeimageby)
+\clearimage
-1.5\blockwidth \relax}{
\raisebox{\dimexpr
(#1)
+\clearimage
-(0.5\blockheight
+(0.5\ht\imagebox - 0.5\blockheight))
- 0.5\vgrowimageby - \vnudgeimageby \relax}{
\usebox\imagebox } } } }
\newpage
\resetnudgeimage }
% XXX
% imagespreadfullbleed[vertical-offset]{caption}{image}
%
% Image spread with full bleed...
%
% +---------------+---------------+
% | . . . |
% | . . . |
% | . . . |
% | . . . |
% | image |
% | . . . |
% | . . . |
% | . . . |
% | . . . c |
% +---------------+---------------+
%
% XXX do we need the same thing but with a left caption???
\newcommand\imagespreadfullbleed[3][0mm]{
\setlength{\photobook@tmpnudgeimageby}{\nudgeimageby}
\setlength{\photobook@tmpvnudgeimageby}{\vnudgeimageby}
\setlength{\photobook@tmpvgrowimageby}{\vgrowimageby}
\cleartoleftpage
\imageleftspreadfullbleed[#1]{}{#3}
\nudgeimage{\photobook@tmpnudgeimageby}
\vnudgeimage{\photobook@tmpvnudgeimageby}
\vgrowimage{\photobook@tmpvgrowimageby}
\imagerightspreadfullbleed[#1]{#2}{#3} }