37 Comments

  1. Do you know if this will allow you to insert a page into a Beamer presentation?

    One of the things I’d like to be able to do is show graphs that fill the full page (no headers, slide design, etc.) of a slide. I’ve had the thought that since I already export graphs to pdf and import them that way, it’d be great if I could just show the graph pdf instead of showing it in a frame.

    • That’s funny, I was just trying to do that and yes it works :-):

      \documentclass[]{beamer}
      \usepackage{pdfpages}
      \begin{document}
      {
      \setbeamercolor{background canvas}{bg=}
      \includepdf[pages=1-4]{file.pdf}
      }
      \end{document}

      Found it on stackexchange. Best, Tom.

  2. Allan

    Hi Tom,

    I am preparing my manuscript for publication and my co-authors want me to remove the trailing dots and page number in the Figure legend. I tried using \renewcommand{\cftdotsep}{\cftnodots}. This does remove the dots but I get an error message saying that cftnodots is undefined. I still haven’t found a way to remove page numbers that trail after each caption.

    Also, in the figure legend each caption is labelled 1, and so forth, my co-authors want it to read Fig. 1 etc., according to the style of the journal we are submitting to. Do you have any advice as to how I clear up these details?

    I found tonnes of other stuff on your site and really appreciate your efforts. Thanks a lot.

    Allan

    • Hi Allan,

      I wasn’t able to reproduce the error you get with cftnodots, unless I don’t load the tocloft package.

      You’ll find an answer to your question on how to remove the page number in the list-of-figures / list-of-tables here.

      This comment will help you adding the word Fig. in front of the figure number.

      Best, Tom.

      • Allan

        Hi Tom,

        Thanks for your comments. I already have loaded the tocloft package, and the only thing that comes to my mind is that it may be interfering with the subfig package. One of the errors I get is that loft depth is already defined and it points towards the subfigure package that I use.

        Thanks

        Allan

      • Allan

        Sorry about my rant here Tom. I figured out how to change lof into Fig., but when I use your advice about getting rid of page numbers (from a previous advice), it completely screws up my lof. I don’t have a loc, would that be why?

        Almost ready to use OpenOffice…

        Allan

      • Hi Allan,

        Sorry for not getting back to you sooner. There is a known conflict between the subfig and the tocloft packages. Try loading the tocloft package with the subfigure option:

        \usepackage[subfigure]{tocloft}

        Or the more flexible solution from here.

        Concerning your list of figures issue, I doubt it’s because you don’t have a table of contents. They are independent, with their respective content saved in two different meta-files (*.lof and *.toc).

        I briefly tried the piece of code that I linked to in my previous comment and it works smoothly. But it’s only a minimal example and your document might have lots of other stuff that may interfere so…

        \documentclass{article}
        \usepackage{tocloft, graphicx}
        \begin{document}
        \let\Contentsline\contentsline
        \renewcommand\contentsline[3]{\Contentsline{#1}{#2}{}}
        \listoffigures
        \begin{figure}[ht]
        \begin{center}
        \includegraphics[width=0.5\textwidth]{test}
        \caption{default}
        \label{default}
        \end{center}
        \end{figure}
        \end{document}

        Do you get any errors when typesetting?

        Best, Tom.

      • Allan

        Hi Tom,

        I finally figured out how to get my tables into the main text so that endfloat isn’t affecting them. I used tabular and now my tables are where they should be, but table captions are not following the tables (I don’t want captions in list of tables as I do for the figures).

        I used this code to get FIGURE CAPTIONS in list of figures in my class file:

        \renewcommand{\@makecaption}[2]{%
        \vskip\abovecaptionskip
        \hbox to \hsize{\hfil #1\hfil}%
        \vskip\belowcaptionskip}
        \let\OrigCaption\caption
        \renewcommand{\caption}[2][X]{\OrigCaption[#2]{}}

        Is this preventing me from having TABLE captions appear below tables in the main text?

        I used the package \capt-off to get captions in TABLES inside the tabular environment such that my tabular looks like this:

         \begin{center}
          \begin{tabular}
              \toprule \toprule
        
              \bottomrule
            \end{tabular}
        \captionof{table}{Hypothesized caption}
        \label{Hypotheses}
        \end{center}

        But, I still don’t get the captions below each their table. Do you have any idea of what’s going on? It’s the last thing I need to have fixed before I can submit.

        Allan

      • Hi Allan,

        When I use the code pieces above, the caption appears below the table. Have you tried surrounding the whole thing with a table floating environment? If that doesn’t help, please provide a full minimal example that I can paste into a document and typeset.

        Thanks, Tom

      • By the way, you’ll need to surround any code that has “@” within your tex-document by \makeatletter...\makeatother. Tom.

      • Allan

        Hi Tom,

        I finally solved the problem. Because I use endfloat latex put both figure and table captions in listoffigures and listoftables (and figures and tables on subsequent pages). To avoid tables being affected by endfloat I avoided the table environment and sufficed with tabular. Using this approach tables remained in text, but not the captions. So here’s what I did in my class file to solve that:

        \RequirePackage{caption}
        \DeclareCaptionTextFormat{empty}{}
        \captionsetup[figure]{labelsep=none,textformat=empty}
        \captionsetup[table]{list=no}
        
        % Use the full caption text (instead of the list-of text)
        % for the List of Figures
        \DeclareCaptionOption{fulltextforlist}[]{%
         \let\OrigCaption\caption
         \renewcommand{\caption}[2][X]{\OrigCaption[##2]{}}}
        \captionsetup[figure]{fulltextforlist}

        Now it all works

        Allan

  3. vishal

    I am trying this code but it does not work with pdflatex

    \documentclass{article}
    \usepackage[final]{pdfpages}
    \begin{document}
    \begin{figure}
     \centering
     \includepdf{incylinder.pdf}
    \end{figure}
    \end{document}

    Please help me include pdf

    • tom

      Hi Vishal,

      If your PDF covers the whole page, you should remove the figure environment. In case your PDF contains a figure that you’d like to add to your document, use the graphicx package instead.

      \documentclass{article}
      \usepackage{graphicx}
      \usepackage[final]{pdfpages}
      \begin{document}
      
      %Full page include
      \includepdf[pages=-]{incylinder.pdf}
      
      %Regular figure
      \begin{figure}[ht]
      \centering
      \includegraphics[width=0.5\linewidth]{incylinder}
      \caption{default}
      \label{fig:cylinder}
      \end{figure}
      \end{document}
      • vishal

        I tried your code does not work pdflatex. When I eliminate the figure section it does and generate dvi and the pdf it gives me blank page as output.

        Thank you

      • tom

        If \includepdf is wrapped in a \begin{figure} ... \end{figure}, the output is blank on my system. Once I removed that, it worked. Not sure what the problem is if that didn’t help. The log file my give you some clue…

        Cheers, Tom

  4. Esben Poulsen

    Dear Tom,

    Thanks for the epic trick! It works like a charm.

    One tiny (but probably tricky request): Is it possible to have the header/footer/page numbers of the main tex file overlay the inserted full page pdf?

    I need this because I am including papers into my PhD-thesis, and I don’t want the reader to be confused by the papers page numbers :).

    Thanks!
    /Esben

  5. Esben Poulsen

    Got it!

    \includepdf[pages=-,frame=true,scale=0.9,pagecommand={}]{include/papers/paper.pdf}

    is what I needed šŸ™‚

    • tom

      Hi Sven,

      Thanks for your comment. Use pax to keep links in PDFs. Check the readme/documentation for details on how it works.

      HTH,
      Tom

  6. SARTORETTO FLAVIO

    Using \includepdf, by pdflatex on Mac, I obtain one page with all pdf pages superimposed.
    Any hint to fix this problem?
    Thank you in advance

    • tom

      Hi Flavio,

      Thanks for your comment. You can find a possible solution here. If this doesn’t solve the problem, please provide a minimal working example. To help, I need to replicate the problem on my computer.

      Best,
      Thomas

  7. Hi Tom,

    I have multiple 20) graphs saved as pdf which I am using to insert in one page, I am able to do it but I would also like to caption each graph and have a common caption for all the graphs together. How to achieve that?

    TIA,
    Jayant

  8. Tihana

    Hi Tom,

    I would need to insert a pdf document of several pages in my thesis, so I was using
    \includepdf[pages=-,scale=0.8,pagecommand={\pagestyle{fancy}}]{workflow}, but I would need to have this document in the list of figures (it can be also seen as a table, thus list of tables). How can I achieve this?

    Cheers

    Tihana

    • Hi Tihana,

      You can manually add entries using one of the two lines of code below. lof stands for list of figures. Alternatively, use lot for list of tables. Insert this command just above your includepdf to get the page number right.

      \addcontentsline{lof}{section}{Description}
      % or
      \addtocontents{lof}{Description}

      Let me know if you get stuck.

      Best, Tom

      • Tihana

        Hi Tom,

        thank you very much for your prompt reply! I guess the manual addition goes in contrast with \listoffigures that I am using with [nottoc]{tocbibind}, since when I compile it screws up the list of figures and tables (they do not appear at all…). Not sure what is the problem, since I do not get any error, they simply disappear.

        Best,

        Tihana

      • Hi Tihana,

        Please provide a minimal working example, so I get an idea of what other packages/configuration you use.

        Best,
        Tom

      • Tihana Vujinovic

        Hi Tom,

        thanks for your prompt reply!

        Here roughly the configuration, with example.

        \documentclass[12pt,a4paper,twoside,english]{book}
        \usepackage[pdftex]{graphicx}
        \usepackage[latin1]{inputenc}
        \usepackage[nottoc]{tocbibind}
        \usepackage{hyperref}
        \usepackage{pdfpages}
        \begin{document}
        \listoffigures
        \listoftables
        \chapter{Chapter1}
        \begin{figure}[!ht]
               \centering%
               \rule{5cm}{5cm}
               \caption[Min N]{Min N}\label{Min_N_NEW}
         \end{figure}
        \appendix
        \chapter{Appendix A}
        %here the pdf that I would like to have in the list of figures (or tables)
        \includepdf[pages=-,scale=0.8,pagecommand={\pagestyle{fancy}}]{Workflow_combined}
        \end{document}

        What I think might be causing the conflict is the hyperref. Maybe. But also I cannot get a number in the list and the correspondent page number. So that is screwing up the list of other figures.

        Another thing is the positioning of the pdf I need to insert. If I put it after a couple of figures, that is where I would like it to appear, while what he does is putting it straigth before anything else. While I can manipulate this with the graphicx package, I don’t know how to fix the position of the pdf with pdfpages.

        Many thanks!

        Tihana

      • Thanks for the example. I wasn’t aware of the addtolist option to \includepdf before (see pdfpages package documentation). This option adds the entry to the list of figures/tables.

        Figure is a floating environment, meaning that a figure float down your document until LaTeX finds enough space for it. However, you can force figures to be printed before some other content using \clearpage. If you add \clearpage just before \includepdf, all figures should appear before the PDF.

        \documentclass[12pt,a4paper,twoside,english]{book}
        \usepackage[pdftex]{graphicx}
        \usepackage[latin1]{inputenc}
        \usepackage[nottoc]{tocbibind}
        \usepackage{hyperref}
        \usepackage{pdfpages}
        \begin{document}
        \tableofcontents
        \listoffigures
        \chapter{Chapter1}
        \begin{figure}[!ht]
        \centering%
        \rule{1cm}{1cm}
        \caption[Min N]{Min N}\label{Min_N_NEW}
        \end{figure}
        \appendix
        \chapter{Appendix A}
        %here the pdf that I would like to have in the list of figures (or tables)
        \includepdf[pages=-,scale=0.8,addtolist={1,figure, My PDF document, pdf:doc1}]{path/pdf_document}
        See \ref{pdf:doc1}
        \end{document}

        Cheers, Tom

Leave a Reply