started polishing templates...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-09-08 04:37:44 +03:00
parent b7602acb30
commit 91819739e0
2 changed files with 127 additions and 40 deletions

View File

@ -1365,16 +1365,16 @@
% %
%% Create a basic absolutely positioned cell. %% Create a basic absolutely positioned cell.
% %
%% >> \begin{cell}{<top>, <left>}{<width>}{<height>} ... \end{cell} %% >> \begin{cell}{<left>, <top>}{<width>}{<height>} ... \end{cell}
% %
%% Oversized content will be clipped. %% Oversized content will be clipped.
%% %%
%% |cell*| is just like |cell| but will not clip its content. %% |cell*| is just like |cell| but will not clip its content.
% %
%% >> \begin{cell*}{<top>, <left>}{<width>}{<height>} ... \end{cell*} %% >> \begin{cell*}{<left>, <top>}{<width>}{<height>} ... \end{cell*}
%% %%
% XXX SYNTAX: place the second arg in braces... % XXX SYNTAX: place the second arg in braces...
% \begin{cell*}(<top>, <left>){<width>}{<height>} % \begin{cell*}(<left>, <top>){<width>}{<height>}
\newenvironment{cell*}[3]{% \newenvironment{cell*}[3]{%
\readlist*\photobook@cell@offset{#1}% \readlist*\photobook@cell@offset{#1}%
% %
@ -1730,7 +1730,7 @@
\photobook@imagecell@RIGHT} \photobook@imagecell@RIGHT}
% inside/outside... % inside/outside...
\define@boolkey{imagecell@args}{inside}[true]{% \define@boolkey{imagecell@args}{inside}[true]{%
\ifthenelse{\isodd{\thepage}}{ \ifthenelse{\isodd{\thepage}}{%
\photobook@imagecell@LEFT% \photobook@imagecell@LEFT%
}{% }{%
\photobook@imagecell@RIGHT}}% \photobook@imagecell@RIGHT}}%
@ -1742,8 +1742,8 @@
% top/bottom... % top/bottom...
\define@boolkey{imagecell@args}{top}[true]{% \define@boolkey{imagecell@args}{top}[true]{%
\def\photobook@imagecell@top{% \def\photobook@imagecell@top{%
\photobook@imagecell@clearance} \photobook@imagecell@clearance}%
\def\photobook@imagecell@captiontop{ \def\photobook@imagecell@captiontop{%
-\dimexpr -\dimexpr
+\cellheight +\cellheight
-\photobook@imagecell@clearance -\photobook@imagecell@clearance
@ -1752,7 +1752,7 @@
\def\photobook@imagecell@top{\dimexpr \def\photobook@imagecell@top{\dimexpr
+\cellheight +\cellheight
-\photobook@imagecell@clearance -\photobook@imagecell@clearance
-\ht\photobook@imagebox \relax} -\ht\photobook@imagebox \relax}%
\def\photobook@imagecell@captiontop{% \def\photobook@imagecell@captiontop{%
\photobook@imagecell@top}}% \photobook@imagecell@top}}%
% clearance=<len>... % clearance=<len>...
@ -1777,7 +1777,7 @@
% captionalign=t|c|b... % captionalign=t|c|b...
\def\photobook@imagecell@captionalign{t} \def\photobook@imagecell@captionalign{t}
\define@choicekey{imagecell@args}{captionalign}{t,c,b}[t]{% \define@choicekey{imagecell@args}{captionalign}{t,c,b}[t]{%
\def\photobook@imagecell@captionalign{#1}}% \def\photobook@imagecell@captionalign{#1}}
% XXX add offset support... % XXX add offset support...
% ...i.e. an argument that will shift the image v/h from base position. % ...i.e. an argument that will shift the image v/h from base position.
@ -1787,13 +1787,14 @@
\newcommand\imagecell[3][]{% \newcommand\imagecell[3][]{%
\begingroup% \begingroup%
% args... % args...
\setkeys{imagecell@args}{ \setkeys{imagecell@args}{%
fit, fit,
center, center,
clearance=0pt, clearance=0pt,
#1}% #1}%
% preload image... % preload image...
% fit... % fit...
% XXX make this respect \bindingoffset when \clearance > 0...
\ifKV@imagecell@args@fit% \ifKV@imagecell@args@fit%
\sbox{\photobook@imagebox}{% \sbox{\photobook@imagebox}{%
\includegraphics[% \includegraphics[%
@ -1816,7 +1817,7 @@
* \ratio{\wd\photobook@imagebox}{\ht\photobook@imagebox}} * \ratio{\wd\photobook@imagebox}{\ht\photobook@imagebox}}
\setlength\photobook@imagecell@cellratio{1pt \setlength\photobook@imagecell@cellratio{1pt
* \ratio{\cellwidth}{\cellheight}} * \ratio{\cellwidth}{\cellheight}}
\ifdim \photobook@imagecell@imgratio < \photobook@imagecell@cellratio \ifdim \photobook@imagecell@imgratio < \photobook@imagecell@cellratio%
\sbox{\photobook@imagebox}{% \sbox{\photobook@imagebox}{%
\includegraphics[% \includegraphics[%
keepaspectratio, keepaspectratio,
@ -1835,7 +1836,6 @@
% XXX for some odd reason without this the alignment completely breaks... % XXX for some odd reason without this the alignment completely breaks...
\vspace{0pt}% \vspace{0pt}%
\adjustbox{% \adjustbox{%
%margin={\photobook@imagecell@left} 0pt 0pt {\photobook@imagecell@top}}{%
margin= margin=
{\dimexpr {\dimexpr
\photobook@imagecell@offsetleft \photobook@imagecell@offsetleft
@ -1958,6 +1958,7 @@
%% in the same cell that takes up space, e.g. text, pictures, ...etc. %% in the same cell that takes up space, e.g. text, pictures, ...etc.
%% Captions are mainly suited to play well with image cells. %% Captions are mainly suited to play well with image cells.
%% %%
% XXX make captions clear left/right of page...
% XXX need a way to make caption boxes independent of other cell content... % XXX need a way to make caption boxes independent of other cell content...
% ...two ways to do this that come to mind: % ...two ways to do this that come to mind:
% - place cell content into a 0-space cell % - place cell content into a 0-space cell
@ -2053,6 +2054,7 @@
%% %%
%% See samples for better illustration. %% See samples for better illustration.
%% %%
% XXX make captions clear top/bottom of page...
% bottomup / topdown... % bottomup / topdown...
\def\photobook@vcaptioncell@orientation{bottomup} \def\photobook@vcaptioncell@orientation{bottomup}
\define@boolkey{vcaptioncell@args}{bottomup}[true]{% \define@boolkey{vcaptioncell@args}{bottomup}[true]{%
@ -2177,6 +2179,7 @@
%% \end{verbatim} %% \end{verbatim}
%% \end{minipage} %% \end{minipage}
%% %%
% XXX make captions clear top/bottom of page...
% XXX add cell spacing... % XXX add cell spacing...
% XXX need to do a caption block -- a cell to one side of an image to the % XXX need to do a caption block -- a cell to one side of an image to the
% end of the page... % end of the page...
@ -2319,6 +2322,7 @@
%%%%% Page cells %%%%% Page cells
%% \DescribeEnv{pagecell} %% \DescribeEnv{pagecell}
%% \DescribeEnv{pagecell*}
% %
%% Page cell. %% Page cell.
%% %%
@ -2343,6 +2347,8 @@
%% \end{verbatim} %% \end{verbatim}
%% \end{minipage} %% \end{minipage}
%% %%
%% The star version accounts for |\bindingoffset|.
%%
%% Note that |layoutmode|'s other than block will change the paper size %% Note that |layoutmode|'s other than block will change the paper size
%% but will not affect this. %% but will not affect this.
%% %%
@ -2351,6 +2357,15 @@
}{% }{%
\end{cell*}} \end{cell*}}
\newenvironment{pagecell*}{%
\begin{cell*}{%
\bleed + \ifnumodd{\thepage}{\bindingoffset}{0pt}%
,\bleed}%
{\pageblockwidth - \bindingoffset}%
{\pageblockheight}%
}{%
\end{cell*}}
%% \DescribeEnv{pagebleedcell} %% \DescribeEnv{pagebleedcell}
% %
@ -2929,23 +2944,22 @@
\captionformat{#1}}} \captionformat{#1}}}
\ImagePageTemplate{ImagePage}{% \ImagePageTemplate{ImagePage}{%
\clearpage%
\begin{page}% \begin{page}%
\begin{pagecell}% \begin{pagecell*}%
\begin{minipage}[t][\cellheight][c]{\cellwidth}% \begin{minipage}[t][\cellheight][c]{\cellwidth}%
\vspace{\imageblockoffsettop\pagetextheight}% \vspace{\imageblockoffsettop\pagetextheight}%
\begin{center}% \begin{center}%
% compensate for \bindingoffset... \begin{inlinecell*}%
\hspace{\ifnumodd{\thepage}{\bindingoffset}{-\bindingoffset}}{% {\imageblockwidth\pagetextwidth}%
\begin{inlinecell*}% {\imageblockheight\pagetextheight}%
{\imageblockwidth\pagetextwidth}% \imagecell[fit,
{\imageblockheight\pagetextheight}% scale=\imagescale,
\imagecell[fit, #1]{#2}{#3}%
scale=\imagescale, \end{inlinecell*}%
#1]{#2}{#3}%
\end{inlinecell*}}%
\end{center}% \end{center}%
\end{minipage}% \end{minipage}%
\end{pagecell}% \end{pagecell*}%
\end{page}} \end{page}}
@ -2978,14 +2992,17 @@
%% %%
%% Default image clearance is set by |\clearimage| global length. %% Default image clearance is set by |\clearimage| global length.
%% %%
%% This respects |\bindingoffset|.
%%
% XXX make captions adaptive??? % XXX make captions adaptive???
\ResettableMacro{ImagePageClearCaption}[1]{% \ResettableMacro{ImagePageClearCaption}[1]{%
\captioncell[under, align=flushright]{% \captioncell[under, align=flushright]{%
\captionformat{#1}}} \captionformat{#1}}}
\ImagePageTemplate{ImagePageClear}{% \ImagePageTemplate{ImagePageClear}{%
\clearpage%
\begin{page}% \begin{page}%
\begin{pagecell}% \begin{pagecell*}%
\imagecell[% \imagecell[%
center, center,
clearance=\clearimage, clearance=\clearimage,
@ -2993,7 +3010,7 @@
offsettop=\imageoffsettop, offsettop=\imageoffsettop,
offsetleft=\imageoffsetleft, offsetleft=\imageoffsetleft,
#1]{#2}{#3}% #1]{#2}{#3}%
\end{pagecell}% \end{pagecell*}%
\end{page}} \end{page}}
@ -3035,17 +3052,18 @@
%% \end{verbatim} %% \end{verbatim}
%% \end{minipage} %% \end{minipage}
%% %%
% TEST... % XXX TEST...
\ResettableMacro{ImagePageClearTCaption}[1]{% \ResettableMacro{ImagePageClearTCaption}[1]{%
\captioncell[under, align=flushright]{% \captioncell[under]{%
\captionformat{#1}}} \captionformat{#1}}}
% XXX the image seems to be a line too low...
\ImagePageTemplate{ImagePageClearT}{% \ImagePageTemplate{ImagePageClearT}{%
\ImagePageClear*[% \ImagePageClear*[%
top, top,
#1]{#2}{#3}} #1]{#2}{#3}}
\ResettableMacro{ImagePageClearBCaption}[1]{% \ResettableMacro{ImagePageClearBCaption}[1]{%
\captioncell[over, align=flushright]{% \captioncell[over]{%
\captionformat{#1}}} \captionformat{#1}}}
\ImagePageTemplate{ImagePageClearB}{% \ImagePageTemplate{ImagePageClearB}{%
\ImagePageClear*[% \ImagePageClear*[%
@ -3104,19 +3122,68 @@
%% %%
%% Default image clearance is set by |\bleed| global length. %% Default image clearance is set by |\bleed| global length.
%% %%
%% If centered image fits vertically this will account for |\bindingoffset|.
%%
% 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}}}
\newif\ifphotobook@ImagePageFit@centered
\photobook@ImagePageFit@centeredfalse
\newlength\photobook@ImagePageFit@imgratio
\newlength\photobook@ImagePageFit@cellratio
\def\photobook@ImagePageFit@opt{}
\def\photobook@ImagePageFit@args{}
\ImagePageTemplate{ImagePageFit}{% \ImagePageTemplate{ImagePageFit}{%
\ImagePageClear*[% \begingroup%
clearance=-\bleed, % see if default alignment is overridden...
#1]{#2}{#3}} \ignoreemptyitems%
\readlist*\photobook@ImagePageFit@args{moo, #1}%
\foreachitem\photobook@ImagePageFit@opt\in\photobook@ImagePageFit@args{%
% XXX add top/bottom versions... \ifthenelse{\equal{\photobook@ImagePageFit@opt}{top}}{%
% ....and combine docs... \photobook@ImagePageFit@centeredtrue}{}
\ifthenelse{\equal{\photobook@ImagePageFit@opt}{left}}{%
\photobook@ImagePageFit@centeredtrue}{}
\ifthenelse{\equal{\photobook@ImagePageFit@opt}{bottom}}{%
\photobook@ImagePageFit@centeredtrue}{}
\ifthenelse{\equal{\photobook@ImagePageFit@opt}{right}}{%
\photobook@ImagePageFit@centeredtrue}{}}
% align center -> check if image fits vertically...
\ifphotobook@ImagePageFit@centered\else%
\sbox{\photobook@imagebox}{\includegraphics{#3}}%
\setlength\photobook@ImagePageFit@imgratio{1pt
* \ratio{\wd\photobook@imagebox}{\ht\photobook@imagebox}}%
% NOTE: subtracting \bindingoffset from \cellwidth here makes sure that
% we avoid offsetting images close enough in ratio to the page and
% messing up bleeds...
\setlength\photobook@ImagePageFit@cellratio{1pt
* \ratio{\cellwidth - \bindingoffset}{\cellheight}}%
\ifdim \photobook@ImagePageFit@imgratio > \photobook@ImagePageFit@cellratio%
\photobook@ImagePageFit@centeredtrue\fi\fi%
%
% ignore \bindingoffset -> center the image...
\ifphotobook@ImagePageFit@centered%
\clearpage%
\begin{page}%
\begin{pagecell}%
\imagecell[%
center,
clearance=-\bleed,
scale=\imagescale,
offsettop=\imageoffsettop,
offsetleft=\imageoffsetleft,
#1]{#2}{#3}%
\end{pagecell}%
\end{page}%
% special case: centered vertical image -> account for \bindingoffset...
\else%
\ImagePageClear*[%
clearance=-\bleed,
#1]{#2}{#3}\fi%
\endgroup}
%% \DescribeMacro{\ImagePageFit<D>\{..\}} %% \DescribeMacro{\ImagePageFit<D>\{..\}}
@ -3161,9 +3228,8 @@
%% \end{verbatim} %% \end{verbatim}
%% \end{minipage} %% \end{minipage}
%% %%
% XXX TEST...
\ResettableMacro{ImagePageFitTCaption}[1]{% \ResettableMacro{ImagePageFitTCaption}[1]{%
\captionblockcell[under]{% \captioncell[under]{%
\captionformat{#1}}} \captionformat{#1}}}
\ImagePageTemplate{ImagePageFitT}{% \ImagePageTemplate{ImagePageFitT}{%
\ImagePageFit*[% \ImagePageFit*[%
@ -3173,6 +3239,7 @@
\ResettableMacro{ImagePageFitBCaption}[1]{% \ResettableMacro{ImagePageFitBCaption}[1]{%
\captioncell[over]{% \captioncell[over]{%
\captionformat{#1}}} \captionformat{#1}}}
% XXX the image seems a bit too low...
\ImagePageTemplate{ImagePageFitB}{% \ImagePageTemplate{ImagePageFitB}{%
\ImagePageFit*[% \ImagePageFit*[%
bottom, bottom,
@ -3285,7 +3352,7 @@
#1]{#2}{#3}% #1]{#2}{#3}%
\end{spreadtopages*}% \end{spreadtopages*}%
% %
\cleartoleftpage% \clearpage%
\usespreadpage[1]{photobook@ImageHalfPageL@cell}} \usespreadpage[1]{photobook@ImageHalfPageL@cell}}
@ -3336,7 +3403,7 @@
#1]{#2}{#3}% #1]{#2}{#3}%
\end{spreadtopages*}% \end{spreadtopages*}%
% %
\cleartoleftpage% \clearpage%
\usespreadpage[2]{photobook@ImageHalfPageR@cell}} \usespreadpage[2]{photobook@ImageHalfPageR@cell}}
@ -3700,6 +3767,24 @@
\end{page}} \end{page}}
%% \DescribeMacro{\pdfmargincomment\{..\}}
%
%% Add pdf comment as overlay.
%%
%% >> \pdfmargincomment{<comment>}
%%
\newcommand{\pdfmargincomment}[1]{%
\begin{cell*}{
\ifnumodd{\thepage}{%
\cellwidth - \marginparwidth - 2\bleed - 1cm
}{%
\bleed + 1cm},
\bleed + 1cm
}{\marginparwidth}{1pt}%
\pdfcomment{#1}%
\end{cell*}}
%% \DescribeMacro{\pdfpagecount\{..\}} %% \DescribeMacro{\pdfpagecount\{..\}}
% %
%% Get pdf page count %% Get pdf page count

View File

@ -132,6 +132,8 @@ printhelp(){
echo "Environment:" echo "Environment:"
echo " \$IMAGE_HIRES_DIR " echo " \$IMAGE_HIRES_DIR "
echo " - source directory for replacement hi-res images." echo " - source directory for replacement hi-res images."
echo " \$ANOTATE_IMAGE_PATHS "
echo " - if true add image paths in anotations."
echo echo
echo "Configuration defaults can be stored in a config file: $CFG_FILE" echo "Configuration defaults can be stored in a config file: $CFG_FILE"
echo echo
@ -189,6 +191,7 @@ else
fi fi
# calculate spread index range...
# XXX add support for negative indexing... # XXX add support for negative indexing...
FROM=$2 FROM=$2
COUNT=$( [ -z $3 ] && echo 1 || echo $3 ) COUNT=$( [ -z $3 ] && echo 1 || echo $3 )
@ -213,7 +216,6 @@ getCaption(){
echo ${C[*]} echo ${C[*]}
} }
getTemplate(){ getTemplate(){
local SPREAD=$1 local SPREAD=$1
local TYPE=$2 local TYPE=$2
@ -240,7 +242,7 @@ anotatePath(){
# NOTE: did not figure out how to make a verbatim comment in latex # NOTE: did not figure out how to make a verbatim comment in latex
# so here we are, doing it in shell... # so here we are, doing it in shell...
path=${path//_/\\_} path=${path//_/\\_}
echo "\\marginpar{\\pdfcomment{Image: $path}}" echo "\\pdfmargincomment{Image: $path}%"
} }