"Undefined control sequence \includegraphics" after TeXstudio update

1,574

Thank you @moewe for pointing me to the thread with the answer: tex.stackexchange.com/q/511138/35864

Just had to update MikTeX and it's working fine. If someone wants more info on the problem, please check the link above.

Share:
1,574

Related videos on Youtube

Bernardo
Author by

Bernardo

Updated on August 01, 2022

Comments

  • Bernardo
    Bernardo over 1 year

    I know there are a gazillion of threads addressing the error

    Undefined control sequence \includegraphics
    

    but I couldn't find the answer to my problem in any of them. So here it goes.

    I am trying to use the command \includegraphics, like I have always done so for the past years, but somehow it doesn't work anymore. I am using TeXstudio 2.12.16. Below is a MWE:

    \documentclass[12pt]{article}
    \usepackage[pdftex]{graphics,graphicx}
    
    \begin{document}
        \includegraphics[width=\linewidth]{photo.png}
    \end{document}
    
    

    When I try to compile, it returns the error

    Undefined control sequence. \includegraphics[width=\linewidth]{photo}
    Undefined control sequence. \includegraphics[width=\linewidth]{photo}
    Undefined control sequence. \includegraphics[width=\linewidth]{photo}
    Undefined control sequence. \includegraphics[width=\linewidth]{photo}
    Undefined control sequence. \includegraphics[width=\linewidth]{photo}
    File `photo' not found. \includegraphics[width=\linewidth]{photo}
    

    I have made sure that the file photo is in the same directory.

    This started happening after I updated TeXstudio, and it happens both in my laptop and desktop. I have reinstalled MiKTeX and TeXstudio countless times in both, but to no avail. I think TeXstudio is unable to detect the graphicx package somehow? The reason why I think it's because of TeXstudio is when I upload this project to Overleaf, there are no issues with it.

    • campa
      campa about 4 years
      Unrelated to the error: \usepackage[pdftex]{graphics,graphicx} should be a plain \usepackage{graphicx}.
    • moewe
      moewe about 4 years
      Can you open the .log file and copy the complete error message. The messages posted in the question seem to be the shortened versions displayed by your editor. Usually the messages are longer and indicate more clearly which command is undefined. Without seeing the error, my money would be on tex.stackexchange.com/q/511138/35864, but I can't be sure. Update MikTeX in Admin and User mode at least twice.
    • daleif
      daleif about 4 years
      Since texstudio is just editing text files and afterwards running latex on these, this issue have nothing to do with texstudio. As moewe states we'd like more information from the real log, not the filtered log that texstudio gives you as it often filters away important information. I agree with moewe, most likely an incomplete miktex update
    • Bernardo
      Bernardo about 4 years
      @moewe You were right, you can have your money back. It was indeed the same problem, I just had to update MikTeX
    • moewe
      moewe about 4 years
      Very good. In that case it would make sense to simply close this question here as a duplicate of tex.stackexchange.com/q/511138/35864. Do you agree?
    • Bernardo
      Bernardo almost 4 years
      Yes I totally agree. I am sorry for opening a new question, but I really couldn't find the answer that you indicated before... Thanks!
  • David Carlisle
    David Carlisle about 4 years
    Note that you were confused becaue texstudio totally scrambled the error message. TeX would have reported which command was undefined, and texstudio mangles that and makes it look as if \includegraphics was defined. There is a long standing bug report open, you could comment there and ask for any updates sourceforge.net/p/texstudio/feature-requests/1068