Títulos de seções em maiúsculas e TOC para classe de documento scrreport

Títulos de seções em maiúsculas e TOC para classe de documento scrreport

Estou tentando combinarMaiúsculas, itálico e hiperlinks no toc do scartcl sem usar tocstyleeCapítulo maiúsculo com script KOMA:

\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

No entanto, os links do TOC não levam a lugar nenhum. Alguma idéia de como consertar isso?

Eu tentei substituir

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

com

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

mas recebo o \MakeUppercase ...ppercaseUnsupportedInPdfStringserro. O documento é produzido com pandoc, então só posso adicionar alguns trechos de látex.

Sou completamente novo no LaTeX, então eu realmente apreciaria não apenas uma solução, mas também qualquer dica sobre como depurar esses problemas sozinho.

UPD: abaixo está um exemplo reproduzível mínimo:

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

Responder1

Atualizar:

Mesmo se eu adicionar \setcounter{secnumdepth}{-\maxdimen}o código ainda funciona para mim, mas eu uso o KOMA-Script versão 3.31 atualizado (22/07/2020). Nas versões anteriores havia um problema com hyperrefseções não numeradas, consulteSolução de problemas e soluções no KOMA-Script 3.30(Alemão). Então talvez você precise atualizar.

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

insira a descrição da imagem aqui

Resposta original:

Ansiando por um comentário:

O exemplo a seguir funciona para mim.

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

Resultado:

insira a descrição da imagem aqui

informação relacionada