! 缺少 $ 插入

! 缺少 $ 插入

我遇到了一种奇怪的错误。我收到了第 727 行的“!缺少 $ 插入。”错误消息。问题是:该行是空的!在错误消息中,他似乎加载了我之前尝试包含的 R 文档。但是,我删除了这行代码,因为文件夹路径中有空格。现在,我完全可以使用我的文件了。你能帮忙吗?我上次保存是 24 小时前……当我用 TexMaker 打开文件时,我总是收到“文件未找到”错误消息。

即使我将文档缩短到少于 727 行,我仍然会收到第 727 行的错误

\documentclass[12pt,a4paper,oldfontcommands,oneside]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage[dvips]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{xcolor}
\usepackage{times}
\usepackage{amsmath}
\usepackage{blindtext}  
\usepackage{fancyhdr}   
\usepackage{etoolbox}
\usepackage{eurosym}    
\usepackage[printonlyused]{acronym} 
\usepackage{booktabs}   
\usepackage[bottom]{footmisc}
\setlength{\footnotemargin}{0.0cm}


\usepackage[breaklinks=true,colorlinks=true,linkcolor=black,urlcolor=black,citecolor=black,
bookmarks=true,bookmarksopenlevel=2]{hyperref}

\usepackage[nosectionbib]{apacite}

\usepackage{epstopdf}

\usepackage{geometry}
%%% PRINTING OPTIONS
\geometry{total={210mm,297mm},
left=33mm,right=33mm,
bindingoffset=0mm, top=25mm,bottom=20mm}

\OnehalfSpacing

%%% CHAPTER'S STYLE
\chapterstyle{article}
%%% STYLE OF SECTIONS, SUBSECTIONS, AND SUBSUBSECTIONS
\setsecheadstyle{\Large\bfseries\sffamily\raggedright}
\setsubsecheadstyle{\large\bfseries\sffamily\raggedright}
\setsubsubsecheadstyle{\bfseries\sffamily\raggedright}


%%% STYLE OF PAGES NUMBERING USING THE FANCYHDR PACKAGE
\pagestyle{fancy}
\fancyhf{}
\lhead{\leftmark}   %%% Show Chapter left in Header
%\lhead{\leftmark}  %%% Show Section left in Header
\cfoot{\thepage}

\maxsecnumdepth{subsection} % chapters, sections, and subsections are numbered
\maxtocdepth{subsection} % chapters, sections, and subsections are in the Table of Contents


%%%---%%%---%%%---%%%---%%%---%%%---%%%---%%%---%%%---%%%---%%%---%%%---%%%

\begin{document}


\end{tabular}

\clearpage

\chapter{Results}

\section{Placeholder}




\appendix
\chapter{The Internal Ratings-Based Approach of the Basel II Concept}
\[Capital = \left\{45\times N \left[\frac{IN(PD)}{\sqrt{1-R}} + \frac{\sqrt{R} \times IN(0.999)}{\sqrt{1-R}}\right] - 45 \times PD \right\} \times \left[\frac{1+(M-2.5) \times b(PD)}{1-1.5 \times b(PD}\right]\]

\chapter{Second Appendix}


\clearpage
%\markboth{BIBLIOGRAPHY}{}  %%% BIBLIOGRAPHY in Header
\bibliographystyle{apacite}
\bibliography{References}
\clearpage

\end{document}





! Missing $ inserted.
<inserted text> 
                $
l.727 ...is/R/Down-and-in Call/down-and-in_call.R}

I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.


! Package Listings Error: File `C:/Users/User/Documents/Master Thesis/R/Down-an
d-in Call/down-and-in_call(.R)' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: R)

Enter file name: 
! Emergency stop.
<read *> 

l.727 ...is/R/Down-and-in Call/down-and-in_call.R}


*** (cannot \read from terminal in nonstop modes)

答案1

我设法将您的示例精简为最小工作示例。为了避免打乱例程filecontents,请尝试这个最简化的示例。创建一个 R 文件,将其命名为我的R并仅添加此行(如果美元符号和下划线是嫌疑犯,为什么不试试呢?):

data$var <- a_1

然后,尝试这个 LaTeX 文档:

\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage{listings}

\begin{document}
\lstinputlisting[language=R]{my.R}
\end{document}

你应该得到如下结果: 源代码清单

好吗?试着将一半的代码复制down-and-in_call.R进去my.R并编译。成功了吗?很好。失败了吗?继续二分,直到找到有问题的行(listings例如,不能很好地处理 UTF-8)。好吗?从你的序言中添加软件包。

如果遇到任何问题,请不要忘记清理帮助文件。这对您有用吗?

相关内容