From e12f13e7dac094a71a65ed3e45f2c23ca0d8c65c Mon Sep 17 00:00:00 2001 From: Liu Xinyu Date: Tue, 7 Nov 2023 16:53:28 +0800 Subject: [PATCH] Use babel for CN/EN support --- algoxy-zh-cn.tex | 4 +--- others/appendix/bib-zh-cn.tex | 2 +- prelude.sty | 12 +++++++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/algoxy-zh-cn.tex b/algoxy-zh-cn.tex index 6557756c7..870f52d94 100644 --- a/algoxy-zh-cn.tex +++ b/algoxy-zh-cn.tex @@ -97,7 +97,6 @@ \subimport{search/}{search-zh-cn.tex} -\renewcommand\appendixname{附录} \appendix \subimport{others/appendix/rbt-del/}{rbt-del-zh-cn.tex} @@ -117,8 +116,7 @@ \chapter{参考答案} \backmatter \phantomsection -\addcontentsline{toc}{chapter}{索引} -\renewcommand\indexname{索引} +\addcontentsline{toc}{chapter}{\indexname} \printindex \end{document} diff --git a/others/appendix/bib-zh-cn.tex b/others/appendix/bib-zh-cn.tex index 22a62351f..6e3450390 100644 --- a/others/appendix/bib-zh-cn.tex +++ b/others/appendix/bib-zh-cn.tex @@ -1,4 +1,4 @@ -\renewcommand\bibname{参考文献} +\markboth{\bibname}{} \phantomsection % so hyperref creates bookmarks \addcontentsline{toc}{chapter}{\bibname} diff --git a/prelude.sty b/prelude.sty index eeceea58c..4c285b5e0 100644 --- a/prelude.sty +++ b/prelude.sty @@ -14,6 +14,7 @@ pdfstartview=FitH]{hyperref} \usepackage{fontspec} +\usepackage[nil,english]{babel} \usepackage{graphicx, color} \usepackage{adjustbox} \usepackage{wrapfig} @@ -76,7 +77,7 @@ numberstyle=\ttfamily\tiny, emphstyle={\bf}, escapeinside={*'}{'*}, - stringstyle=\mdseries\rmfamily, + stringstyle=\mdseries\ttfamily, %rmfamily, keywordstyle=\bfseries\ttfamily, %rmfamily basicstyle=\footnotesize\ttfamily, %sffamily commentstyle = \footnotesize\rmfamily, @@ -279,6 +280,14 @@ % Simplified way to customize Chinese. Or \usepackage[chinese, english]{babel} % However, it need install the additional texlive-lang-chinese. + \addto\captionsenglish{\renewcommand{\contentsname}{目录}} + \addto\captionsenglish{\renewcommand{\appendixname}{附录}} + \addto\captionsenglish{\renewcommand\bibname{参考文献}} + \addto\captionsenglish{\renewcommand\indexname{索引}} + \addto\captionsenglish{\renewcommand{\figurename}{图}} + \addto\captionsenglish{\renewcommand{\tablename}{表}} + \addto\captionsenglish{\renewcommand{\proofname}{证明}} + \newtheorem{axiom}{公理}[section] \newtheorem{theorem}{定理}[section] \newtheorem{lemma}[theorem]{引理} @@ -307,6 +316,7 @@ \newtheorem{corollary}[theorem]{Corollary} \newtheorem{definition}{Definition}[section] \newtheorem{example}{Example}[section] + \babelfont[chinese]{rm}{Noto Serif CJK SC} } \DeclareOption*{\PackageWarning{prelude}{Unknown ‘\CurrentOption’}}