TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been trying to input a graph into my .tex file, but it won't work. I've put the .png file in the same folder as the .tex file and a part of my code looks like:

\documentclass[16pt, a4paper]{article}



The error message I'm getting is:

! LaTeX Error: Can be used only in preamble.

How can I fix this problem ?

share|improve this question
article class has not got a 16pt option, and \usepackage as it says in the errror message has to be in the preamble ie before \begin{document} so just move that line. – David Carlisle Feb 3 '14 at 11:19
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. As David said, put the \usepackage{graphicx} in the preamble, which is between the \documentclass and \begin{document}. – hpesoj626 Feb 3 '14 at 11:21
Thanks, it woks. But the graph is too large. How can I define the size of the graph? – Nikoleta Feb 3 '14 at 11:28
\documentclass[a4paper]{article} %     / after this
\usepackage{graphicx}            % <--{
\begin{document}                 %     \ before this
share|improve this answer

You can also pass an option to set the scale of the image, like so:


In this case, the image will be scaled to half size. Also, including the file extension, i.e. .png is not mandatory.

You can check for additional options here.

share|improve this answer
scale might not be a good idea. Better to scale using say width=0.8\textwidth, or use this interesting answer tex.stackexchange.com/q/157337/3929 – daleif Feb 3 '14 at 15:39
Can you explain why wouldn't scale be a good idea? – Oxfist Feb 3 '14 at 15:44
Do you know the original size? So the value for scale will be trail and error, plus what if the margins change? Then you have to go over all of them to make sure they are no longer too wide. – daleif Feb 3 '14 at 15:48
Great explanation, thanks! – Oxfist Feb 3 '14 at 15:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.