14

I'm inserting a PNG file and it's rendered enlarged, somehow. Here is my MWE:

\documentclass{book}
\usepackage{graphicx}
\begin{document}
\mainmatter
hello, world.
the following screenshot should be rendered in 1:1 scale, isn't it?

\begin{figure}[H] \centering \includegraphics{screenshot.png} \end{figure}

\end{document}

Here is a screenshot I desire to insert: http://conus.info/tmp/screenshot.png I use XeLaTeX.

And here is a result: http://conus.info/tmp/result.pdf

All I want is to insert a PNG picture (screenshot), so it will be rendered in the same width/height in PDF viewed at 100%.

The size of screenshot.png is 726 pixels by 489 pixels. I want it to be exacly the same size when viewed in Acrobat Reader at 100%.

What should I do?

What are the best practices of inserting screenshots into TeX and exporting them to PDF?

TobiBS
  • 5,240
  • 1 px is not equal to 1 mm on the PDF page... what do you mean exactly the same size ? – percusse Sep 12 '16 at 11:35
  • What to do to make it equal? How to insert screenshots to TeX and export to PDF? – Xenia Galinskaya Sep 12 '16 at 11:35
  • you can use \includegraphics[width=\textwidth]{screenshot} to fit in the text – percusse Sep 12 '16 at 11:37
  • I tried, than it's smaller. – Xenia Galinskaya Sep 12 '16 at 11:40
  • I mean that's how you adjust the width. What is the image final size in dimensions of length pt,cm, mm etc. ? – percusse Sep 12 '16 at 11:42
  • basically you can't. You have no way of knowing what the resolution of the screen is so you may make it work for your current screen but opening it on a different computer with a different screen will be wrong. – ArTourter Sep 12 '16 at 11:42
  • I've found that scaling image to 0.75 is close to what I need. Just interesting, where this value is came from? – Xenia Galinskaya Sep 12 '16 at 11:54
  • I downloaded you image, and tried it. I see it typeset at the exact same size as what you have created the screenshot at, namely 265x172mm. The ppt-setting for the image is 72, maybe that is not what you intended, might be an artifact from whatever screenshot-program you used, or imaging-software, if used on the file. – Runar Sep 12 '16 at 12:39
  • Here are similar questions: one and two – pantlmn Sep 12 '16 at 12:51
  • My scaling value is 0.65 (not 0.75 as yours!) Also I am quite not sure that the Acrobat's idea of "100%" is actual 100%. Did you measure the page on your screen with regular ruler? Are you sure that on different screen it will be the same? – pantlmn Sep 12 '16 at 13:22

2 Answers2

20

This question cannot have general answer for ALL monitors.

The size of the PNG image on the screen depends on the screen resolution (e.g. 110.27 PPI (pixels per inch) for my MacBook), and on Retina (220 PPI) it will be twice smaller.

And the size of image inside PDF, shown at real 100%, will be monitor-independent.

Thus solution for my monitor:

\includegraphics[scale=0.65]{screenshot.png}

will be different from yours:

\includegraphics[scale=0.75]{screenshot.png}
pantlmn
  • 1,366
  • 8
  • 17
  • 3
    don't forget the \usepackage{graphicx} AND... the path will most certainly not be screenshot.png more like /Users/mhearn/Documents/original.png – Michael Hearn Dec 03 '19 at 03:37
2
\documentclass{book}

\usepackage{graphicx}

\begin{document}
    \mainmatter

    \begin{figure}[H]
        \centering
        \includegraphics[height = 0.3, width = 0.6]{crocodile.png}
    \end{figure}

\end{document}
KersouMan
  • 1,850
  • 3
  • 13
  • 15
  • 2
    Compiling your document example trow the error: Unknown float option. In preamble you need to load the float package. – Zarko Jul 18 '20 at 21:15