我使用 Sharelatex 提供的预设项目格式之一(带回忆录的论文模板)。.tex 文件如下所示:
\documentclass[11pt,a4paper,oldfontcommands]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage[dvips]{graphicx} %I've tried removing [dvips] here but this doesn't make a difference?
\usepackage{xcolor}
\usepackage{times}
\usepackage[
breaklinks=true,colorlinks=true,
linkcolor=black,urlcolor=black,citecolor=black,% PRINT
bookmarks=true,bookmarksopenlevel=2]{hyperref}
\usepackage{geometry}
\geometry{total={210mm,297mm},left=25mm,right=25mm, bindingoffset=0mm, top=25mm,bottom=25mm}
\OnehalfSpacing
%%% CHAPTER'S STYLE
\chapterstyle{bianchi}
%%% STYLE OF SECTIONS, SUBSECTIONS, AND SUBSUBSECTIONS
\setsecheadstyle{\Large\bfseries\sffamily\raggedright}
\setsubsecheadstyle{\large\bfseries\sffamily\raggedright}
\setsubsubsecheadstyle{\bfseries\sffamily\raggedright}
%%% STYLE OF PAGES NUMBERING
\pagestyle{plain}
\makepagestyle{plain}
\makeevenfoot{plain}{\thepage}{}{}
\makeoddfoot{plain}{}{}{\thepage}
\makeevenhead{plain}{}{}{}
\makeoddhead{plain}{}{}{}
\maxsecnumdepth{subsection}
\maxtocdepth{subsection}
\begin{document}
然后,稍后我在脚本中使用:
\begin{figure}[h]
\includegraphics[width=8cm]{Xray}
\centering
\end{figure}
但这不会产生图片,而只会产生一个包含“Xray.png”的图片框。我的 .png 文件与 .tex 文件位于同一个文件夹中,因此我有点不知道问题可能出在哪里。有谁知道问题可能出在哪里吗?
答案1
[dvips]
从序言中删除选项\usepackage[dvips]{graphicx}
。正如@DavidCarlisle 所述,将\centering
命令放在图形命令行之前。
\begin{figure}[h]
\centering
\includegraphics[width=8cm]{Xray}
\end{figure}