1

Considering this code:

\documentclass[a4paper, landscape]{article}
\usepackage[margin=0cm, showframe=false]{geometry} 
\geometry{paperwidth=15cm, paperheight=30cm}
\usepackage{mwe} % Dummy images

\usepackage{comment}

\usepackage[skins]{tcolorbox} \tcbuselibrary{raster}

\usepackage{eso-pic} \newcommand\myvhcenter[1] {% \begingroup \sbox0{#1}% \raise.5\dimexpr\dp0-\ht0\relax\hbox to 0pt{\hss\usebox0\hss}% \endgroup } \newcommand\myhcenter[1]{\makebox[0pt][c]{#1}}

\usepackage{tikz} \usepackage{tikzpagenodes} % current page text area.center \usetikzlibrary{calc} \usetikzlibrary{decorations.pathreplacing} \usetikzlibrary{decorations.markings} \pgfkeys{/tikz/savevalue/.code 2 args={\global\edef#1{#2}}}

\def\iPlusConstant{\the\numexpr\i+16}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\ShowHelps{0} % 1 'yes' 0 'no'

\newcommand{\PictureIndexStartsAt}{0} \newcommand{\PictureIndexEndsAt}{16}

\newcommand{\ImagePadding}{0} \newcommand{\ScaleImagesAndRulers}{0.7}

\newcommand{\UOneCoordinateX}{0.1} \newcommand{\UOneCoordinateY}{0.054} \newcommand{\UTwoCoordinateX}{0.1} \newcommand{\UTwoCoordinateY}{0.255}

\newcommand{\GridSize}{0.01}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand\ExtraPictureOnEveryPage{ \AddToShipoutPictureBG{\AtPageCenter{ \myvhcenter{ \includegraphics[width=0.4\textwidth]{\NameOfExtraPictureOnEveryPage} } }} }

\AddToShipoutPictureBG{\AtPageUpperLeft{ \begin{tabular}{ l } \vspace{18em}\ \large Weight: 65g\ \large Volume: ?\ \large Density: ?\ \end{tabular} }}

\AddToShipoutPictureBG{\put(\LenToUnit{.5\paperwidth}, 0){ \myhcenter{ \begin{tcbitemize}[size=tight, halign=center, raster equal skip=0pt, raster width=\ScaleImagesAndRulers\textwidth, boxrule = 0pt, frame hidden, colframe=white, colback=white, colbacklower=white, raster left skip=-1mm, raster right skip=-1mm,% including this to solve horizontal alignment issues ] \tcbitem \large Top-bottom rotation \vspace{1.5em}\ \tcbitem \large Side rotation \vspace{1.5em}\ \end{tcbitemize} } }}

\AddToShipoutPictureBG{\AtPageLowerLeft{ \begin{tabular}{ l } \vspace{-2.5em}\ © The Author \ \end{tabular} }}

\begin{document}

\foreach \i in {\PictureIndexStartsAt,...,\PictureIndexEndsAt}{ %%%% Looping through these pictures \foreach \image/\rulerpos\captiontext in { {./Pictures/Cropped-\i}/{2,2}%%%%% Adjust the numbers if you want to have an extra ruler }{%%%%%%%%%%%%%%%

%\centering \begin{tikzpicture}[ remember picture, overlay, % page center 1/3 shift={(current page.center)}, % page center 2/3 font=\sffamily, Help/.style={font=\Huge, red} ] \node[anchor=center, %south west, inner sep=\ImagePadding pt] (myimage) at (0,0) { \IfFileExists{\image.jpg} { \begin{tcbitemize}[size=tight, halign=center, raster equal skip=0pt, raster width=\ScaleImagesAndRulers\textwidth, boxrule = 0pt, frame hidden, colframe=white, colback=white, colbacklower=white, raster left skip=1mm, raster right skip=-1mm]% including this to solve horizontal alignment issues \tcbitem \includegraphics[width=\textwidth]{./Pictures/Cropped-\i.jpg} \tcbitem \includegraphics[width=\textwidth]{./Pictures/Cropped-\iPlusConstant.jpg} \end{tcbitemize}
} { \begin{tcbitemize}[size=tight, halign=center, raster equal skip=0pt, raster width=\ScaleImagesAndRulers\textwidth, boxrule = 0pt, frame hidden, colframe=white, colback=white, colbacklower=white, raster left skip=-1mm, raster right skip=-1mm]% including this to solve horizontal alignment issues \tcbitem \includegraphics[width=\textwidth]{example-image.jpg} \tcbitem \includegraphics[width=\textwidth]{example-image.jpg} \end{tcbitemize}
} }; \begin{scope}[x={($2(myimage.east)$)},y={($2(myimage.north)$)}, shift={(myimage.south west)} % page center 3/3 ] % Restrict the draw area \clip (-0.5,-0.5) rectangle (1.5,1.5); % Frame around image - optional \draw[] (0,0) rectangle (1,1); % optional % CoSy inside node \newcommand\ShowHelpCoSy{ \draw[help lines,xstep=.1,ystep=\GridSize] (0,0) grid (1,1); \foreach \x in {0,1,...,9} { \node[anchor=north] at (\x/10,0) {0.\x}; } \foreach \y in {0,1,...,9} { \node[anchor=east] at (0,\y/10) {0.\y}; } } \ifnum\ShowHelps=1 \ShowHelpCoSy \fi% \ifnum\ShowHelps=1\fill[Help] (0.5,0.75) circle(3pt) node[above]{(0.5,0.75)};\fi% <-- Position Test

% Now the stuff: \path[] (\UOneCoordinateX,\UOneCoordinateY) coordinate(U1) -- (\UTwoCoordinateX,\UTwoCoordinateY) coordinate(U2); \ifnum\ShowHelps=1 \draw[Help] (U1) circle(2pt) node[label=left:U1]{} -- (U2) circle(2pt) node[label=left:U2]{};\fi % show unitlength line

\path let \p1=($(U2)-(U1)$) in \pgfextra{ \pgfmathsetlengthmacro{\unitlength}{veclen(\x1,\y1)} } [savevalue={\u}{\unitlength},savevalue={\mu}{.1*\unitlength}]; \ifnum\ShowHelps=1 \node[Help] at (0.725,0.25) {unitlength U1U2 = \u}; \fi%<--- show unitlength \ifnum\ShowHelps=1 \draw[blue, transform canvas={xshift=2mm}] (U1) -- +(0,\u);\fi % Test

% Small Ruler \draw[very thick] (\rulerpos) coordinate(A) -- +(0,3\u); \foreach \n in {0,1,...,3}{%% \draw[very thick] ([yshift=\n\u]A) -- +(-3mm,0) node[left]{\n} \ifnum\n=0 node[anchor=west, right=3mm]{cm}\fi; }%% \foreach \n in {0.1,0.2,...,3}{%% \draw[] ([yshift=\n*\u]A) -- +(-1.5mm,0); }%%

% Image Ruler y (left) \draw decorate [decoration=ticks,segment length=\mu, /pgf/decoration/amplitude=0.5\mu]{ (-0.005,0) -- (-0.005,1) }; \draw[thick] decorate [decoration=ticks,segment length=\u, /pgf/decoration/amplitude=1\mu]{ (-0.01,0) -- (-0.01,1) }; \begin{scope}[ decoration={ markings, mark=between positions 0 and 1 step \u with { \node [ xshift=-2*\mu, anchor=east, name=mark-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number} ]{ \pgfmathparse{int(\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}-1)} \ifnum\pgfmathresult=1 1,cm \else \pgfmathresult \fi }; } } ] \draw [thick,postaction={decorate}] (0,0) -- (0,1); \end{scope}

% Image Ruler y (right) \draw decorate [decoration=ticks,segment length=\mu, /pgf/decoration/amplitude=0.5\mu]{ (1.005,1) -- (1.005,0) }; \draw[thick] decorate [decoration=ticks,segment length=\u, /pgf/decoration/amplitude=1\mu]{ (1.01,1) -- (1.01,0) }; \begin{scope}[ decoration={ markings, mark=between positions 0 and 1 step \u with { \node [ xshift=2*\mu, anchor=west, name=mark-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number} ]{ \pgfmathparse{int(\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}-1)} \ifnum\pgfmathresult=1 1,cm \else \pgfmathresult \fi }; } } ] \draw [thick,postaction={decorate}] (1,1) -- (1,0); \end{scope}

% Image Ruler x (bottom) \draw decorate [decoration=ticks,segment length=\mu, /pgf/decoration/amplitude=0.5\mu]{ (0,-0.01) -- (1,-0.01) }; \draw[thick] decorate [decoration=ticks,segment length=\u, /pgf/decoration/amplitude=1\mu]{ (0,-0.02) -- (1,-0.02) }; \begin{scope}[ decoration={ markings, mark=between positions 0 and 1 step \u with { \node [ yshift=-4*\mu, anchor=south, name=mark-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number} ]{ \pgfmathparse{int(\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}-1)} \ifnum\pgfmathresult=1 1,cm \else \pgfmathresult \fi }; } } ] \draw [thick,postaction={decorate}] (0,0) -- (1,0); \end{scope}

% Image Ruler x (top) \draw decorate [decoration=ticks,segment length=\mu, /pgf/decoration/amplitude=0.5\mu]{ (1,1.01) -- (0,1.01) }; \draw[thick] decorate [decoration=ticks,segment length=\u, /pgf/decoration/amplitude=1\mu]{ (1,1.02) -- (0,1.02) }; \begin{scope}[ decoration={ markings, mark=between positions 0 and 1 step \u with { \node [ yshift=4*\mu, anchor=north, name=mark-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number} ]{ \pgfmathparse{int(\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}-1)} \ifnum\pgfmathresult=1 1,cm \else \pgfmathresult \fi }; } } ] \draw [thick,postaction={decorate}] (1,1) -- (0,1); \end{scope}

