如何从子目录加载Latex .sty文件? [英] How to load latex .sty files from a subdirectory?

查看:372
本文介绍了如何从子目录加载Latex .sty文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了一些.sty文件,这些文件不是texlive的一部分,并希望将它们包含在main.tex文件夹的子目录中.我使用以下行来加载程序包:

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}

这可行,但是用xelatex编译main.tex并使用橡胶会给我一个警告:

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)

是否有一种方法可以防止此警告或处理这种情况,而不必在所有.sty-files的\ ProvidesPackage命令中包含"sty \"或设置TEXINPUTS环境变量(从主要方面看来是不可能的). tex本身)?

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)?

推荐答案

我相信这里的线程:

谈论的是完全相同的事情:看来,唯一的选择是要么使用TEXINPUTS环境变量,要么使用环境变量.或使用导入包. (请注意,

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.)

关于TEXINPUTS的更多信息:

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!

 

我希望可以直接在tex文件中设置TEXINPUTS路径(通过使用\write18来设置 -请注意,某些LaTeX版本使用--enable-write18,我的版本使用-shell-escape来启用\write18;另请参见 )-但似乎不可能:

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:

" ...这是不可能的....设置了子进程的环境变量,但这对其父进程(TeX)无效."( 关于:在乳胶中设置环境变量TEXINPUTS-comp .text.tex ).

...因此,现在我只需在Linux bash中像这样调用pdflatex:

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

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

,然后它将直接解析myfile.tex文件中的\usepackage{mypackage}-即使mypackage.sty在子目录中,例如./subdir/mypackage.sty.

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.

这篇关于如何从子目录加载Latex .sty文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