1

I want to have a directory called "Templates" where I would like to have .tex files and image files for inclusion. An example template would setup a letter format with watermark, fancy header, language settings, font selection etc. I want to have my templates at one place, and have all other documents at another location. For example:

Documents
   |
   |-  Templates
   |     |
   |     |-- letter_header.tex
   |     |-- company_watermark.png
   |
   |- Contracts
   |     |
   |     |-- Company 01
   |     |     |
   |     |     |-- contract01.tex
   |     |     |-- contract02.tex
   |     |     |-- contract03.tex

Here is my problem. From contract01.tex I would like to do something like this:

\include{../../Templates/letter_header.txt}

However, this won't work because LateX cannot write aux files in that directory. Under Microsoft Windows, there is no symbolic link that could be used. I understand that it is a security risk to allow latex to write into any directory ( (How) can I include the file somedir/file.tex in the file somedir/subdir/anotherfile.tex ). So what is the safe way? Can I specify that under "Documents" it should be able to write to any directory?

Most important question: there must be thousands using LateX with their own templates, and they probably want to separate template code from actual content. Are all of them forced to use clumsy / unsafe solutions?

UPDATE:

Uploaded an example here: https://www.dropbox.com/s/15dxnu48wdqp897/SyncedFolder.zip

What I want is to be able to use my businessletter class from test01.tex, test02.tex, test03.text or from any folder under SyncedFolder/Documents. The watermark.jpg file belongs to the businessletter class, and so it should be loaded from the class file.

results of setting TEXINPUT:

enter image description here

  • why do you want to use \include rather than \input or better just use \documentclass{myletter} that way you only ever need to write aux files to teh current directory – David Carlisle May 7 '14 at 12:04
  • I would use a custom documentclass rather than inputting header code explicitly but if you want to do the latter just use \input{letter_header} and arrange that Documents/Templates is in your TEXINPUTS path, you should not need to put tthe path in the document, just as you don't use \input{/texlive/texmf-dist/tex/latex/base/article.cls} – David Carlisle May 7 '14 at 12:07
  • \input does not work because I have images included in letter_header. They are also located in the templates directory. Unfortunately, \input does not change the current dir so it would be impossible to use relative paths to access the images from letter_header. – nagylzs May 7 '14 at 18:01
  • 1
    the MWE should be small enough to paste inline (unless you plan to maintain that dropbox link foreverand not break the archives of this site) tex looks in the places specified in TEXINPUTS which can be set as an environment variable, or in a texmf.cnf config file, or depending on your environment system, on the command line, I can go TEXINPUTS=.//: pdflatex myfile and then tex will find any tex or image files at any depth of any subdirectory of the current directory. Replace .// by any suitable place on your machine where you want it to look – David Carlisle May 16 '14 at 15:00
  • 1
    That set TEX T INPUTS so does nothing, and presumably you had earlier set TEXINPUTS to the wrong thing – David Carlisle May 16 '14 at 16:20
0

Assuming you're on TeX Live for Windows, here's what works for me:

  1. Find out where your TEXMFHOME folder is located:

    C:\Users\renfro>c:\texlive\2013\bin\win32\tlmgr conf | find /i "TEXMFHOME"
    TEXMFHOME=C:/Users/renfro/texmf
    
  2. Make folders for your class content, complying with the TeX Directory Structure (official word from A Directory Structure for TeX Files, abridged version at the LaTeX Wikibook section Installing Extra Packages).

    C:\Users\renfro>mkdir texmf\tex\latex\base
    
  3. Copy your .cls file to the folder you just created, and use it in documents created elsewhere.

The only difference with other operating systems or other TeX distributions would be the particular paths to tlmgr, kpsexpand, etc., and to your own home directory.

  • Thanks. Well this does not work nicely with dropbox or google drive. My goal was to use LaTex for creating letters, reports and contracts for my company. The style should be defined for the company. I wanted to use the same templates from my computers, and synchronize them with Google Drive. Unfortunately, it seems I cannot use Google Drive folder for making a document class. :-( And it also seems there is no way to give script-relative paths. I'm doomed. – nagylzs May 15 '14 at 17:52
  • I might write a script to recursively copy from Google Drive or Dropbox into the texmf tree, then. Using robocopy for Windows, rsync for Unix-like systems, etc. Either that, or create all documents of a particular class in one particular folder, and put the .cls in that folder as well. – Mike Renfro May 15 '14 at 20:21
  • Can't you change the location of your DropBox directory on Windows? (I've only used it on Linux so maybe the answer is 'No'.) – cfr May 17 '14 at 2:16
  • Here is the solution. For Windows, you can set TEXINPUTS to TEXINPUTS=.\\;c:\Temp\SyncedFolder\Templates\\;c:\texlive\2013\texmf-dist\tex\\ There "templates" is my templates dir and "texmf-dist\tex" is my LiveTex distribution dir. Here are some questions: Where is the value ot TEXINPUTS documented? I have spent the last two hours figuring out the syntax and the meaning, but I could find abolutely nothing on it. Why is that? It took me 30 minutes to come up with a TEXINPUTS value that actually works! – nagylzs May 17 '14 at 7:16
  • Also tried on Linux. Under Linux this works: export TEXINPUTS=.//:~/Dropbox/Documents/Templates: but under Windows, the trailing colon cannot be used, and the only way I could find is to use c:\texlive\2013\texmf-dist\tex\\ – nagylzs May 17 '14 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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