TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently experimenting with lilypod. To generate a PDF from the source, I have to enter

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

When I add this to a Makefile it doesn't work, because the cd doesn't change the directory.

So I wanted to replace

cd charts-out
pdflatex charts.tex


pdflatex charts-out/charts.tex

This does also not work:

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
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
Document Class: amsart 2009/07/02 v2.20.1
For additional information on amsmath, use the `?' option.
(./charts.aux) (/usr/local/texlive/2011/texmf-dist/tex/latex/amsfonts/umsa.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/local/texlive/2011/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty
! 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: 

How can I make it work?

share|improve this question
Why do you think that cd doesn't work?. Whatever you can use pdflatex charts-out/charts.tex. – Marco Daniel Jul 21 '12 at 13:38
I tried it. It worked, when I entered the command manually, but not with the Makefile. NO, pdflatex charts-out/charts.tex DOES NOT WORK! This is the reason why I've asked the question! – Martin Thoma Jul 21 '12 at 13:46
Did you try a small shell script? – Marco Daniel Jul 21 '12 at 13:49
For the cd issue see this question. – canaaerus Jul 21 '12 at 14:00
@Marco: You should never start pdflatex like this. This leads to chaos with \input file. – Ulrike Fischer Jul 21 '12 at 14:47

Try the following trick (it can have side effects I explain later). The following command is run from the "parent" folder, even if the file charts.tex is in a subfolder:

TEXINPUTS=.//:: pdflatex charts.tex

The explanation is as follows. pdflatex searches all input files (.sty loaded via \usepackage, .cls via \documentclass, .tex via \input or \include or command line, etc.) in diffent folders, beginning with those specified in TEXINPUTS environment variable. The value of this variable uses a syntax similar to the one for the system PATH, but it has some particularities.

If a folder name ends with //, then all its subfolders are scanned recursively too. If at some point the "null folder" :: is specified, then the texmf tree used by tex by default is used at this point.

So, in my solution, TEXINPUTS can be read as: "search first the current folder with all its subfolders too, recursively, and then in the default texmf search path".

The drawback is that you cannot (or better should not) have files with the same name in different subfolders, because only the first one found by tex will be considered.

share|improve this answer

I use this, which works for me (though it not be the most efficient):

%.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.ist is my list of songs that I abuse makeindex to make.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.