
Ich versuche zu kombinierenGroßbuchstaben, Kursivschrift und Hyperlinks im Inhaltsverzeichnis von scrartcl ohne Verwendung von tocstyleUndKapitel in Großbuchstaben mit KOMA-Schrift:
\renewcommand\addsectiontocentry[2]{%
\addtocentrydefault{section}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\renewcommand\addsubsectiontocentry[2]{%
\addtocentrydefault{subsection}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\renewcommand\addsubsubsectiontocentry[2]{%
\addtocentrydefault{subsubsection}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\makeatletter
\renewcommand\sectionlinesformat[4]{%
\@hangfrom{\hskip#2#3}{\MakeUppercase{#4}}%
}
\makeatother
Die Inhaltsverzeichnislinks führen jedoch nirgendwohin. Irgendwelche Ideen, wie man das beheben kann?
Ich habe versucht zu ersetzen
\addtocentrydefault{section}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
mit
\addtocentrydefault{section}{#1}{\texorpdfstring{\MakeUppercase{#2}}{\MakeUppercase{#2}}}%
aber ich bekomme den \MakeUppercase ...ppercaseUnsupportedInPdfStrings
Fehler. Das Dokument wurde mit Pandoc erstellt, daher kann ich nur einige Latex-Ausschnitte hinzufügen.
Ich bin ein völliger Neuling bei LaTeX und wäre daher nicht nur für eine Lösung, sondern auch für Hinweise zur Fehlerbehebung bei solchen Problemen sehr dankbar.
UPD: unten ist ein minimal reproduzierbares Beispiel:
% Run "xelatex example.tex" (twice) to compile to pdf
\documentclass{scrartcl}
\usepackage{blindtext}% only for dummy text
\setcounter{tocdepth}{\subsubsectiontocdepth}
\renewcommand\addsectiontocentry[2]{%
\addtocentrydefault{section}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\renewcommand\addsubsectiontocentry[2]{%
\addtocentrydefault{subsection}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\renewcommand\addsubsubsectiontocentry[2]{%
\addtocentrydefault{subsubsection}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\makeatletter
\renewcommand\sectionlinesformat[4]{%
\@hangfrom{\hskip #2#3}{\MakeUppercase{#4}}%
}
\makeatother
\renewcommand{\sectioncatchphraseformat}[4]{%
\hskip #2#3\MakeUppercase{#4}%
}
\usepackage{hyperref}
% This command breaks TOC hyperlinks
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\begin{document}
\tableofcontents
\blinddocument
\blinddocument
\end{document}
Antwort1
Aktualisieren:
Auch wenn ich \setcounter{secnumdepth}{-\maxdimen}
den Code hinzufüge, funktioniert er bei mir immer noch, aber ich verwende die aktuelle KOMA-Script-Version 3.31 (22.07.2020). In früheren Versionen gab es ein Problem mit hyperref
und nicht nummerierten Abschnitten, sieheBekannte Probleme und Änderungen in KOMA-Script 3.30(Deutsch). Vielleicht musst du also aktualisieren.
% Run "xelatex example.tex" (twice) to compile to pdf
\documentclass{scrartcl}[2020/07/22]% version 3.31 or newer
\usepackage{blindtext}% only for dummy text
\setcounter{tocdepth}{\subsubsectiontocdepth}
\renewcommand\addsectiontocentry[2]{%
\addtocentrydefault{section}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\renewcommand\addsubsectiontocentry[2]{%
\addtocentrydefault{subsection}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\renewcommand\addsubsubsectiontocentry[2]{%
\addtocentrydefault{subsubsection}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\makeatletter
\renewcommand\sectionlinesformat[4]{%
\@hangfrom{\hskip #2#3}{\MakeUppercase{#4}}%
}
\makeatother
\renewcommand{\sectioncatchphraseformat}[4]{%
\hskip #2#3\MakeUppercase{#4}%
}
\usepackage{hyperref}
% This command breaks TOC hyperlinks
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\begin{document}
\KOMAScriptVersion% added to show the KOMA-Script version in the document
\tableofcontents
\blinddocument
\blinddocument
\end{document}
Ursprüngliche Antwort:
Zu lange nach einem Kommentar:
Das folgende Beispiel funktioniert bei mir.
\documentclass{scrartcl}
\usepackage{blindtext}% only for dummy text
\setcounter{tocdepth}{\subsectiontocdepth}
\makeatletter
\renewcommand\sectionlinesformat[4]{%
\@hangfrom{\hskip#2#3}{\MakeUppercase{#4}}%
}
\makeatother
\renewcommand{\sectioncatchphraseformat}[4]{%
\hskip#2#3\MakeUppercase{#4}%
}
\renewcommand\addsectiontocentry[2]{%
\addtocentrydefault{section}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\renewcommand\addsubsectiontocentry[2]{%
\addtocentrydefault{subsection}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%
}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\blinddocument
\blinddocument
\end{document}
Ergebnis: