summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/photobook/photobook.cls
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/photobook/photobook.cls')
-rw-r--r--macros/latex/contrib/photobook/photobook.cls92
1 files changed, 66 insertions, 26 deletions
diff --git a/macros/latex/contrib/photobook/photobook.cls b/macros/latex/contrib/photobook/photobook.cls
index a2a84809e8..ae2ecac6b6 100644
--- a/macros/latex/contrib/photobook/photobook.cls
+++ b/macros/latex/contrib/photobook/photobook.cls
@@ -38,6 +38,7 @@
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
+%
% XXX ASAP: imagecell: photobook@imagecell@left and photobook@imagecell@top
% should explicitly account for clearence@left and clearence@top resp.
% XXX ASAP: imagecell: clearance should have the same semantics as cliptocell
@@ -88,12 +89,25 @@
% cell/cell* depend on absolute mode being set globally
%
%
+% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+%
+% Work around an issue with calc's \ratio{..}{..} breaking into an
+% "Arythmetic overflow" when working with large images.
+% (see Issues section for more info)
+%
+% NOTE: if the error persists just make this smaller but note that the
+% smaller this gets the greater the error can be for very small
+% images
+%
+\def\CalcOverflowFactor{0.1}%
+
+
%----------------------------------------------------------------------
%%% NOTE: \def\<module-name>@[A-Z]+ macros will be visible to both the
%%% code and the generated docs...
-\edef\photobook@FILEVERSION{v0.1.29}
-\edef\photobook@FILEDATE{2023-08-24}
+\edef\photobook@FILEVERSION{v0.1.31}
+\edef\photobook@FILEDATE{2024-07-19}
%% \documentclass{ltxdoc}
@@ -248,26 +262,27 @@
%% \begin{minipage}{\textwidth}
%% \begin{verbatim}
%%
+%% <-------------------------------------------------> paperwidth
%% <---> bleed <---> bleed
-%%
-%% + - - - - - - - - - - - - - - - - - - - - - - + - + ^
-%% . . . | bleed
-%% . +-----------------------------------------+----- v . . ---
-%% . | ^ . . = .
-%% . | . . . . . . | . . . = . ^
-%% . |<-- blockwidth ------------------------->= . |
-%% . | . | . . . = . |
-%% . | | . . = . textheight
-%% . | . Page | . . . = . |
-%% . | blockheight . . = . |
-%% . | . | . . <--> bindingoffset |
-%% . | | . . = . |
-%% . | . . . . . . | . <--> gutteroffset v
-%% . | v . . = .
-%% . +-----------------------------------------+----- ^ . . ---
-%% . . . . | bleed
-%% + - - - - - - - - - - - - - - - - - - - - - - + - + v
-%% . .
+%% paperheight v
+%% + - - - - - - - - - - - - - - - - - - - - - - + - + ^ . . . ---
+%% . . . | bleed .
+%% . +-----------------------------------------+----- v . . ---
+%% . | ^ . . = . .
+%% . | . . . . . . | . . . = . ^
+%% . |<-- blockwidth ------------------------->= . | .
+%% . | . | . . . = . |
+%% . | | . . = . textheight .
+%% . | . Page | . . . = . |
+%% . | blockheight . . = . | .
+%% . | . | . . <--> bindingoffset |
+%% . | | . . = . | .
+%% . | . . . . . . | . <--> gutteroffset v
+%% . | v . . = . .
+%% . +-----------------------------------------+----- ^ . . ---
+%% . . . . | bleed .
+%% + - - - - - - - - - - - - - - - - - - - - - - + - + v . . . ---
+%% . . ^
%% | <-- textwidth --------------> . |
%% ^ gutter
%%
@@ -278,6 +293,9 @@
%% account for |\gutteroffset|, namely macros that do not display content
%% with bleeds.
%%
+%% Also note that bleeds are included in \href{https://ctan.org/pkg/geometry}{geometry}'s
+%% |\paperwidth| and |\paperheight|.
+%%
% NOTE: if blockwidth/blockheight are set they will force recalculations
% and overriding of the paperwidth/paperheight if they were changed
% by the user code anywhere between \documentclass[..]{photobook}
@@ -917,7 +935,7 @@
%% \DescribeMacro{\imageblockoffsettop=<ratio>}
%
-%% The ration by which the image is raised in |\ImagePage{..}| and
+%% The ratio by which the image is raised in |\ImagePage{..}| and
%% derived templates.
%%
\edef\imageblockoffsettop{\photobook@imageblockoffsettop}
@@ -2515,8 +2533,9 @@
% NOTE: here we calculate image/cell eccentricity to decide
% to fit to width or heigh of cell...
% NOTE: did I say that I "love" how LaTeX does basic math??
+ % NOTE: \ratio{..}{..} here can break, see Issues for more info...
\setlength\photobook@imagecell@imgratio{%
- 1pt * \ratio{\wd\photobook@imagebox}{\ht\photobook@imagebox}}%
+ 1pt * \ratio{\CalcOverflowFactor\wd\photobook@imagebox}{\CalcOverflowFactor\ht\photobook@imagebox}}%
\setlength\photobook@imagecell@cellratio{%
1pt * \ratio{\cellwidth}{\cellheight}}%
\ifdim \photobook@imagecell@imgratio < \photobook@imagecell@cellratio%
@@ -2524,7 +2543,7 @@
\includegraphics[%
keepaspectratio,
width=\photobook@imagecell@scale\dimexpr
- + \cellwidth
+ \cellwidth
- \photobook@imagecell@clearance@left
- \photobook@imagecell@clearance@right \relax]{#3}}%
\else%
@@ -2532,7 +2551,7 @@
\includegraphics[%
keepaspectratio,
height=\photobook@imagecell@scale\dimexpr
- + \cellheight
+ \cellheight
- \photobook@imagecell@clearance@top
- \photobook@imagecell@clearance@bottom \relax]{#3}}%
\fi\fi\fi%
@@ -4848,8 +4867,9 @@
% align center -> check if image fits vertically...
\ifphotobook@ImagePageFit@centered\else%
\sbox{\photobook@imagebox}{\includegraphics{#3}}%
+ % NOTE: \ratio{..}{..} here can break, see Issues for more info...
\setlength\photobook@ImagePageFit@imgratio{%
- 1pt * \ratio{\wd\photobook@imagebox}{\ht\photobook@imagebox}}%
+ 1pt * \ratio{\CalcOverflowFactor\wd\photobook@imagebox}{\CalcOverflowFactor\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...
@@ -5692,6 +5712,26 @@
%----------------------------------------------------------------------
+%%%% Issues
+%
+%% \subsection*{Large images can cause "Arythmetic overflow"}
+%
+%% \DescribeMacro{\CalcOverflowFactor=0.1}
+%
+%% If the issue occurs set |\CalcOverflowFactor| to a smaller value.
+%% But note, a value too small can lead to errors in the affected macros,
+%% a good value is between 0.1 and 0.01.
+%%
+%% Also note that it is recommended to pre-size images the print outside
+%% of \LaTeX.
+%%
+%% Affected macros: |\imagecell[fill]{..}{..}|, |\ImagePageFit|.
+%%
+% The issue occurs in the calc's |\ratio{..}{..}| macro when calculating
+% image proportions.
+%
+%
+%----------------------------------------------------------------------
% Index...
%
% XXX this prints trash at this point...