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\import
helps with the syntax in some cases, although personally I think it makes things more complicated for little gain.\IfFileExists{exercices/statements/\filenumber}{\input{exercices/statements/\filenumber}}
can be simplified and made more efficient by\InputIfFileExists{exercices/statements/\filenumber}
\foreach \filenumber in {1,2}{\InputIfFileExists{exercices/statements/\filenumber} \InputIfFileExists{exercices/solutions/\filenumber}}
inputs1.tex
and2.tex
from thestatements
folder but it doesn't input2.tex
from thesolutions
folder. I did not do anything in particular about the start, I'm using overleaf so I guess it starts frommain.tex
as usual.{}{No solution}