I'm trying to use a command in my LaTeX file that inputs a file if it exists, and if it doesn't exit, inputs another one. This is the command:
\IfFileExists{/media/kingstonGB/LaTeX/preamble}{\input{/media/kingstonGB/LaTeX/preamble}}{\input{E:\\LaTeX\\preamble}}
In short, the command searches for the file in /media/kinstgonGB (which should succeed on my unix systems, and if it finds it, inputs it. Otherwise, if that file is not found, it means the LaTeX is being compiled on a Windows system, so it should look for files in E:\. However, I get this error message:
! LaTeX Error: Missing \begin{document}.
I've also tried wrapping E:\LaTeX\preamble in quotes, or escaping it (as done here), or both, and the error is the same.
\IfFileExistscommand: What you're looking for should be a file, but the command's first argument looks like a path to a file, not a file itself. Or is there maybe a file namedpreamble.tex? If so, it might be a good idea to add the.texextension explicitly and try recompiling. Separately, you may want to add a second\IfFileExistsinstruction, in the second argument of the first such command, to check explicitly for the existence of the filee:\\LaTeX\\preamble.tex-- unless you're always good and never forget to insert the USB key. :-) – Mico Nov 29 '11 at 13:52preamble.tex. I use a standard preamble for all of my LaTeX documents, so I normally input it in the header. I don't need to specify the.texextension with the\inputcommand, though, right? – Ricardo Altamirano Nov 29 '11 at 13:54.tex, but doing so wouldn't hurt the code's legibility either. :-) Re-check the error message you're getting: is it being generated by the\IfFileExistscommand, or is it maybe being generated by some instruction contained in preamble.tex? For instance, do you get the same error message if the file preamble.tex is in your current working directory and you load it from the main driver file with the command\input preamble? – Mico Nov 29 '11 at 13:56.texextension for both theIfFileExistsand the two\inputcommands, and on Windows, it's still working properly (I'll test on *nix when I'm back at the flat). Thank you! – Ricardo Altamirano Nov 29 '11 at 13:58\InputIfFileExists– Alain Matthes Nov 29 '11 at 14:05