3

I want to include figure in my pdf using TikZ. I used the following code but the figure disappears:

\documentclass[12pt,vi,twoside]{mitthesis}
\usepackage{lgrind}
\usepackage{hyperref}
\usepackage{url}
\usepackage{tikz}
\pagestyle{plain}

\begin{document}
  \pgfdeclareimage{Depth}{images/Depth.jpg}

  \begin{figure}[h]
  \centering
  \resizebox{\linewidth}{!}{%
    \begin{tikzpicture}
      \pgfuseimage{Depth}
    \end{tikzpicture}
    }
    \caption{MyCap.}
    \label{fig:Lab}
  \end{figure}
\end{document}
  • Hi Misaki, welcome to the site! Why do you want to use a tikzpicture with \pgfuseimage to include the picture instead of simply using \includegraphics{<file name>}? Also, it would be great if you could edit your question to turn the code snippet into a complete compilable minimal example (so something starting from \documentclass), that makes it much easier to find the source of the problem. – Jake Apr 9 '13 at 21:30
  • Using ' \includegraphics{<file name>} ' makes figures look blocked or pixelized. – Fadwa Apr 9 '13 at 21:39
  • @Misaki if you want to avoid pixelized figures you should obtain a higher resolution Depth.jpg image. As far as I know you can not make a pixelized jpg image look better with tikz. You can draw another image in tikz, but you can not just simply convert jpg to tikz. – Saaru Lindestøkke Apr 9 '13 at 22:42
  • 3
    The \pgfdeclareimage understands the option interpolate=true and the PDF viewer renders it according to this option. If you you want to use a PGF image you need to use \pgftext{\pgfuseimage{<name of image>}}. (You can also switch from tikzpicture to pgfpicture then.) But beware, the quality of the image won’t rise, JPGs will always be a raster image format. Be it as it may, you do not get any improvement by using TikZ over \includegraphics. – Qrrbrbirlbel Apr 10 '13 at 2:15
  • 2
    @Misaki if your figure is a low quality jpg, it will always stay a low quality image. Doesn't matter which format. Where did you get the Depth.jpg image from? If you're exporting it from another program try exporting it at a bigger size. – Saaru Lindestøkke Apr 10 '13 at 7:19

Browse other questions tagged or ask your own question.