I have nested folders with multiple files containing statements and solutions for exercices.
main.tex
exercices (folder)
⮑ statements (folder)
⮑ 1.tex
⮑ 2.tex
⮑ solutions (folder)
⮑ 2.tex
From what I understand on few topics like input files in different directories, you cannot input files from different nested directories and need to use the import package. So this was the previous code :
\foreach \filenumber in {1,2}{
\IfFileExists{exercices/statements/\filenumber}{\input{exercices/statements/\filenumber}}
\IfFileExists{exercices/solutions/\filenumber}{\input{exercices/solutions/\filenumber}}
}
The issue is that the following code still doesn't work with the \import command.
\documentclass{book}
\usepackage{import}
\usepackage{tikz}
\begin{document}
\foreach \filenumber in {1,2}{
\IfFileExists{exercices/statements/\filenumber}{\import{exercices/statements/}{\filenumber}}
\IfFileExists{exercices/solutions/\filenumber}{\import{exercices/solutions/}{\filenumber}}
}
\end{document}
The code gives the error LaTeX Error: File exercices/solutions/1.tex' not found.

\input, you may find\importhelps with the syntax in some cases, although personally I think it makes things more complicated for little gain. – David Carlisle Jun 28 '23 at 10:43\IfFileExists{exercices/statements/\filenumber}{\input{exercices/statements/\filenumber}}can be simplified and made more efficient by\InputIfFileExists{exercices/statements/\filenumber}– David Carlisle Jun 28 '23 at 10:44\foreach \filenumber in {1,2}{\InputIfFileExists{exercices/statements/\filenumber} \InputIfFileExists{exercices/solutions/\filenumber}}inputs1.texand2.texfrom thestatementsfolder but it doesn't input2.texfrom thesolutionsfolder.I did not do anything in particular about the start, I'm using overleaf so I guess it starts from
– Flowt Jun 28 '23 at 10:59main.texas usual.{}{No solution}– David Carlisle Jun 28 '23 at 11:03