LaTeX forum ⇒ Graphics, Figures & Tablesincludepdf as a figure

Information and discussion about graphics, figures & tables in LaTeX documents.
jibberalan
Posts: 9
Joined: Mon Oct 18, 2010 11:52 pm

includepdf as a figure

Postby jibberalan » Tue Oct 19, 2010 12:49 am

If possible, I would like to have included pdf pages which behave as a figure. I have a pdf file with multiple plots (attached) and I would like to add them in different ways to my document- for example combine the first 4 and then the last two. So far I have been able to get the pdf inserted, keep my page numbers, and add it to my list of figures, however the last needed piece is a caption. It doesn't work inside a float, so it seems that the one thing I could do is add some caption size text below it, but this is not the most elegant solution. It does not need to behave as a float though this would be nice.

Her is the MWE:

  1. \documentclass[11pt,twoside]{article}
  2. \usepackage{pdfpages}
  3. \begin{document}
  4. Dummy Text here
  5. \includepdf[pages = {1-4}, nup=2x2, addtolist = {\thepage, figure, 4 great figures, fig:greatFigs}, pagecommand = {}]{testFigs.pdf}
  6. More Dummy Text
  7. \end{document}


Thanks in advance for any help.
Attachments
testFigs.pdf
(29.78 KiB) Downloaded 117 times

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am
Location: Amherst, MA

Postby frabjous » Tue Oct 19, 2010 2:35 am

Why not simply use the \includegraphics command from the graphicx package? It supports PDFs (at least when compiling with pdflatex). (pdfpages is in fact built on top of graphicx!)

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Location: Colombia

Postby gmedina » Tue Oct 19, 2010 3:03 am

I agree with frabjous's suggestion; the natural thing to do would be to use \includegraphics directly. However, (if for some reason) the original intent persists (to include the graphics using pdfpages and then to add a general caption), you could use the background package:

  1. \documentclass[11pt,twoside]{article}
  2. \usepackage{pdfpages}
  3. \usepackage[some]{background}
  4.  
  5. \SetBgOpacity{1}
  6. \SetBgColor{black}
  7. \SetBgScale{1}
  8. \SetBgAngle{0}
  9. \SetBgPosition{current page.north}
  10. \SetBgVshift{-100}
  11. \SetBgContents{\figurename\ \thefigure: four included figures}
  12.  
  13. \begin{document}
  14. \listoffigures
  15.  
  16. Dummy Text here
  17. \clearpage
  18. \BgThispage
  19. \includepdf[pages = {1-4}, nup=2x2, addtolist = {\thepage, figure, 4 great figures, fig:greatFigs}, pagecommand = {}]{testFigs.pdf}
  20. More Dummy Text
  21.  
  22. \clearpage
  23. \SetBgContents{\figurename\ \thefigure: another four included figures}
  24. \BgThispage
  25. \includepdf[pages = {1-4}, nup=2x2, addtolist = {\thepage, figure, another 4 great figures, fig:greatFigs2}, pagecommand = {}]{testFigs.pdf}
  26. More Dummy Text
  27.  
  28. \end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Link:
BBcode:
HTML:
Hide post links
Show post links

jibberalan
Posts: 9
Joined: Mon Oct 18, 2010 11:52 pm

Postby jibberalan » Tue Oct 19, 2010 10:53 pm

Thanks for the help gmedina. Unless I'm missing something, the \includegraphics command does not allow you to select multiple pages out of the other pdf or arrange them with the nup command- both of which I would like to take advantage of.

Also, thanks for your suggestion of using the background package. It seems like it will do what I need, though I do get an error stating that some is an unknown option for the background package. Guess I'll try and resolve this now...

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Location: Colombia

Postby gmedina » Tue Oct 19, 2010 11:10 pm

jibberalan wrote:...though I do get an error stating that some is an unknown option for the background package. Guess I'll try and resolve this now...


That's strange. Do you get this error with the example code I posted before or when using the package in your actual document? Could you please post some minimal, and complete code allowing us to reproduce the error mentioned?
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Link:
BBcode:
HTML:
Hide post links
Show post links

jibberalan
Posts: 9
Joined: Mon Oct 18, 2010 11:52 pm

Postby jibberalan » Wed Oct 20, 2010 5:30 pm

I get the error using the example that you posted. I have not yet been able to fix it either. I also get undefined control sequence error for \SetBGOpacity and the other commands before \begin{document}. If it makes a differences I'm using Texmaker on Windows.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Location: Colombia

Postby gmedina » Wed Oct 20, 2010 5:50 pm

Perhaps your LaTeX system is outdated? Which distribution (TeX Live, MiKTeX) and which version do you use?

Try this simple test document:

  1. \documentclass[11pt,twoside]{article}
  2. \usepackage{background}
  3.  
  4. \begin{document}
  5.  
  6. Test
  7.  
  8. \end{document}


the outcome should be a one page document with the text "Test" and a red watermark with the message "Draft" displayed diagonally. Report any errors that you get when compiling the above code.
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Link:
BBcode:
HTML:
Hide post links
Show post links

jibberalan
Posts: 9
Joined: Mon Oct 18, 2010 11:52 pm

Postby jibberalan » Thu Oct 21, 2010 12:06 am

I was using MikTeX 2.7, so I updated to 2.8 and I still cannot run the original example. I was able to run the simple example, though the red watermark did not appear.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Location: Colombia

Postby gmedina » Thu Oct 21, 2010 12:21 am

The code has to be compiled twice. Are you compiling with the LaTeX=>PDF profile?

As a side note: I don't use MiKTeX anymore, but the most recent version is 2.9 (I would suggest the complete MiKTeX sysem):

http://miktex.org/2.9/setup
1,1,2,3,5,8,13,21,34,55,89,144,233,...

Link:
BBcode:
HTML:
Hide post links
Show post links

jibberalan
Posts: 9
Joined: Mon Oct 18, 2010 11:52 pm

Postby jibberalan » Fri Oct 22, 2010 5:19 pm

Yes, I am compiling it with LaTeX=>PDF, and I tried 2.9, still no dice.

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: Baidu [Spider] and 8 guests