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





bindingoffset=0mm, top=25mm,bottom=20mm}



\lhead{\leftmark}   %%% Show Chapter left in Header
%\lhead{\leftmark}  %%% Show Section left in Header

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







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

%\markboth{BIBLIOGRAPHY}{}  %%% BIBLIOGRAPHY in Header


! 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
    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.
    – Relam
    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
    – Relam
    Feb 26, 2016 at 18:27

1 Answer 1


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:



You should get something like this: Source code listing

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?
    – Relam
    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.
    – Relam
    Feb 26, 2016 at 19:04
  • @Relam TeXmaker can be quite quirky and quaint. Just for testing purposes, try pdflatexing 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .