I am frequently using the \input{} command in my master.tex file to import text from other files, e.g.
\input{./texts/myText.tex} for inserting the text file "myText.tex", from the folder "texts" into my master.
However, if Latex cannot find the file "./texts/myText.tex" the compilation process stops and I have to search the log file for an explanation. To circumvent this I use the package etoolbox in the preamble, and the following code where I want to insert the file content:
\usepackage{etoolbox} ----- \newcommand{\filename}{./texts/myText.tex} \IfFileExists{\filename}% {\input{\filename}}% {\color{red} Latex cannot find this file: \filename} When using this code Latex will input the file if it finds it, and if not Latex will insert a warning message into the compiled output instead of stopping the compilation process.
This functions great, except for the fact that the new code takes four lines of space compared to one line for the initial code.
My question is, how can I put the four lines of code into a latex function like
\inputMsg{./texts/myText.tex}
where the new function "inputMsg" contains the functionality of four lines of code. How will the code for this new "inputMsg" look like ?
Thanks in advance for any helpful suggestions : )