\end{scope} \end{tikzpicture} } %\vspace*{\fill}

\begin{tcbitemize}[raster columns=3, size=tight, halign=center, raster equal skip=0pt, raster width=1\textwidth, boxrule = 0pt, frame hidden, colframe=white, colback=white, colbacklower=white, raster left skip=-1mm, raster right skip=-1mm,% including this to solve horizontal alignment issues ] \tcbitem \large \textbf{Object-00001}\ \tcbitem \large Found at: \textbf{51.208 North, 4.383 East}\ Found in: \textbf{August 2020}\ \tcbitem \large Picture \i\ of \PictureIndexEndsAt \ \end{tcbitemize}

\newpage }%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}

O0123
  • 1,773
  • Using the axis environment from pgfplots comes to mind. You would have to measure the size of the image and specify [scale only axis] for the width and the height. You might even use a group plot. One can locate the center of the axis area using [name=foo] and (foo.center), or \coordinate (foo) at (rel axis cs: 0.5,0.5); inside the axis environment. – John Kormylo Aug 31 '20 at 20:48
  • If you like an answer and it was helpful, please consider upvoting (by clicking on the arrows next to the score) and marking it as accepted answer (by clicking on the checkmark ✓). The answer is already incredibly comprehensive. I am astounded that you keep asking for more features without awarding the green tick. I would suggest asking follow up questions instead. (Just to be clear, I am not connected in any way with cis.) –  Sep 03 '20 at 01:00

3 Answers3

4

Old version:

The following uses tcolorbox (which based widly on TikZ) for all positioning tasks (no further packages are required here) and TikZ for the ruler-annotations.

First: The unitlength \u should be determined like here.

The method is based on to measure the dimensions of the raster boxes and thus to set the dimensions for the rulers, e.g.

% Image Ruler y
\path let \p1=($(LL)-(UL)$) in 
\pgfextra{  \pgfmathsetlengthmacro{\RasterboxHeight}{veclen(\x1,\y1)}   }
[savevalue={\h}{\RasterboxHeight}];

\pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

Note: Should there not be a common x-ruler for both images, but two separate ones for the two images, the method is exactly the same, only some coordinates has to be changed.

Note: The paper color has been set lightly to gray to see the edges.


A. This is the case on a DIN A4 page with 2cm margins; which is probably useful if the document should be printable. enter image description here

With \def\ShowHelps{0}

enter image description here

B. If it is a purely electronic document and page dimensions are unimportant (and if scale=1 is mandatory for the images), and we comment in
\geometry{paperwidth=15cm, paperheight=30cm, margin=0mm}% optional

enter image description here

With \def\ShowHelps{0}

enter image description here

% arara: pdflatex
% arara: pdflatex
% arara: pdflatex

\documentclass[a4paper, landscape]{article} \pagestyle{empty} \usepackage[showframe=false, margin=20mm, ]{geometry} %\geometry{paperwidth=15cm, paperheight=30cm, margin=2mm}% optional %\usepackage{mwe} % Dummy Images \usepackage{textcomp} % \textcopyright

