0

I just wanted to insert this png (see attachment), but I get a bunch of errors -> undefined control sequence

\documentclass[pdftex,a4paper, 10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{anyfontsize}
\usepackage{fontspec}
\usepackage{graphicx}
\title{Zürich Plan}
\date{text}
\author{text}
\begin{document}
  \maketitle
  
  \section{text}
    \subsection{Next} 

    \subsection{text}
  
  \section{text}
 
  
  \section{text}
  
  \section{Hello}
 \includegraphics[width=200, height=400]{code.png}}

    
  \end{document}

The png is in the same folder as the latex documentcode.png

10
  • 1
    Welcome to TeX.SX! Please tell us more about the error message you get. Which control sequence is undefined?
    – leandriis
    Commented Aug 19, 2020 at 20:40
  • Using fontspec implies you use xelatex as your compiler, thus remove pdftex from your class options. Additionally, height and width need a unit.
    – leandriis
    Commented Aug 19, 2020 at 20:43
  • Besides the issues mentioned by @leandriis you are referring to a pdf once and then to a png. Is it a PDF or a PNG?
    – TobiBS
    Commented Aug 19, 2020 at 20:45
  • ! Undefined control sequence. <argument> \pdfximage \ifnum 0\ifx \Gin@decode \@empty \else 1\fi \ifGin@int... l.32 ...egraphics[width=200, height=400]{code.png} } The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), type I' and the correct Commented Aug 19, 2020 at 20:46
  • @leandriis what do you mean with remove "pdftex from your class"? I'm quite new to latex... Commented Aug 19, 2020 at 20:47

1 Answer 1

3

Please try the following code:

    % !TeX TS-program = pdflatex
\documentclass[a4paper, 10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{anyfontsize}
%\usepackage{fontspec}
\usepackage{graphicx}
\title{Zürich Plan}
\date{text}
\author{text}
\begin{document}
  \maketitle
  
  \section{text}
    \subsection{Next} 

    \subsection{text}
  
  \section{text}
 
  
  \section{text}
  
  \section{Hello}
 \includegraphics[width=200pt, height=400pt]{code.png} %corrected
    
  \end{document}

In my system fontspec is not compatible with pdflatex, so I commented it.

Note the initial line % !TeX TS-program = pdflatex to invoque pdflatex if it is not the default, as in my case. It is called magic comment.

In the \includegraphics of your code you need to include the units (pt I guessed).

Good luck.

enter image description here

You must log in to answer this question.

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