diff --git a/OR_HTML_04/Operations_Research_mit_Python_Version_04.pdf b/OR_HTML_04/Operations_Research_mit_Python_Version_04.pdf index 536a971..b03e234 100644 Binary files a/OR_HTML_04/Operations_Research_mit_Python_Version_04.pdf and b/OR_HTML_04/Operations_Research_mit_Python_Version_04.pdf differ diff --git a/Operations_Research_mit_Python_Version_04.pdf b/Operations_Research_mit_Python_Version_04.pdf index 536a971..b03e234 100644 Binary files a/Operations_Research_mit_Python_Version_04.pdf and b/Operations_Research_mit_Python_Version_04.pdf differ diff --git a/Operations_Research_mit_Python_Version_04/build_version_04.py b/Operations_Research_mit_Python_Version_04/build_version_04.py index 7753dfd..c32027a 100644 --- a/Operations_Research_mit_Python_Version_04/build_version_04.py +++ b/Operations_Research_mit_Python_Version_04/build_version_04.py @@ -1175,6 +1175,27 @@ def baue_pdf() -> None: print("Erzeuge LaTeX ...") subprocess.run(befehl, cwd=BASIS, check=True) + # Pandoc generiert fuer unnummerierte Ueberschriften ({-}) \section* + + # \addcontentsline, aber OHNE \phantomsection dazwischen. Die TOC-Links + # zeigen dann alle auf die falsche Position (auf den zuletzt von hyperref + # gesetzten Anker statt auf die eigene Seite). Ab der ersten nummerierten + # \section stimmt es wieder, weil diese ihren Anker automatisch bekommt. + # Fix: \phantomsection vor jedes \addcontentsline setzen, das auf eine + # unnummerierte Ueberschrift folgt. Das Stichwortregister hat es bereits + # (siehe _STICHWORTREGISTER_BLOCK) - die zweite Sub verhindert Dopplung. + with open(tex, encoding="utf-8") as f: + tex_inhalt = f.read() + tex_inhalt = re.sub( + r"(\\addcontentsline\{toc\})", + r"\\phantomsection\n\1", + tex_inhalt) + tex_inhalt = re.sub( + r"\\phantomsection\s*\\phantomsection", + r"\\phantomsection", + tex_inhalt) + with open(tex, "w", encoding="utf-8") as f: + f.write(tex_inhalt) + print("Uebersetze mit xelatex (3 Durchlaeufe, dazwischen texindy fuer " "das Stichwortregister) ...") for durchlauf in range(1, 4):