1

I am new to latex. I want to import a picture but failing. The picture is .jpg format.

2
  • 6
    Welcome to TEX.SX! Use \includegraphics from the graphicx package will do. // Also please provide a minimum working example (MWE) to show your error. Jan 19 at 8:59
  • 1
    You must specify the engine you use to compile. The latex engine don't accept jpg pictures although pdflatex does.
    – gigiair
    Jan 19 at 10:23

1 Answer 1

4

If pdflatex, xelatex or lualatex is used to compile .tex file. You can use graphicx package to insert .jpg image file.

% pdflatex xelatex lualatex
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=.5\textwidth]{example-image.jpg}
\caption{title}
\end{figure}
\end{document}

If you use latex to compile. I suggest you convert .jpg to .eps. ImageMagick can help you to convert.

convert example-image.jpg example-image.eps
% latex
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=.5\textwidth]{example-image.eps}
\caption{title}
\end{figure}
\end{document}
2
  • .jpg images must be taken into account by the compilation engine. pdflatex accepts them while latex refuses them.
    – gigiair
    Jan 19 at 10:38
  • @gigiair You are right. I have updated my answer.
    – Clara
    Jan 20 at 0:14

You must log in to answer this question.