图像未显示

图像未显示

我包含了 graphicx,并像平常一样使用了以下代码来包含图像。

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{graphicx}
\graphicspath{{images/}}

\begin{document}

\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{figure1.png}
    \label{figure1}
    \caption[Impaired bacterial handling by macrophages when treated with the Glucose-6-phospahatase inhibitor for 5 days]{\emph{Figure legend}}
\end{figure}
\end{document}

我不确定哪里出了问题。警告说“浮动太大”。知道哪里出了问题吗?谢谢

答案1

我已经使用一些随机文件成功编译了您的代码.png。您的图片高度可能太大,您应该尝试以下代码。

如果你想全局更改标题,你还应该考虑以下用法http://www.ctan.org/pkg/caption

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage[textfont=it]{caption}

\begin{document}

\begin{figure}
    \centering
    \includegraphics
        [width=\textwidth, height=0.9\textheight,keepaspectratio]
        {figure1.png}
    \caption
        [Impaired bacterial handling by macrophages when treated with the Glucose-6-phospahatase inhibitor for 5 days]
        {Figure legend}
    \label{figure1}
\end{figure}

\listoffigures
\end{document}

答案2

@Campanlgnis 答案的细微变化:

  • 如果图像的宽度大于其高度,则可以按如下方式包含图像:

    \includegraphics[width=\textwidth]{bacteria-handling} % please use correct name of image ...

  • 相反,当图像的高度大于其宽度时,按如下方式包含图像

    \includegraphics[height=0.85\textheight]{bacteria-handling} % please use correct name of image ...

如果您考虑上述“规则”,图像就必须显示在您的文档中。

对于第二种情况,完整的 MWE 是:

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{fullpage}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage[demo]{graphicx}
\graphicspath{{images/}}
\usepackage[textfont=it]{caption}

%-------------------------------------- only for show page layout
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}

\begin{figure}[htb]
    \centering
\includegraphics[height=0.85\textheight]{bacteria-handling} % please use correct name of image ...
\\[1ex]
\begin{minipage}{\linewidth}
    Figure legend: If the legend is long, i.e. has more lines, than you probably need to reduce image height, for example from \verb+height=0.85\textheight+ to \verb+height=0.8\textheight+.
\end{minipage}
    \caption[Impaired bacterial handling by macrophages]
            {Impaired bacterial handling by macrophages when treated with the Glucose-6-phospahatase inhibitor for 5 days}
    \label{figure1}
\end{figure}

\listoffigures
\end{document}

无关:通常,图的标题会显示图名,最后是图例部分,它们指向 LoF,仅包含图的(短)名称。但是,您可以单独编写图例,如上面的 MWE 所预期的那样,并且在包含中只为 LoF 写短名称,为图标题写长名称。

在此处输入图片描述

相关内容