\usepackage{tikz} \usetikzlibrary{calc} \pgfkeys{/tikz/savevalue/.code 2 args={\global\edef#1{#2}}} %\pagecolor{lightgray!22} % see page margins

\usepackage[most]{tcolorbox} \tcbset{ NoGaps/.style={boxsep=0mm, left=0pt, right=0pt, top=0pt, bottom=0pt, before skip=0pt, after skip=0pt,}, % CommonStyle/.style={sharp corners,
enhanced, % allows TikZ etc. colback=white, boxrule=0mm, % 0.5mm = default colframe=white, %frame hidden, }, % RasterStyle/.style={ raster equal skip=0pt, raster equal height=rows, raster halign=center, raster valign=center, }, }

%\def\ImageScale{0.1} \newcommand\UseImage[1]{% \IfFileExists{#1.jpg}% {\includegraphics[scale=\ImageScale]{#1.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

% ======================================= % Input =================================== \xdef\author{The Author} \def\TopTitleLeft{Object-0001} \def\TopTitleMiddle{Found in August 2020 at 51.2 North, 49.1 East} \def\TopTitleRight{Picture 1 of 16} \def\TopTitleLeftBelow{Weight: 65g \ Volume: ? \ Density: ?} \def\BottomTitle{\textcopyright~\author} \def\ImageScale{0.75} \newcommand\ImageLeft{\UseImage{example-image}} \newcommand\ImageRight{\UseImage{example-image-a}} \pgfmathsetlengthmacro{\u}{51.07425pt}% unitlength % \def\ShowHelps{1} % 1 'yes' 0 'no' % ======================================= % =======================================

\ifnum\ShowHelps=1 \tcbset{ShowHelps/.style={boxrule=1mm, colframe=#1}, ShowHelps/.default={black},
} \else \tcbset{ShowHelps/.style=,}\fi

\newcommand\TopTitle{% \begin{tcbitemize}[CommonStyle, RasterStyle, ShowHelps=brown, NoGaps, boxsep=1mm, fontupper=\large\bfseries, raster columns=100, % Trick: '100 percent'... ] \tcbitem[raster multicolumn=23, halign=left] \TopTitleLeft \tcbitem[raster multicolumn=54, halign=center] \TopTitleMiddle \tcbitem[raster multicolumn=23, halign=right] \TopTitleRight \end{tcbitemize}}

\begin{document} % Page Box: \begin{tcolorbox}[CommonStyle, ShowHelps=red, NoGaps, % top=3mm,
valign=center, halign=center, % Box content to page center height=\textheight, %Top Title ========================== title=\TopTitle, finish={ \node[align=left, anchor=north west] at (title.south west){\TopTitleLeftBelow}; }, % Bottom Title ======================== space to upper, lower separated=false ] % Images: \begin{tcbitemize}[CommonStyle, RasterStyle, NoGaps, ShowHelps=cyan, raster columns=2, halign=center, valign=center, %colback=red,
raster width=\linewidth-2.4cm, % 1.2cm vspace for y Ruler left / right %raster left skip=-1mm, raster right skip=-1mm,% not needed ] \tcbitem[remember as=LeftRasterbox] \ImageLeft \tcbitem[remember as=RightRasterbox] \ImageRight \end{tcbitemize} % remeber as=<name> for later TikZ-usage \tcblower \BottomTitle \end{tcolorbox}

\begin{tikzpicture}[overlay,remember picture, Ruler/.style={thick}, Help/.style={fill=yellow, text=red, inner sep=1pt}, ] \coordinate[] (LL) at (LeftRasterbox.south west); % Lower Left \coordinate[] (LR) at (RightRasterbox.south east);% Lower Right \coordinate[] (UL) at (LeftRasterbox.north west); % Upper Left \coordinate[] (UR) at (RightRasterbox.north east);% Upper Right %\coordinate[label=x] (MR) at (LeftRasterbox.north east); % not used here

% Images Ruler x \path let \p1=($(LL)-(LR)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesWidth}{veclen(\x1,\y1)} } [savevalue={\w}{\RasterboxesWidth}];

\pgfmathsetmacro\NoXdiv{\w/\u} % Number of x dividions \ifnum\ShowHelps=1 \node[Help, align=left, anchor=south east, yshift=3mm] at (LR.north west){Rasterboxes width w= \w \ No. x divisions w/u= \NoXdiv}; \fi

\newcommand\xRuler[5]{ \draw[Ruler] (#1) coordinate(X) -- (#2); \foreach \n in {0,1,...,\NoXdiv}{%% \draw[Ruler] ([xshift=\n\u]X) -- +(0,#4) node[#3, inner sep=1pt]{\ifnum\n=1 \n,cm \else \n\fi}; }%% \foreach \n in {0.1,0.2,...,\NoXdiv}{%% \draw[] ([xshift=\n\u]X) -- +(0,#5); }%% } \xRuler{LL}{LR}{below}{-4mm}{-2mm} \xRuler{UL}{UR}{above}{4mm}{2mm}

% Image Ruler y \path let \p1=($(LL)-(UL)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxHeight}];

\pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions \ifnum\ShowHelps=1 \node[Help, align=left, anchor=north west, xshift=3mm] at (UL.south east){Rasterbox height h= \h \ No. y divisions h/u= \NoYdiv}; \fi

\newcommand\yRuler[5]{ \draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{\ifnum\n=1 \n,cm \else \n\fi}; }%% \foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n\u]Y) -- +(#5,0); }%% } \yRuler{LL}{UL}{left}{-4mm}{-2mm} \yRuler{LR}{UR}{right}{4mm}{2mm}

\ifnum\ShowHelps=1 \node[Help, anchor=south west, yshift=3mm] at (LL.north east) {unitlength setted u= \u}; \foreach \Coord/\Pos in {LL/left,LR/right, UL/left,UR/right} \draw[red, thick] (\Coord) circle(2pt) node[Help, opacity=0.5, \Pos]{\Coord}; \fi \end{tikzpicture} \end{document}

New version:

New 1. Erasing horizontally withespaces.
With measuring out the image-widths like

\pgfmathsetlengthmacro\LeftWidth{width("\ImageLeft")}

it can be used

\tcbitem[remember as=LeftRasterbox, width=\LeftWidth] \ImageLeft

while setting raster force size=false for the tcbitemize-environment.

New 2. Customized x-rulers.

Adding some coordinates and putting in the measuring into the x-ruler-command

% Images Ruler x
\newcommand\xRuler[5]{
\path let \p1=($(#1)-(#2)$) in 
\pgfextra{ \pgfmathsetlengthmacro{\RasterboxesWidth}{veclen(\x1,\y1)} } 
[savevalue={\w}{\RasterboxesWidth}];
\pgfmathsetmacro\NoXdiv{\w/\u}  % Number of x dividions

\draw[Ruler, transform canvas={xshift=0mm}] (#1) coordinate(X) -- (#2); \foreach \n in {0,1,...,\NoXdiv}{%% \draw[Ruler] ([xshift=\n\u]X) -- +(0,#4) node[#3, inner sep=1pt]{\ifnum\n=1 \n,cm \else \n\fi}; }%% \foreach \n in {0.1,0.2,...,\NoXdiv}{%% \draw[transform canvas={xshift=0mm}] ([xshift=\n\u]X) -- +(0,#5); }%% }

allows e.g. \xRuler{LRM}{LR}{below}{-4mm}{-2mm}

enter image description here

With result version \def\ShowHelps{0}

enter image description here

% arara: pdflatex
% arara: pdflatex
% arara: pdflatex

\documentclass[a4paper, landscape]{article} \pagestyle{empty} \usepackage[showframe=false, margin=20mm, ]{geometry} %\geometry{paperwidth=15cm, paperheight=30cm, margin=2mm}% optional %\usepackage{mwe} % Dummy Images \usepackage{textcomp} % \textcopyright

\usepackage{tikz} \usetikzlibrary{calc} \pgfkeys{/tikz/savevalue/.code 2 args={\global\edef#1{#2}}} \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground}

\usepackage[most]{tcolorbox} \tcbset{ NoGaps/.style={boxsep=0mm, left=0pt, right=0pt, top=0pt, bottom=0pt, before skip=0pt, after skip=0pt,}, % CommonStyle/.style={sharp corners,
enhanced, % allows TikZ etc. colback=white, boxrule=0mm, % 0.5mm = default colframe=white, %frame hidden, }, % RasterStyle/.style={ raster equal skip=0mm, raster equal height=rows, raster halign=center, raster valign=center, }, }

%\def\ImageScale{0.1} \newcommand\UseImage[1]{% \IfFileExists{#1.jpg}% {\includegraphics[scale=\ImageScale]{#1.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

% ======================================= % Input =================================== \xdef\author{The Author} \def\TopTitleLeft{Object-0001} \def\TopTitleMiddle{Found in August 2020 at 51.2 North, 49.1 East} \def\TopTitleRight{Picture 1 of 16} \def\TopTitleLeftBelow{Weight: 65g \ Volume: ? \ Density: ?} \def\BottomTitle{\textcopyright~\author} \def\ImageScale{0.75} \def\ImageLeft{\UseImage{example-image}} %\def\ImageScale{0.075} %\def\ImageLeft{\UseImage{cmHgI}} \def\ImageRight{\UseImage{example-image-a}} \pgfmathsetlengthmacro{\u}{51.07425pt}% unitlength % \def\ShowHelps{1} % 1 'yes' 0 'no' % ======================================= % =======================================

\pgfmathsetlengthmacro\LeftWidth{width("\ImageLeft")} \pgfmathsetlengthmacro\RightWidth{width("\ImageRight")}

\ifnum\ShowHelps=1 \pagecolor{lightgray!22} % see page margins \def\HelpBoxRule{5.7pt} \def\HelpGap{0pt} \tcbset{ShowHelps/.style={boxrule=\HelpBoxRule, colframe=#1}, ShowHelps/.default={black},
} \else \def\HelpBoxRule{0mm} \def\HelpGap{0mm} \tcbset{ShowHelps/.style=,}\fi

\newcommand\TopTitle{% \begin{tcbitemize}[CommonStyle, RasterStyle, ShowHelps=brown, NoGaps, boxsep=1mm, fontupper=\large\bfseries, raster columns=100, % Trick: '100 percent'... ] \tcbitem[raster multicolumn=23, halign=left] \TopTitleLeft \tcbitem[raster multicolumn=54, halign=center] \TopTitleMiddle \tcbitem[raster multicolumn=23, halign=right] \TopTitleRight \end{tcbitemize}}

\begin{document} % Page Box: \begin{tcolorbox}[CommonStyle, ShowHelps=red, NoGaps, % top=3mm,
valign=center, halign=center, % Box content to page center height=\textheight,
%Top Title ========================== title=\TopTitle, finish={ \node[align=left, anchor=north west] at (title.south west){\TopTitleLeftBelow}; }, % Bottom Title ======================== space to upper, lower separated=false ] % Images: \begin{tcbitemize}[CommonStyle, RasterStyle, NoGaps, ShowHelps=cyan, raster columns=2, %boxsep=\HelpGap, halign=center, valign=center, %colback=red,
%raster width=\linewidth-2.4cm, % 1.2cm vspace for y Ruler left / right %raster left skip=-1mm, raster right skip=-1mm,% not needed raster force size=false, %size=tight, %raster equal skip=\HelpBoxRule, ] \tcbitem[remember as=LeftRasterbox, ShowHelps=pink, width=\LeftWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageLeft \tcbitem[remember as=RightRasterbox, width=\RightWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageRight \end{tcbitemize} % remeber as=<name> for later TikZ-usage \tcblower \BottomTitle \end{tcolorbox}

\begin{tikzpicture}[overlay,remember picture, Ruler/.style={thick}, Help/.style={|-|, very thick, yellow!77!orange, fill, text=red, inner sep=0.5pt, align=left}, ] \pgfmathsetlengthmacro\hbr{(\HelpBoxRule+0*\HelpGap)} \coordinate[shift={(\hbr,\hbr)}] (LL) at (LeftRasterbox.south west);% Lower Left \coordinate[shift={(-\hbr,\hbr)}] (LR) at (RightRasterbox.south east);% Lower Right \coordinate[shift={(\hbr,-\hbr)}] (UL) at (LeftRasterbox.north west);% Upper Left \coordinate[shift={(-\hbr,-\hbr)}] (UR) at (RightRasterbox.north east);% Upper Right \coordinate[shift={(-\hbr,\hbr)}] (LLM) at (LeftRasterbox.south east);% Lower Left Middle \coordinate[shift={(-\hbr,-\hbr)}] (ULM) at (LeftRasterbox.north east);% Upper Left Middle \coordinate[shift={(\hbr,\hbr)}] (LRM) at ([xshift=0]RightRasterbox.south west);% Lower Right Middle \coordinate[shift={(\hbr,-\hbr)}] (URM) at ([xshift=0]RightRasterbox.north west);% Upper Left Middle

% Images Ruler x \newcommand\xRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesWidth}{veclen(\x1,\y1)} } [savevalue={\w}{\RasterboxesWidth}]; \pgfmathsetmacro\NoXdiv{\w/\u} % Number of x dividions

\draw[Ruler] (#1) coordinate(X) -- (#2); \foreach \n in {0,1,...,\NoXdiv}{%% \draw[Ruler] ([xshift=\n\u]X) -- +(0,#4) node[#3, inner sep=1pt]{\ifnum\n=1 \n,cm \else \n\fi}; }%% \foreach \n in {0.1,0.2,...,\NoXdiv}{%% \draw[] ([xshift=\n\u]X) -- +(0,#5); }%% } %\xRuler{LL}{LR}{below}{-4mm}{-2mm}% old \xRuler{LL}{LLM}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LL) -- +(\w,0) node[Help, pos=0.65, below=2pt] {LeftWidth = \LeftWidth \ LL--LLM = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{LRM}{LR}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LRM) -- +(\w,0) node[Help, pos=0.65, below=2pt] {RightWidth = \RightWidth \ LRM--LR = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{UL}{UR}{above}{4mm}{2mm} %\xRuler{URM}{UR}{above}{4mm}{2mm}

% Image Ruler y \def\ifzero{1} % show zero \newcommand\yRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxesHeight}]; \pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

\draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{ \ifnum\n=0 \ifnum\ifzero=1 \n \fi% \else% \ifnum\n=1 \n,cm% \else \n% \fi\fi}; }%% \foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n\u]Y) -- +(#5,0); }%% }

\yRuler{LL}{UL}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LL) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Left) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi

\yRuler{LR}{UR}{right}{4mm}{2mm}

\def\ifzero{0} % do not show zero \yRuler{LLM}{ULM}{right}{4mm}{2mm}

\yRuler{LRM}{URM}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LRM) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Right) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi

\ifnum\ShowHelps=1 \begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=5mm}] (LL) -- +(\u,0) node[Help, pos=1.05, anchor=west]{Unit-length set u= \u};

\node[draw=cyan, fill=cyan!22, text=cyan, anchor=west, line width=\HelpBoxRule, align=left, inner sep=\HelpBoxRule] at ([yshift=3*\u, xshift=10mm]LRM) {HelpBoxRule = \HelpBoxRule \ 0pt in result};

\foreach \Coord/\Anchor in {LL/{north east}, LR/{north west}, UL/{south east}, UR/{south west}, LLM/{south east}, ULM/{north east}, LRM/{south west}, URM/{north west}% } \draw[red, thick] (\Coord) circle(2pt) node[Help, opacity=0.5, anchor=\Anchor]{\Coord};
\end{pgfonlayer}\fi \end{tikzpicture} \end{document}

cis
  • 8,073
  • 1
  • 16
  • 45
  • Very impressive, thank you! How do you control the spacing in between the images, if you would like to have none? And also how to remove the spacing between the left and right sides of a picture and the rulers? – O0123 Sep 01 '20 at 17:44
  • Are you willing to make a code which allows for having 'not a common x-ruler for both images, but two separate ones for the two images' please? – O0123 Sep 01 '20 at 18:09
  • How would this code be able to be looped using \foreach \i in {\PictureIndexStartsAt,...,\PictureIndexEndsAt}{ ↔️ \def\iPlusConstant{\the\numexpr\i+16} ↔️ LEFT: \includegraphics[width=\textwidth]{./Pictures/XYZ-\i.jpg} ↔️ RIGHT: \includegraphics[width=\textwidth]{./Pictures/XYZ-\iPlusConstant.jpg} ↔️ \newpage please. – O0123 Sep 02 '20 at 17:01
1

Probably doing calculation in terms of \number\numexpr...\relax does work out for you?

% arara: pdflatex
% arara: pdflatex
% arara: pdflatex

\documentclass[a4paper, landscape]{article} \pagestyle{empty} \usepackage[showframe=false, margin=20mm, ]{geometry} %\geometry{paperwidth=15cm, paperheight=30cm, margin=2mm}% optional \usepackage{textcomp}

\usepackage{tikz} \usetikzlibrary{calc} \pgfkeys{/tikz/savevalue/.code 2 args={\global\edef#1{#2}}} \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground}

\usepackage[most]{tcolorbox} \tcbset{ NoGaps/.style={boxsep=0mm, left=0pt, right=0pt, top=0pt, bottom=0pt, before skip=0pt, after skip=0pt,}, % CommonStyle/.style={sharp corners,
enhanced, % allows TikZ etc. colback=white, boxrule=0mm, % 0.5mm = default colframe=white, %frame hidden, }, % RasterStyle/.style={ raster equal skip=\SeperationBetweenImages, raster equal height=rows, raster halign=center, raster valign=center, }, }

\newcommand\NiceForEachElement{}%

% WHY TWO DIFFERENT COMMANDS \UseImageLeft AND \UseImageRight % WHICH DO EXACTLY THE SAME?

\newcommand\UseImageLeft[2]{% % #1 preceding phrase "image-" % #2 number of image \IfFileExists{#1#2.jpg}% {\includegraphics[scale=\ImageScale]{#1#2.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

\newcommand\UseImageRight[2]{% % #1 preceding phrase "image-" % #2 number of image \IfFileExists{#1#2.jpg}% {\includegraphics[scale=\ImageScale]{#1#2.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

% Input ============ \xdef\author{The Author} \def\TopTitleLeft{Object-0001} \def\TopTitleMiddle{Found in August 2020 at 51.2 North, 49.1 East} \def\TopTitleRight{Picture 1 of 16} \def\TopTitleLeftBelow{Weight: 65g \ Volume: ? \ Density: ?} \def\BottomTitle{\textcopyright~\author} \def\ImageScale{0.7} % % WHY TWO DIFFERENT COMMANDS \ImageLeft AND \ImageRight % WHICH DO EXACTLY THE SAME? % \newcommand\ImageLeft[1]{\UseImageLeft{Image-}{#1}} \newcommand\ImageRight[1]{\UseImageRight{Image-}{#1}} \pgfmathsetlengthmacro{\u}{15.07425pt}% unitlength % \def\ShowHelps{0} % 1 'yes' 0 'no' % Input ============

\ifnum\ShowHelps=1 \pagecolor{lightgray!22} % see page margins \def\HelpBoxRule{5.7pt} \def\HelpGap{0mm} \tcbset{ShowHelps/.style={boxrule=\HelpBoxRule, colframe=#1}, ShowHelps/.default={black},
} \pgfmathsetlengthmacro{\SeperationBetweenImages}{1.18cm} \else \def\HelpBoxRule{5.7pt} \pgfmathsetlengthmacro{\SeperationBetweenImages}{1.18cm+\HelpBoxRule+\HelpBoxRule} \def\HelpBoxRule{0mm} \def\HelpGap{0mm} \tcbset{ShowHelps/.style=,} \fi

\newcommand\TopTitle{% \begin{tcbitemize}[CommonStyle, RasterStyle, ShowHelps=brown, NoGaps, boxsep=1mm, fontupper=\large\bfseries, raster columns=100, % Trick: '100 percent'... ] \tcbitem[raster multicolumn=23, halign=left] \TopTitleLeft \tcbitem[raster multicolumn=54, halign=center] \TopTitleMiddle \tcbitem[raster multicolumn=23, halign=right] \TopTitleRight \end{tcbitemize}}

% Definition of Image Ruler x \newcommand\xRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesWidth}{veclen(\x1,\y1)} } [savevalue={\w}{\RasterboxesWidth}]; \pgfmathsetmacro\NoXdiv{\w/\u} % Number of x dividions

\draw[Ruler] (#1) coordinate(X) -- (#2); \foreach \n in {0,1,...,\NoXdiv}{%% \draw[Ruler] ([xshift=\n\u]X) -- +(0,#4) node[#3, inner sep=1pt]{\ifnum\n=1 \n,cm \else \n\fi}; }%% \foreach \n in {0.1,0.2,...,\NoXdiv}{%% \draw[] ([xshift=\n\u]X) -- +(0,#5); }%% }

% Definition of Image Ruler y \def\ifzero{1} % show zero \newcommand\yRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxesHeight}]; \pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

\draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{ \ifnum\n=0 \ifnum\ifzero=1 \n \fi% \else% \ifnum\n=1 \n,cm% \else \n% \fi\fi}; }%% \foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n\u]Y) -- +(#5,0); }%% }

% Definition of Image Ruler y BIS \def\ifzero{1} % show zero \newcommand\yRulerBis[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxesHeight}]; \pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

\draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \ifnum\n=1 \ifdim#4>0pt \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{\n,cm};% 1cm (from left image): bar + text \else \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0);\fi% 1cm (from right image): bar \else \ifdim#4>0pt \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt, minimum width=2.15em]{\n};% all numbers lower than 10 (from left image), excluding 1: bar + text \else \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0);\fi;% all numbers (from right image), excluding 1: bar \fi; };

\foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n*\u]Y) -- +(#5,0); }%% }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % DEFINITION OF CONSTANT DENOTING THE DIFFERENCE BETWEEN INDEX % OF IMAGE AT THE LEFT AND INDEX OF IMAGE AT THE RIGHT: \newcommand\IndexDifference{16}% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Adding \IndexDifference to a given number: \newcommand\AddIndexdifference[1]{% \number\numexpr(#1)+(\IndexDifference)\relax }% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

% outside the loop the width of Image-7.jpg or example-image.jpg:

\pgfmathsetlengthmacro\LeftWidth{width("\noexpand\noexpand\noexpand\ImageLeft{7}")}% %\show\LeftWidth

\pgfmathsetlengthmacro\RightWidth{width("\noexpand\noexpand\noexpand\ImageRight{7}")}% %\show\LeftWidth

\pgfmathsetlengthmacro\RightWidth{width("\noexpand\noexpand\noexpand\ImageRight{\AddIndexdifference{7}}")}% %\show\LeftWidth

% inside the loop:

\foreach \NiceForEachElement in {1,...,3}{% \pgfmathsetlengthmacro\LeftWidth{width("\noexpand\noexpand\noexpand\ImageLeft{\NiceForEachElement}")}% \pgfmathsetlengthmacro\RightWidth{width("\noexpand\noexpand\noexpand\ImageRight{\AddIndexdifference{\NiceForEachElement}}")}% % \show\LeftWidth

% Page Box: \begin{tcolorbox}[CommonStyle, ShowHelps=red, NoGaps, % top=3mm,
valign=center, halign=center, % Box content to page center height=\textheight,
%Top Title ========================== title=\TopTitle, finish={ \node[align=left, anchor=north west] at (title.south west){\TopTitleLeftBelow}; }, % Bottom Title ======================== space to upper, lower separated=false ] % Images: \begin{tcbitemize}[CommonStyle, RasterStyle, NoGaps, ShowHelps=cyan, raster columns=2, %boxsep=\HelpGap, halign=center, valign=center, raster left skip=-1mm, raster right skip=-1mm,% not needed raster force size=false, %size=tight, ] \tcbitem[remember as=LeftRasterbox, ShowHelps=pink, width=\LeftWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageLeft{\NiceForEachElement}% \tcbitem[remember as=RightRasterbox, width=\RightWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageRight{\AddIndexdifference{\NiceForEachElement}}% \end{tcbitemize} \tcblower \BottomTitle \end{tcolorbox}

\begin{tikzpicture}[overlay,remember picture, Ruler/.style={thick}, Help/.style={|-|, very thick, yellow!77!orange, fill, text=red, inner sep=0.5pt, align=left}, ] \pgfmathsetlengthmacro\hbr{(\HelpBoxRule+0*\HelpGap)} \coordinate[shift={(\hbr,\hbr)}] (LL) at (LeftRasterbox.south west);% Lower Left \coordinate[shift={(-\hbr,\hbr)}] (LR) at (RightRasterbox.south east);% Lower Right \coordinate[shift={(\hbr,-\hbr)}] (UL) at (LeftRasterbox.north west);% Upper Left \coordinate[shift={(-\hbr,-\hbr)}] (UR) at (RightRasterbox.north east);% Upper Right \coordinate[shift={(-\hbr,\hbr)}] (LLM) at (LeftRasterbox.south east);% Lower Left Middle \coordinate[shift={(-\hbr,-\hbr)}] (ULM) at (LeftRasterbox.north east);% Upper Left Middle \coordinate[shift={(\hbr,\hbr)}] (LRM) at ([xshift=0]RightRasterbox.south west);% Lower Right Middle \coordinate[shift={(\hbr,-\hbr)}] (URM) at ([xshift=0]RightRasterbox.north west);% Upper Left Middle

% Image Ruler x

\xRuler{LL}{LLM}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LL) -- +(\w,0) node[Help, pos=0.65, below=2pt] {LeftWidth = \LeftWidth \ LL--LLM = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{LRM}{LR}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LRM) -- +(\w,0) node[Help, pos=0.65, below=2pt] {RightWidth = \RightWidth \ LRM--LR = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{UL}{ULM}{above}{4mm}{2mm} \xRuler{URM}{UR}{above}{4mm}{2mm}

% Image Ruler y

\yRuler{LL}{UL}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LL) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Left) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi \yRuler{LR}{UR}{right}{4mm}{2mm}

% Image Ruler y BIS

\def\ifzero{1} % do show zero \yRulerBis{LLM}{ULM}{right}{4mm}{2mm} \yRulerBis{LRM}{URM}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LRM) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Right) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi

\ifnum\ShowHelps=1 \begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=5mm}] (LL) -- +(\u,0) node[Help, pos=1.05, anchor=west]{Unit-length set u= \u};

\node[draw=cyan, fill=cyan!22, text=cyan, anchor=west, line width=\HelpBoxRule, align=left, inner sep=\HelpBoxRule] at ([yshift=3*\u, xshift=10mm]LRM) {HelpBoxRule = \HelpBoxRule \ 0pt in result};

\foreach \Coord/\Anchor in {LL/{north east}, LR/{north west}, UL/{south east}, UR/{south west}, LLM/{south east}, ULM/{north east}, LRM/{south west}, URM/{north west}% } \draw[red, thick] (\Coord) circle(2pt) node[Help, opacity=0.5, anchor=\Anchor]{\Coord};
\end{pgfonlayer}\fi \end{tikzpicture}

\newpage }

\end{document}



Instead of doing calculations using a constant, you can also use \foreach with a list of pattern a/b,c/d,e/f—just do something like:

\foreach \leftelement/\rightelement in {a/b,c/d,e/f}

In first iteration \leftelement will be a, \rightelement will be b.
In second iteration \leftelement will be c, \rightelement will be d.
In third iteration \leftelement will be e, \rightelement will be f.

% arara: pdflatex
% arara: pdflatex
% arara: pdflatex

\documentclass[a4paper, landscape]{article} \pagestyle{empty} \usepackage[showframe=false, margin=20mm, ]{geometry} %\geometry{paperwidth=15cm, paperheight=30cm, margin=2mm}% optional \usepackage{textcomp}

\usepackage{tikz} \usetikzlibrary{calc} \pgfkeys{/tikz/savevalue/.code 2 args={\global\edef#1{#2}}} \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground}

\usepackage[most]{tcolorbox} \tcbset{ NoGaps/.style={boxsep=0mm, left=0pt, right=0pt, top=0pt, bottom=0pt, before skip=0pt, after skip=0pt,}, % CommonStyle/.style={sharp corners,
enhanced, % allows TikZ etc. colback=white, boxrule=0mm, % 0.5mm = default colframe=white, %frame hidden, }, % RasterStyle/.style={ raster equal skip=\SeperationBetweenImages, raster equal height=rows, raster halign=center, raster valign=center, }, }

\newcommand\NiceForEachLeftElement{}% \newcommand\NiceForEachRightElement{}%

% WHY TWO DIFFERENT COMMANDS \UseImageLeft AND \UseImageRight % WHICH DO EXACTLY THE SAME?

\newcommand\UseImageLeft[2]{% % #1 preceding phrase "image-" % #2 number of image \IfFileExists{#1#2.jpg}% {\includegraphics[scale=\ImageScale]{#1#2.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

\newcommand\UseImageRight[2]{% % #1 preceding phrase "image-" % #2 number of image \IfFileExists{#1#2.jpg}% {\includegraphics[scale=\ImageScale]{#1#2.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

% Input ============ \xdef\author{The Author} \def\TopTitleLeft{Object-0001} \def\TopTitleMiddle{Found in August 2020 at 51.2 North, 49.1 East} \def\TopTitleRight{Picture 1 of 16} \def\TopTitleLeftBelow{Weight: 65g \ Volume: ? \ Density: ?} \def\BottomTitle{\textcopyright~\author} \def\ImageScale{0.15} % % WHY TWO DIFFERENT COMMANDS \ImageLeft AND \ImageRight % WHICH DO EXACTLY THE SAME? % \newcommand\ImageLeft[1]{\UseImageLeft{Image-}{#1}} \newcommand\ImageRight[1]{\UseImageRight{Image-}{#1}} \pgfmathsetlengthmacro{\u}{15.07425pt}% unitlength % \def\ShowHelps{0} % 1 'yes' 0 'no' % Input ============

\ifnum\ShowHelps=1 \pagecolor{lightgray!22} % see page margins \def\HelpBoxRule{5.7pt} \def\HelpGap{0mm} \tcbset{ShowHelps/.style={boxrule=\HelpBoxRule, colframe=#1}, ShowHelps/.default={black},
} \pgfmathsetlengthmacro{\SeperationBetweenImages}{1.18cm} \else \def\HelpBoxRule{5.7pt} \pgfmathsetlengthmacro{\SeperationBetweenImages}{1.18cm+\HelpBoxRule+\HelpBoxRule} \def\HelpBoxRule{0mm} \def\HelpGap{0mm} \tcbset{ShowHelps/.style=,} \fi

\newcommand\TopTitle{% \begin{tcbitemize}[CommonStyle, RasterStyle, ShowHelps=brown, NoGaps, boxsep=1mm, fontupper=\large\bfseries, raster columns=100, % Trick: '100 percent'... ] \tcbitem[raster multicolumn=23, halign=left] \TopTitleLeft \tcbitem[raster multicolumn=54, halign=center] \TopTitleMiddle \tcbitem[raster multicolumn=23, halign=right] \TopTitleRight \end{tcbitemize}}

% Definition of Image Ruler x \newcommand\xRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesWidth}{veclen(\x1,\y1)} } [savevalue={\w}{\RasterboxesWidth}]; \pgfmathsetmacro\NoXdiv{\w/\u} % Number of x dividions

\draw[Ruler] (#1) coordinate(X) -- (#2); \foreach \n in {0,1,...,\NoXdiv}{%% \draw[Ruler] ([xshift=\n\u]X) -- +(0,#4) node[#3, inner sep=1pt]{\ifnum\n=1 \n,cm \else \n\fi}; }%% \foreach \n in {0.1,0.2,...,\NoXdiv}{%% \draw[] ([xshift=\n\u]X) -- +(0,#5); }%% }

% Definition of Image Ruler y \def\ifzero{1} % show zero \newcommand\yRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxesHeight}]; \pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

\draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{ \ifnum\n=0 \ifnum\ifzero=1 \n \fi% \else% \ifnum\n=1 \n,cm% \else \n% \fi\fi}; }%% \foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n\u]Y) -- +(#5,0); }%% }

% Definition of Image Ruler y BIS \def\ifzero{1} % show zero \newcommand\yRulerBis[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxesHeight}]; \pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

\draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \ifnum\n=1 \ifdim#4>0pt \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{\n,cm};% 1cm (from left image): bar + text \else \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0);\fi% 1cm (from right image): bar \else \ifdim#4>0pt \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt, minimum width=2.15em]{\n};% all numbers lower than 10 (from left image), excluding 1: bar + text \else \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0);\fi;% all numbers (from right image), excluding 1: bar \fi; };

\foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n*\u]Y) -- +(#5,0); }%% }

\begin{document}

% outside the loop the width of Image-7.jpg or example-image.jpg:

\pgfmathsetlengthmacro\LeftWidth{width("\noexpand\noexpand\noexpand\ImageLeft{7}")}% %\show\LeftWidth

\pgfmathsetlengthmacro\RightWidth{width("\noexpand\noexpand\noexpand\ImageRight{7}")}% %\show\LeftWidth

% inside the loop:

% Assuming pictures image-1.jpg, image-2.jpg, image-3.jpg, % image-17.jpg, image-18.jpg, image-19.jpg \foreach \NiceForEachLeftElement/\NiceForEachRightElement in {1/17,2/18,3/19}{% \pgfmathsetlengthmacro\LeftWidth{width("\noexpand\noexpand\noexpand\ImageLeft{\NiceForEachLeftElement}")}% \pgfmathsetlengthmacro\RightWidth{width("\noexpand\noexpand\noexpand\ImageRight{\NiceForEachRightElement}")}% % \show\LeftWidth

% Page Box: \begin{tcolorbox}[CommonStyle, ShowHelps=red, NoGaps, % top=3mm,
valign=center, halign=center, % Box content to page center height=\textheight,
%Top Title ========================== title=\TopTitle, finish={ \node[align=left, anchor=north west] at (title.south west){\TopTitleLeftBelow}; }, % Bottom Title ======================== space to upper, lower separated=false ] % Images: \begin{tcbitemize}[CommonStyle, RasterStyle, NoGaps, ShowHelps=cyan, raster columns=2, %boxsep=\HelpGap, halign=center, valign=center, raster left skip=-1mm, raster right skip=-1mm,% not needed raster force size=false, %size=tight, ] \tcbitem[remember as=LeftRasterbox, ShowHelps=pink, width=\LeftWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageLeft{\NiceForEachLeftElement}% \tcbitem[remember as=RightRasterbox, width=\RightWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageRight{\NiceForEachRightElement}% \end{tcbitemize} \tcblower \BottomTitle \end{tcolorbox}

\begin{tikzpicture}[overlay,remember picture, Ruler/.style={thick}, Help/.style={|-|, very thick, yellow!77!orange, fill, text=red, inner sep=0.5pt, align=left}, ] \pgfmathsetlengthmacro\hbr{(\HelpBoxRule+0*\HelpGap)} \coordinate[shift={(\hbr,\hbr)}] (LL) at (LeftRasterbox.south west);% Lower Left \coordinate[shift={(-\hbr,\hbr)}] (LR) at (RightRasterbox.south east);% Lower Right \coordinate[shift={(\hbr,-\hbr)}] (UL) at (LeftRasterbox.north west);% Upper Left \coordinate[shift={(-\hbr,-\hbr)}] (UR) at (RightRasterbox.north east);% Upper Right \coordinate[shift={(-\hbr,\hbr)}] (LLM) at (LeftRasterbox.south east);% Lower Left Middle \coordinate[shift={(-\hbr,-\hbr)}] (ULM) at (LeftRasterbox.north east);% Upper Left Middle \coordinate[shift={(\hbr,\hbr)}] (LRM) at ([xshift=0]RightRasterbox.south west);% Lower Right Middle \coordinate[shift={(\hbr,-\hbr)}] (URM) at ([xshift=0]RightRasterbox.north west);% Upper Left Middle

% Image Ruler x

\xRuler{LL}{LLM}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LL) -- +(\w,0) node[Help, pos=0.65, below=2pt] {LeftWidth = \LeftWidth \ LL--LLM = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{LRM}{LR}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LRM) -- +(\w,0) node[Help, pos=0.65, below=2pt] {RightWidth = \RightWidth \ LRM--LR = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{UL}{ULM}{above}{4mm}{2mm} \xRuler{URM}{UR}{above}{4mm}{2mm}

% Image Ruler y

\yRuler{LL}{UL}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LL) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Left) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi \yRuler{LR}{UR}{right}{4mm}{2mm}

% Image Ruler y BIS

\def\ifzero{1} % do show zero \yRulerBis{LLM}{ULM}{right}{4mm}{2mm} \yRulerBis{LRM}{URM}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LRM) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Right) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi

