How to load latex .sty files from a subdirectory?

前端 未结 4 1097
悲&欢浪女
悲&欢浪女 2021-02-02 05:42

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:

4条回答
  •  后悔当初
    2021-02-02 06:37

    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.

提交回复
热议问题