开发者

How can I build PDF LaTeX documents with ANT (or some other build system if you prefer)?

开发者_高级运维

The team I work for manages a large collection of technical documentation which is written in LaTeX.

Currently all the documentation we have is manually built by the editors and then checked into a version control system. Sometimes people forget to compile their documents so we have a situation where the PDF and .tex files are often out of step. Unfortunately when this happens our users find themselves reading old versions of our document.

I've managed to hack a simple script to build PDFs using Make - it's rather clumsy.

I was wondering if there was a better way to do it? Most people in our department use Eclipse + Pydev for a Python project which means we are all very familiar with this IDE. I know that Ant plays nicely with Eclipse, so might we be able to use this tool for our doc building?

So what's the best way of doing this? I hope I will not have to learn everything there is to know about a new build-system in order to automate the building of some quite simple docs.


There is an external Ant task for LaTeX PDF generation, though the site is in German.

To use it, download the jar to a location on your machine, then define a taskdef as follows:

<taskdef name="latex"    classname="de.dokutransdata.antlatex.LaTeX"  
  classpath="/path/to/ant/lib/ant_latex.jar"/> 

Then to use it, define a target like this:

<target name="doLaTeX">  
  <latex  
    latexfile="${ltx2.file}"  
    verbose="on"  
    clean="on"  
    pdftex="off"  
    workingDir="${basedir}"  
  />  
</target> 

Where ltx2.file is the file to process.

This is a link to the howto page listing the parameters. If you need any more options, my German is just about passable enough to explain, maybe.

There is also a maven plugin for LaTeX, but I can't find any documentation.


Haven't tried it, but I remember seeing a blog post about it.


If you know python, this blog post might be interesting

EDIT: Also, I would assume that you're using some kind of version control system, and I can't say for sure, but I use git to manage all my latex docs, and it might be possible to use some kind of post-commit hook to execute a script to rebuild the document. This would depend on how your repository is structured... just thinking out loud, so to speak.


I went into great detail on a large number of build systems for latex in this question, but its slightly different in your case. I think you want rubber or latexmk. The latex-makefile seems a good idea, but only supports building via postscript, which might not be your build process.

In general, its a good idea to keep generated files outside of version control for just this reason. A good exception is when specialist build tools are not widely available, and your situation sounds similar. You might do better with a commit-hook to build automatically upon commit.

I guess I should also point out that committing something without first building it and checking it is a deadly sin, so a better solution might be to stamp that out.


Maven is a better alternative as build system compared to Ant. So I would recommend a maven-plugin to generate PDF from LaTeX sources. Have a look at mathan-latex-maven-plugin

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