includegraphics 缺少插入 $ 和缺少数字,视为零

includegraphics 缺少插入 $ 和缺少数字,视为零

我不明白为什么我的命令在 LaTeX 中失败。

这是我的问题,这行代码导致! Missing $ inserted.

    \includegraphics[width=\textwidth]{../Thesis\ Results/CaptureNoVibrate/d4c9f2c9-afe0-4693-9a1b-20621a7a1953/algorithm_backprojection_sr.png}

所以我将其更改为以下内容并收到此错误!Missing number, treated as zero.

    \includegraphics[width=\textwidth]{../Thesis\ Results/CaptureNoVibrate/d4c9f2c9-afe0-4693-9a1b-20621a7a1953/algorithm\_backprojection\_sr.png}

除此之外,我尝试了各种各样的变化,使用引号、不转义空格、{ }在文件路径周围添加,但总是以提到的错误结束。

这是我的文件结构:先前的代码位于此文件中 /Thesis/Thesis Doc/ch4.tex

我尝试加载的图像在这里

/Thesis/Thesis Results/CaptureNoVibrate/d4c9f2c9-afe0-4693-9a1b-20621a7a1953/alorithm_back_projection_sr.png

我有一个单独的 Matlab 脚本来生成这个结构(结果结构),这就是我在文件路径中使用 GUID 的原因。

我已多次检查过拼写等内容。

任何帮助深表感谢。

编辑

这是基础的 tex 文档

% Baylor University Master's Thesis LaTeX template
% Template created by Jonathan Drake (2013)

% Thesis class, based on report
\documentclass
[
        %short, % omit front matter
        %draft,         % draft heading, don't load graphics, etc.
]
{thesis}

% Optional additional packages
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{chicago}
\usepackage{lipsum} % Because this comes with a demo
\usepackage{hyperref}  % for workin links and bookmarks (alexsalo)
\usepackage{bookmark}  % faster bookmarks manegment (alexsalo)

% Thesis parameters
\title{Baylor University Master's Thesis \LaTeX\ Template}
\author{Tyler Hartwig}
\holding{B.S.}
\seeking{M.S.}
\degree{Master of Science}
\date{May 2017}

% Administration
\graduateDean{J. Larry Lyon, Ph.D.}
\department{Department of Electrical and Computer Engineering}
\departmentChair{Gregory D. Speegle, Ph.D.}

% Supervisor (adviser / mentor)
\supervisor{Keith Evan Schubert, Ph.D.}
\supervisorTitle{Mentor}

%  Readers (committee members)
\readerOne{Robert Marks, Ph.D.}
\readerTwo{Byron, Newberry, Ph.D.}
%\readerThree{J. J. J. Heimer-Schmidt, M.D.}
%\readerFour{...}
%\readerFive{...}

% Abstract
\abstract{Mobile phones and cameras are incredibly popular and the hardware is becoming very impressive. The photos these devices are currently able to take are already of high quality, however it is possible to improve these cameras in software. It is possible to take burst-shot photos and utilize the phase offsets to realize a higher resolution signal. While this takes a large amount of computation, it is possible to reduce that computation by using the IMU devices on mobile phones. This research explores that idea, as well as investigating what signal resolving algorithms produce the highest quality image in combination with the IMU data. IMU sensors are shown to help in reducing the time it takes to register photos to sub-pixel accuracy. It is also shown that the results by using the sensors are comparable to not using these sensors.}

% Acknowledgments (optional)
%\acknowledgements{I want to express my great appreciation to several people.
%Aenean vulputate, est eget tempor dignissim, massa magna dignissim nulla, quis
%pharetra nulla libero ac libero. Cras id ornare augue. Nunc auctor nunc at dolor
%mattis suscipit. Vestibulum eu fringilla est. Morbi elementum varius ornare.
%Nulla vitae nibh sed lectus posuere tincidunt. Praesent sed dignissim turpis.
%Nulla euismod dolor nec nulla ornare blandit.}

% Dedication (optional)
%\dedication{\it Pour la rose qui fait important le temps qu'on perd}

% List of figures (optional)
\makeListOfFigures

% List of tables (optional)
\makeListOfTables

% Document body
\begin{document}
        \pdfbookmark[-1]{CONTENT}{bookmark:Content}  % Top level bookmark to hold all chapters

        % Chapters
        \include{ch1}
        \include{ch2} 
        \include{ch3}
        \include{ch4}
        \include{ch5}

        % Appendices (optional)
        % TODO: make the thesisAppendixPage automagic if the \begin{appendices} exists
        \thesisAppendixPage 
        \begin{appendices}
                \appendix % Vaclav Cibur compile fix
                \include{appendixA}
                \include{appendixB}
        \end{appendices}

        % Bibliography
        \bibliographystyle{chicago} % or whatever style your department uses
        \bibliography{thesis}

\end{document}

这是我正在使用的模板的 repo。 https://github.com/BaylorCS/baylor-cs-thesis

答案1

仅从评论中简要总结一下解决方案:

问题在于文件地址中存在空格(以及一些来自 latex 的误导性错误消息)。您的文件位置格式如下:

\Folder Name\filename.jpg

因此,您需要在文件地址周围添加一些引号,以便 latex 正确处理空格。插入此图像的正确代码是:

\includegraphics{"Folder Name/filename"}

请注意,如果文件名/位置中没有空格,则代码无论带不带引号(“)都可以正常工作。

就我个人而言,我特别注意在文件和文件夹名称中完全避免使用空格,因为很容易忘记引号,然后跑题去想为什么代码突然停止工作,因为错误消息通常很奇怪而且没有帮助。连字符 (-) 和下划线 (_) 通常可以很好地替代文件名中的空格,而且 latex 总是可以毫无问题地处理它们。

相关内容