Pickup dependencies from import and includefrom commands

11 views
Skip to first unread message

jake

unread,
Jul 22, 2010, 7:11:11 PM7/22/10
to latex-makefile-discuss
First of all, thank you for your excellent makefile.

I'm writing a large document where each chapter is organized in a
separate directory. I'm including each chapter in the main .tex file
using the includefrom command provided by the import.sty package.
This way, the files within each chapter directory can \input or
\includegraphics using paths relative to the directory.

For example, normally I would \include{chapter1/file.tex} and in
chapter1/file.tex
I would \includegraphics{chapter1/figs/fig.eps}.
Instead, I would now do \includefrom{chapter1/}{file.tex} and in
chapter1/file.tex
I can do \includegraphics{figs/fig.eps}.

Here's where I came across the import.sty package:
http://www.latex-community.org/forum/viewtopic.php?f=5&t=1756&st=0&sk=t&sd=a&start=10#p7806
and here's the documentation for it:
http://www.tex.ac.uk/CTAN/macros/latex/contrib/import/import.sty

The problem now is that latex-makefile does not pick up the
dependencies of files that use the \import or \includefrom commands.
How hard would it be to add this functionality to the Makefile?


Chris Monson

unread,
Jul 22, 2010, 7:22:07 PM7/22/10
to latex-makef...@googlegroups.com
Heh - I really need a FAQ somewhere for this Makefile.  The issue of subdirectories comes up quite frequently, and unfortunately the answer is simply "That isn't ever going to be fully supported by the makefile."

The reason is that "make" itself really struggles with subdirectories.  Sure, many projects have made it work, but you'd be amazed at the gymnastics they go through to do it, and all of the successful ones rely on an outside script to kickstart the process (like "configure").  And then, cleaning is brittle: the configure script typically has to have its own clean option because "make" can't figure out much more than "rm everything with the following suffix".

When you start looking at how LaTeX works, and how hard it is to tease dependencies out of it in the first place, then see what kinds of back-bending stuff has been put into the Makefile to try to work around all of the deficiencies in the tools, it starts to look pretty hard to handle anything in subdirectories.

So, the makefile *sort of* supports this, as in it will try to compile images in subdirectories.  It will never clean them, though, and adding recursive dependency checking is pretty much right out.

I'm really sorry to have to give you bad news like that.  If I had this to do over again, I'd implement my own theorem prover in Python and use that instead of GNU make as the basis for everything.  Then we'd have a chance at doing the crazy stuff.  As it stands now, though, it just isn't feasible with the chosen technology.

The good news is that, provided you're willing to do a couple of simple things, you can usually find your dependencies and clean everything really easily; you just have to live with a little clutter.  Things I do to manage it:

- Name included files like chapter1._include_.tex - this allows me to write "make" without arguments and it won't try to build documents out of individual chapters (which don't have \document{begin} in them).
- Just shove everything into a single directory, and rely on "make clean" to declutter when needed.

No, it isn't pretty, but it actually works pretty well, especially when combined with the feature that lets you specify where you want your pdf output to go: that way you can at least specify where the most heavily-accessed output file goes, and it can be a less cluttered location.

I'm open to hearing about ideas about how to make this work.  Unfortunately the makefile is incredibly complex, even for its author, and that makes having these discussions somewhat challenging.  :-)

jake

unread,
Jul 22, 2010, 11:27:13 PM7/22/10
to latex-makefile-discuss
> Heh - I really need a FAQ somewhere for this Makefile.  The issue of
> subdirectories comes up quite frequently, and unfortunately the answer is
> simply "That isn't ever going to be fully supported by the makefile."

Thanks, Chris, for the quick and direct answer, as well as some of the
background on the complexities involved.


> - Name included files like chapter1._include_.tex - this allows me to write
> "make" without arguments and it won't try to build documents out of
> individual chapters (which don't have \document{begin} in them).
> - Just shove everything into a single directory, and rely on "make clean" to
> declutter when needed.

I've got to say I'm not keen on renaming files to express
dependencies. I'd rather avoid the "clutter" as well as the confusion
for others working on the project who use their own build tools.

But I'll consider your suggestions, and explore some of the many
configuration options in the makefile.


> Unfortunately the makefile is incredibly complex, even for its author, and
> that makes having these discussions somewhat challenging.  :-)

Agreed! I tried to see if I could make a quick fix to the Makefile,
but even though it's well documented, I gave up after a few
minutes. :)

Chris Monson

unread,
Jul 23, 2010, 8:24:02 AM7/23/10
to latex-makef...@googlegroups.com
By the way, hopefully you aren't discouraged from making other suggestions.  The subdirectory thing is just one of those unfortunate issues that will persist, but if you run into any other bugs or inconveniences, please don't hesitate to file a bug at http://code.google.com/p/latex-makefile/issues .

I'm not always super fast about responding to them, but I do take them all seriously.

- C
Reply all
Reply to author
Forward
0 new messages