尝试插入数字时缺少数字,视为零

尝试插入数字时缺少数字,视为零

出于某种原因,在我所有的数字中,这个似乎不想被插入。它一直给出:

"Missing number, treated as zero." <to be read again>
}
\begin{figure}{h}{\textwidth}

我哪里做错了?

谢谢大家的帮助!

%----------------------------------------------------------------------------------------
%   PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[11pt]{article} % Default font size is 12pt, it can be changed here

\usepackage{geometry} % Required to change the page size to A4
\geometry{a4paper} % Set the page size to be A4 as opposed to the default US Letter

\usepackage{graphicx} % Required for including pictures

\usepackage{float} % Allows putting an [H] in \begin{figure} to specify the exact location of the figure
\usepackage{wrapfig} % Allows in-line images such as the example fish picture

\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template

\linespread{1.2} % Line spacing

%\setlength\parindent{0pt} % Uncomment to remove all indentation from paragraphs
\usepackage{enumitem}
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored
\usepackage{textgreek}
\usepackage{sidecap}
\usepackage[font=small]{caption}
\begin{document}

%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

\begin{titlepage}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % Defines a new command for the horizontal lines, change thickness here

\center % Center everything on the page

\textsc{\School}\\[1.5cm] % Name of your university/college
\textsc{\Large Virology}\\[0.5cm] % Major heading such as course name
\textsc{\large Encephalophitides}\\[0.5cm] % Minor heading such as course title

\HRule \\[0.4cm]
{ \huge \bfseries Rabies Virus}\\[0.4cm] % Title of your document
\HRule \\[1.5cm]

\begin{minipage}{0.4\textwidth}
\begin{flushleft} \large
\emph{Author:}\\
Name \textsc{Name} % Your name
\end{flushleft}
\end{minipage}
~
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{Supervisor:} \\
Dr. Hi \textsc{Hilles} % Supervisor's Name
\end{flushright}
\end{minipage}\\[4cm]

{\large December 4, 2015}\\[3cm] % Date, change the \today to a set date if you want to be precise

%\includegraphics{Logo}\\[1cm] % Include a department/university logo - this will require the graphicx package

\vfill % Fill the rest of the page with whitespace

\end{titlepage}

%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

\tableofcontents % Include a table of contents

\newpage % Begins the essay on a new page instead of on the same page as the table of contents 



\begin{figure}{h}{\textwidth} 
  \begin{center}
    \includegraphics[width=0.4\textwidth]{rabiespathology}
  \end{center}
  \caption{Rabies pathogenesis. \cite{Rabiesdiagnosis}}
\end{figure}

答案1

(不是独立的答案,而是对@ChristianHupfer 的答案的详细说明。)

以下是 Christian Hupfer 的回答中提到的一些“可疑设置”,无特定顺序列出:

  • \\[<length>]]在整个环境中过度使用titlepage会产生换行符和额外的垂直间距。删除这些说明并使用,另起一行\vspace{<length>}。除其他外,使用 ,\vspace您将能够成功地将水平线对称地放置在标题周围。(目前,线条的位置相当不对称。)

  • \center环境中的命令titlepage应该替换为\centering

  • \School您的代码中未定义该宏。

  • 不要使用低级命令\linespread。最好加载包并在前言中setspace执行。\setstretch{1.2}

  • 更改单行字体大小时,请确保以 结束该行,\par以便在行下方获得适合字体大小的垂直空白量。

  • 如果minipage环境中的行数不相等,请务必指定[t]对齐说明符,以便它们彼此正确对齐。

  • 如果您的文档包含图表列表,请提供省略引用标注的标题的“简短版本”。

  • Christian 已经提到:figure环境确实不是采取宽度参数;并且,您应该使用\centering而不是\begin{center}\end{center} 里面环境figure

  • 文档类中的默认字体大小article10pt,而不是12pt


\documentclass[11pt,a4paper]{article} %% Default font size is 10pt (*not* 12pt)

\usepackage{geometry} 

\usepackage[demo]{graphicx} %% Omit "demo" option in real document
\graphicspath{{Pictures/}}

\usepackage{float} 
\usepackage{wrapfig}

%%\linespread{1.2} % Line spacing
\usepackage{setspace}
\setstretch{1.2}

%\setlength\parindent{0pt}
\usepackage{enumitem}
\usepackage{textgreek}
\usepackage{sidecap}
\usepackage[font=small]{caption}
\begin{document}

%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

\begin{titlepage}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

%\center % Center everything on the pagen
\centering

%%\textsc{\School} % Name of your university/college
{\Huge\scshape School Name Here}

