需要帮助创建目录吗?

需要帮助创建目录吗?

在此处输入图片描述

嗨,我基本上想创建这个目录。每行内容都必须超链接到文本中的某个部分。有人能帮忙吗?

我也有这个代码

\documentclass[letterpaper,oneside,12pt]{article} % Creating he document class and telling the document to be off font 10

\usepackage{lipsum} % sample text
\usepackage[explicit]{titlesec} % to change headings
\usepackage{hyperref}

% renew \contentsline for toc to include hypertarget
\let\oldcontentsline\contentsline%
\renewcommand\contentsline[4]{%
\hypertarget{toc#4}{}%
\oldcontentsline{#1}{#2}{#3}{#4}}

% renew \section to link to the toc
\titleformat{\section}
{\normalfont\Large\bf}
{{\thesection} \hyperlink{tocsection.\thesection}{#1}}
{1pc}
{}

% renew \subsection to link to the toc
\titleformat{\subsection}
{\normalfont\bf}
{{\thesection} \hyperlink{tocsubsection.\thesubsection}{#1}}
{1pc}
{}

\usepackage{fontspec,libertinus,lipsum}
\usepackage{color}   %May be necessary if you want to color links

\usepackage{hyperref}
\hypersetup{
    colorlinks,
    citecolor=blue,
    filecolor=blue,
    linkcolor=blue,
    urlcolor=blue}
\pagenumbering{Roman} 

\usepackage{xcolor}
\usepackage{titlesec}
\titleformat{\section}[block]{\color{black}\Large\bfseries\filcenter}{}{1em}{}
\titleformat{\subsection}[hang]{\bfseries}{}{1em}{}
\setcounter{secnumdepth}{0}


\begin{document}
\title{Alan Turing\\[\baselineskip]\normalsize Artificial Intelligence\\[0.3\baselineskip]} % Adding the title of the document
\author{Bilal Rashid} % Setting the name of the author of the document
\date{\today} % Setting the date of the document
\maketitle
\newpage
\tableofcontents
\clearpage


\section{What Is Artificial Intelligence?}
\lipsum[1]
\clearpage



\section{Why Is Alan Turing Known as the Father of Artificial Intelligence and How Did He Aid the Development of Artificial Intelligence?}
\lipsum[2]
\clearpage

\section{The Turing Test}
\lipsum[3]
\clearpage

\section{References}
\lipsum[1]


\end{document}

但是当生成页面重定向时,我在每个页面上都看不到该部分的标题,也看不到内容部分。这里有一张图片来解释:在此处输入图片描述

答案1

示例中的代码非常复杂。据我所知,它无法实现任何通过简单执行无法实现的功能

\usepackage{hyperref} 
\hypersetup{colorlinks,allcolors=blue}

在序言中。

当然,下面的代码实现了您所陈述的排版目标。

\documentclass[letterpaper,oneside,12pt]{article}
\usepackage{fontspec,libertinus,lipsum,xcolor}
\setcounter{secnumdepth}{0}

\usepackage{hyperref} 
\hypersetup{colorlinks,allcolors=blue}
\pagenumbering{Roman} 

\begin{document}

\title{Alan Turing}
\author{Bilal Rashid}
\date{\today}
\maketitle
\clearpage

\tableofcontents
\clearpage 

\section{What Is Artificial Intelligence?}
\lipsum[1]
\clearpage

\section{Why Is Alan Turing Known as the Father of Artificial 
   Intelligence and How Did He Aid the Development of 
   Artificial Intelligence?}
\lipsum[2]
\clearpage

\section{The Turing Test}
\lipsum[3]
\clearpage

\section{References}
\lipsum[4]

\end{document}

相关内容