# Uppercase section titles and TOC for scrreport document class

\renewcommand\addsectiontocentry[2]{%
}
}
}

\makeatletter
\renewcommand\sectionlinesformat[4]{%
\@hangfrom{\hskip#2#3}{\MakeUppercase{#4}}%
}
\makeatother


However, the TOC links do not lead anywhere. Any ideas how to fix this?

I tried to replace

  \addtocentrydefault{section}{#1}{\texorpdfstring{\MakeUppercase{#2}}{#2}}%


with

  \addtocentrydefault{section}{#1}{\texorpdfstring{\MakeUppercase{#2}}{\MakeUppercase{#2}}}%


but I get the \MakeUppercase ...ppercaseUnsupportedInPdfStrings error. The document is produced with pandoc, so I can only add some latex snippets.

I'm completely new to LaTeX, so I would really appreciate not only a solution, but also any hints on how to debug such problems myself.

UPD: below is a minimal reproducible example:

% Run "xelatex example.tex" (twice) to compile to pdf
\documentclass{scrartcl}
\usepackage{blindtext}% only for dummy text
\setcounter{tocdepth}{\subsubsectiontocdepth}

}
}
}

\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}


Update:

Even if I add \setcounter{secnumdepth}{-\maxdimen} the code still works for me, but I use the uptodate KOMA-Script version 3.31 (2020/07/22). In previous versions there was a problem with hyperref and unnumbered sections, see Bekannte Probleme und Änderungen in KOMA-Script 3.30 (German). So maybe you have to update.

% Run "xelatex example.tex" (twice) to compile to pdf
\usepackage{blindtext}% only for dummy text
\setcounter{tocdepth}{\subsubsectiontocdepth}

}
}
}

\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}


To long for a comment:

The following example works for me.

\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}%
}

}
}

\usepackage{hyperref}

\begin{document}
\tableofcontents
\blinddocument
\blinddocument
\end{document}


Result:

• Thanks! Your example also works for me. However, default pandoc template doesn't. I spent two hours stripping down the default template and found the culprit: \setcounter{secnumdepth}{-\maxdimen} % remove section numbering So I guess there is some conflict between MakeUppercase and this line. Any ideas how to fix that? – Max Arnold Sep 7 at 14:07
• I can not reproduce your issue. Maybe you can add a minimal working example to your question which shows the problem. Or you ask a new question including a MWE (minimal working example). – esdd Sep 7 at 15:13
• I used your example document as a base and added the line that breaks TOC hyperlinks. The resulting MWE is added to my question. – Max Arnold Sep 7 at 16:24
• See my updated answer. Which KOMA-Script version do you use? – esdd Sep 8 at 14:30
• Thanks a lot, that was it! I used the default koma-script package that came with MacTeX 2020, I believe it was 3.29. The problem went away after I did sudo tlmgr update --self and then sudo tlmgr update koma-script. I would have never figured that out myself... You rock! – Max Arnold Sep 9 at 14:22