\ifnum\ShowHelps=1 \begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=5mm}] (LL) -- +(\u,0) node[Help, pos=1.05, anchor=west]{Unit-length set u= \u};

\node[draw=cyan, fill=cyan!22, text=cyan, anchor=west, line width=\HelpBoxRule, align=left, inner sep=\HelpBoxRule] at ([yshift=3*\u, xshift=10mm]LRM) {HelpBoxRule = \HelpBoxRule \ 0pt in result};

\foreach \Coord/\Anchor in {LL/{north east}, LR/{north west}, UL/{south east}, UR/{south west}, LLM/{south east}, ULM/{north east}, LRM/{south west}, URM/{north west}% } \draw[red, thick] (\Coord) circle(2pt) node[Help, opacity=0.5, anchor=\Anchor]{\Coord};
\end{pgfonlayer}\fi \end{tikzpicture}

\newpage }

\end{document}

Ulrich Diez
  • 28,770
  • Thank you, the constant is working perfectly. However, the scaling of the \def\ImageScale seems to have stopped working, when using real images (instead of the example-images)? – O0123 Sep 06 '20 at 18:57
  • @VincentMiaEdieVerheyen The .aux-file contains many entries like \pgfsyspdfmark {pgfid4}{7798019}{12836645} and \csgdef{tcb@ehg@height@REG@1@1}{16.35715pt}. When images change and/or scale-factor changes, then these entries change, too. This change is not taken into account in the current LaTeX-run but will be taken into account with the next LaTeX-run. So compile several times without deleting aux-files between compilations. Repeat compiling until the screen/console doesn't display the message LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right. any more. – Ulrich Diez Sep 06 '20 at 19:24
  • So even, if all the auxiliary files were deleted before compiling in a completely new document, one would have to compile multiple times? – O0123 Sep 06 '20 at 19:27
  • I can not compile again with TeXShop. Receiving the message: Latexmk: All targets () are up-to-date. But the scaling problem remains. – O0123 Sep 06 '20 at 19:29
  • @VincentMiaEdieVerheyen Yes. ;-) Always repeat compiling until the screen-output/console-output does not recommend you to rerun LaTeX any more. With many things LaTeX uses the .aux-file for storing/correcting and storing information which is to be used in the next LaTeX-run. – Ulrich Diez Sep 06 '20 at 19:33
  • @VincentMiaEdieVerheyen What happens if you delete all .aux-files and then compile repeatedly? If Latexmk doesn't do it, can you initiate compilation from the shell? – Ulrich Diez Sep 06 '20 at 19:35
  • I am using TeXShop now. It outputs way too large. I am using a completely new file in a completely new directory without any auxiliary files: https://chat.stackexchange.com/transcript/message/55464192#55464192 Can you try with real .jpgs and see if you have the same issue (comparing with Code 3)? – O0123 Sep 06 '20 at 19:37
  • I am not sure which exact command to use, to compile it via the shell? I just did latex filename.tex and I received Cannot determine size of graphic in example-image.jpg (no BoundingBox). – O0123 Sep 06 '20 at 19:40
  • What happens if you use pdflatex instead of latex? – Ulrich Diez Sep 06 '20 at 19:43
  • If I use pdflatex filename.tex on my Mac's Terminal (compiled three times after one another), the images are still oversized in the same manner. – O0123 Sep 06 '20 at 19:47
  • I also noted the following a couple of times: Overfull \hbox (967.63663pt too wide) in paragraph at lines 299--299. – O0123 Sep 06 '20 at 19:48
  • @VincentMiaEdieVerheyen I just tried with other images than the example-image. On my system evewrything worked out. Changing images and/or scale-factor always required three re-compilations for everything to match out. I suppose the latexmk-script (which I do not use) doesn't properly detect the need of recompilation. Does TeXShop have a button for re-compiling, not using Latexmk but calling the pdflatex-compiler directly? – Ulrich Diez Sep 06 '20 at 19:49
  • Yes, I compiled 5 times now with the terminal (shell), using pdflatex. The oversizing remains. --- Yes, also on TeXShop I can compile using 'pdflatex' via Preferences > Typesetting > Default Command > pdflatex ... but the problem remain there also, also after compiling 4 times there via TeXShop. – O0123 Sep 06 '20 at 19:54
  • Would it be an idea to perhaps try your solution here, in the MWE https://tex.stackexchange.com/questions/561629/macro-introduce-a-constant-to-differ-the-index-of-the-right-hand-side-image-c , with \def\ImageScale{0.7} ? – O0123 Sep 06 '20 at 19:55
  • The problem is never produced with the example-images, only with real .jpgs ... Are you sure you compared the sizes of this code, for the same .jpgs, when compared to the sizes of Code 3? – O0123 Sep 06 '20 at 20:05
  • @VincentMiaEdieVerheyen I am.Your overfull \hboxes indicate that something is too large in the horizontal direction. Probably you have large images and the scale-factor 0.7 isn't scaling them small enough for two images horizontally fitting on a page? – Ulrich Diez Sep 06 '20 at 20:11
  • @VincentMiaEdieVerheyen For testing I took the first six images from here and renamed to img-1.jpg, img-2.jpg, img-3.jpg, img-17.jpg, img-18.jpg, img-19.jpg, (constant-difference being 16) and tested with different scale factors/\ImageScales. With \ImgScale = 0.7 some \hbox was too large about 10pt. With smaller \ImageScale no overfull hboxes occurred and images were smaller. – Ulrich Diez Sep 06 '20 at 20:18
  • My images are all 1181 x 1181 in size. – O0123 Sep 06 '20 at 20:19
  • The largest image I used has 500 Pixel x 667 Pixel at a resolution of 72PPI x 72PPI, ie. 17.64cm x 23.53cm. Scaling with 0.7 yielded a width of 12,38cm. Assumed yours also have 72PPI yours will be a bit larger: Width: ((1181Pixel)/(72Pixel/Inch))*(2.54cm/Inch) = about 41,66cm. Scaling down 0.7 will be 29,16cm. You seem to include images at measurements 29,16cm x 29.16cm while an A4-sheet (landscape) is 29,7cm x 21cm... – Ulrich Diez Sep 06 '20 at 21:43
  • Yes, they are also 72 pixels per inch. The correct scale however, is determined using https://tex.stackexchange.com/a/560471/46023. The correct scale for my images is \def\ImageScale{0.7} for \pgfmathsetlengthmacro{\u}{157.04881pt}% unitlength. So I find it uncomfortable that, because of the introduction of this +constant-feature, the size goes off? Not sure how to solve these issues ... I think the unitlength and \ImageScale{...}, when set, should not be fiddled with ... otherwise the rulers will be wrong, or of different relative width than in the other docs leading up to printout. – O0123 Sep 07 '20 at 06:31
  • This is the exact document with which I determine the unitlegnth: https://chat.stackexchange.com/transcript/message/55466864#55466864 – O0123 Sep 07 '20 at 06:36
  • @VincentMiaEdieVerheyen I added another example to this answer where the "constant-feature" is not used at all. Instead, \foreach is called in a different way: The comma-list holds slash-separated number-pairs, the number at the left of the slash denoting the image at the left, the number at the right of the slash denoting the image at the right. If this also does not work out on your system, then the reason for your problems is definitely not the "constant-feature". What does happen when you download/rename some images from here and use them instead? – Ulrich Diez Sep 07 '20 at 09:54
  • Thank you. I will look at it this week. – O0123 Sep 07 '20 at 15:51
