I have problem with path management. Let me explain you:

I work with subfiles that are arranged in this way:


I want to be able to include the code "CodeLab1.m" in the "Report_P1_1.tex" file and "CodeLab2.m" in the "Report_P2_1.tex" and to be able to compile them either separately or from the main (as I use subfile its possible). The trick I use is this:



\usepackage{xcolor, listings, subfiles}

    \ifx\mainCmp\undefined  \renewcommand{\myPathLstONE}{../Matlab} 
    \else                   \renewcommand{\myPathLstONE}{lab1/Matlab}
    \ifx\mainCmp\undefined  \renewcommand{\myPathLstTWO}{../Matlab} 
    \else                   \renewcommand{\myPathLstTWO}{lab2/Matlab}


\part{Labo 1}

\part{Labo 2}




\section{Part 1}

There's a listing:





\section{Part 2}

There's a listing:



It works quite well, the only problem (exept that its not really practical to define every time these command) is that in the output I got, there is always the name of the code file as you can see. I didn't find a way to avoid this.

output of Main.pdf

As its possible to define multiple path for graphics, the inclusion of listings is my only problem working with this architecture.

Can somebody help or propose an other way to do this?

Thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.