0

I created a PNG image using MS Paint to use in my document (old school I know). I would like to keep the figure within the page width without losing image quality. I have tried using a JPG image instead but the quality is still poor (in that the words are too small to see when viewed in PDF mode at 100 % zoom).

Can someone suggest a solution please? I include my code and 2 screenshots.

Thanks in advance!

    \documentclass[a4paper,11pt]{article}
\usepackage{color}
\usepackage{graphicx, epstopdf}
\usepackage{gensymb}
\usepackage{times}
\usepackage{adjustbox}
\usepackage{tabulary}
\usepackage{tabularx}
\usepackage{booktabs,caption, makecell}
\usepackage{pdflscape,afterpage,caption}
\usepackage[british]{babel}
\usepackage[backend=bibtex, citestyle=ieee, bibstyle=ieee]{biblatex}
\usepackage[section]{placeins}%Allows you to permanently fix figures. 

\begin{document}

\begin{figure}[h!]
\centering
\includegraphics[width=1.5\textwidth]{IMAGE_Raman_principles}
\caption{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna.
Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.
Aenean nec lorem. In porttitor. Donec laoreet nonummy augue.
Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque at sem venenatis eleifend. Ut nonummy.
}
\end{figure}

\end{document}

Figure exceeds page width

Poor figure quality but within page width

  • 1
    Scaling a bitmap, be it PNG or JPEG, will always result in loss of quality. – egreg Feb 17 '18 at 16:32
  • 1
    My personal strategy would be to include an version of the image without any text inside a picture environment and overlay all the text directly in latex. Advantages: the text has the same size and font as the surrounding text and it can be searched for in the pdf. – user36296 Feb 17 '18 at 16:35
  • 1
    Related: tex.stackexchange.com/questions/136087 Choose PNG if you want to use a pixel-based format. In any case, consider @samcarter 's advice. – Dr. Manuel Kuehner Feb 17 '18 at 16:41
  • if you must use a bitmap then you will need to create it at the required size with fonts suitable at that size. If you make it too big, but with normal size fonts then the fonts will be too small when scaled. Or better generate the figure without any text and then use latex text over the figure – David Carlisle Feb 17 '18 at 16:41
3

Drawings like this, which consist of straight lines with sharp edges, should really be done as vector graphic for a decent result.

In the following a quick and dirty attempt to recreate your first image in inkscape and export it to pdf+tex. The .svg file which can be edited in inkscape can for the moment be found at https://www.dropbox.com/s/4usem6v976o7r8h/drawing.svg?dl=0 and the resulting .pdf at https://www.dropbox.com/s/wsgfuoe018djtln/drawing.pdf?dl=0 (I'll delete them in a few weeks).

 \documentclass{article}
\usepackage{graphicx}
\usepackage{xcolor}

\begin{document}

\begin{figure}
  \setlength{\unitlength}{.7\textwidth}%
  \begin{picture}(1,0.59469542)%
    \put(0,0){\includegraphics[width=\unitlength]{drawing.pdf}}%
    \put(0.30,0.57){Rayleigh scatter}%
    \put(0.30,0.51){Raman scatter}%
    \put(0.00,0.42){Laser excitation}%
    \put(0.49,0.40){Scattered light}%
    \put(0.36,0.04){\textcolor{white}{Sample}}%
  \end{picture}%
    \caption{text}
\end{figure}

\end{document}

enter image description here


If you must use a pixel based format, choose .png rather then .jpg.

Furthermore consider to export the image without text and add the text in latex. This will have several advantages, for example the text has the same size and font as the surrounding text and it can be searched for in the .pdf

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{figure}
 \setlength{\unitlength}{\textwidth}%
  \begin{picture}(1,0.55070867)%
    \put(0,0){\includegraphics[width=\unitlength]{t4cc9}}%
    \put(0.37,0.51){Rayleigh scatter}%
    \put(0.37,0.46){Raman scatter}%
  \end{picture}%
    \caption{text}
\end{figure}

\end{document}

enter image description here


  • Thanks! I tried the inkscape method and it works really well. For adding the label text in latex, is there an easy way to identify the starting coordinates? I had to input the coordinates and compile each time to see where the labels moved to each time. Thanks. – Kevin Feb 19 '18 at 19:22
  • 1
    @Kevin In inkscape: If you select "omit text and create latex file" (i.stack.imgur.com/dDGLc.png) when you save the file as .pdf not only the .pdf file is created but also a file .pdf_tex which contains the complete picture environment including all the coordinates. To easily include this use \def\svgwidth{.7\textwidth}\input{filename.pdf_tex} – user36296 Feb 19 '18 at 19:32

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.