0

I am a beginner in LaTeX, when I wanted to insert a graph into the document, it shows several errors, could anyone help me with this, what should I do to fix the error?

\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}



\title{problem}
\author{xr}
\date{25th.Feb.202}

\begin{document}
\begin{figure}
    \centering
    \includegraphics[width=0.7\linewidth]{number.png}
    \caption{}
    \label{fig:1}
\end{figure}    

\end{document}

%line 440: Undefined control sequence. } %line 11: Extra \fi. \begin{document}

10
  • 3
    Welcome to TeX.SE... Instead of images, please place the code what you tried so far, from \documentclass to \end{document}
    – MadyYuvi
    Feb 26, 2020 at 5:20
  • 2
    What errors do you get?
    – Johannes_B
    Feb 26, 2020 at 6:04
  • 4
    If I use an example image, your code works to me, which error do you get?
    – CarLaTeX
    Feb 26, 2020 at 6:04
  • 2
    By the way, it is a bad idea to name graphic files by numbers. The same goes for labels.
    – Johannes_B
    Feb 26, 2020 at 6:05
  • 2
    there is nothing wrong with your file other than we do not have a file called 1.png to test it with, and you do not say what errors you get so it is impossible to help. If asking about an error please copy the exact error message from the log file and add it as a code block to your question, so line breaks are preserved in the message. Feb 26, 2020 at 7:51

2 Answers 2

1

this problem has already been solved. the code is correct. it is the problem of the package, it runs well after i updated the package in MiKTex console.

0

The curly braces after \includegraphics should contain the path to the graphic you want to insert, e.g.

\includegraphics[width=0.7\linewidth]{myfigure.png}

So the error message tells you that it is not able to find a figure called "1.png" because you put {1} there. The rest of the error messages is just further errors because it fails to include the graphic.

Just provide the correct path there and the error should go away.

2
  • hiya, I have changed the filename, and it is found now, however, it still shows 2 errors, 1.undefined control sequence, 2. Extra \fi. \begin{document}. have you got anymore idera? thanks!
    – coldwater
    Feb 26, 2020 at 12:17
  • Are you sure that what you show is the only code you use? It compiles fine for me. The error looks like you messed up some command (that's why it says undefined control sequence)
    – pbnoxious
    Feb 26, 2020 at 12:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .