\usepackage{} are (relative) paths possible?

5,203 views
Skip to first unread message

Paul A Norman

unread,
Oct 14, 2010, 4:56:54 AM10/14/10
to latexus...@googlegroups.com
Is there a directive that can be placed in a document to cause
packages to be available from the local filesystem?

I was wondering becasue a .sty in a document's own directory is
recognisable and usable in the current document with out the LaTeX
distro yet knowing about it, so I was wondering if any sort of
document package path directives existed like
\graphicspath{{c:\mypict~1\camera}} does for graphics?

Or whether
there is way of placing a path in the
\usepackage{{{../styles/here/}}myStyle}

The real life purpose is for current team work where people are
potentially on different LaTeX distros, all using TeXWorks and you
want to keep a project file structure with custom packages in a
certain part of that structure, which can be accessed with relative
paths preferably.

(Not re-supplying changed .sty on a document by document basis,
becasue multiple seperate documents (in their own folders) are sharing
the same .sty and all need access to the updated version of it)

Any adivce appreciated please.

Paul

Peter Flynn

unread,
Oct 14, 2010, 10:28:06 AM10/14/10
to latexus...@googlegroups.com

Yes, absolutely. In the file texmf.cnf is the shell path spec for where TeX looks for stuff. You can add and modify these on a per-user basis.


--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To post to this group, send email to latexus...@googlegroups.com.
To unsubscribe from this group, send email to latexusersgro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/latexusersgroup?hl=en.

Paul A Norman

unread,
Oct 14, 2010, 9:34:56 PM10/14/10
to latexus...@googlegroups.com
Thank you Peter,

I have brought this here from a thread on the TeXWorks mail-list.

There we have been canvassing whether this kind of thing which works
on Mac OS and possibly reliably on MikTeX works becasue a standard
issue (un-altered) texmf.cnf or other points of LaTeX casue it to be
so, or whether the result is fickle and unrelaible between differing
LaTeX (*TeX) distros.

This is the sort of thing envisaged which works for some users -
WITHOUT altering the texmf.cnf

>>>> \documentclass[11pt]{book}
>>>> \usepackage{../StyleSheets/Preamble}
>>>> \usepackage{../StyleSheets/AssessmentDocumentConstruction}
>>>> \usepackage{../StyleSheets/QuizConstructionParameters}
>>>> \usepackage{../StyleSheets/GraphicsPaths}
>>>> \begin{document}

Another very experienced user, Bruno Voisin, has suggested:

"That's likely distribution-specific and also platform-specific.

"Namely, the definition of \usepackage (in latex.ltx) is highly
convoluted, it goes through a sequence of cascading definitions
involving \RequirePackage and \InputIfFileExists, and in between more
obscure stuff like \@onefilewithoptions, \@@input and the like.

"But it all seems in the end to go down to the \input TeX
primitive, which is implemented at the time TeX is built.

"Let me be more specific: in TeX Live, file searching involves
kpathsea, which is a C file searching library. So what TeX accepts in
TeX Live comes down to what kpathsea accepts. MikTeX must similarly
involve its own file searching library, which may place different
restrictions on file names and a different syntax for path
specification.

"Over the years I've seen all sorts of situations on different
platforms (Mac and Linux) and different TeX distributions (Textures,
OzTeX, DirectTeX, CMacTeX, teTeX, gwTeX, TeX Live). Some accepted file
names with spaces directly as \input{file name}, others required
quotes \input{"file name"}, others bluntly rejected spaces. Same with
8-bit characters in file names (Textures accepted it, OzTeX rejected
it). Textures accepted to typeset in plain TeX a file with spaces in
its name, but OzTeX didn't; both refused to typeset in LaTeX a file
with a space in its name, owing to the creation and reading of
ancillary files (.aux, etc.).

"Also in the same distro different TeX programs may see things
differently. This may have changed, but originally XeTeX, owing to its
Mac roots, was less strict on the use of spaces in file names than
pdfTeX.

"Similarly the path specification varies from platform to
platform. On Mac OS Classic a subfolder Figures in the current
directory was specified (in \graphicspath) as :Figures: and a
subsubfolder as :Figures:Part1:, but on Mac OS X it's Figures/ and
Figures/Part1/, respectively.

"So I don't think there is any norm on this, and I'm not even
sure where to look for information. I looked briefly at the
documentation of kpathsea for TeX Live, and I couldn't find any info.

"Bruno Voisin

So I am trying to determine whether relataive paths like above would
be able to be relied upon across the board of LaTeX distros - with
out user alteration of the texmf.cnf ?

At the moment it seems not?

Paul

Peter Flynn

unread,
Oct 15, 2010, 8:05:15 AM10/15/10
to latexus...@googlegroups.com

Putting it more crudely, if you specify a relative, absolute, or partial path in a \usepackage command, LaTeX will try to obey it, and won't use texmf.cnf. But this is really only for development or a last resort; regularly-used packages should go in their proper tree (system, local, version, global, user, etc) as defined in texmf.cnf, and be referenced by their name alone.

> Yes, absolutely. In the fil...

--

You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group....

Paul A Norman

unread,
Oct 15, 2010, 5:30:08 PM10/15/10
to latexus...@googlegroups.com
Dear Peter thanks for that.

I whole heartedly agree that we should genereally be steering folk to
using there packetmanagement setups.