0

Adaptations of answer by @cis:

Code 1:

https://chat.stackexchange.com/transcript/message/55466772#55466772

Code 2:

For images of equal height: two seperate images (with minimal spacing between them), middle y-rulers into a common ruler, with shared numbers):

% arara: pdflatex
% arara: pdflatex
% arara: pdflatex

\documentclass[a4paper, landscape]{article} \pagestyle{empty} \usepackage[showframe=false, margin=20mm, ]{geometry} %\geometry{paperwidth=15cm, paperheight=30cm, margin=2mm}% optional \usepackage{textcomp}

\usepackage{tikz} \usetikzlibrary{calc} \pgfkeys{/tikz/savevalue/.code 2 args={\global\edef#1{#2}}} \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground}

\usepackage[most]{tcolorbox} \tcbset{ NoGaps/.style={boxsep=0mm, left=0pt, right=0pt, top=0pt, bottom=0pt, before skip=0pt, after skip=0pt,}, % CommonStyle/.style={sharp corners,
enhanced, % allows TikZ etc. colback=white, boxrule=0mm, % 0.5mm = default colframe=white, %frame hidden, }, % RasterStyle/.style={ raster equal skip=\SeperationBetweenImages, raster equal height=rows, raster halign=center, raster valign=center, }, }

\newcommand\UseImageLeft[1]{% \IfFileExists{#1.jpg}% {\includegraphics[scale=\ImageScale]{#1.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

\newcommand\UseImageRight[1]{% \IfFileExists{#1.jpg}% {\includegraphics[scale=\ImageScale]{#1.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

% Input ============ \xdef\author{The Author} \def\TopTitleLeft{Object-0001} \def\TopTitleMiddle{Found in August 2020 at 51.2 North, 49.1 East} \def\TopTitleRight{Picture 1 of 16} \def\TopTitleLeftBelow{Weight: 65g \ Volume: ? \ Density: ?} \def\BottomTitle{\textcopyright~\author} \def\ImageScale{0.7} \def\ImageLeft{\UseImageLeft{example-image-a}} \def\ImageRight{\UseImageRight{example-image-b}} \pgfmathsetlengthmacro{\u}{15.07425pt}% unitlength % \def\ShowHelps{0} % 1 'yes' 0 'no' % Input ============

\pgfmathsetlengthmacro\LeftWidth{width("\ImageLeft")} \pgfmathsetlengthmacro\RightWidth{width("\ImageRight")}

\ifnum\ShowHelps=1 \pagecolor{lightgray!22} % see page margins \def\HelpBoxRule{5.7pt} \def\HelpGap{0mm} \tcbset{ShowHelps/.style={boxrule=\HelpBoxRule, colframe=#1}, ShowHelps/.default={black},
} \pgfmathsetlengthmacro{\SeperationBetweenImages}{1.18cm} \else \def\HelpBoxRule{5.7pt} \pgfmathsetlengthmacro{\SeperationBetweenImages}{1.18cm+\HelpBoxRule+\HelpBoxRule} \def\HelpBoxRule{0mm} \def\HelpGap{0mm} \tcbset{ShowHelps/.style=,} \fi

\newcommand\TopTitle{% \begin{tcbitemize}[CommonStyle, RasterStyle, ShowHelps=brown, NoGaps, boxsep=1mm, fontupper=\large\bfseries, raster columns=100, % Trick: '100 percent'... ] \tcbitem[raster multicolumn=23, halign=left] \TopTitleLeft \tcbitem[raster multicolumn=54, halign=center] \TopTitleMiddle \tcbitem[raster multicolumn=23, halign=right] \TopTitleRight \end{tcbitemize}}

\begin{document}

% Page Box: \begin{tcolorbox}[CommonStyle, ShowHelps=red, NoGaps, % top=3mm,
valign=center, halign=center, % Box content to page center height=\textheight,
%Top Title ========================== title=\TopTitle, finish={ \node[align=left, anchor=north west] at (title.south west){\TopTitleLeftBelow}; }, % Bottom Title ======================== space to upper, lower separated=false ] % Images: \begin{tcbitemize}[CommonStyle, RasterStyle, NoGaps, ShowHelps=cyan, raster columns=2, %boxsep=\HelpGap, halign=center, valign=center, raster left skip=-1mm, raster right skip=-1mm,% not needed raster force size=false, %size=tight, ] \tcbitem[remember as=LeftRasterbox, ShowHelps=pink, width=\LeftWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageLeft \tcbitem[remember as=RightRasterbox, width=\RightWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageRight \end{tcbitemize} \tcblower \BottomTitle \end{tcolorbox}

\begin{tikzpicture}[overlay,remember picture, Ruler/.style={thick}, Help/.style={|-|, very thick, yellow!77!orange, fill, text=red, inner sep=0.5pt, align=left}, ] \pgfmathsetlengthmacro\hbr{(\HelpBoxRule+0*\HelpGap)} \coordinate[shift={(\hbr,\hbr)}] (LL) at (LeftRasterbox.south west);% Lower Left \coordinate[shift={(-\hbr,\hbr)}] (LR) at (RightRasterbox.south east);% Lower Right \coordinate[shift={(\hbr,-\hbr)}] (UL) at (LeftRasterbox.north west);% Upper Left \coordinate[shift={(-\hbr,-\hbr)}] (UR) at (RightRasterbox.north east);% Upper Right \coordinate[shift={(-\hbr,\hbr)}] (LLM) at (LeftRasterbox.south east);% Lower Left Middle \coordinate[shift={(-\hbr,-\hbr)}] (ULM) at (LeftRasterbox.north east);% Upper Left Middle \coordinate[shift={(\hbr,\hbr)}] (LRM) at ([xshift=0]RightRasterbox.south west);% Lower Right Middle \coordinate[shift={(\hbr,-\hbr)}] (URM) at ([xshift=0]RightRasterbox.north west);% Upper Left Middle

% Images Ruler x \newcommand\xRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesWidth}{veclen(\x1,\y1)} } [savevalue={\w}{\RasterboxesWidth}]; \pgfmathsetmacro\NoXdiv{\w/\u} % Number of x dividions

\draw[Ruler] (#1) coordinate(X) -- (#2); \foreach \n in {0,1,...,\NoXdiv}{%% \draw[Ruler] ([xshift=\n\u]X) -- +(0,#4) node[#3, inner sep=1pt]{\ifnum\n=1 \n,cm \else \n\fi}; }%% \foreach \n in {0.1,0.2,...,\NoXdiv}{%% \draw[] ([xshift=\n\u]X) -- +(0,#5); }%% }

\xRuler{LL}{LLM}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LL) -- +(\w,0) node[Help, pos=0.65, below=2pt] {LeftWidth = \LeftWidth \ LL--LLM = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{LRM}{LR}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LRM) -- +(\w,0) node[Help, pos=0.65, below=2pt] {RightWidth = \RightWidth \ LRM--LR = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{UL}{ULM}{above}{4mm}{2mm} \xRuler{URM}{UR}{above}{4mm}{2mm}

% Image Ruler y \def\ifzero{1} % show zero \newcommand\yRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxesHeight}]; \pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

\draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{ \ifnum\n=0 \ifnum\ifzero=1 \n \fi% \else% \ifnum\n=1 \n,cm% \else \n% \fi\fi}; }%% \foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n\u]Y) -- +(#5,0); }%% }

% Image Ruler y BIS \def\ifzero{1} % show zero \newcommand\yRulerBis[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxesHeight}]; \pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

\draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \ifnum\n=1 \ifdim#4>0pt \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{\n,cm};% 1cm (from left image): bar + text \else \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0);\fi% 1cm (from right image): bar \else \ifdim#4>0pt \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt, minimum width=2.15em]{\n};% all numbers lower than 10 (from left image), excluding 1: bar + text \else \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0);\fi;% all numbers (from right image), excluding 1: bar \fi; };

\foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n*\u]Y) -- +(#5,0); }%% }

\yRuler{LL}{UL}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LL) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Left) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi

