I'm writing a report with multiple programming languages. At the moment I'm trying to include a Makefile.
When I do:
\lstinputlisting[language=make]{./Kodeeksempler/makefile}
I get the following error compiling with texlive in texmaker:
! Missing $ inserted.
<inserted text>
$
l.22 ]{./Kodeeksempler/makefile}
Line 22 of the makefile in question contains the following:
BUILD_DIR=build/host
.. So I know the error message is wrong, as that should be able to display fine. Any help would be greatly appreciated. The same occurs when I try to do lstlisting around the makefile regularly like so:
\begin{lstlisting}
clean:
$(RM) ./build
$(RM) ./bin
@echo "Static libraries persist in ./lib"
${BUILD_DIR}/%.d: %.cpp
$(CXX) -MT ${BUILD_DIR}/$(@:.d=.o) -MM $(CXXFLAGS) $^ > $@
-include $(DEPS)
\end{lstlisting}
EDIT:
I seem to have narrowed down that the error occurs around the line:
-include $(DEPS)
When I remove it, lstlisting includes it just fine.
EDIT2: This is the lstset I use in my preamble:
\lstset{language=make, % Sprog
basicstyle=\ttfamily\scriptsize, % Opsaetning af teksten
keywords={for,if,while,else,elseif, % Noegleord at fremhaeve
end,break,return,case,
switch,function},
keywordstyle=\color{blue}, % Opsaetning af noegleord
commentstyle=\color{commentGreen}, % Opsaetning af kommentarer
stringstyle=\color{stringPurple}, % Opsaetning af strenge
showstringspaces=false, % Mellemrum i strenge enten vist eller blanke
numbers=left, numberstyle=\tiny, % Linjenumre
extendedchars=true, % Tillader specielle karakterer
columns=flexible, % Kolonnejustering
breaklines, breakatwhitespace=true, % Bryd lange linjer
}
I have noticed that even when I omit the last part of the makefile, it seems to work.
EDIT3:
So I found the issue! Appearently the @ key was used as an escape character for an old lstset for C code, and it came back in as a result of a merge conflict. Line 199 in the preamble contained the following:
\lstset{escapechar=@,style=customc}
I removed it, and now it works. Thank you all for your patience.
\lstsetin your document or the document class. And I suppose that you have the optionmathescapeset. – Oct 05 '15 at 20:02\usepackage{listings}in the preamble and the Makefile from the question, it compiles fine. – Arun Debray Oct 05 '15 at 20:07