TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to build a project directory organization structure which follows best-practices. Adapting this structure, part of my project structure would look as follows:


Q: Where should I tell my R output to go though? Is there a generally acceptable best practice which is the least breakable, most modular, most intuitive, etc.?

I see a few options:

  1. myproject/code/r/. In this case main.tex will include statements like \includgraphics{../code/r/output.pdf}. This seems clunky though. Should main.tex really "know" about ../code/r/?
  2. myproject/code-output. In this case main.tex will include something like \includgraphics{../code-output/output.pdf}. main.r would include statements like pdf("../../code-output/output.pdf"). Right now this is my preferred method. It seems logical for main.r to "put" it's output in a directory that is reasonable for main.tex to "see".
  3. myproject/report/img. In this case main.tex will include something like \includgraphics{./img/output.pdf}. main.r would include statements like pdf("../../report/img/output.pdf"). I don't like this approach for the same reasons as "1." above: in this case, it doesn't seem like main.r should "know" about \report\img.

I'm not a programmer but may be doing a lot of this. So, I'm very curious how programmers think about this sort of stuff. All thoughts are welcome!

share|improve this question
up vote 3 down vote accepted

Is there a generally acceptable best practice

There is again no best practice. This is true for all of LaTeX, so please don't ask for best practices again ;-)

I'm not a programmer

If you work with R and TeX you are a programmer :-)

Generally I think all your suggestions are fine. Separating the document from data files is recommended because LaTeX likes to produce lots of auxiliary files. While there is the option to use --output-directory as mentioned in the post you linked to, many editors are not aware of this and place output files in the input/current directory by default. So the rule of thumb regarding LaTeX files is to use a dedicated directory for every document. If you want to compile several versions from more than one source, these should go into different output directories.

Regarding pictures and other data input files: (1) and (2) can theoretically cause problems because it is possible to disable reading files from parent directories (which might make sense in batch-processing environments that receive untrusted input). I usually choose a combination of (1) and (3) by having the data processing tool place its output in the same directory as the input (or similar), and then adding symbolic links to the data/picture files in the LaTeX directory. I think that approach combines the advantages of (1) and (3): the data processing tool doesn't need to know that its output is used in a TeX document, and the document doesn't need to know where the data comes from. So in your case I'd add a symlink myproject/report/img/output.pdf pointing to ../../code/r/output.pdf.

share|improve this answer
@Phillip: Well, whatever. By "best practice" I'm just trying to find out what a good approach may be. Btw, your answer is very helpful. I like this set-up. I'll follow it. – lowndrul Mar 2 '11 at 3:32
@Phillip: I'm trying what you suggested using shortcuts (not symlinks) in Windows and am having trouble. I posted a follow-up question How can I pass a shortcut to \includegraphics. – lowndrul Mar 3 '11 at 2:38
@brian: I think if you want to follow my suggestion, you need symbolic links (which are supported by Windows btw). – Philipp Mar 3 '11 at 13:07
@Phillip: Yes using mklinks from the command line in Windows and making sure that the link had a .pdf extension (since I'm using PdfLaTeX) was the trick. Everything works now. – lowndrul Mar 3 '11 at 15:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.