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.
As for my initial answer below, it might still be of help in that it can eliminate the need of compiling twice.
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
You could set up TeXmaker to use
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
There are other similar options, such as
With respect to Seamus' recent blog post on overkill being a good thing, here's another approach.
The MiKTeX distribution includes