Sometimes I need to run compile twice (eg when I use
lastpage). Is there a way to set things so TeX knows that there is need for second run and do it automatically? I use Texmaker.
EditUpdated: I just noticed I slightly misunderstood your question. There are tools that compile the required number of times automatically, e.g. latexmk.
I don't use it though, but there are certainly users who can tell you all about it. I've been using latexmk for a little while and it works really well (haven't tried it with bibliographies though), even with
biblatex and Biber, and the support is great, the author even answers questions on here.
As for my initial answer below, it might still be of help in that it can eliminate the need of compiling twice.
hyperref is a package that frequently requires compiling twice . You can avoid this by loading the package
Generally, these two should be the last packages you load in your preamble, unless there's a package that specifically asks to be loaded after
hyperref (see Which packages should be loaded after hyperref instead of before?).
bookmark provides some new possibilities, but if you've been using
hyperref and you're not really looking for anything new, you can just load
bookmark -- according to my experience, it won't change anything (besides the number of necessary compilations).
You could set up TeXmaker to use
latexmk to compile.
latexmk is a Perl script that you can set up to automatically run
pdflatex (or other compilers),
makeindex if necessary.
As a very simple, example you could go to Options -> Configure TeXmaker -> Quick Build, and set up a custom Quick Build command such as
latexmk -pdf %.tex
When running Quick Build, this will run
pdflatex on the file as many times as necessary. The
% is TeXmaker's way of representing the filename of the current file (without extension).
latexmk manual (
texdoc latexmk in a terminal) for all the possible options.
There are other similar options, such as
texify in MikTeX, mentioned by Werner, and Rubber. Paulo Cereda wrote a blog post about Rubber, and there was a question concerning the difference between this and
- Blog post: Building documents with Rubber
- Question: What are the differences between latexmk and rubber?
With respect to Seamus' recent blog post on overkill being a good thing, here's another approach.
The MiKTeX distribution includes
pdftexify). These are different from the standard counterparts
pdflatex routines since they automatically recompile a document if needed.