scrreport ドキュメント クラスのセクション タイトルと目次を大文字にする

scrreport ドキュメント クラスのセクション タイトルと目次を大文字にする

私は組み合わせようとしているtocstyle を使用せずに scartcl の toc で大文字、斜体、ハイパーリンクを使用するそして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

しかし、TOC リンクはどこにもつながりません。これを修正する方法はありますか?

交換しようとした

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

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

しかし、エラーが発生します\MakeUppercase ...ppercaseUnsupportedInPdfStrings。ドキュメントは pandoc で作成されているため、LaTeX スニペットをいくつか追加することしかできません。

私は LaTeX について全くの初心者なので、解決策だけでなく、このような問題を自分でデバッグする方法に関するヒントもいただければ幸いです。

UPD: 以下は最小限の再現可能な例です:

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

答え1

アップデート:

コードを追加してもまだ動作しますが、最新のKOMA-Scriptバージョン3.31(2020/07/22)を使用しています。以前のバージョンでは、番号なしのセクション\setcounter{secnumdepth}{-\maxdimen}に問題がありました。hyperrefKOMA スクリプト 3.30 で発生した問題と変更(ドイツ語) そのため、更新する必要があるかもしれません。

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

ここに画像の説明を入力してください

元の回答:

コメントを待ちます:

次の例は私にとっては有効です。

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

結果:

ここに画像の説明を入力してください

関連情報