something broke, \imagepage{..} now complains allot -> replaced with new-style code...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-08-20 16:57:00 +03:00
parent 0ee2e5c33b
commit 97b422883d
2 changed files with 163 additions and 40 deletions

View File

@ -75,7 +75,6 @@
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%%%%% Page geometry %%%%% Page geometry
% %
%% \DescribeMacro{blockwidth=<len>} %% \DescribeMacro{blockwidth=<len>}
@ -121,7 +120,7 @@
% and \begin{document}... % and \begin{document}...
\DeclareStringOption{blockwidth} \DeclareStringOption{blockwidth}
\DeclareStringOption{blockheight} \DeclareStringOption{blockheight}
\DeclareStringOption[0]{bindingoffset}[10mm] \DeclareStringOption[0pt]{bindingoffset}[10mm]
\DeclareStringOption[5mm]{bleed}[5mm] \DeclareStringOption[5mm]{bleed}[5mm]
@ -571,6 +570,17 @@
\edef\imageblockwidth{\photobook@imageblockwidth} \edef\imageblockwidth{\photobook@imageblockwidth}
\edef\imageblockheight{\photobook@imageblockheight} \edef\imageblockheight{\photobook@imageblockheight}
%% \DescribeMacro{\pagetextwidth=<len>}
%% \DescribeMacro{\pagetextheight=<len>}
%
%% Root page text width/height.
%%
\newlength\pagetextwidth
\setlength\pagetextwidth{\textwidth}
\newlength\pagetextheight
\setlength\pagetextheight{\textheight}
%% \DescribeMacro{\imageblockoffsettop=<ratio>} %% \DescribeMacro{\imageblockoffsettop=<ratio>}
% %
%% %%
@ -741,8 +751,6 @@
%---------------------------------------------------------------------- %----------------------------------------------------------------------
% Setup... % Setup...
@ -800,6 +808,9 @@
vcentering, hcentering} vcentering, hcentering}
\fi \fi
\setlength\pagetextwidth{\textwidth}
\setlength\pagetextheight{\textheight}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - % - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% pdf boxes... % pdf boxes...
@ -950,14 +961,14 @@
% XXX workaround a problem with xelatex vs. lualatex... % XXX workaround a problem with xelatex vs. lualatex...
\ifxetex \ifxetex
\newcommand\ShipoutPicture[1]{ \newcommand\ShipoutPicture[1]{%
\AddToShipoutPicture*{#1}} \AddToShipoutPicture*{#1}}
\else \else
% XXX for some reason in pdflatex and lualatex \pagecolor{..} and % XXX for some reason in pdflatex and lualatex \pagecolor{..} and
% \AddToShipoutPicture*{..} start fighting over space... % \AddToShipoutPicture*{..} start fighting over space...
% XXX this draws over page numbers... % XXX this draws over page numbers...
\newcommand\ShipoutPicture[1]{ \newcommand\ShipoutPicture[1]{%
\AddToShipoutPictureFG*{#1}} \AddToShipoutPictureFG*{#1}}
\fi \fi
@ -1035,6 +1046,7 @@
\setlength\cellheight{\dimexpr #2 \relax}% \setlength\cellheight{\dimexpr #2 \relax}%
% %
\begin{minipage}[t][\cellheight][t]{\cellwidth}% \begin{minipage}[t][\cellheight][t]{\cellwidth}%
\ignorespaces%
}{% }{%
\end{minipage}% \end{minipage}%
\endgroup} \endgroup}
@ -1052,11 +1064,14 @@
% XXX SYNTAX: place the second arg in braces... % XXX SYNTAX: place the second arg in braces...
% \begin{cell}(<top>, <left>){<width>}{<height>} % \begin{cell}(<top>, <left>){<width>}{<height>}
\newenvironment{cell}[3]{% \newenvironment{cell}[3]{%
\begingroup%
\setlength\parindent{0em}%
\begin{textblock*}{#2}(#1)% \begin{textblock*}{#2}(#1)%
\begin{inlinecell}{#2}{#3}% \begin{inlinecell}{#2}{#3}%
}{% }{%
\end{inlinecell}% \end{inlinecell}%
\end{textblock*}} \end{textblock*}%
\endgroup}
% \DescribeMacro{\begin\{clipcell\}\{..\} ...} % \DescribeMacro{\begin\{clipcell\}\{..\} ...}
@ -1073,6 +1088,7 @@
\newenvironment{clipcell}[3]{% \newenvironment{clipcell}[3]{%
\begin{cell}{#1}{#2}{#3}% \begin{cell}{#1}{#2}{#3}%
\begin{cliptocell}% \begin{cliptocell}%
\ignorespaces%
}{% }{%
\end{cliptocell}% \end{cliptocell}%
\end{cell}} \end{cell}}
@ -1219,18 +1235,39 @@
%% its content and the whole image surface will be shown. If clipping is %% its content and the whole image surface will be shown. If clipping is
%% needed then use |clipcell| environment as a container. %% needed then use |clipcell| environment as a container.
%% %%
%% |<caption-cell>| is a cell that occupies the same space as the image %% \begin{minipage}{\textwidth}
%% clipped by the containing cell and provides all the cell functionality. %% \begin{verbatim}
%%
%% +-----------------+ - - caption cell size
%% . . .
%% +-----------------+ .
%% | | .
%% ..+-----------------+.. . +
%% . |.caption cell .| . |
%% . | . . | . |
%% . | . | . |
%% . | . . | . |
%% . |. .| . |
%% ..+-----------------+.. . +
%% | |
%% +-----------------+
%%
%% \end{verbatim}
%% \end{minipage}
%%
%% |<caption-cell>| occupies the same space as the image clipped by the
%% containing cell and provides all the cell functionality.
%% %%
% XXX TODO: % XXX TODO:
% - offset fix for fill mode... % - offset fix for fill mode...
% - caption cell in fill mode... % - caption cell in fill mode...
% - do we need to reverse left/right for fill? (feels counter-intuitive)
% XXX HACK -- need to track down where is this coming from and either % XXX HACK -- need to track down where is this coming from and either
% set it to zero or account for it correctly.... % set it to zero or account for it correctly....
% XXX RENAME -- make this global... % XXX RENAME -- make this global...
\newlength\photobook@HFIX \newlength\photobook@HOFFSETFIX
\setlength\photobook@HFIX{1.5pt} \setlength\photobook@HOFFSETFIX{1.5pt}
% XXX should these be lengths or macros??? % XXX should these be lengths or macros???
\def\photobook@imagecell@top{0pt} \def\photobook@imagecell@top{0pt}
@ -1248,25 +1285,25 @@
+0.5\cellheight +0.5\cellheight
-0.5\ht\photobook@imagebox \relax}% -0.5\ht\photobook@imagebox \relax}%
\def\photobook@imagecell@left{\dimexpr \def\photobook@imagecell@left{\dimexpr
+\photobook@HFIX +\photobook@HOFFSETFIX
+0.5\cellwidth +0.5\cellwidth
-0.5\wd\photobook@imagebox \relax}}% -0.5\wd\photobook@imagebox \relax}}%
% left/right... % left/right...
% shortdands... % shortdands...
\newcommand\photobook@imagecell@LEFT{% \newcommand\photobook@imagecell@LEFT{%
\def\photobook@imagecell@left{\dimexpr% \def\photobook@imagecell@left{\dimexpr%
+\photobook@HFIX +\photobook@HOFFSETFIX
+\photobook@imagecell@clearance \relax}}% +\photobook@imagecell@clearance \relax}}%
\newcommand\photobook@imagecell@RIGHT{% \newcommand\photobook@imagecell@RIGHT{%
\def\photobook@imagecell@left{\dimexpr \def\photobook@imagecell@left{\dimexpr
+\photobook@HFIX +\photobook@HOFFSETFIX
+\cellwidth +\cellwidth
-\photobook@imagecell@clearance -\photobook@imagecell@clearance
-\wd\photobook@imagebox \relax}}% -\wd\photobook@imagebox \relax}}%
% args... % args...
\define@boolkey{imagecell@args}{left}[true]{% \define@boolkey{imagecell@args}{left}[true]{%
\photobook@imagecell@LEFT} \photobook@imagecell@LEFT}
\define@boolkey{imagecell@args}{right}[true]{ \define@boolkey{imagecell@args}{right}[true]{%
\photobook@imagecell@RIGHT} \photobook@imagecell@RIGHT}
% inside/outside... % inside/outside...
\define@boolkey{imagecell@args}{inside}[true]{% \define@boolkey{imagecell@args}{inside}[true]{%
@ -1275,7 +1312,7 @@
}{% }{%
\photobook@imagecell@RIGHT}}% \photobook@imagecell@RIGHT}}%
\define@boolkey{imagecell@args}{outside}[true]{% \define@boolkey{imagecell@args}{outside}[true]{%
\ifthenelse{\isodd{\thepage}}{ \ifthenelse{\isodd{\thepage}}{%
\photobook@imagecell@RIGHT% \photobook@imagecell@RIGHT%
}{% }{%
\photobook@imagecell@LEFT}}% \photobook@imagecell@LEFT}}%
@ -1294,7 +1331,7 @@
% XXX can't seem to get rid of small placement errors... % XXX can't seem to get rid of small placement errors...
% ...feels like we've still got a stray space someplace... % ...feels like we've still got a stray space someplace...
% see: \photobook@HFIX % see: \photobook@HOFFSETFIX
% XXX can we make this an env??? % XXX can we make this an env???
\newcommand\imagecell[3][]{% \newcommand\imagecell[3][]{%
\begingroup% \begingroup%
@ -1311,7 +1348,7 @@
- ((\photobook@imagecell@clearance) * 2) \relax, - ((\photobook@imagecell@clearance) * 2) \relax,
height=\dimexpr height=\dimexpr
\cellheight \cellheight
- ((\photobook@imagecell@clearance) * 2) \relax]{#3}} - ((\photobook@imagecell@clearance) * 2) \relax]{#3}}%
% fill... % fill...
\else\ifKV@imagecell@args@fill% \else\ifKV@imagecell@args@fill%
% preload image to get its proportions... % preload image to get its proportions...
@ -1336,7 +1373,7 @@
\vspace{0pt}% \vspace{0pt}%
\adjustbox{% \adjustbox{%
margin= margin=
{\photobook@imagecell@left - \photobook@HFIX} {\photobook@imagecell@left - \photobook@HOFFSETFIX}
0pt 0pt 0pt 0pt
{\photobook@imagecell@top}}{% {\photobook@imagecell@top}}{%
% image.... % image....
@ -1351,16 +1388,14 @@
}{% }{%
\cellwidth - \photobook@imagecell@clearance}}{% \cellwidth - \photobook@imagecell@clearance}}{%
\setlength\cellwidth{\dimexpr% \setlength\cellwidth{\dimexpr%
-2\photobook@HFIX -2\photobook@HOFFSETFIX
+\mindim{\wd\photobook@imagebox}{\cellwidth} \relax}% +\mindim{\wd\photobook@imagebox}{\cellwidth} \relax}%
\setlength\cellheight{% \setlength\cellheight{%
\mindim{\ht\photobook@imagebox}{\cellheight}}% \mindim{\ht\photobook@imagebox}{\cellheight}}%
\setlength\fboxsep{0pt}% \setlength\fboxsep{0pt}%
%\fbox{
\begin{minipage}[b][\cellheight][t]{\cellwidth}% \begin{minipage}[b][\cellheight][t]{\cellwidth}%
#2% #2%
\end{minipage}}% \end{minipage}}%
%}%
\endgroup\fi}% \endgroup\fi}%
\endgroup} \endgroup}
@ -1368,8 +1403,39 @@
% XXX add support for boolkeys: % XXX add support for boolkeys:
% - left/right/top/bottom % - left/right/top/bottom
% - inside/outside % - inside/outside
% - topdown/bottomup % - up/down (vertical text)
%\newcommand\captioncell[2][]{} % or
% - over/under/before/after
% - top/bottom/left/right
% - align=left/right/up/down
% XXX revise keywords...
\define@boolkey{captioncell@args}{left}[true]{}
\define@boolkey{captioncell@args}{right}[true]{}
\define@boolkey{captioncell@args}{top}[true]{}
\define@boolkey{captioncell@args}{bottom}[true]{}
\define@boolkey{captioncell@args}{inside}[true]{%
\KV@captioncell@args@outsidefalse}
\define@boolkey{captioncell@args}{outside}[true]{%
\KV@captioncell@args@insidefalse}
\define@boolkey{captioncell@args}{up}[true]{%
\KV@captioncell@args@downfalse}
\define@boolkey{captioncell@args}{down}[true]{%
\KV@captioncell@args@upfalse}
\newcommand\captioncell[2][]{%
\setkeys{captioncell@args}{top,left,inside,#1}%
% XXX
}
% XXX HACK -- make over/under/... an argument...
\newcommand\captioncellunder[1]{
\vspace{\cellheight}%
\begin{flushright}%
\captionformat{%
\adjustbox{margin=0pt 0.5em}{#1}}%
\end{flushright}}
%% \DescribeMacro{\cimagetocellfit\{..\}} %% \DescribeMacro{\cimagetocellfit\{..\}}
@ -1401,13 +1467,7 @@
% XXX do we need this??? % XXX do we need this???
% XXX revise caption for vertical images... % XXX revise caption for vertical images...
\newcommand\cimagetocellfit[3][0mm]{% \newcommand\cimagetocellfit[3][0mm]{%
\imagecell[center, clearance=#1]{% \imagecell[center, clearance=#1]{\captioncellunder{#2}}{#3}}
\vspace{\cellheight}%
\begin{flushright}%
\captionformat{%
\adjustbox{margin=0.5em}{#2}}%
\end{flushright}}{#3}}
% XXX like fill but trim to cell... % XXX like fill but trim to cell...
@ -1476,7 +1536,7 @@
%% %%
% XXX % XXX
\newenvironment{pagecell}{% \newenvironment{pagecell}{%
\begin{cell}{\bleed, \bleed}{\pageblockwidth}{\pageblockheight}% \begin{cell}{\bleed,\bleed}{\pageblockwidth}{\pageblockheight}%
}{% }{%
\end{cell}} \end{cell}}
@ -1512,7 +1572,7 @@
% XXX EXPERIMENTAL % XXX EXPERIMENTAL
%% \DescribeEnv{pagebleedcell} %% \DescribeEnv{textcell}
% %
%% A cell taking up the page text block. %% A cell taking up the page text block.
% %
@ -1790,12 +1850,6 @@
%---------------------------------------------------------------------- %----------------------------------------------------------------------
%%%% Captions %%%% Captions
% XXX need to be able to configure/pass/override: % XXX need to be able to configure/pass/override:
@ -1952,6 +2006,10 @@
\vfill \vfill
% caption... % caption...
\ShipoutPicture{ \ShipoutPicture{
% XXX for some magical reason \vfill here makes latex err
% "Missing } inserted", removing it fixes the error but breaks
% captions...
% ...also adding a '}' here does not break things...
\vfill \vfill
\vspace{ \dimexpr \vspace{ \dimexpr
% XXX this is not accurate for some reason... % XXX this is not accurate for some reason...
@ -2017,10 +2075,32 @@
%% \end{verbatim} %% \end{verbatim}
%% \end{minipage} %% \end{minipage}
%% %%
\newcommand\imagepage[2]{ \newcommand\imagepageO[2]{
\imagepagefitWH{\imageblockwidth}{\imageblockheight}{#1}{#2} } \imagepagefitWH{\imageblockwidth}{\imageblockheight}{#1}{#2} }
% XXX this is not yet 100% the same as \imagepage{..}
% - vertical offset seems not to match (not sure who's fault is it)...
% XXX needs caption...
\newcommand\imagepage[2]{%
\begin{page}%
\begin{pagecell}%
\begin{minipage}[t][\cellheight][c]{\cellwidth}%
\vspace{\imageblockoffsettop\pagetextheight}%
\begin{center}%
\hspace{\ifnumodd{\thepage}{\bindingoffset}{-\bindingoffset}}{%
\begin{inlinecell}%
{\imageblockwidth\pagetextwidth}%
{\imageblockheight\pagetextheight}%
\imagecell[fit]{\captioncellunder{#1}}{#2}%
\end{inlinecell}}%
\end{center}%
\end{minipage}%
\end{pagecell}%
\end{page}}
% XXX % XXX
% XXX captions wrong... % XXX captions wrong...
%% \DescribeMacro{\imagepagefit\{..\}} %% \DescribeMacro{\imagepagefit\{..\}}

View File

@ -0,0 +1,43 @@
%----------------------------------------------------------------------
\documentclass[
layoutmode=block,
% page size...
blockwidth=240mm, blockheight=220mm,
bleed=4mm,
bindingoffset=5mm,
% image block configuration...
imageblockwidth=0.98, imageblockheight=0.98,
imageblockoffsettop=-0,
% misc...
9pt,final,openany
]{photobook}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\begin{document}
%\TPoptions{showboxes=true}
\null
\newpage
\def\imageblockwidth{1}
\def\imageblockheight{1}
\imagepage{Caption}{DSC00403-2}
\imagepage{Caption}{DSC00403-2}
\imagepage{Caption}{DSC00403-2vert}
%\imagepage{Caption}{DSC00403-2}
%\imagepage{}{DSC00403-2vert}
\end{document}
%----------------------------------------------------------------------
% vim:set ts=4 sw=4 :