From cf755a03879b04f03a235f0de2987f55c7e3a768 Mon Sep 17 00:00:00 2001 From: EthanDeng Date: Wed, 29 Jul 2020 13:37:20 +0800 Subject: [PATCH] hyperref toc clickable --- elegantbook-cn.tex | 4 ++-- elegantbook-en.tex | 9 +++++---- elegantbook.cls | 33 +++++++++++++++++++++++---------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/elegantbook-cn.tex b/elegantbook-cn.tex index e017f49..121659b 100644 --- a/elegantbook-cn.tex +++ b/elegantbook-cn.tex @@ -5,8 +5,8 @@ \author{Ethan Deng \& Liam Huang} \institute{Elegant\LaTeX{} Program} -\date{July 6, 2020} -\version{4.0.2} +\date{July 29, 2020} +\version{4.0.3} \bioinfo{自定义}{信息} \extrainfo{温柔正确的人总是难以生存,因为这世界既不温柔,也不正确。—— 比企谷八幡} diff --git a/elegantbook-en.tex b/elegantbook-en.tex index a2c91bf..e29e291 100644 --- a/elegantbook-en.tex +++ b/elegantbook-en.tex @@ -1,12 +1,12 @@ -\documentclass[11pt,fancy,twoside]{elegantbook} +\documentclass[11pt,fancy,twocol]{elegantbook} \title{An Elegant \LaTeX{} Template for Books} \subtitle{Classic Elegant\LaTeX{} Template} \author{Ethan Deng \& Liam Huang} \institute{Elegant\LaTeX{} Program} -\date{July 6, 2020} -\version{4.0.2} +\date{July 29, 2020} +\version{4.0.3} \bioinfo{Bio}{Information} \extrainfo{Victory won\rq t come to us unless we go to it. } @@ -15,6 +15,7 @@ \cover{cover.jpg} + \begin{document} \maketitle @@ -630,7 +631,7 @@ Let $G$ be a finite group, and let $H$ be a subgroup of $G$. Then the order of \lipsum[3] -\begin{proposition}{Size of Left Coset}{} +\begin{proposition}[Size of Left Coset] Let $H$ be a finite subgroup of a group $G$. Then each left coset of $H$ in $G$ has the same number of elements as $H$. \end{proposition} diff --git a/elegantbook.cls b/elegantbook.cls index 8bc9ce9..3e102e1 100644 --- a/elegantbook.cls +++ b/elegantbook.cls @@ -8,7 +8,7 @@ %%%%%%%%%%%%%%%%%%%%% % % !Mode:: "TeX:UTF-8" \NeedsTeXFormat{LaTeX2e} -\ProvidesClass{elegantbook}[2020/07/06 v4.0.2 ElegantBook document class] +\ProvidesClass{elegantbook}[2020/07/29 v4.0.3 ElegantBook document class] \RequirePackage{kvoptions} \RequirePackage{etoolbox} @@ -60,9 +60,11 @@ \DeclareVoidOption{margintrue}{\ekv{marginpar=margintrue}} \DeclareVoidOption{marginfalse}{\ekv{marginpar=marginfalse}} + \DeclareVoidOption{onecol}{\ekv{toc=onecol}} \DeclareVoidOption{twocol}{\ekv{toc=twocol}} + % ----- Math option ----- \newcommand\mailto[1]{\href{mailto:#1}{\nolinkurl{#1}}} @@ -310,14 +312,7 @@ \setlength{\footnotesep}{12pt} } -\ifdefstring{\ELEGANT@toc}{twocol}{ -\renewcommand{\tableofcontents}{% -\setlength{\columnsep}{2em} -%\setlength{\columnseprule}{.8pt} -\begin{multicols}{2}[\chapter*{\contentsname}]% - \@starttoc{toc}% -\end{multicols}} -}{\relax} + %% 常用宏包 @@ -883,4 +878,22 @@ \begin{enumerate}[label=\small\protect\circled{\arabic*}]}{ \end{enumerate}} -\addbibresource[location=local]{reference.bib} \ No newline at end of file +\addbibresource[location=local]{reference.bib} + +\renewcommand\tableofcontents{% + \hypersetup{linktoc=all, linkcolor=black} + \if@twocolumn + \@restonecoltrue\onecolumn + \else + \@restonecolfalse + \fi + \chapter*{\contentsname + \@mkboth{% + \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% + \ifdefstring{\ELEGANT@toc}{twocol}{ + \setlength{\columnsep}{2em} + \begin{multicols}{2}% + \@starttoc{toc} + \end{multicols}}{ + \@starttoc{toc}} + \if@restonecol\twocolumn\fi} \ No newline at end of file