Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load latex .sty files from a subdirectory?

I use some .sty-files that are not part of texlive and want to have them in a subdirectory of the folder with my main.tex. I used the following line to load the package:

\usepackage{sty/prettythesis} 

This works, but compiling the main.tex with xelatex and using rubber gives me a warning:

sty/prettythesis.sty: You have requested package `sty/prettythesis', but the package provides `prettythesis'. (page 1) 

Is there a way to prevent this warning or handle this case without having to include "sty\" in all .sty-files' \ProvidesPackage command or set the TEXINPUTS environment variable (which seems not to be possible from the main.tex itself)?

like image 629
Bruno Avatar asked Oct 14 '10 18:10

Bruno


People also ask

How do I import a .STY file into LaTeX?

sty ) into your document in two ways: If you have it in your path or in the same folder as the . tex file, simply include this line in your preamble: \usepackage{mystyle} If you have it in a different folder, you can access using its full path as \usepackage{/path/to/folder/mystyle}

Which is the best directory to keep my .STY files?

sty files? If you want to install your own . sty files, then you should copy the files into the directory tex/latex/mystuff relative to a new TEXMF root directory.

Where do .STY files go?

sty or . cls files must be in some subdirectory of tex\latex which can be in any directory of any drive.

What is .STY file in LaTeX?

sty files are loaded by LATEX to provide and improve methods that are used to create documents. Generally speaking, class files implement the specific structure of the document, whereas packages are used to provide either generic functionality to any document, or to 'style' the methods provided by a specific class.


1 Answers

I believe this thread here:

  • LaTeX Community • View topic - Including tex files

talks about precisely the same thing: so it seems, the only alternatives are either using TEXINPUTS environment variable; or using the import package. (note, there is a variant on the import package on ...Including tex files pg 3.)

A bit more about TEXINPUTS:

  • TeX Frequently Asked Questions -- “Temporary” installation of (La)TeX files
  • Setting TeX Environment Variable Paths
  • Environment Variables for Running LaTeX
  • TeX (and Variations) for Writing Math - math.umn.edu (see 'TeX Inputs')
  • Installing LaTeX packages - TeX search paths

Hope this helps;
Cheers!

 

EDIT: I hoped that one could set the TEXINPUTS path directly in the tex file (by using \write18 -- and note, some versions of LaTeX use --enable-write18, mine uses -shell-escape to enable \write18; see also this) - but it seems it is not possible:

"... This isn't possible. ... The environment variable of the child process is set, but this hasn't an effect to its parent process (TeX)." (Re: Setting the environmental variable TEXINPUTS within latex - comp.text.tex).

... so, now I just call pdflatex in my Linux bash like this:

TEXINPUTS=.//:$TEXINPUTS pdflatex ./myfile.tex

and then it will resolve directly \usepackage{mypackage} in the myfile.tex file - even if mypackage.sty is in a subdirectory, say ./subdir/mypackage.sty.

like image 64
sdaau Avatar answered Sep 20 '22 20:09

sdaau