13

I use multiple computers (Mac and PC), so creating a path (e.g. \input{c:/folder/Preamble}) won't work. I really want to assign a URL (in Dropbox) to the file and input the file via the URL, but I don't know what command to use to achieve that. Suggestions?

azetina
  • 28,884
Charlie
  • 253
  • 1
  • 9

2 Answers2

16

This is what has been working great for me for about two years now.

  • create a .sty file containing your universal preamble. A .sty file, basically, is a regular TeX file starting with \ProvidesPackage{mystyle}, ending with \endinput, and everything else inbetween.*)

  • in your Dropbox (or similar), create a directory named texmf-local, and a subdirectory such as mypackages, and put your .sty file there. [it might be a good idea to follow the standard TeX Directory Structure, and make mypackages a subdirectory of temxmf-local/tex/latex/]

  • add that new texmf-local to the list of paths scanned by texhash. In my case (as a TeXLive user), this means modifying texmf.cnf:
    TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local;e:/files/dropbox/texmf-local.

  • run a texhash and kpsewhich mystyle.sty to confirm everything's okay.

  • in your documents, load your preamble via \usepackage{mystyle}. No additional packages are needed for all this to work. Plus, it's completely platform-agnostic.

needless to say, step 3 (and 4) has to be done separately on each machine.

Over time, in my case, this has developed from a mere universal preamble into a full-fledged package with lots of options, internal sub-routines and dependencies. There's a lot of things you can do with a .sty file you can't do with a simple \input...

*) Consult clsguide.pdf for details about package writing.

Nils L
  • 9,716
  • 3
    I would suggest that the local texmf directory follow the TeX Directory Structure, so a custom package would go in temxmf-local/tex/latex/mypackages/ At the same time you can put your images in texmf-local/tex/generic/images, etc. – Matthew Leingang Oct 15 '13 at 19:18
  • yes, that's certainly the more standard way. Added it to my post. – Nils L Oct 15 '13 at 20:15
  • I was curious about the advantages of doing it with a package. I asked a question about it here: http://tex.stackexchange.com/questions/139157/what-are-the-pros-and-cons-of-packages-versus-input-for-a-preamble – twsh Oct 16 '13 at 16:17
6

Here's what I ended up doing:

\usepackage{ifplatform, pdftexcmds, catchfile}

\ifwindows

\input{% windows path to preamble}

\fi

\ifmacosx

\input{% mac path to preamble}

\fi
A.Ellett
  • 50,533
Charlie
  • 253
  • 1
  • 9