How to load latex .sty files from a subdirectory?

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

    As you discovered, putting the package in a subdirectory (say, ./sty/prettythesis.sty with respect to your main .tex file at ./), and calling the package via

    \usepackage{sty/prettythesis}
    

    will successfully load the package, but it will produce the warning

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

    If all you want is to get rid of this warning, and you're OK with minor modifications in the .sty file, then you can simply change the package name that it reports, by changing the \ProvidesPackage command to

    \ProvidesPackage{sty/prettythesis}
    

    This can be inconvenient if you're going to be moving it around loads, but the modifications load isn't too bad either.

    Even better, if what you have in there is a specific, modified version of a standard TeX package (like, say, this patch of natbib), then the change in the package name clearly indicates what package it's providing, and if you reuse the file then it will (most likely) re-raise a warning to prompt you into making sure that you know what you're doing.

提交回复
热议问题