2

Here's an uncommon request. Let's say I have a page, page A. It's x in * y in. On another page, page B, I'd like to shrink the page to say half size (0.5 x in * 0.5 y in), to be used as a figure/illustration. I want them to be linked such that if I change the content of A, B prints with the same changes (meaning no copy-paste for B). See the following as an illustration (not produced from LaTeX, because I don't know how):

page-Apage-B

Note that the mini-page-A on page-B is not just an image, but will be compiled with all the content that's in page-A, and searchable and selectable.

Is there a way to store an entire page's content in a variable? Is it as simple as \newcommand? Then how would I recall it later and shrink it down on page B?

  • Can you do it in two steps? pdflatex first, and then once more where you include, via pdfpages, the page you just have produced? – vaettchen Jul 5 '15 at 15:46
  • I can try, but I will be producing a large volume of these page-minipage documents, and so the extra step isn't desirable if it can be avoided. – tralston Jul 5 '15 at 15:48
  • can you explain more your need? do you have one page A to be reprinted mutiple times in B like pages or mutiple A like pages to multiple B like pages? the contents of A is static or not? – touhami Jul 5 '15 at 16:29
  • I'm producing dozens if not a hundred or so one-page documents, each with different styles, layout, formatting, etc. These are the A-pages. Think of them as a template for proofing by a client. Then I would like to produce a page B for each page A, where a smaller version of A is shown, along with annotations and notes in the margins (which weren't possible on A). Think of page B as a style guide with callouts, lines, and annotations. I want the order of the pages to go: A, B giving a two-page document. This will be the pattern for all hundred documents. – tralston Jul 5 '15 at 16:39
  • 2
    there are several questions concerning the "droste effect" of self-replication. this may also be known as "ouroboros" (infinite nesting) or "quinn". it's not clear to me that any of the existing questions hold the exact answer, but searching for those terms might turn up something useful. – barbara beeton Jul 5 '15 at 16:55
4

atbegshi can be used to capture the page being shipped out. Below I've captured \AtBeginShipoutBox inside my own \mysavedpage for use later:

enter image description here

\documentclass{article}
\usepackage{atbegshi,graphicx,lipsum}
\newsavebox{\mysavedpage}
\begin{document}

% Capture the page being shipped out next
\AtBeginShipoutNext{%
  \global\setbox\mysavedpage=\copy\AtBeginShipoutBox}%

\section{A section}
\lipsum[1]
\begin{center}
  \includegraphics[height=5\baselineskip]{example-image}
\end{center}
\lipsum[2-5]

% Print captured page
\framebox{%
  \resizebox{.5\linewidth}{!}{%
    \usebox{\mysavedpage}}}

\end{document}

You may have to play around with the lengths contained within the box, as it doesn't include the full page... only what's being pushed to the page from the upper left corner.

  • Wow, that we seriously easy. I'm especially impressed with the almost plug-n-play functionality of that package. It looks good, the only thing (and this is minor) is the margins are a little wonky. But it works for me. – tralston Jul 6 '15 at 23:15
  • @tralston: You can only do this for pages prior to the one you want to print it on. – Werner Jul 7 '15 at 5:58
  • I understand. And in my situation that's all I need. I wonder how it would be done if you need to print the mini page before the full page? This is common in textbook prefaces where they illustrate the features of their textbook by insetting a mini version of the page. – tralston Jul 7 '15 at 11:12
1

Here is a solution using answers package and based on write18 compilation.

Edit: update this main file should be compiled with (pdf or xe)latex with option --enable-write18. No output here, but 2 files mtafile.tex and mtBfile.tex will be created and compiled with pdflatex and outputs mtafile.pdf and mtBfile.pdf

\documentclass{article}
\usepackage{answers}
\Newassociation{xxx}{yyy}{page}

% contents of the page 

\Opensolutionfile{page}[mtfile]
\begin{Filesave}{page}
\section{Foo}
\lipsum[1]
\includegraphics[height=3cm]{example-image-a}
\subsection{Barbar}
\lipsum[1]
\end{Filesave}
\Closesolutionfile{page}

%  file A produce normal page A

\Opensolutionfile{page}[mtAfile]
\begin{Filesave}{page}
\documentclass{article}
\usepackage{lipsum,mwe}

\begin{document}
\input{mtfile}
\end{document}
\end{Filesave}
\Closesolutionfile{page}

%  file B produce normal page A and small image of A, boxed just for example

\Opensolutionfile{page}[mtBfile]
\begin{Filesave}{page}
\documentclass{article}
\usepackage{lipsum,mwe}
\begin{document}
\input{mtfile}
\clearpage
\fbox{\includegraphics[scale=.5]{mtAfile}}
\end{document}
\end{Filesave}
\Closesolutionfile{page}

\begin{document}
\immediate\write18{pdflatex mtAfile.tex}
\immediate\write18{pdflatex mtBfile.tex}
\end{document}

if you want you can use

\immediate\write18{xelatex mtAfile.tex}
\immediate\write18{xelatex mtBfile.tex}
  • This doesn't seem to work for me. The log doesn't show any errors, but No pages of output appears. I'm using xelatex. Could that be why? – tralston Jul 6 '15 at 23:11
  • @tralston answer updated – touhami Jul 6 '15 at 23:37
  • Works now. Very interesting, I hadn't thought about producing the files separately. Creative. – tralston Jul 7 '15 at 0:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.