more legacy replacement + refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-08-31 03:25:11 +03:00
parent 2664e4e71d
commit 3b86a3e8de

View File

@ -7,6 +7,10 @@
% - adds basic templates for image pages (XXX) % - adds basic templates for image pages (XXX)
% %
% %
% XXX revise command naming -- should be obvious from name what is what:
% - meta commands -- ??? (currently same as templates)
% - general macros -- \usecell{..}
% - templates -- \ImagePage{..}
% XXX see where we need to \ignorespaces... % XXX see where we need to \ignorespaces...
% XXX might be a good idea to add a spine calculator... % XXX might be a good idea to add a spine calculator...
% XXX LEGACY BUG: fix \OFFSETFIX % XXX LEGACY BUG: fix \OFFSETFIX
@ -2355,7 +2359,7 @@
% %
% >> \<name>*[<options>]{<caption>}{<code>} % >> \<name>*[<options>]{<caption>}{<code>}
% %
% |\<name>{..}| will use |\<name>caption{..}| template command to typeset % |\<name>{..}| will use |\<name>Caption{..}| template command to typeset
% the image caption while |\<name>*{..}| will show the caption as-is. % the image caption while |\<name>*{..}| will show the caption as-is.
% %
\def\ImagePageTemplate#1#2{% \def\ImagePageTemplate#1#2{%
@ -2369,18 +2373,18 @@
% main implementation with caption template... % main implementation with caption template...
\expandafter\newcommand\csname photobook@ImagePageTemplate@#1@captiontpl\endcsname[3][]{% \expandafter\newcommand\csname photobook@ImagePageTemplate@#1@captiontpl\endcsname[3][]{%
\csname photobook@ImagePageTemplate@#1\endcsname[##1]{% \csname photobook@ImagePageTemplate@#1\endcsname[##1]{%
\@ifundefined{#1caption}{% \@ifundefined{#1Caption}{%
##2% ##2%
}{% }{%
\csname #1caption\endcsname{##2}}}{##3}}} \csname #1Caption\endcsname{##2}}}{##3}}}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%% \DescribeMacro{\imagepage\{..\}} %% \DescribeMacro{\ImagePage\{..\}}
%% \DescribeMacro{\imagepagecaption\{..\}} %% \DescribeMacro{\ImagePageCaption\{..\}}
%% \DescribeMacro{\resetimagepagecaption} %% \DescribeMacro{\resetImagePageCaption}
%% \DescribeMacro{\imagepage*\{..\}} %% \DescribeMacro{\ImagePage*\{..\}}
% %
%% Basic image page %% Basic image page
%% %%
@ -2405,27 +2409,27 @@
%% %%
%% Create an image page: %% Create an image page:
% %
%% >> \imagepage{<caption>}{<path>} %% >> \ImagePage{<caption>}{<path>}
% %
%% Image caption template used by |\imagepage{..}|, this can be redefined %% Image caption template used by |\ImagePage{..}|, this can be redefined
%% to change the way |\imagepage{..}| behaves: %% to change the way |\ImagePage{..}| behaves:
% %
%% >> \imagepagecaption{<caption>}{<path>} %% >> \ImagePageCaption{<caption>}{<path>}
% %
%% Create image page with a custom caption, this will not use any caption %% Create image page with a custom caption, this will not use any caption
%% templates: %% templates:
% %
%% >> \imagepage*{<caption>}{<path>} %% >> \ImagePage*{<caption>}{<path>}
% %
%% Reset image caption to default: %% Reset image caption to default:
% %
%% >> \resetimagepagecaption %% >> \resetImagePageCaption
%% %%
\ResettableMacro{imagepagecaption}[1]{% \ResettableMacro{ImagePageCaption}[1]{%
\captioncell[under, align=flushright]{% \captioncell[under, align=flushright]{%
\captionformat{#1}}} \captionformat{#1}}}
\ImagePageTemplate{imagepage}{% \ImagePageTemplate{ImagePage}{%
\begin{page}% \begin{page}%
\begin{pagecell}% \begin{pagecell}%
\begin{minipage}[t][\cellheight][c]{\cellwidth}% \begin{minipage}[t][\cellheight][c]{\cellwidth}%
@ -2444,14 +2448,14 @@
\end{page}} \end{page}}
%% \DescribeMacro{\imagepagefit\{..\}} %% \DescribeMacro{\ImagePageFit\{..\}}
%% \DescribeMacro{\imagepagefitcaption\{..\}} %% \DescribeMacro{\ImagePageFitCaption\{..\}}
%% \DescribeMacro{\resetimagepagefitcaption} %% \DescribeMacro{\resetImagePageFitCaption}
%% \DescribeMacro{\imagepagefit*\{..\}} %% \DescribeMacro{\ImagePageFit*\{..\}}
% %
%% Similar to |\imagepage| but will fit an image into page... %% Similar to |\ImagePage| but will fit an image into page...
% %
%% >> \imagepagefit[<options>]{<caption>}{<image>} %% >> \ImagePageFit[<options>]{<caption>}{<image>}
%% %%
%% \begin{minipage}{\textwidth} %% \begin{minipage}{\textwidth}
%% \begin{verbatim} %% \begin{verbatim}
@ -2482,11 +2486,11 @@
%% is set by |\clearimage| global length. %% is set by |\clearimage| global length.
%% %%
% XXX make captions adaptive??? % XXX make captions adaptive???
\ResettableMacro{imagepagefitcaption}[1]{% \ResettableMacro{ImagePageFitCaption}[1]{%
\captioncell[under, align=flushright]{% \captioncell[under, align=flushright]{%
\captionformat{#1}}} \captionformat{#1}}}
\ImagePageTemplate{imagepagefit}{% \ImagePageTemplate{ImagePageFit}{%
\begin{page}% \begin{page}%
\begin{pagecell}% \begin{pagecell}%
\imagecell[center, clearance=\clearimage, #1]{#2}{#3}% \imagecell[center, clearance=\clearimage, #1]{#2}{#3}%
@ -2494,14 +2498,14 @@
\end{page}} \end{page}}
%% \DescribeMacro{\imagepagefill\{..\}} %% \DescribeMacro{\ImagePageFill\{..\}}
%% \DescribeMacro{\imagepagefillcaption\{..\}} %% \DescribeMacro{\ImagePageFillCaption\{..\}}
%% \DescribeMacro{\resetimagepagefillcaption} %% \DescribeMacro{\resetImagePageFillCaption}
%% \DescribeMacro{\imagepagefill*\{..\}} %% \DescribeMacro{\ImagePageFill*\{..\}}
% %
%% Like |\imagepage| but will fill page with image. %% Like |\ImagePage| but will fill page with image.
% %
%% >> \imagepagefill[<options>]{<caption>}{<image>} %% >> \ImagePageFill[<options>]{<caption>}{<image>}
%% %%
%% \begin{minipage}{\textwidth} %% \begin{minipage}{\textwidth}
%% \begin{verbatim} %% \begin{verbatim}
@ -2528,12 +2532,12 @@
%% Default image clearence (|clearimage| option value in |\imagecell{..}|) %% Default image clearence (|clearimage| option value in |\imagecell{..}|)
%% is set by |\clearimage| global length. %% is set by |\clearimage| global length.
%% %%
\ResettableMacro{imagepagefillcaption}[1]{% \ResettableMacro{ImagePageFillCaption}[1]{%
\captioncell[top, align=flushright]{% \captioncell[top, align=flushright]{%
\captionformat{#1}}} \captionformat{#1}}}
\ImagePageTemplate{imagepagefill}{% \ImagePageTemplate{ImagePageFill}{%
\imagepagefit*[fill, #1]{#2}{#3}} \ImagePageFit*[fill, #1]{#2}{#3}}
% XXX % XXX
@ -2624,13 +2628,12 @@
\newpage } \newpage }
% XXX %% \DescribeMacro{\ImageLeftHalfPage\{..\}}
% XXX \OFFSETFIX %% \DescribeMacro{\ImageLeftHalfPageCaption\{..\}}
%% \DescribeMacro{\imageleftspreadfullbleed\{..\}} %% \DescribeMacro{\resetImageLeftHalfPageCaption}
%% \DescribeMacro{\ImageLeftHalfPage*\{..\}}
% %
%% \LEGACY %% Left half of image filling page with full bleed.
%%
%% Image left page spread with full bleed.
% %
%% >> \imageleftspreadfullbleed[<vertical-offset>]{<caption>}{<image>} %% >> \imageleftspreadfullbleed[<vertical-offset>]{<caption>}{<image>}
% %
@ -2654,43 +2657,28 @@
%% \end{verbatim} %% \end{verbatim}
%% \end{minipage} %% \end{minipage}
%% %%
\newcommand\imageleftspreadfullbleed[3][0mm]{ % XXX TEST...
\sbox{\photobook@imagebox}{ % XXX do a better default...
\includegraphics[ \ResettableMacro{ImageLeftHalfPageCaption}[1]{%
keepaspectratio, \captioncell[bottom, align=flushright]{%
width=\dimexpr \captionformat{#1}}}
2\blockwidth - 2\clearimage + \vgrowimageby \relax,]{#3} }
\clearpage % XXX add nudge/grow support...
\null \ImagePageTemplate{ImageLeftHalfPage}{%
\vfill \begin{spreadtopages*}[2]{photobook@ImageLeftHalfPage@cell}%
\begin{flushright} \imagecell[fill, clearance=\clearimage, #1]{#2}{#3}%
#2 \end{spreadtopages*}%
\end{flushright} %
\ShipoutPicture{ \cleartoleftpage%
\AtPageCenter{ \usespreadpage[1]{photobook@ImageLeftHalfPage@cell}}
\hspace{\dimexpr
\OFFSETFIX
-(\nudgeimageby)
+\clearimage
-0.5\blockwidth \relax}{
\raisebox{\dimexpr
(#1)
+\clearimage
-(0.5\blockheight
+(0.5\ht\photobook@imagebox - 0.5\blockheight))
- 0.5\vgrowimageby - \vnudgeimageby \relax}{
\usebox\photobook@imagebox } } } }
\newpage
\resetnudgeimage }
% XXX %% \DescribeMacro{\ImageRightHalfPage\{..\}}
% XXX \OFFSETFIX %% \DescribeMacro{\ImageRightHalfPageCaption\{..\}}
%% \DescribeMacro{\imagerightspreadfullbleed\{..\}} %% \DescribeMacro{\resetImageRightHalfPageCaption}
%% \DescribeMacro{\ImageRightHalfPage*\{..\}}
% %
%% \LEGACY %% Right half of image filling page with full bleed.
%%
%% Image spread right page with full bleed.
% %
%% >> \imagerightspreadfullbleed[<vertical-offset>]{<caption>}{<image>} %% >> \imagerightspreadfullbleed[<vertical-offset>]{<caption>}{<image>}
% %
@ -2714,37 +2702,20 @@
%% \end{verbatim} %% \end{verbatim}
%% \end{minipage} %% \end{minipage}
%% %%
\newcommand\imagerightspreadfullbleed[3][0mm]{ % XXX TEST...
\sbox{\photobook@imagebox}{ % XXX do a better default...
\includegraphics[ \ResettableMacro{ImageRightHalfPageCaption}[1]{%
keepaspectratio, \captioncell[bottom, align=flushright]{%
width=\dimexpr \captionformat{#1}}}
2\blockwidth - 2\clearimage + \vgrowimageby \relax,]{#3} }
\clearpage % XXX add nudge/grow support...
\null \ImagePageTemplate{ImageRightHalfPage}{%
\vfill \begin{spreadtopages*}[2]{photobook@ImageRightHalfPage@cell}%
% XXX for some reason the last line here is a bit off... \imagecell[fill, clearance=\clearimage, #1]{#2}{#3}%
% XXX do we need to restrict caption width here??? ...0.5\textwidth?? \end{spreadtopages*}%
% XXX make caption sizing a bit more flexible... %
\begin{flushright} \cleartoleftpage%
\captionsize #2 \usespreadpage[2]{photobook@ImageRightHalfPage@cell}}
\end{flushright}
\ShipoutPicture{
\AtPageCenter{
\hspace{\dimexpr
\OFFSETFIX
-(\nudgeimageby)
+\clearimage
-1.5\blockwidth \relax}{
\raisebox{\dimexpr
(#1)
+\clearimage
-(0.5\blockheight
+(0.5\ht\photobook@imagebox - 0.5\blockheight))
- 0.5\vgrowimageby - \vnudgeimageby \relax}{
\usebox\photobook@imagebox } } } }
\newpage
\resetnudgeimage }
@ -2904,14 +2875,14 @@
\newpage } \newpage }
%% \DescribeMacro{\imagespreadleft\{..\}} %% \DescribeMacro{\ImageSpreadLeft\{..\}}
%% \DescribeMacro{\imagespreadleftcaption\{..\}} %% \DescribeMacro{\ImageSpreadLeftCaption\{..\}}
%% \DescribeMacro{\resetimagespreadleftcaption} %% \DescribeMacro{\resetImageSpreadLeftCaption}
%% \DescribeMacro{\imagespreadleft*\{..\}} %% \DescribeMacro{\ImageSpreadLeft*\{..\}}
% %
%% Image spread aligned left (with bleed). %% Image spread aligned left (with bleed).
% %
%% >> \imagespreadleft[<clearence>]{<caption>}{<image>} %% >> \ImageSpreadLeft[<options>]{<caption>}{<image>}
% %
%% \begin{minipage}{\textwidth} %% \begin{minipage}{\textwidth}
%% \begin{verbatim} %% \begin{verbatim}
@ -2935,12 +2906,12 @@
%% %%
% XXX do a better default... % XXX do a better default...
% XXX need a caption box... % XXX need a caption box...
\ResettableMacro{imagespreadleftcaption}[1]{% \ResettableMacro{ImageSpreadLeftCaption}[1]{%
\vcaptioncell[after, align=flushleft]{% \vcaptioncell[after, align=flushleft]{%
\captionformat{#1}}} \captionformat{#1}}}
% XXX add nudge/grow support... % XXX add nudge/grow support...
\ImagePageTemplate{imagespreadleft}{% \ImagePageTemplate{ImageSpreadLeft}{%
\cleartoleftpage% \cleartoleftpage%
\begin{spreadtopages}[2]% \begin{spreadtopages}[2]%
\imagecell[fit, left, clearance=\clearimage, #1]{#2}{#3}% \imagecell[fit, left, clearance=\clearimage, #1]{#2}{#3}%
@ -2948,14 +2919,14 @@
% XXX % XXX
%% \DescribeMacro{\imagespreadright\{..\}} %% \DescribeMacro{\ImageSpreadRight\{..\}}
%% \DescribeMacro{\imagespreadrightcaption\{..\}} %% \DescribeMacro{\ImageSpreadRightCaption\{..\}}
%% \DescribeMacro{\resetimagespreadrightcaption} %% \DescribeMacro{\resetImageSpreadRightCaption}
%% \DescribeMacro{\imagespreadright*\{..\}} %% \DescribeMacro{\ImageSpreadRight*\{..\}}
% %
%% Image spread aligned right (with bleed). %% Image spread aligned right (with bleed).
% %
%% >> \imagespreadright[<options>]{<caption>}{<image>} %% >> \ImageSpreadRight[<options>]{<caption>}{<image>}
% %
%% \begin{minipage}{\textwidth} %% \begin{minipage}{\textwidth}
%% \begin{verbatim} %% \begin{verbatim}
@ -2979,26 +2950,26 @@
%% %%
% XXX need a caption box... % XXX need a caption box...
% XXX do a better default... % XXX do a better default...
\ResettableMacro{imagespreadrightcaption}[1]{% \ResettableMacro{ImageSpreadRightCaption}[1]{%
\vcaptioncell[before, align=flushleft]{% \vcaptioncell[before, align=flushleft]{%
\captionformat{#1}}} \captionformat{#1}}}
% XXX add nudge/grow support... % XXX add nudge/grow support...
\ImagePageTemplate{imagespreadright}{% \ImagePageTemplate{ImageSpreadRight}{%
\cleartoleftpage% \cleartoleftpage%
\begin{spreadtopages}[2]% \begin{spreadtopages}[2]%
\imagecell[fit, right, clearance=\clearimage, #1]{#2}{#3}% \imagecell[fit, right, clearance=\clearimage, #1]{#2}{#3}%
\end{spreadtopages}} \end{spreadtopages}}
%% \DescribeMacro{\imagespreadfill\{..\}} %% \DescribeMacro{\ImageSpreadFill\{..\}}
%% \DescribeMacro{\imagespreadfillcaption\{..\}} %% \DescribeMacro{\ImageSpreadFillCaption\{..\}}
%% \DescribeMacro{\resetimagespreadfillcaption} %% \DescribeMacro{\resetImageSpreadFillCaption}
%% \DescribeMacro{\imagespreadfill*\{..\}} %% \DescribeMacro{\ImageSpreadFill*\{..\}}
% %
%% Image spread with full bleed. %% Image spread with full bleed.
% %
%% >> \imagespreadfill[<options>]{<caption>}{<image>} %% >> \ImageSpreadFill[<options>]{<caption>}{<image>}
% %
%% \begin{minipage}{\textwidth} %% \begin{minipage}{\textwidth}
%% \begin{verbatim} %% \begin{verbatim}
@ -3022,12 +2993,12 @@
%% %%
% XXX do a better default... % XXX do a better default...
\ResettableMacro{imagespreadfillcaption}[1]{% \ResettableMacro{ImageSpreadFillCaption}[1]{%
\captioncell[bottom, align=flushright]{% \captioncell[bottom, align=flushright]{%
\captionformat{#1}}} \captionformat{#1}}}
% XXX add nudge/grow support... % XXX add nudge/grow support...
\ImagePageTemplate{imagespreadfill}{% \ImagePageTemplate{ImageSpreadFill}{%
\cleartoleftpage% \cleartoleftpage%
\begin{spreadtopages}[2]% \begin{spreadtopages}[2]%
\imagecell[fill, clearance=\clearimage, #1]{#2}{#3}% \imagecell[fill, clearance=\clearimage, #1]{#2}{#3}%