ToC、LoF、LoT にハイパーリンクを追加したいのですが、Hyperref を使用するとエラーが発生しました

ToC、LoF、LoT にハイパーリンクを追加したいのですが、Hyperref を使用するとエラーが発生しました

ToC、LoF、LoT の章、節、サブセクションをクリック可能にしたいです。重複している可能性のあるものをいくつか読みましたが、満足できず、私の質問に答えてくれませんでした。その方法については触れられておらず、追加するだけでエラーになります\usepackage{hyperref}。ちなみに、エラー メッセージは次のとおりです。

未定義の制御シーケンス \tableofcontents

未定義の制御シーケンス \tableofcontents

未定義の制御シーケンス \tableofcontents

古い toc ファイルが検出されましたが、使用されていません。LaTeX を再度実行してください。

そして、図と表のリストをクリックすると、図と表に誘導されるようにしたいのですが、今のところ、それについてはわかりません。

ToC で多くのカスタムを使用しているため、それがどのように可能なのかわかりません。

とにかく、これが私の MWE です。私のドキュメントはいくつかの部分に分かれており、すべてをここに含めることができないため、コンパイルできません。お時間を無駄にして申し訳ありませんが、ご協力いただければ幸いです。ありがとうございます。

編集 : ログファイルには\MakeUppercase UnsupportedInPdfStringsと記載されています

\documentclass[a4paper,12pt,oneside,openany]{book}
\usepackage{pgf, tikz}
\usepackage[a4paper, inner=4cm, outer=3cm, top=4cm, bottom=3cm]{geometry}
\usepackage{geometry}
\usepackage[onehalfspacing]{setspace}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{setspace}
\usepackage[titles]{tocloft}
\usepackage{tocbibind}
\usepackage{indentfirst}
\usepackage{blindtext}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage[none]{hyphenat}
\sloppy
\usepackage{times}
\usepackage{enumitem}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage[column=O]{cellspace}
\usepackage{caption}
\usepackage{afterpage}
\usepackage{mathtools}
\usepackage{subcaption}
\usepackage{wrapfig}
\usepackage{cancel}
\usepackage{longtable}
\usepackage[indonesian]{babel}
\usepackage{lipsum}
\usepackage{pdflscape}
\usepackage{makecell} 
\usepackage{ragged2e}
\usepackage{natbib}
%\usepackage[]{hyperref}
%
%\hypersetup{
%   linktoc=all
%}

\newlist{ColEnum}{enumerate}{1}
\setlist[ColEnum,1]{label = \arabic*), left = 0pt, nosep, 
    before= {\begin{minipage}[t]{\hsize}\RaggedRight},
        after = {\end{minipage}}}

\DeclareMathOperator{\Res}{Res}
\numberwithin{equation}{section}

\setlength{\cellspacetoplimit}{5pt}
\setlength{\cellspacebottomlimit}{4pt}
\setlength\bibhang{25pt}

\theoremstyle{plain}
\newtheorem{thm}{Teorema}[section]
\newtheorem{cl}{Corollary}[section]
\newtheorem{lm}{Lemma}[section]

\theoremstyle{definition}
\newtheorem{defn}{Definisi}[section]
\newtheorem{exmp}{Contoh}
\renewcommand{\proofname}{\rm\bf{Bukti}}

\renewcommand\tablename{Tabel}
\renewcommand\figurename{Gambar}


\patchcmd{\section}{\bfseries}{\bfseries\boldmath}{}{}
\patchcmd{\tableofcontents}{\contentsname}{\MakeUppercase\contentsname}{}{}
\patchcmd{\listoffigures}{\listfigurename}{\MakeUppercase\listfigurename}{}{}
\patchcmd{\listoftables}{\listtablename}{\MakeUppercase\listtablename}{}{}
\setlength{\cftbeforesecskip}{10pt}
\setlength{\cftbeforesubsecskip}{10pt}

\fancyhf{}
\cfoot{\thepage}
\linespread{1.5}
\pagestyle{plain}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cftdotsep}{1}
\renewcommand\cftchapdotsep{\cftdotsep}
\renewcommand{\cftchapfont}{\bfseries}
\renewcommand{\cftsecfont}{\bfseries}
\renewcommand{\cftchappagefont}{}
\titleformat{\chapter}[block]
    {\normalfont\bfseries\centering}
    {}{0pt}{}
\titleformat{\section}
    {\normalfont\bfseries}
    {\thesection}{1em}{}
\titleformat{\subsection}
    {\normalfont\bfseries}
    {\thesubsection}{1em}{}
\titlespacing*{\chapter}{0pt}{0pt}{20pt}
\titlespacing*{\section}{0pt}{0pt}{0pt}
\titlespacing*{\subsection}{0pt}{0pt}{0pt}

\renewcommand{\contentsname}{DAFTAR ISI}
\renewcommand{\listtablename}{DAFTAR TABEL}
\renewcommand{\listfigurename}{DAFTAR GAMBAR}
\newcommand\dd{\mathop{}\!\mathrm{d}}

%\addtocontents{toc}{\protect\null\protect\hfill{Halaman}\protect\par}
\setlength\parindent{1.25cm} 

\addtocontents{toc}{~\hfill{Halaman}\par}
%\addtocontents{toc}{\protect\afterpage{~\hfill{Halaman}\par\medskip}}
\addtocontents{lot}{~\hfill{Halaman}\par}
\addtocontents{lof}{~\hfill{Halaman}\par}

\makeatletter
\def\ttl@mkchap@i#1#2#3#4#5#6#7{%
    \ttl@assign\@tempskipa#3\relax\beforetitleunit
    \vspace{\@tempskipa}%<<<<<< REMOVE THE * AFTER \vspace
    \global\@afterindenttrue
    \ifcase#5 \global\@afterindentfalse\fi
    \ttl@assign\@tempskipb#4\relax\aftertitleunit
    \ttl@topmode{\@tempskipb}{%
        \ttl@select{#6}{#1}{#2}{#7}}%
    \ttl@finmarks  % Outside the box!
    \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}}
\makeatother

\begin{document}

\clearpage
\thispagestyle{empty}
\include{cover1}
\frontmatter %

\pagestyle{fancy}   
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\bibname}{DAFTAR PUSTAKA}

\include{cover2}
\begin{spacing}{0.1}
    \tableofcontents
    
\end{spacing}
\begin{spacing}{1.5}
    \listoffigures
    \listoftables
\end{spacing}

\mainmatter 
\pagestyle{fancyplain}
\fancyhf{}
\fancyhead[R]{\thepage}
\renewcommand{\headrulewidth}{0pt}
\include{bab1}
\include{bab2}
\include{bab3}

\backmatter
\bibliography{dafpus}
\bibliographystyle{unejstyle}
\nocite{*}
\include{lampiran}


\end{document}

答え1

\texorpdfstring私にとってはうまくいきました。\patchcmd

つまり次のようになります:

\patchcmd{\tableofcontents}{\contentsname}{\texorpdfstring{\MakeUppercase\contentsname}{\contentsname}}{}{}
\patchcmd{\listoffigures}{\listfigurename}{\texorpdfstring{\MakeUppercase\listfigurename}{\listfigurename}}{}{}
\patchcmd{\listoftables}{\listtablename}{\texorpdfstring{\MakeUppercase\listtablename}{\listtablename}}{}{}

関連情報