How to load latex .sty files from a subdirectory?

前端 未结 4 1104
悲&欢浪女
悲&欢浪女 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:32

    You can do it in your TeX file without changing your system's environment (do not forget the trailing slash / with each directory):

    \makeatletter
    \def\input@path{{../one-directory/}{../another-directory/}}
    \makeatother
    
    \documentclass{myclass} 
    \usepackage{mypackage}
    

    This way, though, may be not recommended for portability. As other answers mention, the "correct" way is to set the TEXINPUTS variable in your system environment before you call latex; in Windows it is (you can place it in a batch file):

    set TEXINPUTS=../one-directory/;../another-directory/;%TEXINPUTS%
    pdflatex myfile.tex
    

提交回复
热议问题