0

I have this minimal example:

\begin{document}
    \begin{abstract}
        \pdfbookmark[0]{First Chapter}{abs:1}
        ...things...
    \end{abstract}
    \begin{abstract}
        \pdfbookmark[0]{Second Chapter}{abs:2}
        ...things...
    \end{abstract}
\end{document}

Unfortunately, practically randomly, no bookmarks show in the document or they appea rin bad place or on bad level. What is going on, what is the exact meaning of the first parameter?

4
  • latex never acts randomly. Just as for a standard table of contents within the document you need to run latex at least twice, as documented, and as as the message in the log will inform you. Commented Nov 15, 2023 at 19:13
  • @DavidCarlisle Not long ago, you answered a question (mine) that would be very helpful for this kind of situation. It could write a very prominent message, in capitals, at the very end of Terminal outout (for those who compile using Terminal): YOU MUST COMPILE AGAIN. I recommend that your code, or something like it, be added as a regular part of LaTeX and friends. See tex.stackexchange.com/questions/699701/…
    – user287367
    Commented Nov 15, 2023 at 20:35
  • 1
    @rallg latex is already putting a re-run message on the terminal and log just saying it again, and just for luatex wouldn't really help I think. Commented Nov 15, 2023 at 20:37
  • Yes. But finding that post by google, I am not sure if I had read so much from it.
    – peterh
    Commented Dec 16, 2023 at 0:03

1 Answer 1

0

After a lot of debugging and hunting, I found this sentence in this answer:

You must compile the document twice.

And suddenly I understood, that these files with .log, .out and so on, they represent some type of intermediate state. They must be cleaned up, and then we need to twice execute the latex command.

Hopefully there will be another answer which shares more details, but the clearly phenomenological solution for the problem is something like this. This is what I use to compile all.tex into a working pdf:

rm -vf all.log all.out all.pdf all.aux
pdflatex all.tex
pdflatex all.tex

So, first I delete the intermediary files and then I execute pdflatex twice.

8
  • If a better answer arrives with more details, that will get the pipe. We need details, why is it so. Honestly, I am not very happy on such surprises.
    – peterh
    Commented Nov 15, 2023 at 17:51
  • 4
    it is normally not necessary to clean up (and it slows down later compilation as you then always start from the beginning). Apart from this: lots of things in LaTeX need more than one compilation and normally you find a warning in the log if that is needed, for the bookmarks e.g. there is Package rerunfilecheck Warning: File `test-utf8.out' has changed. Rerun to get outlines right. Commented Nov 15, 2023 at 18:05
  • you will usually need more than 2 runs Commented Nov 15, 2023 at 19:14
  • @DavidCarlisle Oh thanks. If there will be some problem even so, I will give a try to a third run. :-) Possible alternative solution would be to execute latex in a loop until the result pdf won't change any more.
    – peterh
    Commented Nov 16, 2023 at 8:49
  • 1
    Don't remove all .aux files! That's where TOC and cross-reference entries are written! Commented Dec 15, 2023 at 19:52

Not the answer you're looking for? Browse other questions tagged .