I am creating a template for document creation, where I need to insert images of varying sizes (sometimes 1024px, sometimes ~4000px wide). Those images can be oriented both vertically and horizontally.

The problem is, I can't afford to have them shrunk (there is text in them).
Is there a way to force LaTeX to create a new page as big as the picture, which picture would fully fill?

I thought of a macro, which would end document style and temporarily use a different one (change pages to horizontal, change sizes...), but I don't think this would handle sizes well.

In the past, I did this manually via Adobe Acrobat (which was able to insert an image as an independent page with its own size). I use MiKTeX 2.9.

  • 3
    Short answer: Use pdfpages or standalone depending on what you want (include an image page to LaTeX or create a page reduced to the contents). – Schweinebacke Feb 3 '17 at 13:08
  • pdfpages looks like it inserts pdf pages, I have those images in .jpg, .png or something like that. Anyway, it might work with some effort. Does it preserve the size of included pages? About standalone package, I can't really imagine how would I use it. Ideally, I would like to create macro, which would take image.jpg(.png...) as an argument and create a new page, which would contain only image.jpg – liskacek Feb 3 '17 at 14:44
  • See tex.stackexchange.com/questions/6834/… OTOH, are you sure you are losing resolution? A PDF viewer with a zoom feature should be able to recover the full resolution (and the resulting PDF files can become huge). – John Kormylo Feb 3 '17 at 15:23
  • You mean that if I were to insert image into a page and it was resized, it stil should be able to recover the full resolution? Like putting 4600px * 3450px on A4 page and with enough zoom, it would still show it in original size? – liskacek Feb 3 '17 at 15:46
  • Yes, but you would have to know the zoom factor to use. Another option is to use \href (hyperref package) to link to the image file. – John Kormylo Feb 3 '17 at 21:01

Here is an example using the PNG shown below. While zooming in on the circle shows stair-stepping, both images when zoomed look the same.


\href{http://www.elfsoft2000.com/projects/large.png}{link to web image}

\href[pdfnewwindow]{large.pdf}{link to local pdf}




example iamge

It turns out you can only link to images on the web or local PDFs. However, one can easily convert images to PDFs using standalone.

| improve this answer | |
  • May I ask for an example of targeting local pdf? I tried \href{pom.pdf}{link to image}. pom.pdf is located in the same folder. – liskacek Feb 4 '17 at 12:35
  • I tried to enter relative path \hyperbaseurl{pom.pdf} and absolute path \hyperbaseurl{D:\Test\Img\}, but that did not work. Main file has an image prepared in pom.pdf, which is in the same folder. I tried googling, but I did not find much about \hyperbaseurl. – liskacek Feb 5 '17 at 11:51
  • My experiments show that \hyperbaseurl has to go into the preamble. My latest experiments show that the baseurl is ignored with local PDFs. Weird! – John Kormylo Feb 5 '17 at 17:21
  • The heart of \baseurl is the command \special{html:<base href="\@baseurl">} which is executed AtBeginDocument. In other words, the base url is written as HTML directly to the PDF driver. – John Kormylo Feb 5 '17 at 18:11
  • I managed to find an easy way how to deal with this problem: ftp.math.purdue.edu/mirrors/ctan.org/macros/latex/contrib/… ... "The graphics can be centered for a given paper format or the paper may be resized to the graphics dimensions." It looks like it is exactly what I needed. Thank you for your answers. – liskacek Feb 6 '17 at 20: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.