shiblon / latex-makefile

A Makefile for LaTeX - drop it in, type make, and magic happens.
Other
186 stars 30 forks source link

Inkscape pdf+LaTeX support #13

Open Finwood opened 8 years ago

Finwood commented 8 years ago

Beside the normal pdf export, Inkscape features a pdf+LaTeX mode, in which Inkscape exports an extra file containing the text, which is being typeset and inserted by LaTeX.

From graphic.svg Inkscape produces graphic.pdf without text and a graphic.pdf_tex for typesetting (or graphic.eps and graphic.eps_tex respectively). The file is then included not with \includegraphics{graphic.pdf}, but using \input{graphic.pdf_tex}.

What would be the appropriate way to include automatic compiling in this makefile? I'd be glad to implement this feature, but unfortunately I don't know where to start.

shiblon commented 8 years ago

Unfortunately this is the sort of thing that LaTeX really struggles with. Anytime you have an \input dependency, that is basically inlining code. LaTeX can't run through a full compilation without it, since that means that code that follows it could be broken, so the whole "compile to figure out what's missing" flow breaks in that case.

The approach that has been taken with other things (pstex is the canonical example) to create a special target and require the user to type something like "make all-inkscape" or similar (make all-pstex is again an example of how this is currently done). You can see examples of this in the makefile where that's the workaround for this \input problem.

As a bit of background, what the makefile is doing is basically this:

This works great for things like graphicx because a missing graphic is not missing code. That means that everything can compile just fine, but the images won't be present. They will, however, be present in the logs, so we suck them out of there, add them as dependencies (in .d files) and that forces make to try again (a new .d file or a changed .d file causes a recursive rebuild).

When the dependency is part of \input, that means that we get at most one such error each time we try to build. If there were, say, 50 images built in this way requiring \input, that would mean at least 50 runs of LaTeX just to get the dependencies sorted, and that would take for-freaking-ever. So, that's why the workaround is what it is.

I'm totally supportive of putting such a target (like all-inkscape-inputs or something - commence bikeshedding now) into the makefile. It isn't very hard to do and it doesn't muck with anything else, so it has that going for it, which is nice.