\yRuler{LR}{UR}{right}{4mm}{2mm}

\def\ifzero{1} % do show zero \yRulerBis{LLM}{ULM}{right}{4mm}{2mm} \yRulerBis{LRM}{URM}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LRM) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Right) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi

\ifnum\ShowHelps=1 \begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=5mm}] (LL) -- +(\u,0) node[Help, pos=1.05, anchor=west]{Unit-length set u= \u};

\node[draw=cyan, fill=cyan!22, text=cyan, anchor=west, line width=\HelpBoxRule, align=left, inner sep=\HelpBoxRule] at ([yshift=3*\u, xshift=10mm]LRM) {HelpBoxRule = \HelpBoxRule \ 0pt in result};

\foreach \Coord/\Anchor in {LL/{north east}, LR/{north west}, UL/{south east}, UR/{south west}, LLM/{south east}, ULM/{north east}, LRM/{south west}, URM/{north west}% } \draw[red, thick] (\Coord) circle(2pt) node[Help, opacity=0.5, anchor=\Anchor]{\Coord};
\end{pgfonlayer}\fi \end{tikzpicture} \end{document}


What remains now is to have a loop, such that multiple images can be loaded, 2 per page.

Perhaps with

  • \foreach \i in {\PictureIndexStartsAt,...,\PictureIndexEndsAt}{
  • \def\iPlusConstant{\the\numexpr\i+16}
  • LEFT \includegraphics[width=\textwidth]{./Pictures/XYZ-\i.jpg}
  • RIGHT \includegraphics[width=\textwidth]{./Pictures/XYZ-\iPlusConstant.jpg}
  • \newpage

Using the answer of Ulrich Diez of this OP: \pgfmathsetlengthmacro uncompatible with a loop?, got this far:

Code 3:

% arara: pdflatex
% arara: pdflatex
% arara: pdflatex

\documentclass[a4paper, landscape]{article} \pagestyle{empty} \usepackage[showframe=false, margin=20mm, ]{geometry} %\geometry{paperwidth=15cm, paperheight=30cm, margin=2mm}% optional \usepackage{textcomp}

\usepackage{tikz} \usetikzlibrary{calc} \pgfkeys{/tikz/savevalue/.code 2 args={\global\edef#1{#2}}} \pgfdeclarelayer{background} \pgfdeclarelayer{foreground} \pgfsetlayers{background,main,foreground}

\usepackage[most]{tcolorbox} \tcbset{ NoGaps/.style={boxsep=0mm, left=0pt, right=0pt, top=0pt, bottom=0pt, before skip=0pt, after skip=0pt,}, % CommonStyle/.style={sharp corners,
enhanced, % allows TikZ etc. colback=white, boxrule=0mm, % 0.5mm = default colframe=white, %frame hidden, }, % RasterStyle/.style={ raster equal skip=\SeperationBetweenImages, raster equal height=rows, raster halign=center, raster valign=center, }, }

\newcommand\NiceForEachElement{}%

\newcommand\UseImageLeft[2]{% % #1 preceding phrase "image-" % #2 number of image \IfFileExists{#1#2.jpg}% {\includegraphics[scale=\ImageScale]{#1#2.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

\newcommand\UseImageRight[2]{% % #1 preceding phrase "image-" % #2 number of image \IfFileExists{#1#2.jpg}% {\includegraphics[scale=\ImageScale]{#1#2.jpg}}% {\includegraphics[scale=\ImageScale]{example-image.jpg}}% }

% Input ============ \xdef\author{The Author} \def\TopTitleLeft{Object-0001} \def\TopTitleMiddle{Found in August 2020 at 51.2 North, 49.1 East} \def\TopTitleRight{Picture 1 of 16} \def\TopTitleLeftBelow{Weight: 65g \ Volume: ? \ Density: ?} \def\BottomTitle{\textcopyright~\author} \def\ImageScale{0.7} \newcommand\ImageLeft[1]{\UseImageLeft{Image-}{#1}} \newcommand\ImageRight[1]{\UseImageRight{Image-}{#1}} \pgfmathsetlengthmacro{\u}{15.07425pt}% unitlength % \def\ShowHelps{0} % 1 'yes' 0 'no' % Input ============

\ifnum\ShowHelps=1 \pagecolor{lightgray!22} % see page margins \def\HelpBoxRule{5.7pt} \def\HelpGap{0mm} \tcbset{ShowHelps/.style={boxrule=\HelpBoxRule, colframe=#1}, ShowHelps/.default={black},
} \pgfmathsetlengthmacro{\SeperationBetweenImages}{1.18cm} \else \def\HelpBoxRule{5.7pt} \pgfmathsetlengthmacro{\SeperationBetweenImages}{1.18cm+\HelpBoxRule+\HelpBoxRule} \def\HelpBoxRule{0mm} \def\HelpGap{0mm} \tcbset{ShowHelps/.style=,} \fi

\newcommand\TopTitle{% \begin{tcbitemize}[CommonStyle, RasterStyle, ShowHelps=brown, NoGaps, boxsep=1mm, fontupper=\large\bfseries, raster columns=100, % Trick: '100 percent'... ] \tcbitem[raster multicolumn=23, halign=left] \TopTitleLeft \tcbitem[raster multicolumn=54, halign=center] \TopTitleMiddle \tcbitem[raster multicolumn=23, halign=right] \TopTitleRight \end{tcbitemize}}

% Definition of Image Ruler x \newcommand\xRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesWidth}{veclen(\x1,\y1)} } [savevalue={\w}{\RasterboxesWidth}]; \pgfmathsetmacro\NoXdiv{\w/\u} % Number of x dividions

\draw[Ruler] (#1) coordinate(X) -- (#2); \foreach \n in {0,1,...,\NoXdiv}{%% \draw[Ruler] ([xshift=\n\u]X) -- +(0,#4) node[#3, inner sep=1pt]{\ifnum\n=1 \n,cm \else \n\fi}; }%% \foreach \n in {0.1,0.2,...,\NoXdiv}{%% \draw[] ([xshift=\n\u]X) -- +(0,#5); }%% }

% Definition of Image Ruler y \def\ifzero{1} % show zero \newcommand\yRuler[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxesHeight}]; \pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

\draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{ \ifnum\n=0 \ifnum\ifzero=1 \n \fi% \else% \ifnum\n=1 \n,cm% \else \n% \fi\fi}; }%% \foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n\u]Y) -- +(#5,0); }%% }

% Definition of Image Ruler y BIS \def\ifzero{1} % show zero \newcommand\yRulerBis[5]{ \path let \p1=($(#1)-(#2)$) in \pgfextra{ \pgfmathsetlengthmacro{\RasterboxesHeight}{veclen(\x1,\y1)} } [savevalue={\h}{\RasterboxesHeight}]; \pgfmathsetmacro\NoYdiv{\h/\u} % Number of y dividions

\draw[Ruler] (#1) coordinate(Y) -- (#2); \foreach \n in {0,1,...,\NoYdiv}{%% \ifnum\n=1 \ifdim#4>0pt \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt]{\n,cm};% 1cm (from left image): bar + text \else \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0);\fi% 1cm (from right image): bar \else \ifdim#4>0pt \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0) node[#3, inner sep=1pt, minimum width=2.15em]{\n};% all numbers lower than 10 (from left image), excluding 1: bar + text \else \draw[Ruler] ([yshift=\n\u]Y) -- +(#4,0);\fi;% all numbers (from right image), excluding 1: bar \fi; };

\foreach \n in {0.1,0.2,...,\NoYdiv}{%% \draw[] ([yshift=\n*\u]Y) -- +(#5,0); }%% }

\begin{document}

% outside the loop the width of Image-7.jpg or example-image.jpg:

\pgfmathsetlengthmacro\LeftWidth{width("\noexpand\noexpand\noexpand\ImageLeft{7}")}% %\show\LeftWidth

\pgfmathsetlengthmacro\RightWidth{width("\noexpand\noexpand\noexpand\ImageRight{7}")}% %\show\LeftWidth

% inside the loop:

\foreach \NiceForEachElement in {1,...,3}{% \pgfmathsetlengthmacro\LeftWidth{width("\noexpand\noexpand\noexpand\ImageLeft{\NiceForEachElement}")}% \pgfmathsetlengthmacro\RightWidth{width("\noexpand\noexpand\noexpand\ImageRight{\NiceForEachElement}")}% % \show\LeftWidth

% Page Box: \begin{tcolorbox}[CommonStyle, ShowHelps=red, NoGaps, % top=3mm,
valign=center, halign=center, % Box content to page center height=\textheight,
%Top Title ========================== title=\TopTitle, finish={ \node[align=left, anchor=north west] at (title.south west){\TopTitleLeftBelow}; }, % Bottom Title ======================== space to upper, lower separated=false ] % Images: \begin{tcbitemize}[CommonStyle, RasterStyle, NoGaps, ShowHelps=cyan, raster columns=2, %boxsep=\HelpGap, halign=center, valign=center, raster left skip=-1mm, raster right skip=-1mm,% not needed raster force size=false, %size=tight, ] \tcbitem[remember as=LeftRasterbox, ShowHelps=pink, width=\LeftWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageLeft{\NiceForEachElement}% \tcbitem[remember as=RightRasterbox, width=\RightWidth+\HelpBoxRule+\HelpBoxRule+\HelpGap+\HelpGap] \ImageRight{\NiceForEachElement}% \end{tcbitemize} \tcblower \BottomTitle \end{tcolorbox}

\begin{tikzpicture}[overlay,remember picture, Ruler/.style={thick}, Help/.style={|-|, very thick, yellow!77!orange, fill, text=red, inner sep=0.5pt, align=left}, ] \pgfmathsetlengthmacro\hbr{(\HelpBoxRule+0*\HelpGap)} \coordinate[shift={(\hbr,\hbr)}] (LL) at (LeftRasterbox.south west);% Lower Left \coordinate[shift={(-\hbr,\hbr)}] (LR) at (RightRasterbox.south east);% Lower Right \coordinate[shift={(\hbr,-\hbr)}] (UL) at (LeftRasterbox.north west);% Upper Left \coordinate[shift={(-\hbr,-\hbr)}] (UR) at (RightRasterbox.north east);% Upper Right \coordinate[shift={(-\hbr,\hbr)}] (LLM) at (LeftRasterbox.south east);% Lower Left Middle \coordinate[shift={(-\hbr,-\hbr)}] (ULM) at (LeftRasterbox.north east);% Upper Left Middle \coordinate[shift={(\hbr,\hbr)}] (LRM) at ([xshift=0]RightRasterbox.south west);% Lower Right Middle \coordinate[shift={(\hbr,-\hbr)}] (URM) at ([xshift=0]RightRasterbox.north west);% Upper Left Middle

% Image Ruler x

\xRuler{LL}{LLM}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LL) -- +(\w,0) node[Help, pos=0.65, below=2pt] {LeftWidth = \LeftWidth \ LL--LLM = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{LRM}{LR}{below}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=25mm}] (LRM) -- +(\w,0) node[Help, pos=0.65, below=2pt] {RightWidth = \RightWidth \ LRM--LR = w = \w \ No. x divisions w/u = \NoXdiv}; \end{pgfonlayer}\fi

\xRuler{UL}{ULM}{above}{4mm}{2mm} \xRuler{URM}{UR}{above}{4mm}{2mm}

% Image Ruler y

\yRuler{LL}{UL}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LL) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Left) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi \yRuler{LR}{UR}{right}{4mm}{2mm}

% Image Ruler y BIS

\def\ifzero{1} % do show zero \yRulerBis{LLM}{ULM}{right}{4mm}{2mm} \yRulerBis{LRM}{URM}{left}{-4mm}{-2mm} \ifnum\ShowHelps=1
\begin{pgfonlayer}{foreground} \draw[Help, transform canvas={xshift=5mm}] (LRM) -- +(0,\h) node[Help, pos=0.85, right=2pt] {(Right) Image Height h= \h \ No. y divisions h/u= \NoYdiv}; \end{pgfonlayer}\fi

\ifnum\ShowHelps=1 \begin{pgfonlayer}{foreground} \draw[Help, transform canvas={yshift=5mm}] (LL) -- +(\u,0) node[Help, pos=1.05, anchor=west]{Unit-length set u= \u};

\node[draw=cyan, fill=cyan!22, text=cyan, anchor=west, line width=\HelpBoxRule, align=left, inner sep=\HelpBoxRule] at ([yshift=3*\u, xshift=10mm]LRM) {HelpBoxRule = \HelpBoxRule \ 0pt in result};

\foreach \Coord/\Anchor in {LL/{north east}, LR/{north west}, UL/{south east}, UR/{south west}, LLM/{south east}, ULM/{north east}, LRM/{south west}, URM/{north west}% } \draw[red, thick] (\Coord) circle(2pt) node[Help, opacity=0.5, anchor=\Anchor]{\Coord};
\end{pgfonlayer}\fi \end{tikzpicture}

\newpage }

\end{document}

Still needs some i+16 for image on right...

O0123
  • 1,773