# ! Missing $inserted im experiencing a kind of weird error. I receive the "! Missing$ inserted." error message for line 727. The problem: the line is empty! In the error message he seems to load an R document that I tried to include before. However, I have deleted this line of code as I have spaces in the folder paths. Now, I can work with my file at all. Can you please help? My last save is 24h old... When i open the file with TexMaker I always receive a "File not found" error message.

Even if I shorten the document to have <727 lines, I still get an error for line 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}

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

%%% STYLE OF PAGES NUMBERING USING THE FANCYHDR PACKAGE
\pagestyle{fancy}
\fancyhf{}
\cfoot{\thepage}

\maxsecnumdepth{subsection} % chapters, sections, and subsections are numbered

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

\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
\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

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

Enter file name:
! Emergency stop.

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

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

• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
– Null
Feb 26, 2016 at 18:13
• Note sure if that works as a MWE. Sorry, I'm just working with Latex since a couple of weeks and until now I was always able to identify the errors myself. Feb 26, 2016 at 18:22
• Changing the name Call/down-and-in_call.R for some without underscore _ may be a simple way to solve your problem. Feb 26, 2016 at 18:25
• I'd love to do that, but that line of code does not exist anymore. I deleted it the \lstinputlisting{} argument as the error appeared first Feb 26, 2016 at 18:27

I managed to reduce your example to the minimum working one. To avoid messing with the filecontents routine, try this most minimal example. Create an R file, name it my.R and add this line only (if dollar signs and underscores are the suspects, why not try them?):

data\$var <- a_1


Then, try this LaTeX document:

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

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


You should get something like this:

Fine? Try to copy half of your down-and-in_call.R into my.R and compile it. It works? Good. Does not work? Continue bisecting till you find the problematic line (listings does not handle UTF-8 well, for example). Good? Add the packages from your preamble.

And in case of any trouble, do not forget to do the cleanup of helper files. Does this work for you?

• Thanks Andrei. If I try to compile that almost virgin document, I receive three "Log file not found" error pop ups. Any idea? Feb 26, 2016 at 18:43
• Which editor do you use (TeXStudio, TeXworks, WinEdt, ...)? Which OS and which LaTeX distribution (MiKTeX or TeXLive)? Feb 26, 2016 at 19:00
• @Relam It is always a good idea to strip even the logs and PDFs, remaining only with the .tex source and .R code. Then, in order to go full virgin, you should open up the command line in your folder (in Windows, Shift+Right-click on the empty space in your folder and “Open Command Window”, in Linux just call the terminal from that folder or cd there) and try executing pdflatex myfile.tex. The purest thing possible. If there is an error, the problem is with your LaTeX distribution. If not, your text editor is the culprit. Feb 26, 2016 at 19:04
• Tekmaker with Miktex. I just reinstalled Miktex tried to compile the last backup (~24h ago) and now receive the following error: ! LaTeX Error: Command \footruleskip already defined. Feb 26, 2016 at 19:04
• @Relam TeXmaker can be quite quirky and quaint. Just for testing purposes, try pdflatex`ing your document either from the Windows command prompt (as described above) or from the TeXWorks editor (included in the “Complete” installation). Does any of those complain? Feb 26, 2016 at 19:07