It does appear from the feed back I am getting along with our own
needs, that during coillaberative and other projects, there may be
situations where in-house (but geographically seperated) and other
needs require the use of packages which are not appropriate or useful
for CTAN - not having a wider auidience, and often times the LaTEX
user (while capible at LaTeX tasks) is not going to be proficient with
altering their Dostro's configuartion (seriously:- might even be
scared of touching it).

I have today received this on the TeXWorks mail list.

> > a) can packages be accessed by \usepackage{} on relative paths from
> > the document's directory,
>
> It depends on the setting of openin_any in texmf.cnf.
>
> % Allow TeX \openin, \openout, or \input on filenames starting with `.'
> % (e.g., .rhosts) or outside the current tree (e.g., /etc/passwd)?
> % a (any) : any file can be opened.
> % r (restricted) : disallow opening "dotfiles".
> % p (paranoid) : as `r' and disallow going to parent directories, and
> % restrict absolute paths to be under $TEXMFOUTPUT.
> openout_any = p
> openin_any = a

But, just to confirm and clarify, your understanding points us to the
fact that LaTeX will try to attempt to interpret and use any path
statement in \usepackage{} any way?

Thanks again,
paul

> --
>
> You received this message because you are subscribed to the Google Groups
> "LaTeX Users Group" group....
>
> On 15 October 2010 03:28, Peter Flynn <angleb...@gmail.com> wrote:
>> Yes, absolutely. In the fil...
>
> --
> You received this message because you are subscribed to the Google Groups

Paul A Norman

unread,
Oct 16, 2010, 5:42:45 AM10/16/10
to latexus...@googlegroups.com
This is where this one ended up...

"When it is not approapiate for a package to be in the .tex files
directory, nor on CTAN then ...

"It looks to me like an admin / education issue if someone can't get a
package to load thorugh a relative path, rather than an area where
TeXWorks could help,
what is to be done is give them guidence on
1) placing packages in their local system where their *TeX distro is
then 2) told to find them.

Paul

Peter Flynn

unread,
Oct 16, 2010, 6:29:19 PM10/16/10
to latexus...@googlegroups.com
On Fri, Oct 15, 2010 at 5:30 PM, Paul A Norman <paul.a...@gmail.com> wrote:
Dear Peter thanks for that.

I whole heartedly agree that we should genereally be steering folk to
using there packetmanagement setups.

It does appear from the feed back I am getting along with our own
needs, that during coillaberative and other projects, there may be
situations where in-house (but geographically seperated) and other
needs require the use of packages which are not appropriate or useful
for CTAN - not having a wider auidience, and often times the LaTEX
user (while capible at LaTeX tasks) is not going to be proficient with
altering their Dostro's configuartion (seriously:- might even be
scared of touching it).

Yep. Those should go in a specially-created tree, such as /usr/local/share/texmf-mycompany
but that would mean requiring higher-level control over everyone's texmf.cnf.
 

I have today received this on the TeXWorks mail list.

>  >    a) can packages be accessed by \usepackage{} on relative paths from
>  > the document's directory,
>
> It depends on the setting of openin_any in texmf.cnf.
>
> % Allow TeX \openin, \openout, or \input on filenames starting with `.'
> % (e.g., .rhosts) or outside the current tree (e.g., /etc/passwd)?
> % a (any)        : any file can be opened.
> % r (restricted) : disallow opening "dotfiles".
> % p (paranoid)   : as `r' and disallow going to parent directories, and
> %                  restrict absolute paths to be under $TEXMFOUTPUT.
> openout_any = p
> openin_any = a

But, just to confirm and clarify, your understanding points us to the
fact that LaTeX will try to attempt to interpret and use any path
statement in \usepackage{} any way?

AFAIK, a simple package name will get resolved using the rules in texmf.cnf, as applied by kpsewhich.
Anything that looks like it's a path will get resolved using that path, and if it fails, I don't think it will default back to a match with kpsewhich. In other words, if you say \usepackage{foo}, then kpsewhich will look in the current working directory first, and if not found, it will then search all the ls-R databases in all the paths in texmf.cnf for foo.sty, and if that still isn't found, it's an error. If you say \usepackage{docs/foo} then it will look only in the docs subdirectory of the current working directory for foo.sty and then give up if it's not there.

But I stand to be corrected by someone who knows the code better. This is the kind of question which should really go to comp.text.tex where the people who actually write this stuff hang out.

///Peter

Paul A Norman

unread,
Oct 16, 2010, 8:49:31 PM10/16/10
to latexus...@googlegroups.com
Mnay thanks for that Peter,

I'll keep comp.text.tex in mind if it becomes necessary to get
greater clarity on this.

Paul

Donald Arseneau

unread,
Oct 27, 2010, 2:45:54 AM10/27/10
to LaTeX Users Group
On Oct 14, 1:56 am, Paul A Norman <paul.a.nor...@gmail.com> wrote:
> Is there a directive that can be placed in a document to cause
> packages to be available from the local filesystem?
>
> I was wondering becasue a .sty in a document's own directory is
> recognisable and usable in the current document with out the LaTeX
> distro yet knowing about it, so I was wondering if any  sort of
> document package path directives existed like
> \graphicspath{{c:\mypict~1\camera}} does for graphics?
>
> Or whether
> there is way of placing a path in the
> \usepackage{{{../styles/here/}}myStyle}

As others have said, the environment variables like TEXINPUTS can
add paths. Also, within LaTeX tou can define \input@path to be
a list of paths

\def\input@path{{here/I/am}{there/you/are}}

Reply all
Reply to author
Forward
0 new messages