2

I want to insert one page from a PDF file into my Lyx presentation file. I use Insert-->File-->External, PDFPages, select the PDF file, then I go to Options and type 'pages={1}' to select the first page from the PDF.

The result looks like a jumbled overlaid mess of all 7 pages of the PDF. This jumbled image does not show up at all in a compiled pdflatex output file. And it also causes an error when I try to preview the file by hitting command-t; the error reads "LaTex Error: File `' not found."

I am new to Beamer in Lyx (though not entirely new to Lyx), I might be missing something basic. Do I need to install a package or something?

Thank you for your help.

2

I'm not very familiar with beamer presentations in LyX, but I will quote a passage from the beamer manual, page 18-19 (emphasis mine):

\usepackage{pdfpages}

Commands like \includepdf only work outside frames as they produce pages “by themselves.” You may also wish to say

\setbeamercolor{background canvas}{bg=}

when you use such a command since the background (even a white background) will otherwise be printed over the image you try to include. Example:

\begin{document}
\begin{frame}
\titlepage
\end{frame}
{
\setbeamercolor{background canvas}{bg=}
\includepdf{somepdfimages.pdf}
}
\begin{frame}
A normal frame.
\end{frame}
\end{document}

LyX doesn't use \begin{frame}/\end{frame}, it defines some custom commands instead (\lyxframe/\lyxframeend), but the same point applies I would guess: the \includepdf cannot be inside a frame, so you have to place after a \lyxframeend (EndFrame from the style menu), before the next \lyxframe (BeginFrame from the style menu).

The second point requires an ERT. Create one with Ctrl + L (or Insert --> TeX code) just before the inserted PDF, and write

{\setbeamercolor{background canvas}{bg=}

in it. Add a second ERT just after, and add a closing brace, }, in this. This is probably why the PDF didn't appear, because it is covered by the background colour. The braces are necessary to keep the redefinition of the background colour to that single slide.

Possible alternative, \includegraphics

Depending on what you're after, you can perhaps use the standard Insert --> Graphics to insert the page. In the LaTeX and LyX options you can add page=5 to insert page number 5 of the PDF. As this is inserted as an image, the header, footer etc. of your presentation will be visible.

  • LyX's \lyxframe...\endlyxframe, in my opinion, is broken, as I found out when trying to solve \includeonlyframes not working in LyX beamer. – Werner Jan 10 '14 at 21:13
  • @Werner Quite possibly, I've never really tried figuring out that thing. – Torbjørn T. Jan 10 '14 at 21:18
  • Torbjorn's suggestions worked like a charm. I removed the \includepdf from the frame setting. Note that the image still looks garbled when displayed in the Lyx editor, and it still does not show up in the compiled preview (command-t), but it looks fine when compiled into pdflatex. My only gripe is that it's cumbersome to insert these ERT's before and after every image and I know other people have managed to avoid this (see this website: elsa.berkeley.edu/~saez/course/capitalincometax/…). But many thanks for your helpful advice. – user43953 Jan 10 '14 at 23:34
  • Nevermind on that gripe--I can put \setbeamercolor{background canvas}{bg=} into the preamble. That seems to work and now I don't have to re-type it for every new image. – user43953 Jan 10 '14 at 23:41
  • @Werner Note that LyX's beamer interface has been redesigned in version 2.1. – scottkosty Jan 11 '14 at 8:51

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.