mirror of
https://github.com/flynx/photobook.git
synced 2025-10-29 10:20:08 +00:00
fixed caption cell positioning for all alignment and fit/fill modes... (hopefully)
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
353500d64d
commit
bc79b6ecb6
102
photobook.cls
102
photobook.cls
@ -1263,15 +1263,12 @@
|
|||||||
% - 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)
|
% - 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
|
|
||||||
% set it to zero or account for it correctly....
|
|
||||||
% XXX RENAME -- make this global...
|
|
||||||
\newlength\photobook@HOFFSETFIX
|
|
||||||
\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}
|
||||||
\def\photobook@imagecell@left{0pt}
|
\def\photobook@imagecell@left{0pt}
|
||||||
|
\def\photobook@imagecell@captiontop{0pt}
|
||||||
|
\def\photobook@imagecell@captionleft{0pt}
|
||||||
|
|
||||||
\newlength\photobook@imagecell@clearance
|
\newlength\photobook@imagecell@clearance
|
||||||
\setlength\photobook@imagecell@clearance{0pt}
|
\setlength\photobook@imagecell@clearance{0pt}
|
||||||
@ -1287,21 +1284,30 @@
|
|||||||
+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@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@HOFFSETFIX
|
+\photobook@imagecell@clearance \relax}%
|
||||||
+\photobook@imagecell@clearance \relax}}%
|
\def\photobook@imagecell@captionleft{
|
||||||
|
% XXX not sure why this branch is needed...
|
||||||
|
\ifKV@imagecell@args@fit
|
||||||
|
0pt
|
||||||
|
\else%
|
||||||
|
\dimexpr%
|
||||||
|
+\cellwidth
|
||||||
|
-\photobook@imagecell@clearance
|
||||||
|
-\wd\photobook@imagebox \relax\fi}}%
|
||||||
\newcommand\photobook@imagecell@RIGHT{%
|
\newcommand\photobook@imagecell@RIGHT{%
|
||||||
\def\photobook@imagecell@left{\dimexpr
|
\def\photobook@imagecell@left{\dimexpr
|
||||||
+\photobook@HOFFSETFIX
|
|
||||||
+\cellwidth
|
+\cellwidth
|
||||||
-\photobook@imagecell@clearance
|
-\photobook@imagecell@clearance
|
||||||
-\wd\photobook@imagebox \relax}}%
|
-\wd\photobook@imagebox \relax}
|
||||||
|
% XXX not sure why 0.5 but it seems to work...
|
||||||
|
\def\photobook@imagecell@captionleft{%
|
||||||
|
-0.5\photobook@imagecell@left}}%
|
||||||
% args...
|
% args...
|
||||||
\define@boolkey{imagecell@args}{left}[true]{%
|
\define@boolkey{imagecell@args}{left}[true]{%
|
||||||
\photobook@imagecell@LEFT}
|
\photobook@imagecell@LEFT}
|
||||||
@ -1321,12 +1327,19 @@
|
|||||||
% 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{
|
||||||
|
-\dimexpr
|
||||||
|
+\cellheight
|
||||||
|
-\photobook@imagecell@clearance
|
||||||
|
-\ht\photobook@imagebox \relax}}%
|
||||||
\define@boolkey{imagecell@args}{bottom}[true]{%
|
\define@boolkey{imagecell@args}{bottom}[true]{%
|
||||||
\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{%
|
||||||
|
\photobook@imagecell@top}}%
|
||||||
% clearance=<len>...
|
% clearance=<len>...
|
||||||
\define@key{imagecell@args}{clearance}{%
|
\define@key{imagecell@args}{clearance}{%
|
||||||
\setlength\photobook@imagecell@clearance{#1}}%
|
\setlength\photobook@imagecell@clearance{#1}}%
|
||||||
@ -1335,9 +1348,6 @@
|
|||||||
\define@choicekey{imagecell@args}{caption-align}{t,c,b}[t]{%
|
\define@choicekey{imagecell@args}{caption-align}{t,c,b}[t]{%
|
||||||
\def\photobook@imagecell@captionalign{#1}}%
|
\def\photobook@imagecell@captionalign{#1}}%
|
||||||
|
|
||||||
% XXX can't seem to get rid of small placement errors...
|
|
||||||
% ...feels like we've still got a stray space someplace...
|
|
||||||
% 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%
|
||||||
@ -1378,43 +1388,39 @@
|
|||||||
% 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=
|
margin={\photobook@imagecell@left} 0pt 0pt {\photobook@imagecell@top}}{%
|
||||||
{\photobook@imagecell@left - \photobook@HOFFSETFIX}
|
|
||||||
0pt 0pt
|
|
||||||
{\photobook@imagecell@top}}{%
|
|
||||||
% image....
|
% image....
|
||||||
\usebox\photobook@imagebox%
|
\usebox\photobook@imagebox%
|
||||||
% caption cell...
|
% caption cell...
|
||||||
% XXX the \ifx here does not work...
|
% XXX do not do this if no caption is given...
|
||||||
\ifx #2 \empty \else%
|
\begingroup%
|
||||||
\begingroup%
|
\hspace{-\mindim{%
|
||||||
% XXX test for portrait images...
|
\wd\photobook@imagebox
|
||||||
\hspace{-\mindim{%
|
}{%
|
||||||
\wd\photobook@imagebox
|
+\cellwidth
|
||||||
|
-\photobook@imagecell@captionleft
|
||||||
|
-0.5\dimexpr
|
||||||
|
+\cellwidth
|
||||||
|
-\wd\photobook@imagebox \relax }}{%
|
||||||
|
% prep for caption cell...
|
||||||
|
\setlength\cellwidth{%
|
||||||
|
\mindim{\wd\photobook@imagebox}{\cellwidth}}%
|
||||||
|
\setlength\cellheight{%
|
||||||
|
\mindim{\ht\photobook@imagebox}{\cellheight}}%
|
||||||
|
\setlength\fboxsep{0pt}%
|
||||||
|
%
|
||||||
|
% adjust top if image is taller than cell...
|
||||||
|
\raisebox{-\mindim{%
|
||||||
|
0pt
|
||||||
}{%
|
}{%
|
||||||
\cellwidth
|
+ 0.5\dimexpr
|
||||||
-0.5\dimexpr
|
+\cellheight
|
||||||
\cellwidth
|
-\ht\photobook@imagebox
|
||||||
-\wd\photobook@imagebox \relax }}{%
|
-\photobook@imagecell@captiontop \relax}}{%
|
||||||
% prep for caption cell...
|
\begin{minipage}[b][\cellheight][\photobook@imagecell@captionalign]{\cellwidth}%
|
||||||
\setlength\cellwidth{\dimexpr%
|
#2%
|
||||||
-2\photobook@HOFFSETFIX
|
\end{minipage}}}
|
||||||
+\mindim{\wd\photobook@imagebox}{\cellwidth} \relax}%
|
\endgroup}%
|
||||||
\setlength\cellheight{%
|
|
||||||
\mindim{\ht\photobook@imagebox}{\cellheight}}%
|
|
||||||
\setlength\fboxsep{0pt}%
|
|
||||||
%
|
|
||||||
% adjust top if image is taller than cell...
|
|
||||||
\raisebox{-\mindim{%
|
|
||||||
0pt
|
|
||||||
}{%
|
|
||||||
0.5\dimexpr
|
|
||||||
\cellheight
|
|
||||||
-\ht\photobook@imagebox \relax}}{%
|
|
||||||
\begin{minipage}[b][\cellheight][\photobook@imagecell@captionalign]{\cellwidth}%
|
|
||||||
#2%
|
|
||||||
\end{minipage}}}
|
|
||||||
\endgroup\fi}%
|
|
||||||
\endgroup}
|
\endgroup}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user