As the name suggests - can I do something like:


LaTeX is throwing errors at me when I try to do it.

  • 1
    You should drop the .sty, but apart from that, there should be no problem. What kind of errors is LaTeX throwing your way? – Werner Oct 14 '13 at 5:48
  • @Werner L-l-l-legend! Dropping .sty fixed it. If you make your comment into an answer I will accept it – nebffa Oct 14 '13 at 5:52
  • 5
    It is a syntax error to put a file path in the name argument. Like many TeX errors it is possible to do it anyway and get some sort of result. but it is still an error. – David Carlisle Oct 14 '13 at 9:48

Instead of using a full path, it is a much better practice to put your file in an appropriate place where TeX will find it. It seems you are a *NIX user, so you may try

$ less `kpsewhich texmf.cnf`

to know which places are these. There is a lot of comments in this file, they will help you. Alternatively, you can use the TEXMFHOME or the TEXINPUTS environment variable. Their use is detailed in texmf.cnfas well.

You probably want to distinguish three cases of use for your software package mypackage:

  • Site-wide installation, it is then adapted to store your TeX files in a site-wide available directory and ${TEXMFLOCAL}/tex/latex/mypackage is probably a good choice. (Use kpsexpand to know which actual path to use, as in kpsexpand '${TEXMFLOCAL}/tex/latex/mypackge').

  • User specific installation, the directory ${TEXMFHOME}/tex/latex/mypackage then looks appropriate.

  • Development, while you are developing your package, you probably want to avoid repeteadly installing TeX related files and prefer add the appropriate locations to the TEXINPUTS environment variable.

The file texmf.cnf contains useful informations about these variables.

  • @DavidCarlisle is there another way to do this? I am writing a Python (programming) package and need to bundle my .sty file with the package. – nebffa Oct 14 '13 at 12:12
  • 3
    @nebffa Then (to be portable) you really don't want to require users to put an absolute path in their latex document. You should just use \usepackage{name} and then stick name.sty anywhere on the tex input path, either the current directory or one of the standard places, or a new place that you add to the path. – David Carlisle Oct 14 '13 at 12:20
  • @nebffa If you really want to input a file from a fixed location it is not (to latex) a package so just use \input{/path/to/file.tex} and put the macros in a .tex file (starting with \makeatletter if needed. – David Carlisle Oct 14 '13 at 12:22
  • 2
    TeX use the k path search library to lookup files. It is documented in info kpathsea. If you are distributing a software package called mypackage installed system-wide, your files could go in /usr/local/share/texmf/tex/latex/mypackage or a similar path (see texmf.cnf as I wrote in my answer). If your package is installed for only one user, then your package should go in $TEXMFHOME/tex/latex/mypackage and kpsewhich --var-value TEXMFHOME tells you which values is actually considered. I would rather use the environment variable for engineering not for deployment. – Michael Le Barbier Grünewald Oct 14 '13 at 14:23
  • 2
    You should incorporate your comment about the different texmf locations into your answer. I suspect many people (don't know that they) are looking for the information contained in the comment. – jon Oct 16 '13 at 1:51

\usepackage{<file>} can take a full path, but requires you to drop the file extension. That is, it assumes \usepackage{<path>/file} will include file.sty located in <path>, self-appending the extension (known as \@pkgextension). So, drop the .sty.

The following MWE reproduces the problem:


yielding the error message:

! LaTeX Error: File `graphicx.sty.sty' not found.

Type X to quit or  to proceed,
or enter new name. (Default extension: sty)
  • 2
    LaTeX issues a warning, if the package name in \usepackage does not match the package name in \ProvidesPackage of the package file: LaTeX Warning: You have requested package "...", but the package provides "...". – Heiko Oberdiek Oct 14 '13 at 6:39
  • 1
    @HeikoOberdiek It does. And it is one of the most annoying things it does if you do \usepackage{../mypkg} – yo' Oct 14 '13 at 7:13
  • 5
    It is wrong to use a full path and one of the main reasons of the \ProvidesPackage system is to warn users of that. – David Carlisle Oct 14 '13 at 9:46

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.