Search code examples
latexfigure

Why Figure is not displayed in the latex file and text is shown instead of it


I am newbie in latex and trying to add figure into the latex file as follows:

\documentclass{bmcart}

%%% Load packages
\usepackage{amsthm,amsmath}

\usepackage[utf8]{inputenc} %unicode support
\usepackage{mathtools}
\usepackage{amsmath}
\usepackage{graphicx}


\def\includegraphic{}
\def\includegraphics{}

\startlocaldefs
\endlocaldefs

\begin{document}
    
\begin{figure}[h!]
    \includegraphics{figures/GBMfigure3.jpg}
    \caption{show the results of the different settings for the parameters of the penalty model for solving the problem \ref{q11}.}
    
\end{figure}

\end{document}

But, the figure is not displayed and the text itself is displayed instead of the figure, for example the resulted file is as below:

enter image description here

So, what's the solution of that issue please.


Solution

  • With \def\includegraphics{} you redefine the command to do nothing. If you want it to include your image, don't do such a redefinition.

    \documentclass{bmcart}
    
    %%% Load packages
    \usepackage{amsthm,amsmath}
    
    \usepackage[utf8]{inputenc} %unicode support
    \usepackage{mathtools}
    \usepackage{amsmath}
    \usepackage{graphicx}
    
    
    %\def\includegraphic{}
    %\def\includegraphics{}
    
    \startlocaldefs
    \endlocaldefs
    
    \begin{document}
        
    \begin{figure}[h!]
        \includegraphics{example-image-duck}
        \caption{show the results of the different settings for the parameters of the penalty model for solving the problem \ref{q11}.}
        
    \end{figure}
    
    \end{document}
    

    enter image description here