So I'm trying to add a Matlab script to my latex document using the mcode and listings packages. The way I use it is \lstinputlisting{/Users/Username/Documents/MATLAB/exampleintegral.m} I then get the error "Package Listings Error: File /Users/Username/Documents/MATLAB/exampleintegral(.m) not found" If I have the .m file in the same folder as the latex file it will retrieve it, but some of the lines will continue over the edge of the page even if I use \lstinputlisting[breaklines=true]{exampleintegral.m}. The weird thing is that I used this method when writing my thesis and it worked like a charm. Now, all of a sudden, the program is unable to find any files.

Has anyone encountered this before? Any solutions?

MWE:

\documentclass[12pt]{article}
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}
\usepackage{listings}
\begin{document}
\lstinputlisting{/Users/User name/Documents/MATLAB/cosmology/exampleintegral.m}
\end{document}


What I use to get around this (by having the code in the same folder as the tex file), although the code will look nasty (some lines break some don't).

\lstinputlisting[breaklines=true]{exampleintegral.m}

• Welcome to TeX.SE! Can you please show us a short compilable code you have tried so far? – Kurt Oct 28 '17 at 15:43
• Does your username contain any special characters or spaces? But as Kurt says it would be easier for us to help you if you could add a MWE (minimal, compilable code example). – TeXnician Oct 28 '17 at 16:23
• Edit your question instead of posting code in comments. There is an edit link right above the comments. After pasting the code into the question, select it and hit Ctrl + K (or click the button marked {}). – Torbjørn T. Oct 28 '17 at 18:24
• Is the space in user name also in your real user name? – user36296 Oct 28 '17 at 18:45
• In which folder is your tex file? – user36296 Oct 28 '17 at 18:46

• using a relative file path instead of a total one, i.e. using \lstinputlisting{./MATLAB/cosmology/exampleintegral.m} instead of \lstinputlisting{/Users/User name/Documents/MATLAB/cosmology/exampleintegral.m}