当我不在目录中时,如何执行 pdflatex?

当我不在目录中时,如何执行 pdflatex?

我目前正在尝试使用 lilypod。要从源代码生成 PDF,我必须输入

mkdir -p charts-out
lilypond-book --output=charts-out/ --pdf  charts.tex
cd charts-out
pdflatex charts.tex

当我将其添加到它时,Makefile它不起作用,因为它cd不会改变目录。

所以我想更换

cd charts-out
pdflatex charts.tex

pdflatex charts-out/charts.tex

这也不起作用:

moose@pc07:~$ pdflatex charts-out/charts.tex
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
 restricted \write18 enabled.
entering extended mode
(./charts-out/charts.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman-x-2011-07-01, ngerman-x-2011-07-01, afrikaans, ancientgreek, ibycus, arabi
c, armenian, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danis
h, dutch, ukenglish, usenglishmax, esperanto, estonian, ethiopic, farsi, finnis
h, french, galician, german, ngerman, swissgerman, monogreek, greek, hungarian,
 icelandic, assamese, bengali, gujarati, hindi, kannada, malayalam, marathi, or
iya, panjabi, tamil, telugu, indonesian, interlingua, irish, italian, kurmanji,
 lao, latin, latvian, lithuanian, mongolian, mongolianlmc, bokmal, nynorsk, pol
ish, portuguese, romanian, russian, sanskrit, serbian, serbianc, slovak, sloven
ian, spanish, swedish, turkish, turkmen, ukrainian, uppersorbian, welsh, loaded
.
(/usr/local/texlive/2011/texmf-dist/tex/latex/amscls/amsart.cls
Document Class: amsart 2009/07/02 v2.20.1
(/usr/local/texlive/2011/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2011/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2011/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2011/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2011/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2011/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2011/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/local/texlive/2011/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/local/texlive/2011/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2011/texmf-dist/tex/latex/latexconfig/graphics.cfg)
(/usr/local/texlive/2011/texmf-dist/tex/latex/pdftex-def/pdftex.def
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/infwarerr.sty)
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))
(./charts.aux) (/usr/local/texlive/2011/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2011/texmf-dist/tex/latex/amsfonts/umsb.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(/usr/local/texlive/2011/texmf-dist/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/ifluatex.sty))
(/usr/local/texlive/2011/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty
(/usr/local/texlive/2011/texmf-dist/tex/latex/oberdiek/grfext.sty
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/local/texlive/2011/texmf-dist/tex/latex/oberdiek/kvoptions.sty
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty
(/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/etexcmds.sty)))
(/usr/local/texlive/2011/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
! I can't find file `53/lily-2fb3a572-systems.tex'.
l.30 \input 53/lily-2fb3a572-systems.tex

(Press Enter to retry, or Control-D to exit)
Please type another input file name: 

我怎样才能让它工作?

答案1

尝试以下技巧(它可能会产生副作用,我稍后会解释)。即使文件charts.tex位于子文件夹中,以下命令也会从“父”文件夹运行:

TEXINPUTS=.//:: pdflatex charts.tex

解释如下。从环境变量中指定的文件夹开始,pdflatex搜索不同文件夹中的所有输入文件(通过、via 、via或或命令行等.sty加载) 。此变量的值使用与系统类似的语法,但它有一些特殊性。\usepackage.cls\documentclass.tex\input\includeTEXINPUTSPATH

如果文件夹名称以 结尾//,则也会递归扫描其所有子文件夹。如果在某个时刻::指定了“空文件夹”,则texmf此时将使用 tex 默认使用的树。

因此,在我的解决方案中,TEXINPUTS可以读作:“首先递归搜索当前文件夹及其所有子文件夹,然后在默认的 texmf 搜索路径中搜索”。

缺点是您不能(或者最好不应该)在不同的子文件夹中拥有同名的文件,因为只会考虑 tex 找到的第一个文件。

答案2

我用的是这个,对我有用(虽然不是最有效的):

%.pdf: %.lytex *.ly songs.ist
    lilypond-book --pdf --left-padding=0 --output=out --include=$(CURDIR) *$.lytex
    cd out ; pdflatex $*
    cd out ; makeindex -s ../songs.ist $*.idx

songs.istmakeindex是我滥用制作的歌曲列表。

相关内容