Recommended build system for latex? [closed]

2019-01-12 17:53发布

I'm trying to figure out the best build system for latex.

Currently, I use latex-makefile, editing in vim, and viewing changes in Okular or gv. The major problem is that it sometimes gets hides errors on me, and I have to run latex manually. The major advantages are that it does all the iteration I need, and offers both pdf and ps simply.

If you have experience with

  • latex-mk
  • vim-latex
  • kile
  • lyx
  • miktex
  • latex-makefile
  • the ultimate latex makefile
  • rubber
  • any others I havent come across

Would you recommend them, and why/why not?

15条回答
霸刀☆藐视天下
2楼-- · 2019-01-12 18:29

I use Eclipse with the TexEcplise add-on for editing my TeX-files. It has syntax highlight for LaTeX. When you ask a preview of a non-altered and already compiled tex file, it open the file in the viewer. When the tex file was altered, then it compiles the tex file prior to viewing it. It does the necessary iterations, but only if needed.

Another advantage is that all errors and warnings are summarised in a box and they are highlighted in the tex file! This is a screenshot from the TexEclipse homepage.

查看更多
聊天终结者
3楼-- · 2019-01-12 18:31

Ok, so this question is a bit old, but it came up when I googled "latex build system" so I thought I'd add my two cents. I tried the Makefile based solutions, but found the output a bit verbose and unwieldy. I figured someone might have built a scons extension for latex, but was pleasantly surprised to find that scons already natively supports latex! All you need to do is create a SConsctruct file like this:

env = Environment()  
env.PDF(target="report.pdf", source="report.tex")

To build just run scons report.pdf. Scons will automatically build .tex files included by report.tex, handle bibliographies and perform repeated builds in order to resolve all references - simple!

You can create DVI and PS files in the same way. For more info on these builders check out http://www.scons.org/doc/2.0.1/HTML/scons-user/a8524.html .

For more info on scons (a make replacement), see http://www.scons.org/

查看更多
我命由我不由天
4楼-- · 2019-01-12 18:31

I wanted to use the script you posted in your final answer.

Unfortunately, it didn’t work with my setting (MacVim with vim-latexsuite, Skim as the viewer and XeTeX). I also use forward search (i.e. I use the feature that pressing \ls in Vim will jump to the corresponding point in the PDF document in the open viewer).

Furthermore, my document isn’t called thesis.tex (big surprise; it’s not a thesis). I’ve therefore done some more configuration work that I’d like to share. Attention, my bash skills are horrible.

#!/bin/bash

set -x
ulimit -t 10 # sometimes pdflatex gets stuck

if [ "$1" = "" ]; then
    echo "No target name specified"
    exit 1
fi

TARGET=$1
SOURCE=$1.tex
TMPSOURCE=_$TARGET.tex
TMPTARGET=_$TARGET

while [ 1 ]; do
    # Compile a different file ($TMPSOURCE.pdf) so that it doesn't reload mid-compile
    cp $SOURCE $TMPSOURCE
    # better than running pdflatex manually, as this wont rebuild if there's nothing there.
    latexmk -pdf -silent $TMPTARGET > /dev/null

    # For rubber-info
    cp $TMPTARGET.log $TARGET.log

    if [ -e $TMPTARGET.pdf ]; then # Check the compile succeeded first
        # No output file yet.
        [ ! -e $TARGET.pdf ]
        HASNOPDF=$?
        # ignore if it's unchanged.
        # OS X diff doesn't consider binary files. Single-line output, return value 2
        diff $TARGET.pdf $TMPTARGET.pdf
        OUTPUTDIFFERS=$?
        if [ $HASNOPDF -eq 0 -o $OUTPUTDIFFERS -ne 0 ]; then
            # Do NOT RM since Skim cannot deal with this.
            cp $TMPTARGET.pdf $TARGET.pdf
        fi
    fi

    sleep 1 # give it time to be killed by a CTRL-C
done

This compiles a temporary file and copies it back to whatever name was given (instead of the other way round as your script does); usage of the script:

./scriptname project

Where project is the name of the TeX file, without file extension.

I’ve also changed the rubber-info line:

autocmd FileType tex exe "set makeprg=rubber-info\\ _" . expand("%:t:r") . ".log"

And I needed to patch my latexmk to use XeTeX since the name of the executable was hard-coded.

Unfortunately, this still destroys the output PDF file when I’ve saved my document before completing a statement, since latexmk seems to always produce a PDF file, even on error – and its return code is always 0, which sucks.

(To clarify this, say that I’ve just typed emph{ into my document and save it. The background script will promptly compile the document, and fail. But it will still produce a (largely empty) output file).

Additionally, forward search no longer works properly; it basically jumps to a wrong point in the document. I suspect that this has something to do with my copying the document before compilation.

So, this is still a completely unsatisfactory solution, even though I didn’t even enable continuous saving on typing in MacVim yet.

查看更多
登录 后发表回答