From bb43c496bd77971159bf12061d9c83796a3d45b4 Mon Sep 17 00:00:00 2001 From: gunjianpan Date: Sat, 16 Jul 2022 16:29:02 +0800 Subject: [PATCH] Feature(lanuage): support multi-lingual format. --- README.md | 2 + doc/example/chap/chap1.tex | 41 +++++++------- doc/example/thesis.tex | 108 +++++++++++++++++++------------------ tex/pkuthss-gbk.def | 12 +++-- tex/pkuthss-utf8.def | 10 +++- tex/pkuthss.cls | 98 ++++++++++++++++++++++++++------- 6 files changed, 174 insertions(+), 97 deletions(-) diff --git a/README.md b/README.md index 8cdac8a..b74f1aa 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ To use pkuthss in the overleaf platform, and to support some customization requi - Supported scanned pdf insert(origin and copy pages); - Add fontset mode, change bfseries -> AutoFakeBold in windows; - Simplify user settings in blind mode; + - Support multi-lingual format(chinese and english); ## Quick Start @@ -58,6 +59,7 @@ The following files have been changed - [x] Fix table of contents. - [x] Support insert pdf (copy and origin pages). - [x] Adaptive pkuthss v1.9.2. +- [x] Support multi-lingual format. ## Change Log diff --git a/doc/example/chap/chap1.tex b/doc/example/chap/chap1.tex index becb567..e7709c5 100644 --- a/doc/example/chap/chap1.tex +++ b/doc/example/chap/chap1.tex @@ -12,26 +12,26 @@ \section{封面及pkuthssinfo相关} 封面部分参考《北京大学研究生学位论文写作指南V2.0-2019》(以下简称写作指南)第1.1节中描述和《硕士论文模板2020》进行修改。 \begin{Verbatim} -\pkuthss{}info{ - cthesisname = {硕士学位论文}, - thesiscover = {硕士研究生学位论文}, - ethesisname = {Master Thesis}, - ctitle = {基于XXXX的XXXX系统设计与实现}, - etitle = {Design and implementation of a XXXXX system based on XXXX}, - cauthor = {扎克·施耐德}, eauthor = {Zack Snyder}, - studentid = {180XXXXXXX}, - % 具体时间以教务为准,初稿3月,送审4月,答辩5月,最终6月。 - date = {\zhdigits{2021}\ \ 年\ \ \zhnumber{6}\ \ 月}, - school = {XXXXXX学院}, - cmajor = {XXXX}, emajor = {XXXX}, - direction = {XXXX}, - mentorlines = {2}, % 导师个数 - % 副教授 A.P. 讲师 Lec. - cmentor = {XXX\ \ 教授\\YYY\ \ 教授}, ementor = {Prof.\ XXX and Prof.\ YYY}, - ckeywords = {A,B,C,D}, - ekeywords = {A,B,C,D}, - % 盲审模式参数, 需在documentclass增加blind - blindid = {XXXXXXXXX}, discipline = {XXXX} +\pkuthssinfo{ + cthesisname = {硕士学位论文}, + thesiscover = {硕士研究生学位论文}, + ethesisname = {Master Thesis}, + ctitle = {基于XXXX的XXXX系统设计与实现}, + etitle = {Design and implementation of a XXXXX system based on XXXX}, + cauthor = {扎克·施耐德}, eauthor = {Zack Snyder}, + studentid = {180XXXXXXX}, + % 具体时间以教务为准,初稿3月,送审4月,答辩5月,最终6月。 + date = {\zhdigits{2021}\ \ 年\ \ \zhnumber{6}\ \ 月}, + school = {XXXXXX学院}, + cmajor = {XXXX}, emajor = {XXXX}, + direction = {XXXX}, + mentorlines = {2}, % 导师个数 + % 副教授 A.P. 讲师 Lec. + cmentor = {XXX\ \ 教授\\YYY\ \ 教授}, ementor = {Prof.\ XXX and Prof.\ YYY}, + ckeywords = {A,B,C,D}, + ekeywords = {A,B,C,D}, + % 盲审模式参数, 需在documentclass增加blind + blindid = {XXXXXXXXX}, discipline = {XXXX} } \end{Verbatim} @@ -275,4 +275,5 @@ \section{与\pkuthss{} \iofubaseversion{}异同} \item 字体模式 \item 简化blind模式下用户设定 \item Windows 下中易宋体的粗体用假粗体替代 + \item 语言模式 \end{enumerate} diff --git a/doc/example/thesis.tex b/doc/example/thesis.tex index 32edb79..5a8aecc 100644 --- a/doc/example/thesis.tex +++ b/doc/example/thesis.tex @@ -1,15 +1,15 @@ % Copyright (c) 2008-2009 solvethis % Copyright (c) 2010-2016,2018-2019,2021-2022 Casper Ti. Vector % Copyright (c) 2021 Kurapica -% Copyright (c) 2021 iofu728 +% Copyright (c) 2022 iofu728 % Local version. %********************************************************************* % iofu728-pkuthss: 北京大学研究生学位论文模板 -% 2021/06/09 v1.0.0 +% 2022/07/16 v1.1.0 % % 重要提示: -% 1. 当前overleaf版符合2021研究生学位论文要求,可通过图书馆审核 +% 1. 当前overleaf版符合2022研究生学位论文要求,可通过图书馆审核 % 2. 当前版本基于pkuthss v1.9.2 % 3. 请使用UTF-8编码,XeLaTeX方式编译 % 4. 请仔细阅读用户文档 @@ -17,10 +17,11 @@ % 6. 如有疑问github/iofu728/pkuthss上提问或联系作者@iofu728 %********************************************************************* -\documentclass[fontset=fandol,ugly]{pkuthss} +\documentclass[fontset=fandol,ugly,language=chinese]{pkuthss} % 学位论文模式 ugly (默认打开,请保留) - % 盲审模式 blind (默认关闭) - % 字体库 fontset + % 盲审模式 blind (默认关闭) + % 语言 language (默认chinese | english) + % 字体库 fontset % auto | windows | windows@overleaf | mac | fandol | ubuntu | none % 除fandol,ubuntu外为商业字体,如需使用请遵循相应版权协议(需要已安装相应的字体) % fandol与windows效果相近,但字符库偏少,推荐使用(默认); @@ -44,63 +45,66 @@ \renewcommand*{\bibfont}{\zihao{5}\linespread{1.27}\selectfont} \pkuthssinfo{ - cthesisname = {硕士学位论文}, - thesiscover = {硕士研究生学位论文}, - ethesisname = {Master Thesis}, - ctitle = {基于XXXX的XXXX系统设计与实现}, - etitle = {Design and implementation of a XXXXX system based on XXXX}, - cauthor = {扎克·施耐德}, eauthor = {Zack Snyder}, - studentid = {180XXXXXXX}, - % 具体时间以教务为准,初稿3月,送审4月,答辩5月,最终6月。 - date = {\zhdigits{2021}\ \ 年\ \ \zhnumber{6}\ \ 月}, - school = {XXXXXX学院}, - cmajor = {XXXX}, emajor = {XXXX}, - direction = {XXXX}, - mentorlines = {2}, % 导师个数 - % 副教授 A.P. 讲师 Lec. - cmentor = {XXX\ \ 教授\\YYY\ \ 教授}, ementor = {Prof.\ XXX and Prof.\ YYY}, - ckeywords = {A,B,C,D}, - ekeywords = {A,B,C,D}, - % 盲审模式参数, 需在documentclass增加blind - blindid = {XXXXXXXXX}, discipline = {XXXX} + cthesisname = {硕士学位论文}, + thesiscover = {硕士研究生学位论文}, + ethesisname = {Master Thesis}, + ctitle = {基于XXXX的XXXX系统设计与实现}, + etitle = {Design and implementation of a XXXXX system based on XXXX}, + cauthor = {扎克·施耐德}, eauthor = {Zack Snyder}, + studentid = {180XXXXXXX}, + % 具体时间以教务为准,初稿3月,送审4月,答辩5月,最终6月。 + date = {\zhdigits{2022}\ \ 年\ \ \zhnumber{6}\ \ 月}, % June, 2022 + school = {XXXXXX学院}, + cmajor = {XXXX}, emajor = {XXXX}, + direction = {XXXX}, + mentorlines = {2}, % 导师个数 + % 副教授 A.P. 讲师 Lec. + cmentor = {XXX\ \ 教授\\YYY\ \ 教授}, ementor = {Prof.\ XXX and Prof.\ YYY}, + ckeywords = {A,B,C,D}, + ekeywords = {A,B,C,D}, + % 盲审模式参数, 需在documentclass增加blind + blindid = {XXXXXXXXX}, discipline = {XXXX} } \addbibresource{thesis.bib} \begin{document} - \frontmatter - \pagestyle{empty} - \maketitle - \cleardoublepage - % 需替换门户版权声明pdf - \include{chap/copy} - - \cleardoublepage - \pagestyle{plain} - \setcounter{page}{0} - \pagenumbering{Roman} - \include{chap/abs} - \tableofcontents - % 如有需要使用主要符号对照表 - \include{chap/deno} - - \mainmatter - \include{chap/chap1} - \include{chap/chap2} - \include{chap/chap3} - \include{chap/chap4} - \include{chap/chap5} - \include{chap/chap6} + \frontmatter + \pagestyle{empty} + \maketitle + \cleardoublepage + % 需替换门户版权声明pdf + \include{chap/copy} + + \cleardoublepage + \pagestyle{plain} + \setcounter{page}{0} + \pagenumbering{Roman} + \include{chap/abs} + \tableofcontents + % 如有需要使用表格索引、插图索引 + \listoftables + \listoffigures + % 如有需要使用主要符号对照表 + \include{chap/deno} + + \mainmatter + \include{chap/chap1} + \include{chap/chap2} + \include{chap/chap3} + \include{chap/chap4} + \include{chap/chap5} + \include{chap/chap6} \appendix \printbibliography[heading = bibintoc] % 如有需要使用研究生成果页 \include{chap/ach} - \backmatter - \include{chap/ack} - % 需替换门户原创页pdf/扫描pdf - \include{chap/origin} + \backmatter + \include{chap/ack} + % 需替换门户原创页pdf/扫描pdf + \include{chap/origin} \end{document} diff --git a/tex/pkuthss-gbk.def b/tex/pkuthss-gbk.def index e3fa745..045d649 100644 --- a/tex/pkuthss-gbk.def +++ b/tex/pkuthss-gbk.def @@ -3,7 +3,7 @@ % Copyright (c) 2008-2009 solvethis % Copyright (c) 2010-2013,2015,2021 Casper Ti. Vector % Copyright (c) 2021 Kurapica -% Copyright (c) 2021 iofu728 +% Copyright (c) 2022 iofu728 % % This work may be distributed and/or modified under the conditions of the % LaTeX Project Public License, either version 1.3 of this license or (at @@ -29,13 +29,19 @@ for the pkuthss document class] \def\label@ctitle{Ŀ} +\def\label@etitle{Title: } \def\label@cauthor{\hphantom{}} +\def\label@eauthor{Name: } \def\label@studentid{ѧ\hphantom{}ţ} +\def\label@estudentid{Student ID: } \def\label@school{Ժ\hphantom{}ϵ} +\def\label@eschool{Affiliation: } \def\label@cmajor{ר\hphantom{}ҵ} +\def\label@emajor{Major: } \def\label@direction{о} +\def\label@edirection{Research Division: } \def\label@cmentor{\hphantom{}ʦ} -\def\label@ementor{Directed by\ } +\def\label@ementor{Directed by: } \def\label@ckeywords{ؼʣ} \def\label@ekeywords{KEY WORDS:\ } \def\label@blindcover{ķ棩} @@ -49,7 +55,7 @@ \def\cuniversity{ѧ} \def\euniversity{Peking University} \def\cthesisname{˶ʿѧλ} -\def\ethesisname{Doctor Thesis} +\def\ethesisname{Master Thesis} \def\thesiscover{˶ʿоѧλ} \def\cabstractname{ժҪ} \def\eabstractname{ABSTRACT} diff --git a/tex/pkuthss-utf8.def b/tex/pkuthss-utf8.def index 71ee5bc..c21a237 100644 --- a/tex/pkuthss-utf8.def +++ b/tex/pkuthss-utf8.def @@ -3,7 +3,7 @@ % Copyright (c) 2008-2009 solvethis % Copyright (c) 2010-2013,2015,2021 Casper Ti. Vector % Copyright (c) 2021 Kurapica -% Copyright (c) 2021 iofu728 +% Copyright (c) 2022 iofu728 % % This work may be distributed and/or modified under the conditions of the % LaTeX Project Public License, either version 1.3 of this license or (at @@ -29,13 +29,19 @@ for the pkuthss document class] \def\label@ctitle{题目:} +\def\label@etitle{Title: } \def\label@cauthor{姓\hphantom{汉字}名:} +\def\label@eauthor{Name: } \def\label@studentid{学\hphantom{汉字}号:} +\def\label@estudentid{Student ID: } \def\label@school{院\hphantom{汉字}系:} +\def\label@eschool{Affiliation: } \def\label@cmajor{专\hphantom{汉字}业:} +\def\label@emajor{Major: } \def\label@direction{研究方向:} +\def\label@edirection{Research Division: } \def\label@cmentor{导\hphantom{汉字}师:} -\def\label@ementor{Directed by\ } +\def\label@ementor{Directed by: } \def\label@ckeywords{关键词:} \def\label@ekeywords{KEY WORDS:\ } \def\label@blindcover{(匿名评阅论文封面)} diff --git a/tex/pkuthss.cls b/tex/pkuthss.cls index 145f8ea..e97ac1d 100644 --- a/tex/pkuthss.cls +++ b/tex/pkuthss.cls @@ -29,7 +29,7 @@ [2022/05/05 v1.9.2 Peking University dissertation document class] \def\pkuthss{pkuthss} \def\iofupkuthss{iofu728/pkuthss} -\def\iofuversion{v1.0.0} +\def\iofuversion{v1.1.0} \def\iofubaseversion{v1.9.2} \newcommand\thss@error[1]{% \ClassError{pkuthss}{#1}{}% @@ -125,6 +125,13 @@ }, default = UTF8, }, + language = { + choices = { + chinese, + english, + }, + default = chinese, + }, } % eg. `\thss@int@boolopt{spacing}{true}' will expand to: @@ -204,6 +211,38 @@ \input{pkuthss-utf8.def} \fi +% Set the name of chapter and section. +\newcommand\thss@set@chapter@names{% + \ifthss@language@chinese + \def\listfigurename{插图索引}% + \def\listtablename{表格索引}% + \else + \ifthss@language@english + \def\bibname{References}% + \def\appendixname{Appendix}% + \def\contentsname{Contents}% + \def\listfigurename{List of Figures}% + \def\listtablename{List of Tables}% + \def\figurename{Figure}% + \def\tablename{Table}% + \def\indexname{Index}% + \ctexset{ + part/name = {\partname\space}, + part/number = {\thepart}, + chapter = { + name = {\chaptername\space}, + number = {\thechapter}, + aftername = {\space}, + }, + section/aftername = {\space}, + subsection/aftername = {\space}, + autoindent = {0.8cm}, + } + \fi + \fi +} +\thss@set@chapter@names + \ifthss@opt@pkufont % Use Times New Roman / Arial according to school regulation. \ifxetex @@ -468,7 +507,7 @@ \fancyhf{}\renewcommand*{\headrulewidth}{0.75bp} \fancyfoot[C]{\zihao{5}\normalfont{\thepage}} \if@twoside - \fancyhead[CE]{\zihao{5}\normalfont{\cuniversity\cthesisname}} + \fancyhead[CE]{\zihao{5}\normalfont{\ifthss@language@chinese{\cuniversity\cthesisname}\else{\euniversity\ \ethesisname}\fi}} \fancyhead[CO]{\zihao{5}\normalfont\thss@int@setcase{\leftmark}} \else \fancyhead[C]{\zihao{5}\normalfont\thss@int@setcase{\leftmark}} @@ -518,13 +557,14 @@ \zihao{1}\includegraphics[height = 2.4em]{pkulogo}\hspace{0.4em}% \raisebox{0.4em}{\includegraphics[height = 1.6em]{pkuword}}\\[0.8em] \fi% - {\heiti\ifx\thesiscover\empty{\cthesisname}\else{\thesiscover}\fi}% + {\heiti\ifthss@language@chinese{\ifx\thesiscover\empty{\cthesisname}\else{\thesiscover}\fi}\else{\ethesisname}\fi}% } \vfill + % Title of the thesis. {% - \zihao{2}\linespread{1.6}\selectfont{\label@ctitle}% - \thss@int@fillinblank{2}{0.64\textwidth}{\heiti{\zihao{1}\@ctitle}}% + \zihao{2}\linespread{1.6}\selectfont{\ifthss@language@chinese{\label@ctitle}\else{\label@etitle}\fi}% + \thss@int@fillinblank{2}{0.64\textwidth}{\heiti{\zihao{1}\ifthss@language@chinese{\@ctitle}\else{\@etitle}\fi}}% } \vfill % Information about the author. @@ -532,20 +572,39 @@ % Slightly adjust the line skip when using new font size. \zihao{3}\linespread{1.75}\selectfont \def\thss@tmp@len{0.56\textwidth} - \begin{tabular}{l@{\extracolsep{0.2em}}c} - {\heiti{\zihao{-3}\label@cauthor}} & - \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@cauthor} \\ - {\heiti{\zihao{-3}\label@studentid}} & - \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@studentid} \\ - {\heiti{\zihao{-3}\label@school}} & - \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@school} \\ - {\heiti{\zihao{-3}\label@cmajor}} & - \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@cmajor} \\ - {\heiti{\zihao{-3}\label@direction}} & - \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@direction} \\ - {\heiti{\zihao{-3}\label@cmentor}} & - \thss@int@fillinblank{\mentorlines}{\thss@tmp@len}{\fangsong\@cmentor} \\ - \end{tabular}% + \ifthss@language@chinese + \begin{tabular}{l@{\extracolsep{0.2em}}c} + {\heiti{\zihao{-3}\label@cauthor}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@cauthor} \\ + {\heiti{\zihao{-3}\label@studentid}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@studentid} \\ + {\heiti{\zihao{-3}\label@school}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@school} \\ + {\heiti{\zihao{-3}\label@cmajor}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@cmajor} \\ + {\heiti{\zihao{-3}\label@direction}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@direction} \\ + {\heiti{\zihao{-3}\label@cmentor}} & + \thss@int@fillinblank{\mentorlines}{\thss@tmp@len}{\fangsong\@cmentor} \\ + \end{tabular}% + \else + \ifthss@language@english + \begin{tabular}{c@{\extracolsep{0.2em}}c} + {\heiti{\zihao{-3}\label@eauthor}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@eauthor} \\ + {\heiti{\zihao{-3}\label@estudentid}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@studentid} \\ + {\heiti{\zihao{-3}\label@eschool}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@school} \\ + {\heiti{\zihao{-3}\label@emajor}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@emajor} \\ + {\heiti{\zihao{-3}\label@edirection}} & + \thss@int@fillinblank{1}{\thss@tmp@len}{\fangsong\@direction} \\ + {\heiti{\zihao{-3}\label@ementor}} & + \thss@int@fillinblank{\mentorlines}{\thss@tmp@len}{\fangsong\@ementor} \\ + \end{tabular}% + \fi + \fi } \vfill % Date. @@ -605,7 +664,6 @@ \vfill\noindent\label@ekeywords{\@ekeywords}% } - % Typeset the tableofcontents. \renewcommand*{\tableofcontents}{% \chapter*{\contentsname}%