# Create “inner” and “outer” parbox

Is there a way to automate the mirroring of parboxes every time a new page occurs?

I have a \documentclass{book} that consists of two side-by-side \parbox. I would like one of the \parbox to always remain the "outer" and the other to always remain the "inner". The pages should essentially mirror each other.

In this example, I would like the skinny column to always be the inner column:

MWE:

\documentclass{book}

\usepackage{lipsum}

\begin{document}

\noindent
\parbox[t][][t]{.7\linewidth}{\lipsum[1]}\hfill
\parbox[t][][t]{.25\linewidth}{\lipsum[2]}

\noindent
\parbox[t][][t]{.7\linewidth}{\lipsum[8]}\hfill
\parbox[t][][t]{.25\linewidth}{\lipsum[9]}

\end{document}

• Does your document only contain these \parboxes? Do you always insert these the same way? Is there any flow from one page to the next? – Werner Mar 7 '17 at 4:06
• You can also do this using paracol. See tex.stackexchange.com/questions/320065/… for example. – John Kormylo Mar 7 '17 at 4:31
• @Werner, yes, let's assume that the document contains only the \parboxes, the content within them will be of different lengths, and there is flow from one page to the next. – AML Mar 7 '17 at 10:46
• @John, do you think paracol is a better solution here? Would you please propose an example solution? – AML Mar 7 '17 at 11:12
• @JohnKormylo I figured out what you meant: \twosided[pc]% swap margins and columns under \usepackage{paracol}. Does anyone know how to achieve the same thing but with \parbox? – AML Mar 7 '17 at 13:18

The \parbox macros are optional. Their only effect here is to force a \newpage if there is not enough space for the whole thing. Alignment is handled by \switchcolumn*. (Without the \parbox you should use \sloppy.)

\documentclass{book}
\usepackage{lipsum}
\usepackage{paracol}

\setcolumnwidth{.7\textwidth,.25\textwidth}
\columnsep=.05\textwidth
\twosided[pc]% swap margins and columns

\begin{document}
\begin{paracol}{2}
\noindent\parbox{\columnwidth}{\lipsum[1]}
\switchcolumn
\noindent\parbox{\columnwidth}{\lipsum[2]}
\switchcolumn*
\noindent\parbox{\columnwidth}{\lipsum[8]}
\switchcolumn
\noindent\parbox{\columnwidth}{\lipsum[9]}
\end{paracol}

\end{document}


Here is a solution using the ifoddpage package. It takes two runs, since \checkoddpage stores the page number in the aux file. The \makebox is used to force the page change before testing.

\documentclass{book}
\usepackage{lipsum}
\usepackage{ifoddpage}

\newcommand{\swapboxes}[2]% #1 = wide text, #2 = narrow text
{\noindent\makebox[\textwidth]{\checkoddpage
\ifoddpageoroneside
\parbox[t]{.7\textwidth}{#1}\hfill\parbox[t]{.25\textwidth}{#2}%
\else
\parbox[t]{.25\textwidth}{#2}\hfill\parbox[t]{.7\textwidth}{#1}%
\fi}}

\begin{document}

\swapboxes{\lipsum[1]}{\lipsum[2]}

\swapboxes{\lipsum[8]}{\lipsum[9]}

\end{document}