如何使用 ANT(或其他构建系统,如果您愿意)构建 PDF LaTeX 文档?

发布于 2024-08-06 15:22:13 字数 395 浏览 3 评论 0原文

我工作的团队管理着大量用 LaTeX 编写的技术文档。

目前,我们拥有的所有文档都是由编辑手动构建,然后签入版本控制系统。有时人们忘记编译他们的文档,因此我们会遇到 PDF 和 .tex 文件经常不一致的情况。不幸的是,当发生这种情况时,我们的用户发现自己正在阅读我们文档的旧版本。

我已经成功地破解了一个简单的脚本来使用 Make 构建 PDF - 它相当笨拙。

我想知道是否有更好的方法来做到这一点?我们部门的大多数人都使用 Eclipse + Pydev 来完成 Python 项目,这意味着我们都非常熟悉这个 IDE。我知道 Ant 与 Eclipse 配合得很好,那么我们是否可以使用这个工具来构建文档?

那么最好的方法是什么?我希望我不必为了自动构建一些非常简单的文档而学习有关新构建系统的所有知识。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

得不到的就毁灭 2024-08-13 15:22:13

有一个用于 LaTeX PDF 生成的外部 Ant 任务,尽管该网站是德语的。

要使用它,请将 jar 下载到计算机上的某个位置,然后按如下方式定义 taskdef:

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

然后要使用它,请定义如下目标:

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

其中 ltx2.file 是要处理的文件。

这是指向列出参数的操作方法页面的链接。如果您需要更多选择,也许我的德语足以解释。

还有一个 LaTeX 的 maven 插件,但我找不到任何文档。

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.

聆听风音 2024-08-13 15:22:13

没试过,但我记得 看到一篇关于它的博客文章

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

浅笑依然 2024-08-13 15:22:13

如果您了解 python,这篇博文可能是有趣

编辑:另外,我假设你正在使用某种版本控制系统,我不能肯定地说,但我使用 git 来管理我所有的乳胶文档,并且可以使用某种提交后挂钩来执行脚本来重建文档。这取决于您的存储库的结构……可以这么说,只是大声思考。

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.

仙女山的月亮 2024-08-13 15:22:13

我在这个问题中详细介绍了乳胶的大量构建系统,但在你的情况下略有不同。我想你想要橡胶或乳胶。 Latex-makefile 似乎是个好主意,但仅支持通过 postscript 构建,这可能不是您的构建过程。

一般来说,出于这个原因,将生成的文件保留在版本控制之外是一个好主意。一个很好的例外是,当专业构建工具没有广泛使用时,并且您的情况听起来很相似。您可能会更好地使用提交挂钩来在提交时自动构建。

我想我还应该指出,在没有先构建并检查它的情况下进行某些操作是一种致命的罪过,所以更好的解决方案可能是消除这种情况。

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.

兰花执着 2024-08-13 15:22:13

与 Ant 相比,Maven 是一个更好的构建系统替代方案。所以我会推荐一个 maven 插件来从 LaTeX 源生成 PDF。看看 mathan-latex-maven-plugin

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文