[Tex/LaTex] Naming LaTeX files: best practice

best practicesfile-lookup

What's the best practice for naming LaTeX files?

I know R, Matlab, and Java all differ in their use of ., _, -, camel case, capitalization, etc. What do people generally use for naming LaTeX files? Is this easily portable across systems?

I remember having a HUGE problem interpreting a Matlab program of mine. Turned out that I had named the file in a way that Matlab couldn't handle. To avoid such issues in the future, I'd just like to start naming my LaTeX files using best practices.

Best Answer

It depends a little if this files are only used by you are if you are planning to share them with other people, e.g. if you work with them on one document or the files are part of a LaTeX package.

But in general I would strongly recommend you to limit yourself to lowercase alphanumeric ASCII characters, i.e. a-z, 0-9 and -.

The reasons for that are:

  • Unicode or other non-ASCII characters can cause trouble when copied on a different file system with a different code page. I had the case that I couldn't even see files with German umlauts on a Windows share mounted by Linux. This is now much better, but still a risk. The normal TeX doesn't like non-ASCII character that much either.
  • Some file systems (FS) are case sensitive (e.g. under *nix FSs) others aren't (e.g. FAT, NTFS). If you keep you file names all lowercase you avoid collisions between files which can lead to loss of data when copied from a case sensitive to a case insensitive FS. Also you will run intro trouble on case sensitive systems when the actual filename has a different capitalization as on the hard drive. You might not realize that on e.g. Windows, but it will hit you then hard on a different FS.
  • Characters which are special in TeX will work as long they are valid at this position which excludes % and #. Others as & can cause trouble as well and there is no real reason to use them, so avoid them. Even _ which is commonly used and will work inside \input can cause trouble when the filename should be printed, so avoid it as well.
  • Spaces are "evil" in filename as well because some external tools will take them as file name separator. TeX should be fine with them, except when they used multiple times in a row. TeX will then combine them to one prior to the interpretation as a filename!
  • Dots will confuse the simple extension extraction algorithms used by LaTeX. See this question for an example.

I'm going through some effort in the svn-multi package to allow for arbitrary file names. This is done using verbatim mode which doesn't help for other input macros like \input, \include or \includegraphics.