1

I'm typesetting lecture notes (book class) as my main document. I'm also creating supplementary slides from that document using beamer and beamerarticle, mostly using the figures in the lecture notes to go on the slides for further explanation during class.

For better accessibility I want to print the original lecture notes page number of the figure on that figure's slide - so people can easily find it in the notes when they're looking at the slide. But I can't figure out how I can access the lecture notes' page numbering within a slide, since as far as I understand basically everything but \begin{frame}...\end{frame} will be ignored with option ignorenonframetext being active in beamerarticle.

Here's a MWE consisting of three documents: 1. The body, that is being used for both versions, called body.tex.

\mode*
\chapter{First Chapter}
\section{This is the first section}
\lipsum[1-4]

\section{This is the second section}
\lipsum[1-4]

\begin{frame}
\only<presentation>{\frametitle{\insertsection}}
\begin{figure}[htb]
    \centering
    \includegraphics[width=0.5\linewidth]{example-image-a}
    \caption{Example image. \only<presentation>{This image sits on page \pageref{fig:A} of the book.}}
    \label{fig:A}
\end{figure}
\end{frame}

\textbf{Figure \ref{fig:A} sits on page \pageref{fig:A} of the book.}
\lipsum[1]
  1. The main document for the lecture notes utilize the body.tex to generate a book:
\documentclass[
,oneside
,openany
,a4paper]{book}

\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{beamerarticle}

\title{This is the Booktitle}
\author{Author Name}

\begin{document}
\maketitle

\input{MWE_body.tex}

\end{document}
  1. The main document for the slides uses the same body.tex to generate the presentation, and only grabs the frame environments through the ignorenonframetext option in beamer. Of course the page numbering of the slides messes up the page reference to the lecture notes in the caption of the figure.
\documentclass[ignorenonframetext]{beamer}
\usepackage{graphicx}
\usepackage{lipsum}

\title{Presentation Title}
\author{Author Name}

\begin{document}

\begin{frame}
<presentation>\titlepage
\end{frame}

\mode<all>{\input{MWE_body.tex}}

\end{document}

So basically I'm looking for a way to acquire the page number of the figure in the book, and display it in the slides. Can this be done? Any help appreciated!

  • Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including \documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – user36296 Apr 2 at 11:28
0

With the xr-hyper package you could import the labels from the book document into the presentation with a prefix of your choice and then use the prefixed label for the presentation only command. Note that you need to use the hyperref package in your book document to make this work and the book document needs to be compiled before compiling the presentation.

\mode*
\chapter{First Chapter}
\section{This is the first section}
\lipsum[1-4]

\section{This is the second section}
\lipsum[1-4]

\begin{frame}
\only<presentation>{\frametitle{\insertsection}}
\begin{figure}[htb]
    \centering
    \includegraphics[width=0.5\linewidth]{example-image-a}
    \caption[example]{Example image. \only<presentation>{This image sits on page \pageref{book-fig:A} of the book.}}
    \label{fig:A}
\end{figure}
\end{frame}

Figure \ref{fig:A} sits on page \pageref{fig:A} of the book.
\lipsum[1]

\RequirePackage{xr-hyper}
\documentclass[ignorenonframetext]{beamer}
\usepackage{graphicx}
\usepackage{lipsum}
\externaldocument[book-]{document}

\title{Presentation Title}
\author{Author Name}

\begin{document}

\begin{frame}
<presentation>\titlepage
\end{frame}

\mode<all>{\input{body.tex}}

\end{document}

\documentclass[
,oneside
,openany
,a4paper]{book}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{beamerarticle}
\usepackage{hyperref}
\title{This is the Booktitle}
\author{Author Name}

\begin{document}
\maketitle

\input{body.tex}

\end{document}

enter image description here

  • Works like a charm! Thanks! I had difficulties making it work outside the MWE, but found out that putting the \externaldocument-line to a document class file (.cls) caused missing labels in the output. Putting the \externaldocument-line directly in the main document preamble solved that problem. – ChrisM Apr 2 at 20:13
  • @ChrisM Great to hear that it is working for you! – user36296 Apr 2 at 20:14

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.