2

I would like to use the following folder structure for my project:

/template
  template.tex
  template.sty
/doc1
  doc1.tex
/doc2
  doc2.tex

The doc documents are supposed to access the template that defines part of the preamble. So, doc looks like

\input{../template/template.tex}
\usepackage{...} %additional packages to load
\begin{document}
...
\end{document}

and template.tex looks as follows:

\documentclass[12pt]{scrartcl}
\usepackage{template}
\usepackage{...}

However, this does not work, because template.sty is not found, which seems to be a problem of relative/absolute paths. Is there a nice solution to this problem?

1 Answer 1

1

Search path at TeX macro level

The macro \input@path can contain additional search paths:

\makeatletter
\providecommand*{\input@path}{}
\g@addto@macro\input@path{{../template/}}
\makeatother
\input{template.tex}
% ...
\begin{document}
...
\end{document}

Environment variables

Another way is setting the environment variable TEXINPUTS to add the path ../template to the search path for TeX input files, e.g. for TeX Live/Linux/bash:

export TEXINPUTS=:../template

Also an absolute path could be used instead of the relative path. The colon at the begin (probably semicolon in Windows) says that first the configured paths without TEXINPUTS are searched, then TeX looks into ../template.

TEXMFHOME

Also the template files could be installed in the home TEXMF tree, example for TeX Live/Linux:

~/texmf/tex/latex/template/template.tex
~/texmf/tex/latex/template/template.sty

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.