[Tex/LaTex] Folder structure of your work

best practicesfolders

Users,
I am using LaTeX for homework at university. By now, I had always other programs generating some files, that I used in my LaTeX-document. For example MATLAB generated some graphs, Inkscape generated some pictures and so on.

I always used a folder structure like this:

/experiment01/matlab/
/experiment02/matlab/
/experiment02/inkscape/
...

/beamer-presentation01/
/beamer-presentation02/
...

/fulltext01/
/fulltext02/
...

With this, I am on the one hand able to use figures again in different versions of presentations and the thesis text. On the other hand, my latex references break, if I rename folders. Also the old presentations do not have a fixed state, because the sketches done by Inkscape might change (if not versioned).

What do you recommend? Do you keep your proper work separated from the LaTeX-files? Do you refer to the same figure again in different documents or do you copy it?

Best Answer

This is highly dependent on your work flow. For example, I do all of my plotting in pgfplots so data is central to me rather than plot images. A typical paper that I'm writing will have

  • A master folder with the .tex file. Inside the master folder are:
    • A folder for images, figures and externalized (it using TikZ/pgfplots) figures.
    • A folder for data. Keep this away from your programs!
    • A folder for scripts and programs. Don't write directly to the data folder!

However, each paper is a very simple document. For something much larger like my thesis I had an elaborate directory structure, with each chapter in its own folder. The master .tex file sat in a special folder called build rather than at the top of the structure. Each chapter was otherwise treated like a paper in the simple structure above, and there were a couple of other special folders to contain the preamble and macros etc.

For (very) simple documents it may not be worth having any structure at all, opting for a pool of files in a single folder.

Putting aside my paranoia about having data to be published in the same directory as scripts and programs that can overwrite it, modern operating systems offer simple ways to view the contents of a directory by type in the UI. In a *nix terminal this is trivial too with something like

ls *.dat

to view just data files. One could therefore make a case for no special directory structure at all for all but the largest documents.

A final note; for large documents, consider using version control. I suggest Git, but that's a matter of taste. It's saved my skin more times than I care to mention.