As the name suggests - can I do something like:
\usepackage{/home/nebffa/Desktop/maths/questions/fillwithlines.sty}
LaTeX is throwing errors at me when I try to do it.
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.cnf
as 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.
.sty
file with the package.
\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.
Commented
Oct 14, 2013 at 12:20
\input{/path/to/file.tex}
and put the macros in a .tex
file (starting with \makeatletter
if needed.
Commented
Oct 14, 2013 at 12:22
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.
Commented
Oct 14, 2013 at 14:23
texmf
locations into your answer. I suspect many people (don't know that they) are looking for the information contained in the comment.
\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:
\documentclass{article}
\usepackage{graphicx.sty}
\begin{document}
Test
\end{document}
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)
\usepackage
does not match the package name in \ProvidesPackage
of the package file: LaTeX Warning: You have requested package "...", but the package provides "...".
Commented
Oct 14, 2013 at 6:39
\usepackage{../mypkg}
\ProvidesPackage
system is to warn users of that.
Commented
Oct 14, 2013 at 9:46
.sty
, but apart from that, there should be no problem. What kind of errors is LaTeX throwing your way?.sty
fixed it. If you make your comment into an answer I will accept it