几天来我一直在尝试创建目录,但尽管尝试了几次,它还是没有达到我想要的最终形状。简单来说,我想要:
Contents:
Acknowledgement ii
Copyright ii
Abstract and Table of Contents iii
1 Introduction
2 Alexander Polynomials
3. ..
4. ...
但问题是,我处于文章类,无法使用书籍类。此外,前三个部分不是部分!我只想让目录在单击时转到这些页面。
我尝试了网络上不同的技术,通过添加命令
\makeatletter
\newif\if@mainmatter \@mainmattertrue
\newcommand\frontmatter{%
\cleardoublepage
\@mainmatterfalse
\pagenumbering{roman}}
\newcommand\mainmatter{%
\cleardoublepage
\@mainmattertrue
\pagenumbering{arabic}}
\makeatother
但我已经设法创建了我想要的内容,但链接在第一页上跳转如下:
\frontmatter
\addcontentsline{toc}{section}{Acknowledgement}
\addcontentsline{toc}{section}{Copyright}
\addcontentsline{toc}{section}{Abstract and Table of Contents}
\tableofcontents
\clearpage
\mainmatter
\section{Introduction}
\pagenumbering{arabic}
在目录中,前三部分前面都显示 (i)。如何将目录中的链接转移到我想要的页面?
如果有人能帮助我解决这个问题,我真的很感激他们付出的时间和精力。
以下是我的所有代码:
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{enumitem}
\usepackage{color}
\usepackage{framed}
\usepackage{todonotes}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage[colorlinks]{hyperref}
\usepackage{mathrsfs}
\usepackage{setspace}
\usepackage{graphicx}
\graphicspath{ {./Images/} }
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{hyperref}
\usepackage[english]{babel}
\usepackage{blindtext}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=blue,
}
\urlstyle{same}
\renewcommand{\baselinestretch}{1.3}
\makeatletter
\newif\if@mainmatter \@mainmattertrue
\newcommand\frontmatter{%
\cleardoublepage
\@mainmatterfalse
\pagenumbering{roman}}
\newcommand\mainmatter{%
\cleardoublepage
\@mainmattertrue
\pagenumbering{arabic}}
\makeatother
\title{Title}
\author{Author}
\date{August 2021}
\pagenumbering{roman}
\begin{document}
\maketitle
\pagebreak
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
Please be sure to answer the question. Provide details and share your research!
But avoid …
Asking for help, clarification, or responding to other answers.
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers. \\ \\
\noindent \textbf{{\Large Author's contact details:}} \\
Asking for help, clarification, or responding to other answers.
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
\noindent \textbf{{\Large Acknowledgement:}} \\
Asking for help, clarification, or responding to other answers.
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
\noindent \textbf{{\Large Copyright:}}
Asking for help, clarification, or responding to other answers.
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
\begin{abstract}
hjgjhg jhgjhg
\end{abstract}
\frontmatter
\addcontentsline{toc}{section}{Acknowledgement}
\addcontentsline{toc}{section}{Copyright}
\addcontentsline{toc}{section}{Abstract and Table of Contents}
\tableofcontents
\clearpage
\mainmatter
\section{Introduction}
\pagenumbering{arabic}
\end{document}
答案1
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{enumitem}
\usepackage{color}
\usepackage{framed}
\usepackage{todonotes}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage[colorlinks]{hyperref}
\usepackage{mathrsfs}
\usepackage{setspace}
\usepackage{graphicx}
\graphicspath{ {./Images/} }
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{titlesec}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=blue,
}
\urlstyle{same}
\setcounter{secnumdepth}{0}
\makeatletter
\newif\if@mainmatter \@mainmattertrue
\newcommand\frontmatter{%
\cleardoublepage
\@mainmatterfalse
\pagenumbering{roman}}
\newcommand\mainmatter{%
\cleardoublepage
\@mainmattertrue
\pagenumbering{arabic}}
\makeatother
\pagenumbering{roman}
\begin{document}
\frontmatter
\phantomsection
\section{Acknowledgement}
\phantomsection
\section{Copyright}
\tableofcontents
\addcontentsline{toc}{section}{Abstract and Table of Contents}
\mainmatter
\setcounter{secnumdepth}{1}
\section{Introduction}
\section{Alexander Polynomial $\triangle (t)$}
\subsection{History and overview}
\section{Conway Polynomial $\nabla (z)$}
\subsection{History and overview}
\section{Jones Polynomial $V(q)$}
\subsection{History and overview}
\section{HOMFLY Polynomial $H(a,z)$}
\subsection{History and overview}
\section{Vassiliev Invariant}
\subsection{History and overview}
\section{Conclusion}
\section{References}
\end{document}
答案2
你绝对不需要用这种假装\frontmatter/\mainmatter
和secnumdepth
切换来战斗,这绝对是过度的。标准解决方案是
\section*{...}
取消前 3 个部分的编号\addcontentsline{toc}{section}{...}
将带星号的部分包含在其中toc
,就像您所做的那样。\phantomsection
获取超链接,如@ulrike 评论所建议的那样。如果您愿意,请像往常一样手动将
\pagenumbering{roman}
和插入到合适的位置。\pagenumbering{arabic}
梅威瑟:
\documentclass[12pt,titlepage]{article}
\usepackage{hyperref}
\title{Title}
\author{Author}
\date{August 2021}
\hypersetup{
colorlinks=true,
linkcolor=blue}
\begin{document}
\pagenumbering{roman}
\maketitle
\section*{Acknowledgements}
\addcontentsline{toc}{section}{Acknowledgements}
\phantomsection
A text...
\section*{Copyright}
\addcontentsline{toc}{section}{Copyright}
\phantomsection
An other text...
\section*{Abstract and Table of Contents}
\addcontentsline{toc}{section}{Abstract and Table of Contents}
\phantomsection
Some text...
\tableofcontents
% Here starts the main matter
\newpage
\pagenumbering{arabic}
\section{Introduction}
More text...
\end{document}
\addcontentsline
注意:和\phantomsection
相对于相应元素(之前或之后)的位置可能根据上下文而变化。