1

In a two-sided scrbook, I'm attempting to spread a series of many broad figures along with their explanations over two facing pages, as shown in the sketch below:

Example image of the facing-page layout.

Between the numbers 5 and 6, I highlighted the simple thing: To separate the items on both pages, I currently use a \rule that has the \textwidth as width. However, the left and right page items belong together, so I would like to have the rules extend into the inner margins (all up to the page border), so that they appear as one line when printed rather than two lines on the same height.

For an even page, I could just add something to the width of my rule, say \rule{\dimexpr\textwidth+\innermarginwidth}{0.5pt} to achieve this. But on odd pages, how can the line be extended into the "negative" direction? If length is added, the rule will just go into the outer margin. Also, hacky as this approach seems, I wonder if there is a more elegant solution.

Consider this MWE, where \rowrule is the command in question. A case switch for odd/even pages is not a problem, since I could use \Ifthispageodd. It is more of a conceptual question on how to expand a rule into the inner margins.

\documentclass[twoside, DIV=11]{scrbook}

\usepackage{dpfloat} \usepackage{array} \usepackage{lipsum}

\newcommand{\rowcontent}[1]{% \begin{tabular}{>{\raggedleft\sffamily\bfseries\arraybackslash}p{10mm}l} Nr.~#1 & \raisebox{-.4\height}{\rule{.4\textwidth}{25mm}\quad\rule{.4\textwidth}{25mm}} \end{tabular}}

\newcommand{\rowrule}{\begin{center}\rule{\textwidth}{.5pt}\end{center}}

\newcommand{\explanation}[1]{% \vphantom{\rowcontent{#1}}% \begin{minipage}{\textwidth} Explanatory text for nr.~#1. \end{minipage}% }

\begin{document} \lipsum[1-1]

\begin{leftfullpage} \noindent% \rowcontent{1} \rowrule \rowcontent{2} \rowrule \rowcontent{3} \end{leftfullpage}
\begin{fullpage} \noindent% \explanation{1} \rowrule \explanation{2} \rowrule \explanation{3} \end{fullpage} \end{document}


Update 2023-01-23: Werner's excellent approach resulted in a mismatch of the corresponding heights: On the right side, each item received more space than on the left. I narrowed down the problem to the use of \hspace*{\linewidth} in \resetleftrightblocksep. To resolve the issue, I combined both answers and now use the following, respectively:

\resetleftrightblocksep{\unskip\begin{flushright}\rule{0pt}{0pt}\llap{\rule{\paperwidth}{.5pt}}\end{flushright}}
\resetleftrightblocksep{\unskip\begin{flushleft}\rule{0pt}{0pt}\rlap{\rule{\paperwidth}{.5pt}}\end{flushleft}}

2 Answers2

1

There's no need to be exact. You can draw a line of length 2\textwidth or more. Enclose the rules in \rlap or \llap and then flushleft and flushright respectively to avoid vertical spacing issues. Also, start the lines with \rule{0pt}{0pt}.

enter image description here

Here are the macros:

\newcommand{\leftrowrule}{\begin{flushleft}\rule{0pt}{0pt}\rlap{\rule{2\textwidth}{.5pt}}\end{flushleft}}
\newcommand{\rightrowrule}{\begin{flushright}\rule{0pt}{0pt}\llap{\rule{2\textwidth}{.5pt}}\end{flushright}}

And the code:

\begin{leftfullpage}
    \noindent%
    \rowcontent{1}
    \leftrowrule
    \rowcontent{2}
    \leftrowrule
    \rowcontent{3}
\end{leftfullpage}  
\begin{fullpage}
    \noindent%
    \explanation{1}
    \rightrowrule
    \explanation{2}
    \rightrowrule
    \explanation{3}
\end{fullpage}
\end{document}
Sandy G
  • 42,558
  • Thank you for this concise solution! (And for also taking into account the spacing issues, which may have otherwise led to a follow-up question.) – hschmauder Jan 17 '23 at 23:04
1

The following aims to combine the process into a single environment - fullleftrightpage - and use a \splitcontent{<left>}{<right>} macro to capture what goes on the <left>/<right> page, respectively.

enter image description here

\documentclass[twoside, DIV=11]{scrbook}

\usepackage{lipsum} \usepackage{etoolbox} \usepackage[export]{adjustbox}

% For measuring content on left/right pages \newsavebox{\leftblock} \newsavebox{\rightblock} \newcommand{\leftrightblocksep}{}

\NewDocumentCommand{\splitcontent}{ m m }{% % \splitcontent{<left>}{<right>} \begin{lrbox}{\leftblock}#1\end{lrbox}% Store #1 \begin{lrbox}{\rightblock}\begin{minipage}{\linewidth}#2\end{minipage}\end{lrbox}% Store #2 \edef\x{\noexpand\def\noexpand\x{% Define proper strut based on max total height \noexpand\rule[-\fpeval{max(\dp\leftblock,\dp\rightblock)}pt]{0pt}{\fpeval{max(\dp\leftblock+\ht\leftblock,\dp\rightblock+\ht\rightblock)}pt}}}\x% % Add content for left page \expandafter\listadd\expandafter{\expandafter\leftpagelist\expandafter}\expandafter{\x% \begingroup#1\endgroup% }% % Add content for right page \expandafter\listadd\expandafter{\expandafter\rightpagelist\expandafter}\expandafter{\x% \begin{minipage}{\linewidth}#2\end{minipage}% }% }

\newcommand{\resetleftrightblocksep}[1]{% % Delayed update (https://tex.stackexchange.com/a/89187/5764) \renewcommand{\leftrightblocksep}{\renewcommand{\leftrightblocksep}{% \par\addvspace{.5\baselineskip}% #1% \par\addvspace{.5\baselineskip}}}% }

\NewDocumentEnvironment{fullleftrightpage}{}{% \clearpage \Ifthispageodd{\mbox{}\clearpage}{}% \global\let\leftpagelist\relax% Clear list with left page content \global\let\rightpagelist\relax% Clear list with right page content \setlength{\parindent}{0pt}% Remove paragraph indent }{% % Process left page \resetleftrightblocksep{\rlap{\rule{\paperwidth}{.5pt}}}% \renewcommand{\do}[1]{\leftrightblocksep##1}% \dolistloop{\leftpagelist}% Process left page list \clearpage % Process right page \resetleftrightblocksep{\hspace*{\linewidth}\llap{\rule{\paperwidth}{.5pt}}}% \dolistloop{\rightpagelist}% Process right page list \clearpage }

\begin{document} \lipsum[1-1]

\begin{fullleftrightpage} \splitcontent{left}{right}% \splitcontent{\bfseries Nr~1 \quad \includegraphics[valign=m,height=3\baselineskip]{example-image}}{\lipsum[1]}% \splitcontent{left}{right}% \splitcontent {\makebox[\linewidth]{\bfseries Nr~2 \hfill \includegraphics[valign=m,height=3.14\baselineskip]{example-image-a}\quad\includegraphics[valign=m,height=3.14\baselineskip]{example-image-b}}} {right} \splitcontent{left}{right}% \end{fullleftrightpage}

\end{document}

The process stores the left/right components in lists and processes them for each page using etoolbox's list management/processing capabilities. With each element pair, the contents is stored in a box to measure the maximum total height (depth + height) and use that as a strut to obtain an equal height across the pages.

Werner
  • 603,163
  • Thanks, @Werner, for the extensive effort! In order to make your solution work, I had to make minor adjustments: adjustbox and pstricks don't play along well (both define some \clipbox), and I had to add a line \def\do{} right before your \renewcommand{\do}.... However the box height measurement in my document is not working properly; I'd like to post a screenshot but don't know how in the comments (fairly new to TeX.SE, sorry!). My \vphantom approach was not exact, but the differences between left and right page are much worse with your elegant solution. Why is that...? – hschmauder Jan 21 '23 at 22:10
  • I updated the question to let you see the difference. The left side contains a tabular of equal height in each row, the right side only contains plain text. – hschmauder Jan 21 '23 at 22:26