\vspace{1.5cm}

{\Large\scshape Virology\par} % Major heading, such as course name

\vspace{0.5cm} 

{\large\scshape Encephalophitides\par} % Minor heading, such as course title

\vspace{0.5cm} 

\HRule 

\vspace{0.4cm}

{\huge \bfseries Rabies Virus\par} % Title of document

\vspace{0.4cm} 

\HRule 

\vspace{1.5cm}

\begin{minipage}[t]{0.4\textwidth}
\begin{flushleft} \large
\emph{Author:}\\
Name {\scshape Name} % Your name
\end{flushleft}
\end{minipage}
~
\begin{minipage}[t]{0.4\textwidth}
\large
\begin{flushright} 
\emph{Supervisor:} \\
Dr.\ Hi \textsc{Hilles} % Supervisor's Name
\end{flushright}
\end{minipage}

\vspace{4cm}

{\large December 4, 2015} % Date, change "\today" to a set hard-coded date

\vspace{3cm}

%\includegraphics{Logo}\\[1cm] % Include a department/university logo

%%\vfill % Fill the rest of the page with whitespace

\end{titlepage}

%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

\tableofcontents % Include a table of contents

\listoffigures %% Provide a list of figures

\newpage % Begins the essay on a new page instead of on the same page as the table of contents 



\begin{figure}[h!]%{h} %%%{\textwidth} 
  %%\begin{center}
  \centering
    \includegraphics[width=0.4\textwidth]{rabiespathology}
  %%\end{center}
  \caption[Rabies pathogenesis]{Rabies pathogenesis. \cite{Rabiesdiagnosis}}
\end{figure}
\end{document}

答案2

\begin{figure}[h]{\textwidth}是错误的,原因有二:

  1. figure没有强制性的参数,{\textwidth}毫无用处
  2. \textwidth是维度寄存器,不能以此方式使用。维度寄存器可以分配为其他长度,但值必须用 进行排版\the\textwidth

还有其他值得怀疑的设置,但是这并不会导致文档编译失败!


\documentclass[11pt]{article} % Default font size is 12pt, it can be changed here

\usepackage{geometry} % Required to change the page size to A4
\geometry{a4paper} % Set the page size to be A4 as opposed to the default US Letter

\usepackage[demo]{graphicx} % Required for including pictures

\usepackage{float} % Allows putting an [H] in \begin{figure} to specify the exact location of the figure
\usepackage{wrapfig} % Allows in-line images such as the example fish picture

\usepackage{lipsum} % Used for inserting dummy 'Lorem ipsum' text into the template

\linespread{1.2} % Line spacing

%\setlength\parindent{0pt} % Uncomment to remove all indentation from paragraphs
\usepackage{enumitem}
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored
\usepackage{textgreek}
\usepackage{sidecap}
\usepackage[font=small]{caption}
\begin{document}

%----------------------------------------------------------------------------------------
%   TITLE PAGE
%----------------------------------------------------------------------------------------

\begin{titlepage}

\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % Defines a new command for the horizontal lines, change thickness here

\center % Center everything on the page

%\textsc{\School}\\[1.5cm] % Name of your university/college
\textsc{\Large Virology}\\[0.5cm] % Major heading such as course name
\textsc{\large Encephalophitides}\\[0.5cm] % Minor heading such as course title

\HRule \\[0.4cm]
{ \huge \bfseries Rabies Virus}\\[0.4cm] % Title of your document
\HRule \\[1.5cm]

\begin{minipage}{0.4\textwidth}
\begin{flushleft} \large
\emph{Author:}\\
Name \textsc{Name} % Your name
\end{flushleft}
\end{minipage}
~
\begin{minipage}{0.4\textwidth}
\begin{flushright} \large
\emph{Supervisor:} \\
Dr. Hi \textsc{Hilles} % Supervisor's Name
\end{flushright}
\end{minipage}\\[4cm]

{\large December 4, 2015}\\[3cm] % Date, change the \today to a set date if you want to be precise

%\includegraphics{Logo}\\[1cm] % Include a department/university logo - this will require the graphicx package

\vfill % Fill the rest of the page with whitespace

\end{titlepage}

%----------------------------------------------------------------------------------------
%   TABLE OF CONTENTS
%----------------------------------------------------------------------------------------

\tableofcontents % Include a table of contents

\clearpage



\begin{figure}[h]%{\textwidth} 
   \centering

    \includegraphics[width=0.4\textwidth]{rabiespathology}

  \caption{Rabies pathogenesis. \cite{Rabiesdiagnosis}}
\end{figure}

\end{document}

相关内容