13

I often switch between Linux and Windows. A number of my LaTeX files use images from a central folder. All of these are within a Dropbox folder, which is how I sync between them.

The dropbox folders are in different paths on Windows and Linux, so I would like to make a macro which detects the OS and uses the correct path.

superbriggs
  • 2,052

3 Answers3

20

There should be no need to put any tests in your documents, just use

\includegraphics{file}

and arrange that your dropbox folder is in your TEXINPUTS environment variable or (better) texmf.cnf setting on your two machines and it should all just work.

David Carlisle
  • 757,742
17

write into your document

\graphicspath{{c:/Windows/images/User/}{/home/me/images/}}

and then use only the filename of the image. You have to use slashes for directories in Linux and Windows.

6

For windows refugees, remember that Windows also has symlinks (use mklink or from right click window->new create shortcut).

 \graphicspath{{../Dropbox/pic/}{{/home/me/images/}}}

where, Dropbox is the shortcut name to the Dropbox shortcut.

The advantage of this, is that I wouldn't have the LaTeX file in the dropbox folder (all sorts of problems). Rather place your LaTeX file somewhere separate say your Github folder.

My suggestion also is that is always better to use a version control system and only use Dropbox for back-ups.

yannisl
  • 117,160