diff options
author | Norbert Preining <norbert@preining.info> | 2021-09-12 03:05:00 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-09-12 03:05:00 +0000 |
commit | cac1f99f7d65e4d3c8bc7575c30f6b1bc605a683 (patch) | |
tree | 5f9e3be4c324b6dd447d114753337b4977615c64 /macros | |
parent | bbb409a0db8bab4e45fd1fa3e7f269a855296bbc (diff) |
CTAN sync 202109120304
Diffstat (limited to 'macros')
26 files changed, 3360 insertions, 97 deletions
diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/README.md b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/README.md index 8df188541e..8e0a745fdc 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/README.md +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/README.md @@ -1,4 +1,4 @@ -<b>Date of last change: 2021-08-19 to version v1.0z</b> +<b>Date of last change: 2021-09-11 to version v1.1a</b> # biblatex-gb7714-2015: a biblatex style package @@ -95,7 +95,7 @@ biblatex-gb7714-2015 宏包是中文参考文献著录/标注标准 `GB/T 7714-2 * [biblatex-map bib文件修改工具](https://github.com/hushidong/biblatex-map/) * [biblatex-check bib文件检查工具](https://github.com/Pezmc/BibLatex-Check) * [biblatex-caspervector: caspervector 设计的中文参考文献样式](https://github.com/CasperVector/biblatex-caspervector) -* [gbt7714-bibtex-style: GB/T7714-2015 标准的bst实现版本](https://github.com/zepinglee/gbt7714-bibtex-style) +* [gbt7714-bibtex-style: GB/T7714-2015 标准的bst实现版本](https://github.com/CTeX-org/gbt7714-bibtex-style) * [LaTeX学习网站](http://www.latexstudio.net/) * [LaTeX交流论坛](http://www.ctex.org/) @@ -680,6 +680,13 @@ GB/T 7714-2015标准实现的bst版本,已经由[zeping lee](https://github.co 请邮件联系hzzmail@163.com或在项目内发issue提问即可。 +* <b>注意帮助的文档的查询顺序?</b> + +一般用户的话查:biblatex-gb7714-2015.pdf,biblatex-solution-to-latex-bibliography.pdf,biblatex-zh-cn.PDF。 +宏包作者的话查:gb7714-2015*.C/BBX,biblatex.PDF,numeric/authoryear.c/BBX,standard.bbx,biblatex.def,biblatex.sty,english.lbx +注意别忘了lbx文件。 + + #### 4.2 Bibliography format/文献表著录格式 * <b>请问可以在参考文献表中实现类似于word那样的与文献内容等间距标签对齐格式么?</b> @@ -966,6 +973,29 @@ biblatex-gb7714-2015设计了两种多语言对照参考文献的实现方式, 可通过设置选项uniquelist=false实现,该设置标签中的作者只会是指定的1个: ```\usepackage[backend=biber,style=gb7714-2015ay,uniquelist=false]{biblatex}``` + + +* <b>请问希望正文中作者年制的标注(引用)标签希望作者给出3个,而且最后一个作者的前面用和及&符号链接,该怎么处理?</b> + + +首先设置标注标签中的作者的最大数量为3个: + +```\usepackage[backend=biber,style=gb7714-2015ay,maxcitenames=3]{biblatex}``` + +然后修改标注中的本地化字符串: + +``` +\DefineBibliographyStrings{english}{ + andincitecn = {\str@andcn},%将标注中的分开,便于与文献表中的区分 + andincite = {\&}} +``` + +最后重新定义finalandcomma标点,注意这里与语言相关的标点,需要用DefineBibliographyExtras命令定义。 + +``` +\DefineBibliographyExtras{english}{\def\finalandcomma{}}% +``` + @@ -1515,6 +1545,7 @@ please see the file 'biblatex-gb7714-2015.pdf' for further information! * 2021/04/03 v1.0x,ctan * 2021/05/06 v1.0y,ctan * 2021/08/19 v1.0z,ctan +* 2021/09/11 v1.1a,ctan diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.pdf b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.pdf Binary files differindex a15d4208b7..7f970fb784 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.pdf +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.pdf diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.tex b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.tex index 1d80d67bda..60833504ae 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.tex +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/biblatex-gb7714-2015.tex @@ -1268,7 +1268,25 @@ leftrule=0pt,rightrule=0pt,toprule=0.4pt,bottomrule=0.4pt] %上一段2016-1114更新,下面是以前的说法。 %\qd{根据文种文献集中的要求,修改了nyt排序格式,增加了userb作为name前的排序域,当有需求进行多文种分集且有特殊顺序时,在bib文件中给相应文种的文献设置适合排序的字符串。比如中文文献设置为cn,英文文献设置为en,法文文献设置为fr,那么排序中,相应的中文文献排在最前面,英文文献在中间,法文文献最后,因为升序情况下字母顺序是c然后e然后f。} -打印出的文献表主要有两个部分的格式需要控制,一是文献表的段落格式,二是文献表中各条文献的著录格式: +打印出的文献表主要有三个部分的格式需要控制,一是文献表的标题格式,二是文献表的段落格式,三是文献表中各条文献的著录格式: + +\subsubsection{标题格式控制} + +标题内容的设置有三种方式,这里再重复一下:一是直接在printbibliography命令中利用选项title设置,二是gbctexset=true时,重定义bibname和refname来设置,三是gbctexset=true是false时,利用本地化字符串进行设置。具体参见gbctexset选项。 + +标题格式的设置主要是通过重定义参考文献环境的heading进行,比如: + +\begin{example}{文献表标题格式}{eg:biblist:title} +\begin{texlist} +%将参考文献标题设置为段落的层级,若是其它层级则使用对应的命令,比如chapter,section等 +\defbibheading{bibliography}[\bibname]{% +\paragraph{#1}}% +\end{texlist} +\end{example} + +更多的设置方法,请参考: +\href{https://github.com/hushidong/biblatex-solution-to-latex-bibliography/blob/master/biblatex-solution-to-latex-bibliography.pdf}% +{biblatex高级使用方法和样式包设计实现方法} \subsubsection{段落格式控制} diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.bbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.bbx index d4beba03b6..f383483dd4 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.bbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.bbx @@ -11,7 +11,7 @@ % % 版本和时间信息 % -\def\versionofgbtstyle{2021/08/19 v1.0z} +\def\versionofgbtstyle{2021/09/11 v1.1a} \def\versionofbiblatex{\abx@version} \ProvidesFile{gb7714-2015.bbx}[\versionofgbtstyle biblatex bibliography style] %\RequireBiber[3]%显式指定用biber后端,当用bibtex时会报错,但其实不会影响编译,只是采用bibtex后无法达成格式需求 @@ -907,7 +907,7 @@ and = {\addcomma},%将第2和3人名间的and符号改成逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 andcn = {\addcomma},%and本地化字符串的中文对应词 andincitecn = {\str@andcn},%将标注中的分开,便于与文献表中的区分 - andincite = {\addcomma}, + andincite = {\addcomma\space},%注意add开头的命令会其把前面的空格去掉 %andothers = {et al.},%将超过3个人名的省略,et al.改成为 等 andotherscn = {\str@andotherscn},%将超过3个人名的省略,et al.改成为 等 andothersincitecn={\str@andotherscn},%将标注中的分开,便于与文献表中的区分 @@ -2445,14 +2445,14 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andincitecn}}{}% \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}% \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}% - \iffieldequalstr{\userfieldabcde}{english}{\space\bibstring{andincite}\space}{}% - \iffieldequalstr{\userfieldabcde}{french}{\space\bibstring{and}\space}{}% - \iffieldequalstr{\userfieldabcde}{russian}{\space\bibstring{and}\space}{}% + \iffieldequalstr{\userfieldabcde}{english}{\bibstring{andincite}}{}% + \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}% + \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}% %\space% \or% \bibstring{andincitecn}%\space% \or% -\space\bibstring{andincite}\space% +\bibstring{andincite}% \fi} \DeclareDelimFormat[bib,biblist]{finalnamedelim}{% @@ -2472,9 +2472,9 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}% \space% \or% - \bibstring{andcn}\space% + \bibstring{andcn}% \or% - \bibstring{and}\space% + \bibstring{and}% \fi} @@ -2517,6 +2517,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \DeclareNameFormat{namefmtselected}{% \iffieldundef{namefmtid}{}% {\defcounter{gbnamefmtcase}{\thefield{namefmtid}}}% +%\printtext{\thegbnamefmtcase}% \ifcase\value{gbnamefmtcase}% \ifgiveninits {\usebibmacro{name:gbuppercase} @@ -2618,9 +2619,11 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 %\DeclareDelimFormat[textcite]{andothersdelim}{\addspace}% %GB/T 7714-2015 风格,全部大写 +\def\gbcaselocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 +\renewcommand*{\revsdnamepunct}{}%%%来源biblatex.def +} \newbibmacro*{name:gbuppercase}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 -\renewcommand*{\revsdnamepunct}{}% + \gbcaselocalset% \ifuseprefix% {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2647,8 +2650,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 %GB/T 7714-2015 风格,大小写不变,根据bib文件内输入原样输出 \newbibmacro*{name:gblowercase}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \gbcaselocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2674,10 +2676,11 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 } %中文常见风格,汉语拼音全拼模式 -\newbibmacro*{name:gbpinyin}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY +\def\gbpinyinlocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def -\renewrobustcmd*{\bibnamedelima}{\mbox{-}}% +\renewrobustcmd*{\bibnamedelima}{\mbox{-}}} +\newbibmacro*{name:gbpinyin}[4]{\bibauthorfont% +\gbpinyinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2703,10 +2706,11 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \ifdefvoid{#4}{}{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}% } %中文常见风格,汉语拼音全拼模式 -\newbibmacro*{name:gbquanpin}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY +\def\gbquanpinlocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def -\renewrobustcmd*{\bibnamedelima}{}% +\renewrobustcmd*{\bibnamedelima}{}} +\newbibmacro*{name:gbquanpin}[4]{\bibauthorfont% +\gbquanpinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2737,8 +2741,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 {}{ %GB/T 7714-2015 风格,全部大写 \renewbibmacro*{name:gbuppercase}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \gbcaselocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2771,8 +2774,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 %GB/T 7714-2015 风格,大小写不变,根据bib文件内输入原样输出 \renewbibmacro*{name:gblowercase}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \gbcaselocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2797,9 +2799,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 %中文常见风格,汉语拼音全拼模式 \renewbibmacro*{name:gbpinyin}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def - \renewrobustcmd*{\bibnamedelima}{\mbox{-}}% + \gbpinyinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2823,9 +2823,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 } %中文常见风格,汉语拼音全拼模式 \renewbibmacro*{name:gbquanpin}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def - \renewrobustcmd*{\bibnamedelima}{}% + \gbquanpinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.cbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.cbx index b95d7cd3d8..ddc80006c2 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.cbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015.cbx @@ -7,8 +7,7 @@ %% Released under the LaTeX Project Public License v1.3c or later %% --------------------------------------------------------------- %% -\def\versionofgbtstyle{2021/08/19 v1.0z} -\ProvidesFile{gb7714-2015.cbx}[\versionofgbtstyle biblatex citation style] +\ProvidesFile{gb7714-2015.cbx}[a biblatex citation style for GB/T 7714-2015] % % 加载标准样式 diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.bbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.bbx index fb67497c2f..25455abe4a 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.bbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.bbx @@ -10,7 +10,7 @@ % % 版本和时间信息 % -\def\versionofgbtstyle{2021/08/19 v1.0z} +\def\versionofgbtstyle{2021/09/11 v1.1a} \def\versionofbiblatex{\abx@version} \ProvidesFile{gb7714-2015ay.bbx}[\versionofgbtstyle biblatex bibliography style] %\RequireBiber[3]%显式指定用biber后端,当用bibtex时会报错,但其实不会影响编译,只是采用bibtex后无法达成格式需求 @@ -857,7 +857,7 @@ and = {\addcomma},%将第2和3人名见的and符号改成 逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 andcn = {\addcomma},%\str@andcn\ and本地化字符串的中文对应词 andincitecn = {\str@andcn},%将标注中的分开,便于与文献表中的区分 - andincite = {\addcomma}, + andincite = {\addcomma\space},%注意add开头的命令会其把前面的空格去掉 %andothers = {et al.}, %将超过3个人名的省略,et al.改成为 等 andotherscn = {\str@andotherscn},%将超过3个人名的省略,et al.改成为 等 andothersincitecn={\str@andotherscn},%将标注中的分开,便于与文献表中的区分 @@ -2297,14 +2297,14 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andincitecn}}{}% \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}% \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}% - \iffieldequalstr{\userfieldabcde}{english}{\space\bibstring{andincite}\space}{}% - \iffieldequalstr{\userfieldabcde}{french}{\space\bibstring{and}\space}{}% - \iffieldequalstr{\userfieldabcde}{russian}{\space\bibstring{and}\space}{}% + \iffieldequalstr{\userfieldabcde}{english}{\bibstring{andincite}}{}% + \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}% + \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}% %\space% \or% \bibstring{andincitecn}%\space% \or% -\space\bibstring{andincite}\space% +\bibstring{andincite}% \fi} \DeclareDelimFormat[bib,biblist]{finalnamedelim}{% @@ -2324,9 +2324,9 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}% \space% \or% - \bibstring{andcn}\space% + \bibstring{andcn}% \or% - \bibstring{and}\space% + \bibstring{and}% \fi} @@ -2472,9 +2472,11 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 %\DeclareDelimFormat[textcite]{andothersdelim}{\addspace}% %GB/T 7714-2015 风格,全部大写 +\def\gbcaselocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 +\renewcommand*{\revsdnamepunct}{}%%%来源biblatex.def +} \newbibmacro*{name:gbuppercase}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 -\renewcommand*{\revsdnamepunct}{}% + \gbcaselocalset% \ifuseprefix% {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2501,8 +2503,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 %GB/T 7714-2015 风格,大小写不变,根据bib文件内输入原样输出 \newbibmacro*{name:gblowercase}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \gbcaselocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2528,10 +2529,11 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 } %中文常见风格,汉语拼音全拼模式 -\newbibmacro*{name:gbpinyin}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY +\def\gbpinyinlocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def -\renewrobustcmd*{\bibnamedelima}{\mbox{-}}% +\renewrobustcmd*{\bibnamedelima}{\mbox{-}}} +\newbibmacro*{name:gbpinyin}[4]{\bibauthorfont% + \gbpinyinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2557,10 +2559,11 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 \ifdefvoid{#4}{}{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}% } %中文常见风格,汉语拼音全拼模式 -\newbibmacro*{name:gbquanpin}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY +\def\gbquanpinlocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def -\renewrobustcmd*{\bibnamedelima}{}% +\renewrobustcmd*{\bibnamedelima}{}} +\newbibmacro*{name:gbquanpin}[4]{\bibauthorfont% +\gbquanpinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2591,8 +2594,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 {}{ %GB/T 7714-2015 风格,全部大写 \renewbibmacro*{name:gbuppercase}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \gbcaselocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2625,8 +2627,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 %GB/T 7714-2015 风格,大小写不变,根据bib文件内输入原样输出 \renewbibmacro*{name:gblowercase}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \gbcaselocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2651,9 +2652,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 %中文常见风格,汉语拼音全拼模式 \renewbibmacro*{name:gbpinyin}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def - \renewrobustcmd*{\bibnamedelima}{\mbox{-}}% + \gbpinyinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2677,9 +2676,7 @@ test {\iftoggle{iftlseven}}%biblatex<=3.7 } %中文常见风格,汉语拼音全拼模式 \renewbibmacro*{name:gbquanpin}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def - \renewrobustcmd*{\bibnamedelima}{}% + \gbquanpinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.cbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.cbx index 6149ee149f..e6540216ba 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.cbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ay.cbx @@ -7,8 +7,7 @@ %% Released under the LaTeX Project Public License v1.3c or later %% --------------------------------------------------------------- %% -\def\versionofgbtstyle{2021/08/19 v1.0z} -\ProvidesFile{gb7714-2015ay.cbx}[\versionofgbtstyle biblatex citation style] +\ProvidesFile{gb7714-2015.cbx}[a biblatex citation style for GB/T 7714-2015] % % 加载标准样式 diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.bbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.bbx index 2ae26b511e..3044440ca2 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.bbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.bbx @@ -11,7 +11,7 @@ % % 版本和时间信息 % -\def\versionofgbtstyle{2021/08/19 v1.0z} +\def\versionofgbtstyle{2021/09/11 v1.1a} \def\versionofbiblatex{\abx@version} \ProvidesFile{gb7714-2015ms.bbx}[\versionofgbtstyle biblatex bibliography style] %\RequireBiber[3]%显式指定用biber后端,当用bibtex时会报错,但其实不会影响编译,只是采用bibtex后无法达成格式需求 @@ -619,7 +619,7 @@ and = {\addcomma},%将第2和3人名间的and符号改成逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 andcn = {\addcomma},%and本地化字符串的中文对应词 andincitecn = {\addcomma},%将标注中的分开,便于与文献表中的区分 - andincite = {\addcomma}, + andincite = {\addcomma\space},%注意add开头的命令会其把前面的空格去掉 %andothers = {et al.}, %将超过3个人名的省略,et al.改成为 等 andotherscn = {\str@andotherscn}, %将超过3个人名的省略,et al.改成为 等 andothersincitecn={\str@andotherscn},%将标注中的分开,便于与文献表中的区分 @@ -1507,9 +1507,11 @@ %\DeclareDelimFormat[textcite]{andothersdelim}{\addspace}% %GB/T 7714-2015 风格,全部大写 +\def\gbcaselocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 +\renewcommand*{\revsdnamepunct}{}%%%来源biblatex.def +} \newbibmacro*{name:gbuppercase}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 -\renewcommand*{\revsdnamepunct}{}% + \gbcaselocalset% \ifuseprefix% {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -1536,8 +1538,7 @@ %GB/T 7714-2015 风格,大小写不变,根据bib文件内输入原样输出 \newbibmacro*{name:gblowercase}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \gbcaselocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -1563,10 +1564,11 @@ } %中文常见风格,汉语拼音全拼模式 -\newbibmacro*{name:gbpinyin}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY +\def\gbpinyinlocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def -\renewrobustcmd*{\bibnamedelima}{\mbox{-}}% +\renewrobustcmd*{\bibnamedelima}{\mbox{-}}} +\newbibmacro*{name:gbpinyin}[4]{\bibauthorfont% + \gbpinyinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -1593,10 +1595,11 @@ } %中文常见风格,汉语拼音全拼模式 -\newbibmacro*{name:gbquanpin}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY +\def\gbquanpinlocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def -\renewrobustcmd*{\bibnamedelima}{}% +\renewrobustcmd*{\bibnamedelima}{}} +\newbibmacro*{name:gbquanpin}[4]{\bibauthorfont% + \gbquanpinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -1952,9 +1955,9 @@ togl{bbx:gbstyle} or test {\iffieldequalstr{userd}{chinese}}% \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}% \space% \or% - \bibstring{andcn}\space% + \bibstring{andcn}% \or% - \bibstring{and}\space% + \bibstring{and}% \fi}% % % url和url日期格式 diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.cbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.cbx index 5160edfcfc..fce42d508b 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.cbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015ms.cbx @@ -7,8 +7,7 @@ %% Released under the LaTeX Project Public License v1.3c or later %% --------------------------------------------------------------- %% -\def\versionofgbtstyle{2021/08/19 v1.0z} -\ProvidesFile{gb7714-2015ms.cbx}[\versionofgbtstyle biblatex citation style] +\ProvidesFile{gb7714-2015.cbx}[a biblatex citation style for GB/T 7714-2015] % % 加载样式 diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.bbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.bbx index 475f9bee60..e622a03e49 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.bbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.bbx @@ -11,7 +11,7 @@ % % 版本和时间信息 % -\def\versionofgbtstyle{2021/08/19 v1.0z} +\def\versionofgbtstyle{2021/09/11 v1.1a} \def\versionofbiblatex{\abx@version} \ProvidesFile{gb7714-2015mx.bbx}[\versionofgbtstyle biblatex bibliography style] %\RequireBiber[3]%显式指定用biber后端,当用bibtex时会报错,但其实不会影响编译,只是采用bibtex后无法达成格式需求 @@ -666,7 +666,7 @@ and = {\addcomma},%将第2和3人名间的and符号改成逗号,用\finalnamedelim命令也可以定义,参见3.9.1节 andcn = {\addcomma},%and本地化字符串的中文对应词 andincitecn = {\addcomma},%将标注中的分开,便于与文献表中的区分 - andincite = {\addcomma}, + andincite = {\addcomma\space},%注意add开头的命令会其把前面的空格去掉 %andothers = {et al.},%将超过3个人名的省略,et al.改成为 等 andotherscn = {\str@andotherscn},%将超过3个人名的省略,et al.改成为 等 andothersincitecn={\str@andotherscn},%将标注中的分开,便于与文献表中的区分 @@ -1914,9 +1914,9 @@ \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}% \space% \or% - \bibstring{andincitecn}\space% + \bibstring{andincitecn}% \or% - \bibstring{andincite}\space% + \bibstring{andincite}% \fi} \DeclareDelimFormat[bib,biblist]{finalnamedelim}{% @@ -1936,9 +1936,9 @@ \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}% \space% \or% - \bibstring{andcn}\space% + \bibstring{andcn}% \or% - \bibstring{and}\space% + \bibstring{and}% \fi} @@ -2082,9 +2082,11 @@ %\DeclareDelimFormat[textcite]{andothersdelim}{\addspace}% %GB/T 7714-2015 风格,全部大写 +\def\gbcaselocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 +\renewcommand*{\revsdnamepunct}{}%%%来源biblatex.def +} \newbibmacro*{name:gbuppercase}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 -\renewcommand*{\revsdnamepunct}{}% + \gbcaselocalset% \ifuseprefix% {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2111,8 +2113,7 @@ %GB/T 7714-2015 风格,大小写不变,根据bib文件内输入原样输出 \newbibmacro*{name:gblowercase}[4]{\bibauthorfont% - \renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉 - \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def + \gbcaselocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2138,10 +2139,11 @@ } %中文常见风格,汉语拼音全拼模式 -\newbibmacro*{name:gbpinyin}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY +\def\gbpinyinlocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def -\renewrobustcmd*{\bibnamedelima}{\mbox{-}}% +\renewrobustcmd*{\bibnamedelima}{\mbox{-}}} +\newbibmacro*{name:gbpinyin}[4]{\bibauthorfont% + \gbpinyinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% @@ -2168,10 +2170,11 @@ } %中文常见风格,汉语拼音全拼模式 -\newbibmacro*{name:gbquanpin}[4]{\bibauthorfont% -\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY +\def\gbquanpinlocalset{\renewrobustcmd*{\bibinitperiod}{}%将名字简写后的点去掉,%来源biblatex2.STY \renewcommand*{\revsdnamepunct}{}%%来源biblatex.def -\renewrobustcmd*{\bibnamedelima}{}% +\renewrobustcmd*{\bibnamedelima}{}} +\newbibmacro*{name:gbquanpin}[4]{\bibauthorfont% + \gbquanpinlocalset% \ifuseprefix {\usebibmacro{name:delim}{#3#1}% \usebibmacro{name:hook}{#3#1}% diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.cbx b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.cbx index 6b64e85bae..7eacc808dd 100644 --- a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.cbx +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714-2015mx.cbx @@ -7,8 +7,7 @@ %% Released under the LaTeX Project Public License v1.3c or later %% --------------------------------------------------------------- %% -\def\versionofgbtstyle{2021/08/19 v1.0z} -\ProvidesFile{gb7714-2015mx.cbx}[\versionofgbtstyle biblatex citation style] +\ProvidesFile{gb7714-2015.cbx}[a biblatex citation style for GB/T 7714-2015] % % 加载标准样式 diff --git a/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714texttobib.pl b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714texttobib.pl new file mode 100644 index 0000000000..68f265bbf6 --- /dev/null +++ b/macros/latex/contrib/biblatex-contrib/biblatex-gb7714-2015/gb7714texttobib.pl @@ -0,0 +1,1705 @@ +##% +##% --------------------------------------------------------------- +##% gb7714texttobib--- A transformation tool for GB/T 7714-2015 style +##% bibliography text to bib source file +##% +##% Maintained by huzhenzhen +##% Homepage: <https://github.com/hushidong/biblatex-gb7714-2015> +##% history: +##% 2017/02/26 v1.0g +##% 2021/09/04 add compatablity for text with no space after punctuations. +##% E-mail: +##% hzzmail@163.com +##% Released under the LaTeX Project Public License v1.3c or later +##% usage: +##% perl gb7714texttobib.pl in=textfilename out=bibfilename +##% options(need to do): +##% style=ay or default +##% key=ay or default +##% +##% --------------------------------------------------------------- +#%Target:: 将pdf文档中拷出的参考文献文本转换成bib文件,文本文件中的一条参考文献为一行 +#%Method:: 利用perl进行文本处理,处理和判断的两个重要方面是: +# 分析分割后的文本的位置和内容,使用的是正则表达式匹配,主要两种方式 +# 1.根据标点和本文特征一部分一部分的解析,比如book条目处理 +# 2.直接列出所有可能的正则表达式一个个匹配,比如article条目处理 +#%Date :: 2017-02-22 +#%Note :: 1.网址之类如果解析出错,应确认其前导词http://之前没有空格 +# 2.有些以.连接有从属关系的机构作者,可以把.后的空格去掉便于正确解析 +# 3.有些尽管解析到的域不是真实的域,但不影响著录格式(显示效果),相应条目的域 +# 可以在bib文件中完善,尽管从实用角度并不需要这么做。 +# +##% --------------------------------------------------------------- +##% todo: 1. pdf 的比较? +##% obsolete intro: +##% 1.源文件文档如果个别地方不符合规范,可以修改一下 +##% (a):inbook/standard类中,当出现//后面第二项是booktitle且其中存在:时,先把父标题的冒号改成colon,比如 +##% [M]//李承森. 宋史: 第 1 册. 北京: 中华书局. 应把宋史后的冒号改掉 +##% [S]//全国文献工作标准化技术委员会. 文献工作国家标准汇编: 3. 北京: 中国标准出版社, 1988: 59–92. +##% --------------------------------------------------------------- + + +foreach $file(@ARGV){ + print 'file:',$file,"\n"; + if($file=~m/in=/){ + ($infile)=($file=~m/in=(.*)/) + } + if($file=~m/out=/){ + ($outfile)=($file=~m/out=(.*)/) + } +} + +open (FHR,"<$infile"); +open (FHW,">$outfile"); +print FHW '% Encoding: UTF-8',"\n"; + +@references=<FHR>;#将所有的文献存为@references数组,各文献以<行>为单位进行区分 + + +#有些文本标点后面没有空格,所以先对这个问题进行处理 +#在所有的关键标点后面加上空格 +#20210904,HZZ +foreach $stra (@references) { + print "$stra\n"; + $stra=~s/\.(\S)/\. $1/g; + $stra=~s/\,(\S)/\, $1/g; + $stra=~s/\:(\S)/\: $1/g; + print "$stra\n"; + } +print "@references\n"; + + + +$ns=1; +$ne=@references; +$nline=0; +foreach $reference(@references){ + + $nline=$nline+1; + if($nline<$ns){next;} #先跳过几行进行,配合后面的last进行当行测试 + + while($reference=~m/–/){ + $reference=~s/–/-/;#直接利用正则表达式更正页码/日期/网址中的连字符 + } + print "ref: $reference ";#打印各文献的内容 + + $lenstr=length($reference); + print "lenstr=$lenstr\n"; + $lenstr=rindex $reference."\$","\$"; + print "lenstr=$lenstr\n"; + + if ($lenstr>1){ + undef $entrytype; + undef $author; + undef $title; + undef $journal; + undef $translator; + undef $bookauthor; + undef $booktitle; + undef $version; + undef $address; + undef $publisher; + undef $institution; + undef $year; + undef $type; + undef $date; + undef $volume; + undef $number; + undef $pages; + undef $eventdate; + undef $urldate; + undef $url; + undef $doi; + undef $note; + undef $eventyvn; + undef $endeventyvn; + undef $eventdate; + undef $eventvol; + undef $eventnum; + undef $endeventdate; + undef $endeventvol; + undef $endeventnum; + + #--------------------------------------------------------------- + #条目类型:期刊和期刊中析出的文献/periodical、article + #--------------------------------------------------------------- + if(1){ + if($reference=~m/\[J\]/){ + #避免在标题中存在在冒号的问题,所以从[J]开始匹配,通常也不需要从[J/OL]开始因为periodical通常不会出现online + #2021.09.04,hzz,修改 + if($reference=~m/:\s/ and $reference=~m/\[J\].*:\s\D/){#根据存在出版社前的冒号加空格区分 + print 'this entry is periodical',"\n"; + $entrytype='periodical'; + }else{ + print 'this entry is article',"\n"; + $entrytype='article'; + } + } + + if($entrytype eq 'periodical'){#字符串比较用eq而数字比较用==,如果用==那么两边都是1,则是真 + $regexformach='\[J\]\.'; + &bfidentifier; + + ($preadderess, $pospublisher)=($reference=~m/\[J\]\.(.*):\s(.*)/); + print 'preadderess =',$preadderess,"\n"; + print 'pospublisher=',$pospublisher,"\n"; + ($eventyear, $address)=($preadderess=~m/(.*)\.\s(.*)/); + print 'eventyear =',$eventyear,"\n"; + print 'address =',$address,"\n"; + ($eventyvn, $endeventyvn)=($eventyear=~m/(.*)\-(.*)/);#yvn表示year,volume,number + print 'eventyvn =',$eventyvn,"\n"; + print 'endeventyvn =',$endeventyvn,"\n"; + if($eventyvn=~m/.*,.*/){#存在逗号表明有卷信息 + ($eventdate, $eventvol, $eventnum)=($eventyvn=~m/\s*(.*),\s(.*)\((.*)\)/);#yvn表示year,volume,number + print 'eventdate =',$eventdate,"\n"; + print 'eventvol =',$eventvol,"\n"; + print 'eventnum =',$eventnum,"\n"; + if($endeventyvn){ + ($endeventdate, $endeventvol, $endeventnum)=($endeventyvn=~m/\s*(.*),\s(.*)\((.*)\)/);#yvn表示year,volume,number + print 'endeventdate =',$endeventdate,"\n"; + print 'endeventvol =',$endeventvol,"\n"; + print 'endeventnum =',$endeventnum,"\n"; + } + }else{ + ($eventdate, $eventnum)=($eventyvn=~m/\s*(.*)\((.*)\)/);#yvn表示year,volume,number + print 'eventdate =',$eventdate,"\n"; + print 'eventvol =',$eventvol,"\n"; + print 'eventnum =',$eventnum,"\n"; + if($endeventyvn){ + ($endeventdate, $endeventnum)=($endeventyvn=~m/\s*(.*)\((.*)\)/);#yvn表示year,volume,number + print 'endeventdate =',$endeventdate,"\n"; + print 'endeventvol =',$endeventvol,"\n"; + print 'endeventnum =',$endeventnum,"\n"; + } + } + if($endeventdate){ + $date=$eventdate.'-'.$endeventdate; + }else{ + $date=$eventdate + } + if($endeventvol){ + $volume=$eventvol.'-'.$endeventvol; + }else{ + $volume=$eventvol + } + if($endeventnum){ + $number=$eventnum.'-'.$endeventnum; + }else{ + $number=$eventnum + } + print 'date =',$date,"\n"; + print 'volume =',$volume,"\n"; + print 'number =',$number,"\n"; + ($publisher)=($pospublisher=~m/(.*),/); + print 'publisher =',$publisher,"\n"; + } + + if($entrytype eq 'article'){ + $regexformach='\[J\]\.'; + &bfidentifier; + + $flagmatched=0; + $regexbfjournal='\]\.\s(.*),\s(.*),\s(.*)\((.*)\):\s(.*)\.';#包括全部信息 + if($reference=~m/$regexbfjournal/){ + ($journal,$date,$volume,$number,$pages)=($reference=~m/$regexbfjournal/); + $flagmatched=1; + print '包括全部信息',"\n"; + } + $regexbfjournal='\]\.\s(.*),\s(.*),\s(.*)\((.*)\)\.';#没有页码 + if($reference=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$volume,$number)=($reference=~m/$regexbfjournal/); + $flagmatched=1; + print '没有页码',"\n"; + } + $regexbfjournal='\]\.\s(.*),\s(.*),\s(.*):\s(.*)\.';#没有期 + if($reference=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$volume,$pages)=($reference=~m/$regexbfjournal/); + $flagmatched=1; + print '没有期',"\n"; + } + $regexbfjournal='\]\.\s(.*),\s(.*)\((.*)\):\s(.*)\.';#没有卷/年 + if($reference=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$number,$pages)=($reference=~m/$regexbfjournal/); + $flagmatched=1; + if($date!~m/\d{4}/){ + $volume=$date; + $date=''; + } + print '没有卷/年',"\n"; + } + $regexbfjournal='\]\.\s(.*),\s(.*),\s(.*)\.';#没有页码,期 + if($reference=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$volume)=($reference=~m/$regexbfjournal/); + $flagmatched=1; + print '没有页码,期',"\n"; + } + $regexbfjournal='\]\.\s(.*),\s(.*)\((.*)\)\.';#没有页码,卷/年 + if($reference=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$number)=($reference=~m/$regexbfjournal/); + $flagmatched=1; + if($date!~m/\d{4}/){ + $volume=$date; + $date=''; + } + print '没有页码,卷/年',"\n"; + } + $regexbfjournal='\]\.\s(.*),\s(.*):\s(.*)\.';#没有卷/年,期 + if($reference=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$pages)=($reference=~m/$regexbfjournal/); + $flagmatched=1; + if($date!~m/\d{4}/){ + $volume=$date; + $date=''; + } + print '没有卷/年,期',"\n"; + } + + if($flagmatched==0){ + print 'the text after title was not matched, please add a regex for the current entry in the perl source code!',"\n"; + print '当前条目标题之后的内容没有匹配的正则表达式,请在perl代码中增加适合该条目正则表达式!',"\n"; + } + + print 'journal =',$journal,"\n"; + print 'date =',$date,"\n"; + print 'volume =',$volume,"\n"; + print 'number =',$number,"\n"; + print 'pages =',$pages,"\n"; + + } + + #判断期刊中析出的文献,带url + if($reference=~m/\[J\/OL\]/){ + print 'this entry is article with url',"\n"; + $entrytype='article'; + + $regexformach='\[J\/OL\]\.'; + &bfidentifier; + + ($postitle)=($reference=~m/\[J\/OL\]\.\s(.*)/); + if($postitle=~m/\[.*\]/){#存在urldate + ($preurldate,$urldate,$posurl)=($postitle=~m/(.*)\[(.*)\]\.\s(.*)/); + }else{#不存在urldate + ($preurldate,$posurl)=($postitle=~m/(.*)(http:.*)/); + } + unless($preurldate=~m/\.$/){$preurldate=$preurldate.'.';}#加个点统一上面两种方式 + + #处理url和doi + $regexposurl='(.*)doi:\s(.*)';#处理url和doi + if($posurl=~m/$regexposurl/i){ + ($url,$doi)=($posurl=~m/$regexposurl/i); + }else{ + $url=$posurl; + } + + #处理urldate前的内容,基本article不带url的情况相同 + $flagmatched=0; + $regexbfjournal='(.*),\s(.*),\s(.*)\((.*)\):\s(.*)\.';#包括全部信息 + if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$volume,$number,$pages)=($preurldate=~m/$regexbfjournal/); + $flagmatched=1; + } + $regexbfjournal='(.*),\s(.*),\s(.*)\((.*)\)\.';#没有页码 + if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$volume,$number)=($preurldate=~m/$regexbfjournal/); + $flagmatched=1; + } + $regexbfjournal='(.*),\s(.*),\s(.*):\s(.*)\.';#没有期 + if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$volume,$pages)=($preurldate=~m/$regexbfjournal/); + $flagmatched=1; + } + $regexbfjournal='(.*),\s(.*)\((.*)\):\s(.*)\.';#没有卷/年 + if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$number,$pages)=($preurldate=~m/$regexbfjournal/); + $flagmatched=1; + if($date!~m/\d{4}/){ + $volume=$date; + $date=''; + } + } + $regexbfjournal='(.*),\s(.*),\s(.*)\.';#没有页码,期 + if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$volume)=($preurldate=~m/$regexbfjournal/); + $flagmatched=1; + } + $regexbfjournal='(.*),\s(.*)\((.*)\)\.';#没有页码,卷/年 + if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$number)=($preurldate=~m/$regexbfjournal/); + $flagmatched=1; + if($date!~m/\d{4}/){ + $volume=$date; + $date=''; + } + } + $regexbfjournal='(.*),\s(.*):\s(.*)\.';#没有卷/年,期 + if($preurldate=~m/$regexbfjournal/ and $flagmatched==0){ + ($journal,$date,$pages)=($preurldate=~m/$regexbfjournal/); + $flagmatched=1; + if($date!~m/\d{4}/){ + $volume=$date; + $date=''; + } + } + + if($flagmatched==0){ + print 'the text after title was not matched, please add a regex for the current entry in the perl source code!',"\n"; + print '当前条目标题之后的内容没有匹配的正则表达式,请在perl代码中增加适合该条目正则表达式!',"\n"; + } + + print 'journal =',$journal,"\n"; + print 'date =',$date,"\n"; + print 'volume =',$volume,"\n"; + print 'number =',$number,"\n"; + print 'pages =',$pages,"\n"; + print 'urldate =',$urldate,"\n"; + print 'url =',$url,"\n"; + print 'doi =',$doi,"\n"; + + + } + } + + #--------------------------------------------------------------- + #条目类型:判断报纸中析出的文献/newspaper + #--------------------------------------------------------------- + if(1){ + if($reference=~m/\[N\]/){ + print 'this entry is newspaper',"\n"; + $entrytype='newspaper'; + $note='news'; + $regexnewsflag='\[N\]'; + $onlineflag=0; + } + if($reference=~m/\[N\/OL\]/){ + print 'this entry is newspaper with url',"\n"; + $entrytype='newspaper'; + $note='news'; + $regexnewsflag='\[N\/OL\]'; + $onlineflag=1; + } + if($entrytype eq 'newspaper'){ + if($onlineflag==1){ + $regexformach='\[N\/OL\]'; + &bfidentifier; + + print 'has url',"\n"; + $flagmatched=0; + $regexnewspostitle='\.\s(.*),\s(.*)\((.*)\)\s*\[(.*)\]\.\s(.*)'; + if($reference=~m/$regexnewsflag$regexnewspostitle/ and $flagmatched==0){ + $flagmatched=1; + ($journal,$date,$number,$urldate,$posurl)=($reference=~m/$regexnewsflag$regexnewspostitle/);} + $regexnewspostitle='\.\s(.*),\s(.*)\s*\[(.*)\]\.\s(.*)'; + if($reference=~m/$regexnewsflag$regexnewspostitle/ and $flagmatched==0){ + $flagmatched=1; + ($journal,$date,$urldate,$posurl)=($reference=~m/$regexnewsflag$regexnewspostitle/);} + if($flagmatched==0){ + print 'the text after title was not matched, please add a regex for the current entry in the perl source code!',"\n"; + print '当前条目标题之后的内容没有匹配的正则表达式,请在perl代码中增加适合该条目正则表达式!',"\n"; + } + }else{ + $regexformach='\[N\]'; + &bfidentifier; + + print 'no url',"\n"; + $regexnewspostitle='\.\s(.*),\s(.*)\((.*)\)'; + ($journal,$date,$number)=($reference=~m/$regexnewsflag$regexnewspostitle/); + } + #处理url和doi + $regexposurl='(.*)doi:\s(.*)';#处理url和doi + if($posurl=~m/$regexposurl/i){ + ($url,$doi)=($posurl=~m/$regexposurl/i); + }else{ + $url=$posurl; + } + + # print 'journal =',$journal,"\n"; + # print 'date =',$date,"\n"; + # print 'volume =',$volume,"\n"; + # print 'number =',$number,"\n"; + # print 'pages =',$pages,"\n"; + # print 'urldate =',$urldate,"\n"; + # print 'url =',$url,"\n"; + # print 'doi =',$doi,"\n"; + } + } + + + #--------------------------------------------------------------- + #条目类型:论文集中析出的文献/inproceedings + #--------------------------------------------------------------- + if(1){#\/\/ + if ($reference=~m/\[C\/OL\]\/\//){ + $entrytype='inproceedings'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[C\/OL\]\/\/'; + &bfidentifier; + + $regexformach='C\/OL\]\/\/'; + &bfaddressinbook; + + &afpublisherbookurl; + }elsif($reference=~m/\[C\]\/\//){ + $entrytype='inproceedings'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[C\]\/\/'; + &bfidentifier; + + $regexformach='C\]\/\/'; + &bfaddressinbook; + + &afpublisherbook; + } + + if ($entrytype eq 'inproceedings'){ + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + } + + } + + + #--------------------------------------------------------------- + #条目类型:论文集/proceedings + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[C\/OL\]\./){ + $entrytype='proceedings'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[C\/OL\]\.'; + &bfidentifier; + + $regexformach='C\/OL\]\.'; + &bfaddressbook; + + &afpublisherbookurl; + }elsif($reference=~m/\[C\]\./){ + $entrytype='proceedings'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[C\]\.'; + &bfidentifier; + + $regexformach='C\]\.'; + &bfaddressbook; + + &afpublisherbook; + } + + if ($entrytype eq 'proceedings'){ + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + print 'date=',"$date"; + } + } + + + + + #--------------------------------------------------------------- + #条目类型:未出版物/unpublished + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[Z\/OL\]\./){ + $entrytype='unpublished'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[Z\/OL\]\.'; + &bfidentifier; + + $regexformach='Z\/OL\]\.'; + &bfaddressbook; + + &afpublisherbookurlb; + }elsif($reference=~m/\[Z\]\./){ + $entrytype='unpublished'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[Z\]\.'; + &bfidentifier; + + $regexformach='Z\]\.'; + &bfaddressbook; + + &afpublisherbookb; + } + + if ($entrytype eq 'unpublished'){ + $date=$year; + print 'date=',"$date"; + } + } + + + #--------------------------------------------------------------- + #条目类型:手册、档案/manual + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[A\/OL\]\./){ + $entrytype='manual'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[A\/OL\]\.'; + &bfidentifier; + + $regexformach='A\/OL\]\.'; + &bfaddressbook; + + &afpublisherbookurlb; + }elsif($reference=~m/\[A\]\./){ + $entrytype='manual'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[A\]\.'; + &bfidentifier; + + $regexformach='A\]\.'; + &bfaddressbook; + + &afpublisherbookb; + } + + if ($entrytype eq 'manual'){ + $date=$year; + print 'date=',"$date"; + } + } + + + + #--------------------------------------------------------------- + #条目类型:报告/report + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[R\/OL\]\./){ + $entrytype='report'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[R\/OL\]\.'; + &bfidentifier; + + $regexformach='R\/OL\]\.'; + &bfaddressbook; + + &afpublisherbookurlb; + }elsif($reference=~m/\[R\]\./){ + $entrytype='report'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[R\]\.'; + &bfidentifier; + + $regexformach='R\]\.'; + &bfaddressbook; + + &afpublisherbookb; + } + + if ($entrytype eq 'report'){ + $date=$year; + print 'date=',"$date"; + } + + } + + #--------------------------------------------------------------- + #条目类型:标准/standard + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[S\/OL\]\./){ + $entrytype='standard'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[S\/OL\]\.'; + &bfidentifier; + + $regexformach='S\/OL\]\.'; + &bfaddressbook; + &afpublisherbookurl; + }elsif($reference=~m/\[S\]\./){ + $entrytype='standard'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[S\]\.'; + &bfidentifier; + + $regexformach='S\]\.'; + &bfaddressbook; + + &afpublisherbook; + }elsif ($reference=~m/\[S\/OL\]\/\//){ + $entrytype='standard'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[S\/OL\]\/\/'; + &bfidentifier; + + $regexformach='S\/OL\]\/\/'; + &bfaddressinbook; + + &afpublisherbookurl; + }elsif($reference=~m/\[S\]\/\//){ + $entrytype='standard'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[S\]\/\/'; + &bfidentifier; + + $regexformach='S\]\/\/'; + &bfaddressinbook; + + &afpublisherbook; + } + if ($entrytype eq 'standard'){ + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + $note='standard'; + print 'date=',"$date"; + print 'note=',"$note"; + } + + } + + #--------------------------------------------------------------- + #条目类型:学位论文/thesis + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[D\/OL\]\./){ + $entrytype='thesis'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[D\/OL\]\.'; + &bfidentifier; + + $regexformach='D\/OL\]\.'; + &bfaddressbook; + + &afpublisherbookurl; + }elsif($reference=~m/\[D\]\./){ + $entrytype='thesis'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[D\]\.'; + &bfidentifier; + + $regexformach='D\]\.'; + &bfaddressbook; + + &afpublisherbook; + } + + if ($entrytype eq 'thesis'){ + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + print 'date=',"$date"; + } + + } + + + #--------------------------------------------------------------- + #条目类型:汇编中析出的文献/incollection + #--------------------------------------------------------------- + if(1){#\/\/ + if ($reference=~m/\[G\/OL\]\/\//){ + $entrytype='incollection'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[G\/OL\]\/\/'; + &bfidentifier; + + $regexformach='G\/OL\]\/\/'; + &bfaddressinbook; + + &afpublisherbookurl; + }elsif($reference=~m/\[G\]\/\//){ + $entrytype='incollection'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[G\]\/\/'; + &bfidentifier; + + $regexformach='G\]\/\/'; + &bfaddressinbook; + + &afpublisherbook; + } + + if ($entrytype eq 'incollection'){ + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + } + + } + + + #--------------------------------------------------------------- + #条目类型:汇编/collection + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[G\/OL\]\./){ + $entrytype='collection'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[G\/OL\]\.'; + &bfidentifier; + + $regexformach='G\/OL\]\.'; + &bfaddressbook; + + &afpublisherbookurl; + }elsif($reference=~m/\[G\]\./){ + $entrytype='collection'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[G\]\.'; + &bfidentifier; + + $regexformach='G\]\.'; + &bfaddressbook; + + &afpublisherbook; + } + + if ($entrytype eq 'collection'){ + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + print 'date=',"$date"; + } + } + + + #--------------------------------------------------------------- + #条目类型:专利/patent + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[P\/OL\]\./){ + $entrytype='patent'; + print "this entry's type is: $entrytype with url\n"; + $regexformach='\[P\/OL\]\.'; + &bfidentifier; + }elsif($reference=~m/\[P\]\./){ + $entrytype='patent'; + print "this entry's type is: $entrytype \n"; + $regexformach='\[P\]\.'; + &bfidentifier; + } + + if($entrytype eq 'patent'){ + ($postitle)=($reference=~m/$regexformach\s*(.*)/); + print 'postitle=',$postitle,"\n"; + $titlenumber=$title; + if($titlenumber=~m/:\s*\d.*/){ + ($title,$number)=($titlenumber=~m/(.*):\s*(\d.*)/); + print 'title =',$title,"\n"; + print 'number =',$number,"\n"; + } + + if($postitle=~m/\[.*\]/ and $reference=~m/\[P\/OL\]\./){ + ($date,$urldate,$posurl)=($postitle=~/(.*)\s*\[(.*)\]\.\s*(.*)/); + print 'date=',$date,"\n"; + print 'urldate =',$urldate,"\n"; + print 'posurl =',$posurl,"\n"; + if($posurl=~m/DOI/i){#匹配存在doi的话 + ($url,$doi)=($posurl=~m/(.*)DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + $url=$posurl; + print 'url =',"$url \n"; + } + }else{ + $posurl=$postitle; + if($posurl=~m/DOI/i){#匹配存在doi的话 + ($date,$doi)=($posurl=~m/(.*)DOI:(.*)\./i); + print 'date=',"$date \n"; + print 'doi =',"$doi \n"; + }else{ + $date=$posurl; + print 'date =',"$date \n"; + } + } + } + } + + + #--------------------------------------------------------------- + #条目类型:电子资源/online + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[EB\/OL\]\./){#匹配[EB/OL]判断为online类型 + $entrytype='online'; + print "this entry's type is: $entrytype \n"; + + $regexformach='\[EB\/OL\]\.'; + &bfidentifier; + + ($postitle)=($reference=~m/$regexformach\s*(.*)/); + print 'postitle=',$postitle,"\n"; + + if($postitle=~m/\(.*\)/ and $postitle=~m/\[.*\]/){#存在更新日期和引用日期 + ($eventdate,$urldate,$posurl)=($postitle=~/\s*\((.*)\)\s*\[(.*)\]\.\s*(.*)/); + }elsif($postitle=~m/\(.*\)/ and $postitle!~m/\[.*\]/){#存在更新日期但无引用日期 + ($eventdate,$posurl)=($postitle=~/\s*\((.*)\)\.\s*(.*)/); + }elsif($postitle!~m/\(.*\)/ and $postitle=~m/\[.*\]/){#存在引用日期但无更新日期 + ($urldate,$posurl)=($postitle=~/\s*\[(.*)\]\.\s*(.*)/); + }else{ + ($posurl)=($postitle=~/\s*(.*)/); + } + print 'eventdate=',$eventdate,"\n"; + print 'urldate =',$urldate,"\n"; + print 'posurl =',$posurl,"\n"; + + if($posurl=~m/DOI/i){#匹配存在doi的话 + ($url,$doi)=($posurl=~m/(.*)DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + $url=$posurl; + print 'url =',"$url \n"; + } + } + } + + #--------------------------------------------------------------- + #条目类型:专著/book + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[M\]\./){#匹配[M]判断为book类型 + print "this entry's type is: book \n"; + $entrytype='book'; + + $regexformach='\[M\]\.'; + &bfidentifier; + + $regexformach='M\]\.'; + &bfaddressbook; + + &afpublisherbook; + + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + } + } + + #--------------------------------------------------------------- + #条目类型:专著但存在网址/book with url + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[M\/OL\]\./){ + print "this entry's type is: book with url\n"; + $entrytype='book'; + + $regexformach='\[M\/OL\]\.'; + &bfidentifier; + + $regexformach='M\/OL\]\.'; + &bfaddressbook; + + &afpublisherbookurl; + + + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + } + } + + + #--------------------------------------------------------------- + #条目类型:专著中析出文献/inbook + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[M\]\/\//){#匹配[M]//判断为inbook类型 + print "this entry's type is: inbook \n"; + $entrytype='inbook'; + + $regexformach='\[M\]\/\/'; + &bfidentifier; + + $regexformach='M\]\/\/'; + &bfaddressinbook; + + &afpublisherbook;#出版社及之后的信息inbook/book一样的 + + + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + } + } + + + #--------------------------------------------------------------- + #条目类型:专著中析出文献但存在网址/inbook with url + #--------------------------------------------------------------- + if(1){ + if ($reference=~m/\[M\/OL\]\/\//){#匹配[M]//判断为inbook类型 + print "this entry's type is: inbook \n"; + $entrytype='inbook'; + + + $regexformach='\[M\/OL\]\/\/'; + &bfidentifier; + + $regexformach='M\/OL\]\/\/'; + &bfaddressinbook; + + &afpublisherbookurl;#出版社及之后的信息inbook/book一样的 + + + if ($address=~m/\[S\.l\.\]/ or $address=~m/出版地不详/) {#当存在英文的[s.n.] + $address=""; + } + if ($publisher=~m/\[s\.n\.\]/ or $publisher=~m/出版者不详/) {#当存在英文的[s.n.] + $publisher=""; + } + $date=$year; + } + } + + + #--------------------------------------------------------------- + #输出到bib文件中 + #--------------------------------------------------------------- + if(1){ + if($date=~m/-\d{4}/){#存在enddate的情况下,将中间的连字符转化成斜杠 + print 'date=',$date,"\n"; + ($datetempa,$datetempb)=($date=~m/(.*)-(\d{4}.*)/); + $date=$datetempa.'/'.$datetempb; + print 'date=',$date,"\n"; + } + + if($url=~m/.*\.$/){ + $urlplusdot=$url; + ($url)=($urlplusdot=~m/(.*)\.$/);#去掉处于条目末尾的url地址后的点 + } + #最后输出 + print "\n"; + #print '@',"$entrytype",'{',"ref-$nline-$sn",',',"\n"; + print '@',"$entrytype",'{',"$author$date",',',"\n"; + $author&& print 'author = {',$author,'},',"\n"; + $title&& print 'title = {',$title,'},',"\n"; + $journal&& print 'journal = {',$journal,'},',"\n"; + $translator&& print 'translator= {',$translator,'},',"\n"; + $bookauthor&& print 'bookauthor= {',$bookauthor,'},',"\n"; + $booktitle&& print 'booktitle = {',$booktitle,'},',"\n"; + $version&& print 'version = {',$version,'},',"\n"; + $address&& print 'address = {',$address,'},',"\n"; + $publisher&& print 'publisher = {',$publisher,'},',"\n"; + $type&& print 'type = {',$type,'},',"\n"; + $date&& print 'date = {',$date,'},',"\n"; + $volume&& print 'volume = {',$volume,'},',"\n"; + $number&& print 'number = {',$number,'},',"\n"; + $pages&& print 'pages = {',$pages,'},',"\n"; + $eventdate&& print 'eventdate = {',$eventdate,'},',"\n"; + $urldate&& print 'urldate = {',$urldate,'},',"\n"; + $url&& print 'url = {',$url,'},',"\n"; + $doi&& print 'doi = {',$doi,'},',"\n"; + $note&& print 'note = {',$note,'},',"\n"; + print '}',"\n"; + print 'authorlabel=',$authorlabel,"\n"; + + + #print FHW "\n@","$entrytype",'{',"ref-$nline-$sn-$authorlabel",',',"\n"; + print FHW "\n@","$entrytype",'{',"$authorlabel$date",',',"\n"; + $author&& print FHW 'author = {',$author,'},',"\n"; + $title&& print FHW 'title = {',$title,'},',"\n"; + $journal&& print FHW 'journal = {',$journal,'},',"\n"; + $translator&& print FHW 'translator= {',$translator,'},',"\n"; + $bookauthor&& print FHW 'bookauthor= {',$bookauthor,'},',"\n"; + $booktitle&& print FHW 'booktitle = {',$booktitle,'},',"\n"; + $version&& print FHW 'version = {',$version,'},',"\n"; + $address&& print FHW 'address = {',$address,'},',"\n"; + $publisher&& print FHW 'publisher = {',$publisher,'},',"\n"; + $type&& print FHW 'type = {',$type,'},',"\n"; + $date&& print FHW 'date = {',$date,'},',"\n"; + $volume&& print FHW 'volume = {',$volume,'},',"\n"; + $number&& print FHW 'number = {',$number,'},',"\n"; + $pages&& print FHW 'pages = {',$pages,'},',"\n"; + $eventdate&& print FHW 'eventdate = {',$eventdate,'},',"\n"; + $urldate&& print FHW 'urldate = {',$urldate,'},',"\n"; + $url&& print FHW 'url = {',$url,'},',"\n"; + $doi&& print FHW 'doi = {',$doi,'},',"\n"; + $note&& print FHW 'note = {',$note,'},',"\n"; + print FHW '}',"\n"; + } + } + + + print "\n"; + if($nline>=$ne){last;} #先跳过几行进行,配合后面的last进行当行测试 +} + + sub bfidentifier{#bf表示before,标识符前所有的类型都一样 + #$regexpformach=@_; + #print '@_=',@_,"\n"; + #print 'regexpformach=',"$regexpformach \n"; + #标识符之前很容易匹配三个内容,序号,作者和标题 + if($reference=~m/.*\D\.\s\D.*$regexformach/){#匹配存在作者后的点的话,同时点号周围不是数字,有时标题中可能出现1.1这样的信息 + ($sn , $author , $title)=($reference=~m/\[(\d+)\]\s*(.*)\.\s(.*)$regexformach/); + print 'sn =',"$sn \n"; + print 'author=',"$author \n";#作者多个姓名还需要处理,还要注意有前后缀的情况 + print 'title =',"$title \n"; + if($author=~m/等/){ + $author=~s/等/others/;#将等换成others + }else{ + $author=~s/,\s*$//;#将最后一个逗号去掉 + } + if($author=~m/et\sal/){ + $author=~s/et\sal/others/;#将et al.换成others + }else{ + $author=~s/,\s*$//;#将最后一个逗号去掉 + } + while($author=~m/,/){ + $author=~s/,/ and /;#将逗号换成and + } + #当“等”直接与作者相连时,需要在others前面增加一个and + if($author=~m/others/){#若存在other是且其前面没有and时 + if ($author=~m/and\s*others/){} + else{ + $author=~s/others/ and others/; + } + } + print 'author=',"$author \n"; + }else{#不存在作者的话\[M\]\/\/ + ($sn , $title)=($reference=~m/\[(\d+)\]\s*(.*)$regexformach/);#标识符之前很容易匹配三个内容,序号,作者和标题 + print 'sn =',"$sn \n"; + print 'title =',"$title \n"; + } + + #进一步处理责任者的姓名,主要针对英文名需要有一些符号进行区分姓,名,前缀和后缀。 + @names=split('and',$author); + print 'names=',@names,"\n"; + $author=""; + $j=0; + foreach $name(@names){#一个姓名一个姓名处理 + + $j=$j+1; + #print $name,"\n"; + @nameparts=split(' ',$name); + #print 'nameparts=',@nameparts,"\n"; + + $org=0; + for($k=0;$k<@nameparts;$k++){ + if(@nameparts[$k]=~m/.{2,}/ and @nameparts[$k]!~m/\s*von\s*/i and @nameparts[$k]!~m/\s*jr\s*/i){ + #当分解的单作者的各个部分,存在两个以上为2个字符以上的情况,说明不是一般的姓名而是机构作者 + #这个判断是对的,因为国标规定要求缩写的,否则就是不是国标了,对于不标准的情形请输出后手动处理即去掉作者外包围的花括号。 + $org=$org+1; + print 'org=',"$org\n"; + } + } + + if(@nameparts>1){ + if(@nameparts[0]=~m/\s*von\s*/i){#确定姓的位置 + $family=1; + @nameparts[1]=@nameparts[1].','; + }else{ + $family=0; + @nameparts[0]=@nameparts[0].','; + } + if(@nameparts[-1]=~m/\s*jr\s*/i){#确定后缀的位置 + @nameparts[-1]=@nameparts[-1].'.,'; + $given=@nameparts-2; + $suffix=1; + }else{ + $suffix=0; + $given=@nameparts-1; + } + print 'family=',$family,"\n"; + print 'given=',$given,"\n"; + print 'suffix=',$suffix,"\n"; + print 'familyname=',@nameparts[$family],"\n"; + + $namefmt=""; + for($i=0;$i<=$family;$i++){ + $namefmt=$namefmt.@nameparts[$i].' '; + print $i,$family,$namefmt,"\n"; + } + if($suffix){ + $namefmt=$namefmt.@nameparts[-1].' '; + } + for($i=$family+1;$i<=$given;$i++){ + $namefmt=$namefmt.@nameparts[$i].' '; + print $i,$family,$namefmt,"\n"; + } + }else{ + $namefmt=$name; + } + if($org > 1){#当是机构作者时 + $namefmt='{'.$name.'}'; + } + print 'namefmt=',"$namefmt \n"; + + if($j==1){#把姓名用and连接起来 + $author=$namefmt; + }else{ + $author=$author.' and '.$namefmt; + } + + if($j==1){#根据第一个作者构建authorlabel + if($org > 1){#机构作者取各单词的首字母 + $authorlabel=''; + for($k=0;$k<@nameparts;$k++){ + ($strtmp)=($nameparts[$k]=~/^(.)/); + $authorlabel=$authorlabel.$strtmp; + } + }else{#姓名则仅取作者姓 + ($authorlabel)=$nameparts[$family]; + if($authorlabel=~m/,$/){$authorlabel=~s/,$//;}#去掉最后的逗号 + } + } + } + while($author=~m/\s{2,}/){ + $author=~s/\s{2,}/ /;#将多余的空格去掉 + } + while($author=~m/\.{2,}/){ + $author=~s/\.{2,}/\./;#将多余的点去掉 + } + print 'author=',"$author\n"; + } + + + sub bfaddressbook{#bf表示before,出版者前book和inbook不一样 + #对于book类型,必然存在出版地和出版者信息,以此为根据展开 + print 'sub:bfaddressbook ',"\n"; + if($reference!~m/$regexformach\s*[^:]+:\s\D{1,}.*/){#如果不存在出版地和出版者信息 + ($pospublisher)=($reference=~m/$regexformach\s*(.*)/); + print 'pospublisher=',"$pospublisher \n"; + }else{ + ($preaddress, $pospublisher)=($reference=~m/$regexformach\s*([^:]+):\s(\D{1,}.*)/);#标识符之后根据第一个冒号分为包括地址的信息和包括出版者的信息两部分 + print 'preaddress =',"$preaddress \n"; + print 'pospublisher=',"$pospublisher \n"; + + #处理出版地及其前面的信息 + if ($preaddress=~m/.*\[S\.l\.\].*/) {#当存在英文的[S.l.],英文的一般不存在译者,所以下面处理比较简单 + $preaddress=~s/\[S\.l\.\]/\[S-l-\]/; #先将[S.l.]换成[S-l-]然后换回来 + } + if ($preaddress=~m/.*\d.*\.\s*.*/){#匹配存在数字版本的话 + ($preversion, $version, $address)=($preaddress=~m/(.*)(\d)[^\.]*\.\s*(.*)/); + print 'preversion =',"$preversion \n"; + print 'version =',"$version \n"; + print 'address =',"$address \n"; + if($preversion=~m/.*\..*/){#如果存在译者等信息 + ($translator)=($preversion=~m/(.*)\..*/); + print 'translator =',"$translator \n";#作者多个姓名还需要处理,还有译这个标识 + } + }else {#不存在数字版本的话 + if($preaddress=~m/.*\.\s+.*/){#存在点加空格,表示存在其他作者信息,区别点在末尾但无空格 + ($preversion,$address)=($preaddress=~m/(.*)\.\s*(.*)/); + print 'preversion =',"$preversion \n"; + print 'address =',"$address \n"; + $translator=$preversion; + print 'translator =',"$translator \n"; + }else{ + $address=$preaddress; + print 'address =',"$address \n"; + } + } + + if($translator=~m/译/){#当译者真实存在 + $translator=~s/,\s*译//;#将译去掉 + if($translator=~m/等/){ + $translator=~s/等/others/;#将等换成others + }else{ + $translator=~s/,\s*$//;#将最后一个逗号去掉 + } + while($translator=~m/,/){ + $translator=~s/,/ and /;#将逗号换成and + } + print 'translator =',"$translator \n"; + }else {#当译者不存在,那么translator中信息可能是非数字的版本信息 + unless($version) {#除非version没有信息 + $version=$translator; + $translator=""; + }else{ + print "version is already exisit!\n"; + print 'version=',$version,"\n"; + print 'translator=',$translator,"\n"; + } + } + + if ($address=~m/.*\[S-l-\].*/) {#当存在英文的[S-l-][S.l.] + $address=~s/\[S-l-\]/\[S\.l\.\]/; #将[S-l-]换回[S.l.] + } + } + } + + + sub bfaddressinbook{#bf表示before,出版者前book和inbook不一样 + ($postitle)=($reference=~m/$regexformach\s*(.*)/); + print 'postitle=',$postitle,"\n"; + if($postitle=~m/^[^:\.]+:[^:\.]+\./){#当存在析出源第一项中出现:时 + $postitle=~s/:/colon/;#先将该冒号换成colon + print 'postitle=',$postitle,"\n"; + } + #对于inbook类型,必然存在出版地和出版者信息,以此为根据展开 + ($preaddress, $pospublisher)=($postitle=~m/\s*(.*):\s(\D.*)/); + #($preaddress, $pospublisher)=($postitle=~m/\s*([^:]+):\s(\D.*)/); + #标识符之后根据第一个冒号分为包括地址的信息和包括出版者的信息两部分 + print 'preaddress =',"$preaddress \n"; + print 'pospublisher=',"$pospublisher \n"; + + #处理出版地及其前面的信息 + if ($preaddress=~m/.*\[S\.l\.\].*/) {#当存在英文的[S.l.],英文的一般不存在译者,所以下面处理比较简单 + $preaddress=~s/\[S\.l\.\]/\[S-l-\]/; #先将[S.l.]换成[S-l-]然后换回来 + } + if ($preaddress=~m/.*\d.*\.\s+.*/ and ($preaddress=~m/.*th\sed.*/ or $preaddress=~m/.*版.*/)){#匹配存在数字版本的话 + ($preversion, $version, $address)=($preaddress=~m/(.*)(\d)[^\.]*\.\s+(.*)/); + print 'preversion =',"$preversion \n"; + print 'version =',"$version \n"; + print 'address =',"$address \n"; + if($preversion=~m/.*\.\s+.*/){#如果存在译者等信息 + ($translator)=($preversion=~m/(.*)\.\s+.*/); + print 'translator =',"$translator \n";#作者多个姓名还需要处理,还有译这个标识 + } + }else {#不存在数字版本的话 + if($preaddress=~m/.*\.\s+.*/){#存在点加空格,表示存在其他作者信息,区别点在末尾但无空格 + ($preversion,$address)=($preaddress=~m/(.*)\.\s+(.*)/); + print 'preversion =',"$preversion \n"; + print 'address =',"$address \n"; + if($preversion=~m/.*\.\s+.*/){#中间还存在点加空格 + ($bookauthor,$booktitle)=($preversion=~m/(.*)\.\s+(.*)/); + + if($bookauthor=~m/等/){ + $bookauthor=~s/等/others/;#将等换成others + }else{ + $bookauthor=~s/,\s*$//;#将最后一个逗号去掉 + } + if($bookauthor=~m/et\sal/){ + $bookauthor=~s/et\sal/others/;#将et al.换成others + }else{ + $bookauthor=~s/,\s*$//;#将最后一个逗号去掉 + } + while($bookauthor=~m/,/){ + $bookauthor=~s/,/ and /;#将逗号换成and + } + print 'bookauthor=',"$bookauthor \n"; + }else{ + $booktitle=$preversion; + } + }else{ + $address=$preaddress; + print 'address =',"$address \n"; + } + } + + if ($address=~m/.*\[S-l-\].*/) {#当存在英文的[S-l-][S.l.] + $address=~s/\[S-l-\]/\[S\.l\.\]/; #将[S-l-]换回[S.l.] + } + if ($booktitle=~m/.*colon.*/) {#当存在colon + $booktitle=~s/colon/:/; #将colon换回: + } + + #进一步处理责任者的姓名,主要针对英文名需要有一些符号进行区分姓,名,前缀和后缀。 + @names=split('and',$bookauthor); + print 'names=',@names,"\n"; + $bookauthor=""; + $j=0; + foreach $name(@names){ + $j=$j+1; + #print $name,"\n"; + @nameparts=split(' ',$name); + #print 'nameparts=',@nameparts,"\n"; + + $org=0; + for($k=0;$k<@nameparts;$k++){ + if(@nameparts[$k]=~m/.{2,}/ and @nameparts[$k]!~m/\s*von\s*/i and @nameparts[$k]!~m/\s*jr\s*/i){ + #当分解的单作者的各个部分,存在两个以上为2个字符以上的情况,说明不是一般的姓名而是机构作者 + $org=$org+1; + print 'org=',"$org\n"; + } + } + + if(@nameparts>1){ + if(@nameparts[0]=~m/\s*von\s*/i){#确定姓的位置 + $family=1; + @nameparts[1]=@nameparts[1].','; + }else{ + $family=0; + @nameparts[0]=@nameparts[0].','; + } + if(@nameparts[-1]=~m/\s*jr\s*/i){#确定后缀的位置 + @nameparts[-1]=@nameparts[-1].'.,'; + $given=@nameparts-2; + $suffix=1; + }else{ + $suffix=0; + $given=@nameparts-1; + } + #print 'family=',$family,"\n"; + #print 'given=',$given,"\n"; + #print 'suffix=',$suffix,"\n"; + + $namefmt=""; + for($i=0;$i<=$family;$i++){ + $namefmt=$namefmt.@nameparts[$i].' '; + #print $i,$family,$namefmt,"\n"; + } + if($suffix){ + $namefmt=$namefmt.@nameparts[-1].' '; + } + for($i=$family+1;$i<=$given;$i++){ + $namefmt=$namefmt.@nameparts[$i].' '; + } + }else{ + $namefmt=$name; + } + if($org > 1){#当是机构作者时 + $namefmt='{'.$name.'}'; + } + #print 'namefmt=',"$namefmt \n"; + + if($j==1){ + $bookauthor=$namefmt; + }else{ + $bookauthor=$bookauthor.' and '.$namefmt; + } + } + while($bookauthor=~m/\s{2,}/){ + $bookauthor=~s/\s{2,}/ /;#将多余的空格去掉 + } + while($bookauthor=~m/\.{2,}/){ + $bookauthor=~s/\.{2,}/\./;#将多余的点去掉 + } + print 'bookauthor=',"$bookauthor\n"; + } + + + sub afpublisherbook{#af表示after,出版者后book和inbook一样,但如果存在url则不同 + #处理出版者及其后面的信息 + if ($pospublisher=~m/.*\[s\.n\.\].*/) {#当存在英文的[s.n.] + $pospublisher=~s/\[s\.n\.\]/\[s-n-\]/; #先将[s.n.]换成[s-n-]然后换回来 + } + if ($pospublisher=~m/.*,\s*\d{4}\S+/){#匹配存在年份的话 + ($publisher, $year, $posyear)=($pospublisher=~m/(.*),\s*(\d{4})(.*)/); + print 'publisher=',"$publisher \n"; + print 'year =',"$year \n"; + print 'posyear =',"$posyear \n"; + if($posyear=~m/^:/){#匹配存在页码前面的冒号的话 + ($pages, $pospages)=($posyear=~m/^:([^\.]+)\.(.*)/); + print 'pages =',"$pages \n"; + print 'pospages=',"$pospages \n"; + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($doi)=($pospages=~m/DOI:(.*)\./i); + print 'doi=',"$doi \n"; + } + }else{#不存在页码的话 + if($posyear=~m/DOI/i){#匹配存在doi的话 + ($doi)=($posyear=~m/DOI:(.*)\./i); + print 'doi=',"$doi \n"; + } + } + }else{#不存在年份,匹配一下是否存在冒号和页码 + if($pospublisher=~m/.*[^DOI]:.*/i){#当存在不是doi后面的冒号时,说明有页码 + ($publisher, $pages, $pospages)=($pospublisher=~m/([^:]*):([^\.]*)\.(.*)/); + print 'publisher=',"$publisher \n"; + print 'pages =',"$pages \n"; + print 'pospages =',"$pospages \n"; + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($doi)=($pospages=~m/DOI:(.*)\./i); + print 'doi=',"$doi \n"; + } + }else{#没有页码冒号以点作为出版者后的分隔点 + ($publisher, $pospages)=($pospublisher=~m/([^\.]*)\.(.*)/); + print 'publisher=',"$publisher \n"; + print 'pospages =',"$pospages \n"; + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($doi)=($pospages=~m/DOI:(.*)\./i); + print 'doi=',"$doi \n"; + } + } + } + if ($publisher=~m/.*\[s-n-\].*/) {#当存在英文的[s-n-] + $publisher=~s/\[s-n-\]/\[s\.n\.\]/; #将[s-n-]换回[s.n.] + } + } + + + sub afpublisherbookurl{#af表示after,出版者后book和inbook一样,但如果存在url则不同 + #处理出版者及其后面的信息 + if ($pospublisher=~m/.*\[s\.n\.\].*/) {#当存在英文的[s.n.] + $pospublisher=~s/\[s\.n\.\]/\[s-n-\]/; #先将[s.n.]换成[s-n-]然后换回来 + } + if ($pospublisher=~m/.*,\s*\d{4}[^\d-]/){#匹配存在年份的话,4个数字后面跟着不能是数字和连字符- + ($publisher, $year, $posyear)=($pospublisher=~m/(.*),\s*(\d{4})(.*)/); + print 'publisher=',"$publisher \n"; + print 'year =',"$year \n"; + print 'posyear =',"$posyear \n"; + if($posyear=~m/^:/){#匹配存在页码前面的冒号的话 + ($pages, $pospages)=($posyear=~m/^:([^\.]+)\.(.*)/); + print 'pages =',"$pages \n"; + print 'pospages=',"$pospages \n"; + if($pages=~m/\[.*\]/){ + ($pagesa, $urldate)=($pages=~m/(.*)\[(.*)\]/); + $pages=$pagesa; + print 'urldate=',"$urldate \n"; + print 'pages=',"$pages \n"; + } + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + ($url)=($pospages=~m/(.*)\./i); + print 'url=',"$url \n"; + } + } + else{#不存在页码的话 + if($posyear=~m/\[.*\]/){ + ($urldate,$pospages)=($posyear=~m/.*\[(.*)\]\.(.*)/); + print 'urldate=',"$urldate \n"; + print 'pospages=',"$pospages \n"; + } + else{#不存在页码,又不存在引用日期的话,那么会有一个点和空格 + ($pospages)=($posyear=~m/.*\s(.*)/); + print 'pospages=',"$pospages \n"; + } + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + ($url)=($pospages=~m/(.*)\./i); + print 'url=',"$url \n"; + } + } + }else{#不存在年份,匹配一下是否存在冒号和页码 + if($pospublisher=~m/.*[^DOIhttp]:.*/i){#当存在不是doi或http后面的冒号时,说明有页码 + ($publisher, $pages, $pospages)=($pospublisher=~m/([^:]*):([^\.]*)\.(.*)/); + print 'publisher=',"$publisher \n"; + print 'pages =',"$pages \n"; + print 'pospages =',"$pospages \n"; + if($pages=~m/\[.*\]/){ + ($pagesa, $urldate)=($pages=~m/(.*)\[(.*)\]/); + $pages=$pagesa; + print 'urldate=',"$urldate \n"; + print 'pages=',"$pages \n"; + } + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + ($url)=($pospages=~m/(.*)\./i); + print 'url=',"$url \n"; + } + }else{#没有页码冒号以点作为出版者后的分隔点 + ($publisher, $pospages)=($pospublisher=~m/([^\.]*)\.(.*)/); + print 'publisher=',"$publisher \n"; + print 'pospages =',"$pospages \n"; + if($publisher=~m/\[.*\]/){ + ($publishera, $urldate)=($publisher=~m/(.*)\[(.*)\]/); + $publisher=$publishera; + print 'urldate=',"$urldate \n"; + print 'publisher=',"$publisher \n"; + } + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + ($url)=($pospages=~m/(.*)\./i); + print 'url=',"$url \n"; + } + } + } + if ($publisher=~m/.*\[s-n-\].*/) {#当存在英文的[s-n-] + $publisher=~s/\[s-n-\]/\[s\.n\.\]/; #将[s-n-]换回[s.n.] + } + } + + + sub afpublisherbookb{#af表示after,出版者后book和inbook一样,但如果存在url则不同 + #处理出版者及其后面的信息 + if ($pospublisher=~m/.*\[s\.n\.\].*/) {#当存在英文的[s.n.] + $pospublisher=~s/\[s\.n\.\]/\[s-n-\]/; #先将[s.n.]换成[s-n-]然后换回来 + } + if ($pospublisher=~m/.*[\.\s,]*\d{4}[\D\S]+/){#匹配存在年份的话,年份前面没有逗号+空格 + ($publisher, $year, $posyear)=($pospublisher=~m/(.*)[\.\s,]*(\d{4})([\D\S].*)/); + print 'publisher=',"$publisher \n"; + if($publisher=~m/[,\s]+$/){$publisher=~s/[,\s]+$//;}#去掉最后的逗号 + unless($address){#当没有出版地时,也没有必要存在 + $version=$publisher; + $publisher=''; + } + print 'year =',"$year \n"; + print 'posyear =',"$posyear \n"; + if($posyear=~m/^:/){#匹配存在页码前面的冒号的话 + ($pages, $pospages)=($posyear=~m/^:([^\.]+)\.(.*)/); + print 'pages =',"$pages \n"; + print 'pospages=',"$pospages \n"; + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($doi)=($pospages=~m/DOI:(.*)\./i); + print 'doi=',"$doi \n"; + } + }else{#不存在页码的话 + if($posyear=~m/DOI/i){#匹配存在doi的话 + ($doi)=($posyear=~m/DOI:(.*)\./i); + print 'doi=',"$doi \n"; + } + } + }else{#不存在年份,匹配一下是否存在冒号和页码 + if($pospublisher=~m/.*[^DOI]:.*/i){#当存在不是doi后面的冒号时,说明有页码 + ($publisher, $pages, $pospages)=($pospublisher=~m/([^:]*):([^\.]*)\.(.*)/); + print 'publisher=',"$publisher \n"; + print 'pages =',"$pages \n"; + print 'pospages =',"$pospages \n"; + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($doi)=($pospages=~m/DOI:(.*)\./i); + print 'doi=',"$doi \n"; + } + }else{#没有页码冒号以点作为出版者后的分隔点 + ($publisher, $pospages)=($pospublisher=~m/([^\.]*)\.(.*)/); + print 'publisher=',"$publisher \n"; + print 'pospages =',"$pospages \n"; + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($doi)=($pospages=~m/DOI:(.*)\./i); + print 'doi=',"$doi \n"; + } + } + if($publisher=~m/,$/){$publisher=~s/,$//;}#去掉最后的逗号 + unless($address){#当没有出版地时,也没有必要存在 + $type=$publisher; + $publisher=''; + } + } + if ($publisher=~m/.*\[s-n-\].*/) {#当存在英文的[s-n-] + $publisher=~s/\[s-n-\]/\[s\.n\.\]/; #将[s-n-]换回[s.n.] + } + } + + + + sub afpublisherbookurlb{#af表示after,出版者后book和inbook一样,但如果存在url则不同 + #处理出版者及其后面的信息 + if ($pospublisher=~m/.*\[s\.n\.\].*/) {#当存在英文的[s.n.] + $pospublisher=~s/\[s\.n\.\]/\[s-n-\]/; #先将[s.n.]换成[s-n-]然后换回来 + } + if ($pospublisher=~m/.*[\.\s,]*\d{4}[^\d-]/){#匹配存在年份的话,4个数字后面跟着不能是数字和连字符- + ($publisher, $year, $posyear)=($pospublisher=~m/(.*)[\.\s,]*(\d{4})([^\d-].*)/); + print 'publisher=',"$publisher \n"; + print 'year =',"$year \n"; + print 'posyear =',"$posyear \n"; + if($publisher=~m/,$/){$publisher=~s/,$//;}#去掉最后的逗号 + unless($address){#当没有出版地时,也没有必要存在 + $version=$publisher; + $publisher=''; + } + if($posyear=~m/^:/){#匹配存在页码前面的冒号的话 + ($pages, $pospages)=($posyear=~m/^:([^\.]+)\.(.*)/); + print 'pages =',"$pages \n"; + print 'pospages=',"$pospages \n"; + if($pages=~m/\[.*\]/){ + ($pagesa, $urldate)=($pages=~m/(.*)\[(.*)\]/); + $pages=$pagesa; + print 'urldate=',"$urldate \n"; + print 'pages=',"$pages \n"; + } + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + ($url)=($pospages=~m/(.*)\./i); + print 'url=',"$url \n"; + } + } + else{#不存在页码的话 + if($posyear=~m/\[.*\]/){ + ($urldate,$pospages)=($posyear=~m/.*\[(.*)\]\.(.*)/); + print 'urldate=',"$urldate \n"; + print 'pospages=',"$pospages \n"; + } + else{#不存在页码,又不存在引用日期的话,那么会有一个点和空格 + ($pospages)=($posyear=~m/.*\s(.*)/); + print 'pospages=',"$pospages \n"; + } + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + ($url)=($pospages=~m/(.*)\./i); + print 'url=',"$url \n"; + } + } + }else{#不存在年份,匹配一下是否存在冒号和页码 + if($pospublisher=~m/.*[^DOIhttp]:.*/i){#当存在不是doi或http后面的冒号时,说明有页码 + ($publisher, $pages, $pospages)=($pospublisher=~m/([^:]*):([^\.]*)\.(.*)/); + print 'publisher=',"$publisher \n"; + print 'pages =',"$pages \n"; + print 'pospages =',"$pospages \n"; + if($pages=~m/\[.*\]/){ + ($pagesa, $urldate)=($pages=~m/(.*)\[(.*)\]/); + $pages=$pagesa; + print 'urldate=',"$urldate \n"; + print 'pages=',"$pages \n"; + } + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + ($url)=($pospages=~m/(.*)\./i); + print 'url=',"$url \n"; + } + }else{#没有页码冒号以点作为出版者后的分隔点 + ($publisher, $pospages)=($pospublisher=~m/([^\.]*)\.(.*)/); + print 'publisher=',"$publisher \n"; + print 'pospages =',"$pospages \n"; + if($publisher=~m/\[.*\]/){ + ($publishera, $urldate)=($publisher=~m/(.*)\[(.*)\]/); + $publisher=$publishera; + print 'urldate=',"$urldate \n"; + print 'publisher=',"$publisher \n"; + } + if($pospages=~m/DOI/i){#匹配存在doi的话 + ($url, $doi)=($pospages=~m/(.*)\.\s*DOI:(.*)\./i); + print 'url=',"$url \n"; + print 'doi=',"$doi \n"; + }else{ + ($url)=($pospages=~m/(.*)\./i); + print 'url=',"$url \n"; + } + } + if($publisher=~m/,$/){$publisher=~s/,$//;}#去掉最后的逗号 + unless($address){#当没有出版地时,也没有必要存在 + $type=$publisher; + $publisher=''; + } + } + if ($publisher=~m/.*\[s-n-\].*/) {#当存在英文的[s-n-] + $publisher=~s/\[s-n-\]/\[s\.n\.\]/; #将[s-n-]换回[s.n.] + } + } + + + +close (FHR); +close (FHW);
\ No newline at end of file diff --git a/macros/unicodetex/latex/njuthesis/LICENSE b/macros/unicodetex/latex/njuthesis/LICENSE new file mode 100644 index 0000000000..4db9b5af29 --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/LICENSE @@ -0,0 +1,415 @@ +The LaTeX Project Public License +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +LPPL Version 1.3c 2008-05-04 + +Copyright 1999 2002-2008 LaTeX3 Project + Everyone is allowed to distribute verbatim copies of this + license document, but modification of it is not allowed. + + +PREAMBLE +======== + +The LaTeX Project Public License (LPPL) is the primary license under +which the LaTeX kernel and the base LaTeX packages are distributed. + +You may use this license for any work of which you hold the copyright +and which you wish to distribute. This license may be particularly +suitable if your work is TeX-related (such as a LaTeX package), but +it is written in such a way that you can use it even if your work is +unrelated to TeX. + +The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE', +below, gives instructions, examples, and recommendations for authors +who are considering distributing their works under this license. + +This license gives conditions under which a work may be distributed +and modified, as well as conditions under which modified versions of +that work may be distributed. + +We, the LaTeX3 Project, believe that the conditions below give you +the freedom to make and distribute modified versions of your work +that conform with whatever technical specifications you wish while +maintaining the availability, integrity, and reliability of +that work. If you do not see how to achieve your goal while +meeting these conditions, then read the document `cfgguide.tex' +and `modguide.tex' in the base LaTeX distribution for suggestions. + + +DEFINITIONS +=========== + +In this license document the following terms are used: + + `Work' + Any work being distributed under this License. + + `Derived Work' + Any work that under any applicable law is derived from the Work. + + `Modification' + Any procedure that produces a Derived Work under any applicable + law -- for example, the production of a file containing an + original file associated with the Work or a significant portion of + such a file, either verbatim or with modifications and/or + translated into another language. + + `Modify' + To apply any procedure that produces a Derived Work under any + applicable law. + + `Distribution' + Making copies of the Work available from one person to another, in + whole or in part. Distribution includes (but is not limited to) + making any electronic components of the Work accessible by + file transfer protocols such as FTP or HTTP or by shared file + systems such as Sun's Network File System (NFS). + + `Compiled Work' + A version of the Work that has been processed into a form where it + is directly usable on a computer system. This processing may + include using installation facilities provided by the Work, + transformations of the Work, copying of components of the Work, or + other activities. Note that modification of any installation + facilities provided by the Work constitutes modification of the Work. + + `Current Maintainer' + A person or persons nominated as such within the Work. If there is + no such explicit nomination then it is the `Copyright Holder' under + any applicable law. + + `Base Interpreter' + A program or process that is normally needed for running or + interpreting a part or the whole of the Work. + + A Base Interpreter may depend on external components but these + are not considered part of the Base Interpreter provided that each + external component clearly identifies itself whenever it is used + interactively. Unless explicitly specified when applying the + license to the Work, the only applicable Base Interpreter is a + `LaTeX-Format' or in the case of files belonging to the + `LaTeX-format' a program implementing the `TeX language'. + + + +CONDITIONS ON DISTRIBUTION AND MODIFICATION +=========================================== + +1. Activities other than distribution and/or modification of the Work +are not covered by this license; they are outside its scope. In +particular, the act of running the Work is not restricted and no +requirements are made concerning any offers of support for the Work. + +2. You may distribute a complete, unmodified copy of the Work as you +received it. Distribution of only part of the Work is considered +modification of the Work, and no right to distribute such a Derived +Work may be assumed under the terms of this clause. + +3. You may distribute a Compiled Work that has been generated from a +complete, unmodified copy of the Work as distributed under Clause 2 +above, as long as that Compiled Work is distributed in such a way that +the recipients may install the Compiled Work on their system exactly +as it would have been installed if they generated a Compiled Work +directly from the Work. + +4. If you are the Current Maintainer of the Work, you may, without +restriction, modify the Work, thus creating a Derived Work. You may +also distribute the Derived Work without restriction, including +Compiled Works generated from the Derived Work. Derived Works +distributed in this manner by the Current Maintainer are considered to +be updated versions of the Work. + +5. If you are not the Current Maintainer of the Work, you may modify +your copy of the Work, thus creating a Derived Work based on the Work, +and compile this Derived Work, thus creating a Compiled Work based on +the Derived Work. + +6. If you are not the Current Maintainer of the Work, you may +distribute a Derived Work provided the following conditions are met +for every component of the Work unless that component clearly states +in the copyright notice that it is exempt from that condition. Only +the Current Maintainer is allowed to add such statements of exemption +to a component of the Work. + + a. If a component of this Derived Work can be a direct replacement + for a component of the Work when that component is used with the + Base Interpreter, then, wherever this component of the Work + identifies itself to the user when used interactively with that + Base Interpreter, the replacement component of this Derived Work + clearly and unambiguously identifies itself as a modified version + of this component to the user when used interactively with that + Base Interpreter. + + b. Every component of the Derived Work contains prominent notices + detailing the nature of the changes to that component, or a + prominent reference to another file that is distributed as part + of the Derived Work and that contains a complete and accurate log + of the changes. + + c. No information in the Derived Work implies that any persons, + including (but not limited to) the authors of the original version + of the Work, provide any support, including (but not limited to) + the reporting and handling of errors, to recipients of the + Derived Work unless those persons have stated explicitly that + they do provide such support for the Derived Work. + + d. You distribute at least one of the following with the Derived Work: + + 1. A complete, unmodified copy of the Work; + if your distribution of a modified component is made by + offering access to copy the modified component from a + designated place, then offering equivalent access to copy + the Work from the same or some similar place meets this + condition, even though third parties are not compelled to + copy the Work along with the modified component; + + 2. Information that is sufficient to obtain a complete, + unmodified copy of the Work. + +7. If you are not the Current Maintainer of the Work, you may +distribute a Compiled Work generated from a Derived Work, as long as +the Derived Work is distributed to all recipients of the Compiled +Work, and as long as the conditions of Clause 6, above, are met with +regard to the Derived Work. + +8. The conditions above are not intended to prohibit, and hence do not +apply to, the modification, by any method, of any component so that it +becomes identical to an updated version of that component of the Work as +it is distributed by the Current Maintainer under Clause 4, above. + +9. Distribution of the Work or any Derived Work in an alternative +format, where the Work or that Derived Work (in whole or in part) is +then produced by applying some process to that format, does not relax or +nullify any sections of this license as they pertain to the results of +applying that process. + +10. a. A Derived Work may be distributed under a different license + provided that license itself honors the conditions listed in + Clause 6 above, in regard to the Work, though it does not have + to honor the rest of the conditions in this license. + + b. If a Derived Work is distributed under a different license, that + Derived Work must provide sufficient documentation as part of + itself to allow each recipient of that Derived Work to honor the + restrictions in Clause 6 above, concerning changes from the Work. + +11. This license places no restrictions on works that are unrelated to +the Work, nor does this license place any restrictions on aggregating +such works with the Work by any means. + +12. Nothing in this license is intended to, or may be used to, prevent +complete compliance by all parties with all applicable laws. + + +NO WARRANTY +=========== + +There is no warranty for the Work. Except when otherwise stated in +writing, the Copyright Holder provides the Work `as is', without +warranty of any kind, either expressed or implied, including, but not +limited to, the implied warranties of merchantability and fitness for a +particular purpose. The entire risk as to the quality and performance +of the Work is with you. Should the Work prove defective, you assume +the cost of all necessary servicing, repair, or correction. + +In no event unless required by applicable law or agreed to in writing +will The Copyright Holder, or any author named in the components of the +Work, or any other party who may distribute and/or modify the Work as +permitted above, be liable to you for damages, including any general, +special, incidental or consequential damages arising out of any use of +the Work or out of inability to use the Work (including, but not limited +to, loss of data, data being rendered inaccurate, or losses sustained by +anyone as a result of any failure of the Work to operate with any other +programs), even if the Copyright Holder or said author or said other +party has been advised of the possibility of such damages. + + +MAINTENANCE OF THE WORK +======================= + +The Work has the status `author-maintained' if the Copyright Holder +explicitly and prominently states near the primary copyright notice in +the Work that the Work can only be maintained by the Copyright Holder +or simply that it is `author-maintained'. + +The Work has the status `maintained' if there is a Current Maintainer +who has indicated in the Work that they are willing to receive error +reports for the Work (for example, by supplying a valid e-mail +address). It is not required for the Current Maintainer to acknowledge +or act upon these error reports. + +The Work changes from status `maintained' to `unmaintained' if there +is no Current Maintainer, or the person stated to be Current +Maintainer of the work cannot be reached through the indicated means +of communication for a period of six months, and there are no other +significant signs of active maintenance. + +You can become the Current Maintainer of the Work by agreement with +any existing Current Maintainer to take over this role. + +If the Work is unmaintained, you can become the Current Maintainer of +the Work through the following steps: + + 1. Make a reasonable attempt to trace the Current Maintainer (and + the Copyright Holder, if the two differ) through the means of + an Internet or similar search. + + 2. If this search is successful, then enquire whether the Work + is still maintained. + + a. If it is being maintained, then ask the Current Maintainer + to update their communication data within one month. + + b. If the search is unsuccessful or no action to resume active + maintenance is taken by the Current Maintainer, then announce + within the pertinent community your intention to take over + maintenance. (If the Work is a LaTeX work, this could be + done, for example, by posting to comp.text.tex.) + + 3a. If the Current Maintainer is reachable and agrees to pass + maintenance of the Work to you, then this takes effect + immediately upon announcement. + + b. If the Current Maintainer is not reachable and the Copyright + Holder agrees that maintenance of the Work be passed to you, + then this takes effect immediately upon announcement. + + 4. If you make an `intention announcement' as described in 2b. above + and after three months your intention is challenged neither by + the Current Maintainer nor by the Copyright Holder nor by other + people, then you may arrange for the Work to be changed so as + to name you as the (new) Current Maintainer. + + 5. If the previously unreachable Current Maintainer becomes + reachable once more within three months of a change completed + under the terms of 3b) or 4), then that Current Maintainer must + become or remain the Current Maintainer upon request provided + they then update their communication data within one month. + +A change in the Current Maintainer does not, of itself, alter the fact +that the Work is distributed under the LPPL license. + +If you become the Current Maintainer of the Work, you should +immediately provide, within the Work, a prominent and unambiguous +statement of your status as Current Maintainer. You should also +announce your new status to the same pertinent community as +in 2b) above. + + +WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE +====================================================== + +This section contains important instructions, examples, and +recommendations for authors who are considering distributing their +works under this license. These authors are addressed as `you' in +this section. + +Choosing This License or Another License +---------------------------------------- + +If for any part of your work you want or need to use *distribution* +conditions that differ significantly from those in this license, then +do not refer to this license anywhere in your work but, instead, +distribute your work under a different license. You may use the text +of this license as a model for your own license, but your license +should not refer to the LPPL or otherwise give the impression that +your work is distributed under the LPPL. + +The document `modguide.tex' in the base LaTeX distribution explains +the motivation behind the conditions of this license. It explains, +for example, why distributing LaTeX under the GNU General Public +License (GPL) was considered inappropriate. Even if your work is +unrelated to LaTeX, the discussion in `modguide.tex' may still be +relevant, and authors intending to distribute their works under any +license are encouraged to read it. + +A Recommendation on Modification Without Distribution +----------------------------------------------------- + +It is wise never to modify a component of the Work, even for your own +personal use, without also meeting the above conditions for +distributing the modified component. While you might intend that such +modifications will never be distributed, often this will happen by +accident -- you may forget that you have modified that component; or +it may not occur to you when allowing others to access the modified +version that you are thus distributing it and violating the conditions +of this license in ways that could have legal implications and, worse, +cause problems for the community. It is therefore usually in your +best interest to keep your copy of the Work identical with the public +one. Many works provide ways to control the behavior of that work +without altering any of its licensed components. + +How to Use This License +----------------------- + +To use this license, place in each of the components of your work both +an explicit copyright notice including your name and the year the work +was authored and/or last substantially modified. Include also a +statement that the distribution and/or modification of that +component is constrained by the conditions in this license. + +Here is an example of such a notice and statement: + + %% pig.dtx + %% Copyright 2005 M. Y. Name + % + % 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 your option) any later version. + % The latest version of this license is in + % http://www.latex-project.org/lppl.txt + % and version 1.3 or later is part of all distributions of LaTeX + % version 2005/12/01 or later. + % + % This work has the LPPL maintenance status `maintained'. + % + % The Current Maintainer of this work is M. Y. Name. + % + % This work consists of the files pig.dtx and pig.ins + % and the derived file pig.sty. + +Given such a notice and statement in a file, the conditions +given in this license document would apply, with the `Work' referring +to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being +generated from `pig.dtx' using `pig.ins'), the `Base Interpreter' +referring to any `LaTeX-Format', and both `Copyright Holder' and +`Current Maintainer' referring to the person `M. Y. Name'. + +If you do not want the Maintenance section of LPPL to apply to your +Work, change `maintained' above into `author-maintained'. +However, we recommend that you use `maintained', as the Maintenance +section was added in order to ensure that your Work remains useful to +the community even when you can no longer maintain and support it +yourself. + +Derived Works That Are Not Replacements +--------------------------------------- + +Several clauses of the LPPL specify means to provide reliability and +stability for the user community. They therefore concern themselves +with the case that a Derived Work is intended to be used as a +(compatible or incompatible) replacement of the original Work. If +this is not the case (e.g., if a few lines of code are reused for a +completely different task), then clauses 6b and 6d shall not apply. + + +Important Recommendations +------------------------- + + Defining What Constitutes the Work + + The LPPL requires that distributions of the Work contain all the + files of the Work. It is therefore important that you provide a + way for the licensee to determine which files constitute the Work. + This could, for example, be achieved by explicitly listing all the + files of the Work near the copyright notice of each file or by + using a line such as: + + % This work consists of all files listed in manifest.txt. + + in that place. In the absence of an unequivocal list it might be + impossible for the licensee to determine what is considered by you + to comprise the Work and, in such a case, the licensee would be + entitled to make reasonable conjectures as to which files comprise + the Work. diff --git a/macros/unicodetex/latex/njuthesis/README.md b/macros/unicodetex/latex/njuthesis/README.md new file mode 100644 index 0000000000..d7c4cb33aa --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/README.md @@ -0,0 +1,29 @@ +# NJU Thesis + +[![njuthesis](https://img.shields.io/badge/njuthesis-latex-blue)](https://git.nju.edu.cn/nju-lug/nju-latex-templates) +[![overleaf](https://img.shields.io/badge/overleaf-supported-brightgreen)](https://tex.nju.edu.cn) + +## Overview + +This is A LaTex Template for Nanjing University Bachelor Thesis. The Template needs `xelatex` or `lualatex`. + +## License + +----- + This work may be distributed and/or modified under the conditions of + the [LaTeX Project Public License](http://www.latex-project.org/lppl.txt), + either version 1.3c of this license or (at your option) any later + version. +----- + +## Contributing + +If you find a problem with the template, please submit an issue or PR in Github + +## Wiki + +Please see [Chinese wiki](https://github.com/nju-lug/NJUThesis/wiki)。 + +----- + +Copyright © NJU-LUG diff --git a/macros/unicodetex/latex/njuthesis/figure/njulogo.pdf b/macros/unicodetex/latex/njuthesis/figure/njulogo.pdf Binary files differnew file mode 100644 index 0000000000..a298271f5b --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/figure/njulogo.pdf diff --git a/macros/unicodetex/latex/njuthesis/figure/njuname-large.jpg b/macros/unicodetex/latex/njuthesis/figure/njuname-large.jpg Binary files differnew file mode 100644 index 0000000000..b69db06921 --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/figure/njuname-large.jpg diff --git a/macros/unicodetex/latex/njuthesis/figure/njuname.pdf b/macros/unicodetex/latex/njuthesis/figure/njuname.pdf Binary files differnew file mode 100644 index 0000000000..150958a0ec --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/figure/njuname.pdf diff --git a/macros/unicodetex/latex/njuthesis/njuthesis.cls b/macros/unicodetex/latex/njuthesis/njuthesis.cls new file mode 100644 index 0000000000..d8d8f57f3a --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/njuthesis.cls @@ -0,0 +1,96 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesExplClass{njuthesis}{2021-09-11}{0.7.3}{NJU Thesis LaTeX Template} + +% 通过类传递参数 +\RequirePackage{l3keys2e} + +\LoadClass[ + a4paper, + twoside, + UTF8, + scheme=chinese, + linespread=1.625,% laTex默认1.2行距,word默认行距是1.3,要求1.5倍word行距,故1.5/1.2*1.3 = 1.625 + fontset=none, + zihao=-4 + ]{ctexbook}[2018/04/01] + +% 定义模板键值 +% 用于格式控制的键值 +\keys_define:nn { nju } +{ + titlelength .int_set:N = \nju_titlelength, + titlelength .initial:n = 1, + + secondmentor .bool_set:N = \nju_second_mentor, + secondmentor .initial:n = false, + + degree .tl_set:N = \nju_degree, + degree .initial:n = UG, + + type .tl_set:N = \nju_type, + type .initial:n = thesis, + + systemfont .bool_set:N = \nju_systemfont, + systemfont .initial:n = true, + + customlatinfont .tl_set:N = \nju_customlatinfont, + customlatinfont .initial:n = windows, + + customchinesefont .tl_set:N = \nju_customchinesefont, + customchinesefont .initial:n = windows, + + info .meta:nn = { nju / info } { #1 } +} + +\keys_define:nn { nju / info } +{ + % 题目 + TitleA .tl_set:N = \nju_title_a, + TitleB .tl_set:N = \nju_title_b, + TitleC .tl_set:N = \nju_title_c, + TitleEN .tl_set:N = \nju_title_en, + + % 年级学号姓名 + Grade .tl_set:N = \nju_grade, + StudentID .tl_set:N = \nju_student_id, + StudentName .tl_set:N = \nju_student_name, + StudentNameEN .tl_set:N = \nju_student_name_en, + + % 院系专业方向 + Department .tl_set:N = \nju_department, + DepartmentEN .tl_set:N = \nju_department_en, + Major .tl_set:N = \nju_major, + MajorEN .tl_set:N = \nju_major_en, + Field .tl_set:N = \nju_field, + FieldEN .tl_set:N = \nju_field_en, + + % 导师 + MentorA .tl_set:N = \nju_mentor_a, + MentorAEN .tl_set:N = \nju_mentor_a_en, + MentorATitle .tl_set:N = \nju_mentor_a_title, + MentorATitleEN .tl_set:N = \nju_mentor_a_title_en, + + % 第二导师 + MentorB .tl_set:N = \nju_mentor_b, + MentorBEN .tl_set:N = \nju_mentor_b_en, + MentorBTitle .tl_set:N = \nju_mentor_b_title, + MentorBTitleEN .tl_set:N = \nju_mentor_b_title_en, + + % 日期 + SubmitDate .tl_set:N = \nju_submit_date, + DefenseDate .tl_set:N = \nju_defense_date, +} + +\NewDocumentCommand \njusetup { m } +{ \keys_set:nn { nju } { #1 } } + +\ProcessKeysOptions { nju } + +% 输入配置文件 +\RequirePackage{profile/packages} +\RequirePackage{profile/font} +\RequirePackage{profile/page} +\RequirePackage{profile/reference} +\RequirePackage{profile/components} +\RequirePackage{profile/cover} +\RequirePackage{profile/abstract} diff --git a/macros/unicodetex/latex/njuthesis/njuthesis.pdf b/macros/unicodetex/latex/njuthesis/njuthesis.pdf Binary files differnew file mode 100644 index 0000000000..11b1922dea --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/njuthesis.pdf diff --git a/macros/unicodetex/latex/njuthesis/profile/abstract.sty b/macros/unicodetex/latex/njuthesis/profile/abstract.sty new file mode 100644 index 0000000000..37814cef13 --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/profile/abstract.sty @@ -0,0 +1,136 @@ +\ProvidesExplPackage{profile/abstract}{2021-09-11}{0.7.0}{NJU Thesis abstract design} + +% 判断学位 +\str_if_eq:eeTF {\nju_degree} { ug } +{ + % 本科摘要环境 + \NewDocumentEnvironment{abstract} {} + {% + \pagestyle{plain} + \pagenumbering{Roman} + % \phantomsection\addcontentsline{toc}{chapter}{中文摘要} % 将摘要插入目录和pdf书签 + \pdfbookmark[0]{中文摘要}{中文摘要} % 将摘要插入pdf书签,与上一行不可共存 + \begin{center} + \kaishu\zihao{-2}{\textbf{\uuline{南京大学本科生毕业论文(设计、作品)中文摘要}}} + \end{center} + {\bgroup + \kaishu\zihao{-4} + \tl_set:Nn \tabcolsep {0pt} + \tl_set:Nn \arraystretch {0.8} + \noindent + 题目: \nju_title \\ + 院系: \nju_department \\ + 专业: \nju_major \\ + 本科生姓名: \nju_student_name \\ + 指导教师(姓名、职称):\nju_mentor_full \\ + 摘要: + \egroup + } + \kaishu\zihao{-4}\par% + }{% + \newpage + } + + % 中文关键词 + \NewDocumentCommand \keywords {m} {% + \par\vspace{2ex}\noindent% + {\kaishu\zihao{-4}\makebox[4em][s]{关键词{:}}}~{#1}% + } + + % 英文摘要 + \NewDocumentEnvironment{englishabstract} {} + {% + \pagestyle{plain} + % \phantomsection\addcontentsline{toc}{chapter}{英文摘要} % 将摘要插入目录和pdf书签 + \pdfbookmark[0]{英文摘要}{英文摘要} % 将摘要插入pdf书签,与上一行不可共存 + \begin{center} + \kaishu\zihao{-2}{\textbf{\uuline{南京大学本科生毕业论文(设计、作品)英文摘要}}} + \end{center} + { + \bgroup + THESIS: ~~\nju_title_en \\ + DEPARTMENT: ~~\nju_department_en \\ + SPECIALIZATION: ~~\nju_major_en \\ + UNDERGRADUATE:~~\nju_student_name_en \\ + MENTOR:~~\nju_mentor_full_en \\ + ABSTRACT: + \egroup + } + \zihao{-4}\par% + }{% + \cleardoublepage + \newpage + } + + % 英文关键词 + \NewDocumentCommand \englishkeywords {m} {% + \par\vspace{2ex}\noindent% + {KEYWORDS{:}}~~{#1}% + } +} +{ + % 摘要环境 + \NewDocumentEnvironment{abstract} {} + {% + \pagestyle{plain} + \pagenumbering{Roman} + % \phantomsection\addcontentsline{toc}{chapter}{中文摘要} % 将摘要插入目录和pdf书签 + \pdfbookmark[0]{中文摘要}{中文摘要} % 将摘要插入pdf书签,与上一行不可共存 + \begin{center} + \kaishu\zihao{-2}{\textbf{\uuline{南京大学研究生毕业论文中文摘要首页用纸}}} + \end{center} + + \bgroup + \kaishu\zihao{4} + \tl_set:Nn \tabcolsep {0pt} + \tl_set:Nn \arraystretch {0.8} + \noindent + % 毕业论文题目:\ \uline{\nju_title} \\ % 下划线有问题 + 毕业论文题目:\ \nju_title \\ + \uline{\makebox[9em]{\nju_major}}专业\uline{\makebox[3em]{\nju_grade}}级 + \str_if_eq:eeTF {\nju_degree} { d } {博}{硕} + 士生姓名:\uline{\hfill\nju_student_name\hfill} \\ + 指导教师(姓名、职称):\uline{\hfill\nju_mentor_full\hfill}\par + \egroup + + \kaishu\zihao{4}\par% + }{% + \newpage + } + + % 中文关键词 + \NewDocumentCommand \keywords {m} {% + \par\vspace{2ex}\noindent% + {\kaishu\zihao{4}\makebox[4em][s]{关键词{:}}}~{#1}% + } + + % 英文摘要 + \NewDocumentEnvironment{englishabstract} {} + {% + \pagestyle{plain} + % \phantomsection\addcontentsline{toc}{chapter}{英文摘要} % 将摘要插入目录和pdf书签 + \pdfbookmark[0]{英文摘要}{英文摘要} % 将摘要插入pdf书签,与上一行不可共存 + \begin{center} + \kaishu\zihao{-2}{\textbf{\uuline{南京大学研究生毕业论文英文摘要首页用纸}}} + \end{center} + { + \bgroup + \zihao{4} + THESIS: ~~\nju_title_en \\ + SPECIALIZATION: ~~\nju_major_en \\ + POSTGRADUATE:~~\nju_student_name_en \\ + MENTOR:~~\nju_mentor_full_en\par + \egroup + } + \zihao{4}\par% + }{% + \cleardoublepage + \newpage + } + + % 英文关键词 + \NewDocumentCommand \englishkeywords {m} {% + \par\vspace{2ex}\noindent% + {KEYWORDS{:}}~~{#1}% + } +} diff --git a/macros/unicodetex/latex/njuthesis/profile/components.sty b/macros/unicodetex/latex/njuthesis/profile/components.sty new file mode 100644 index 0000000000..4a24fe4f59 --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/profile/components.sty @@ -0,0 +1,173 @@ +\ProvidesExplPackage{profile/components}{2021-09-11}{0.6.0}{NJU Thesis components configuration} + +% 图表位置调整 +\floatsetup[lstlisting]{ % Captions for lstlistings + capposition=above,% + margins=centering,% + floatwidth=\textwidth% +} +\floatsetup[figure]{ % Captions for figures + capposition=bottom,% + margins=centering,% + floatwidth=\textwidth% +} +\floatsetup[table]{ % Captions for tables + capposition=above,% + margins=centering,% + floatwidth=\textwidth% +} + +% 代码样式 +\lstset{ + basicstyle=\ttfamily\linespread{1}\small\selectfont, + keywordstyle=\bfseries,% use bold style for keywords + commentstyle=\rmfamily\itshape,% use italic style for comments + stringstyle=\ttfamily,% 字符串风格 + flexiblecolumns,% ? + numbers=left,% left-aligned numbering + showspaces=false,% hide markers for spaces + showstringspaces=false, + captionpos=t,% place the caption at the top + % frame=lrtb,% show all four sides of the frame + % linewidth=.8\textwidth, + % breakatwhitespace=true, + breaklines=true, + xleftmargin=2em,xrightmargin=2em,% set the width of the code environment +} + +\lstdefinestyle{LaTeX}{ + language=TeX, + morekeywords={begin, caption, label, mathrm, frac, toprule, midrule, bottomrule, includegraphics} +} + +% 图表标题样式 +\DeclareCaptionFont{songticap}{\zihao{5}\bf\songti} +\captionsetup{ + font=small,% + labelfont=songticap, + textfont=songticap, + strut=no,% + hypcap=true, % Links point to the top of the figure + % indention=0pt, % Suppress indentation + % % parindent=0pt, % Suppress space between paragraphs + aboveskip=6pt, % Increase the space between the figure and the caption + belowskip=6pt, % Increase the space between the caption and the table +} + +% list configuration +\renewcommand{\labelitemi}{\tiny$\blacktriangleright$} +\renewcommand{\labelitemii}{\textbullet} + +\setlist[itemize]{noitemsep} +\setlist[enumerate]{noitemsep} +\setlist[description]{noitemsep} + +% 数学环境 +\declaretheoremstyle[ + %spaceabove=.5\thm@preskip, + %spacebelow=.5\thm@postskip, + headfont=\bf\songti,%\scshape, + notefont=\songti,% notebraces={ (}{)}, + bodyfont=\songti, + %headformat={\NAME\space\NUMBER\space\NOTE}, + headpunct={}, + %postheadspace={.5em plus .1em minus .1em}, + %prefoothook={\hfill\qedsymbol} + ]{njuthm} + +\theoremstyle{njuthm} + +\let\oldproofname=\proofname +\renewcommand*{\proofname}{\rm\bf\songti{\oldproofname}} % 修改证明环境标题 + +\declaretheorem[ + name=算法, + style=njuthm, + refname={算法,算法}, + Refname={算法,算法}, + % numberwithin=section, +]{algorithm} +\declaretheorem[ + name=假设, + style=njuthm, + refname={假设,假设}, + Refname={假设,假设}, + % numberwithin=section, +]{assumption} +\declaretheorem[ + name=公理, + style=njuthm, + refname={公理,公理}, + Refname={公理,公理}, + % numberwithin=section, +]{axiom} +\declaretheorem[ + name=结论, + style=njuthm, + refname={结论,结论}, + Refname={结论,结论}, + % numberwithin=section, +]{conclusion} +\declaretheorem[ + name=条件, + style=njuthm, + refname={条件,条件}, + Refname={条件,条件}, + % numberwithin=section, +]{condition} +\declaretheorem[ + name=推论, + style=njuthm, + refname={推论,推论}, + Refname={推论,推论}, + % numberwithin=section, +]{corollary} +\declaretheorem[ + name=定义, + style=njuthm, + refname={定义,定义}, + Refname={定义,定义}, + % numberwithin=section, +]{definition} +\declaretheorem[ + name=例, + style=njuthm, + refname={例,例}, + Refname={例,例}, + % numberwithin=section, +]{example} +\declaretheorem[ + name=引理, + style=njuthm, + refname={引理,引理}, + Refname={引理,引理}, + % numberwithin=section, +]{lemma} +\declaretheorem[ + name=性质, + style=njuthm, + refname={性质,性质}, + Refname={性质,性质}, + % numberwithin=section, +]{property} +\declaretheorem[ + name=命题, + style=njuthm, + refname={命题,命题}, + Refname={命题,命题}, + % numberwithin=section, +]{proposition} +\declaretheorem[ + name=注解, + style=njuthm, + refname={注解,注解}, + Refname={注解,注解}, + % numberwithin=section, +]{remark} +\declaretheorem[ + name=定理, + style=njuthm, + refname={定理,定理}, + Refname={定理,定理}, + numberwithin=section, +]{theorem} diff --git a/macros/unicodetex/latex/njuthesis/profile/cover.sty b/macros/unicodetex/latex/njuthesis/profile/cover.sty new file mode 100644 index 0000000000..8293e64780 --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/profile/cover.sty @@ -0,0 +1,251 @@ +\ProvidesExplPackage{profile/cover}{2021-09-11}{0.7.0}{NJU Thesis cover design} + +% 拼合标题 +\tl_const:Nn \nju_title {\nju_title_a \nju_title_b \nju_title_c} + +% 拼合导师 +\bool_if:NTF \nju_second_mentor +{ + \tl_const:Nn \nju_mentor_full + { + \nju_mentor_a\ \nju_mentor_a_title + \ \ \nju_mentor_b\ \nju_mentor_b_title + } + \tl_const:Nn \nju_mentor_full_en + { + \nju_mentor_a_en\ \nju_mentor_a_title_en + \ \ \nju_mentor_b_en\ \nju_mentor_b_title_en + } +} +{ + \tl_const:Nn \nju_mentor_full + { + \nju_mentor_a\ \nju_mentor_a_title + } + \tl_const:Nn \nju_mentor_full_en + { + \nju_mentor_a_en\ \nju_mentor_a_title_en + } +} + +% 封面下划线 +\cs_new:Npn \nju_cover_underline_ug:nn #1 #2 { + \uline{\makebox[#1]{\rm\songti#2}} +} +\cs_new:Npn \nju_cover_underline_g:n #1 { + \uline{\makebox[215pt]{\rm\kaishu#1}} +} + +% 封面表格边框 +\cs_new:Npn \nju_coverbox_ug:n #1 { + \makebox[4.2em][s]{#1} +} +\cs_new:Npn \nju_coverbox_g:n #1 { + \makebox[6em][s]{#1\hspace{1em}} +} + +% 判断学位 +\str_if_eq:eeTF {\nju_degree} { ug } +{ \tl_const:Nn \nju_degree_name {本\hfill 科\hfill } } % 本科 +{ + % 本科以外都是研究生 + \tl_const:Nn \nju_degree_name {研\hfill 究\hfill 生\hfill } + + % 研究生类别 + \str_case_e:nn { \nju_degree } + { + { mg } { \tl_const:Nn \nju_degree_title {硕士} } + { mf } { \tl_const:Nn \nju_degree_title {硕士专业} } + { d } { \tl_const:Nn \nju_degree_title {博士} } + } +} + +% 判断类型 +\str_if_eq:eeTF {\nju_type} {thesis} +{\tl_const:Nn \nju_type_name {\nju_degree_name 毕\hfill 业\hfill 论\hfill 文}} +{\tl_const:Nn \nju_type_name {\nju_degree_name 毕\hfill 业\hfill 设\hfill 计}} + +% 封面信息栏 本科 +\tl_new:N \nju_printcoverinfo_ug +\tl_set:Nn \nju_printcoverinfo_ug { + \begin{tabular}{p{4.2em}c} + \nju_coverbox_ug:n {院\hfill 系} + & \nju_cover_underline_ug:nn {250pt}{\nju_department}\\ + \nju_coverbox_ug:n {专\hfill 业} + & \nju_cover_underline_ug:nn {250pt}{\nju_major}\\ + + % 标题换行 + \int_case:nn {\nju_titlelength} + { + { 1 } { + \nju_coverbox_ug:n {题\hfill 目} + & \nju_cover_underline_ug:nn {250pt}{\bf{\nju_title_a}} \\ } + { 2 } { + \nju_coverbox_ug:n {题\hfill 目} + & \nju_cover_underline_ug:nn {250pt}{\bf{\nju_title_a}} \\ + & \nju_cover_underline_ug:nn {250pt}{\bf{\nju_title_b}} \\ } + { 3 } { + \nju_coverbox_ug:n {题\hfill 目} + & \nju_cover_underline_ug:nn {250pt}{\bf{\nju_title_a}} \\ + & \nju_cover_underline_ug:nn {250pt}{\bf{\nju_title_b}} \\ + & \nju_cover_underline_ug:nn {250pt}{\bf{\nju_title_c}} \\} + } + \end{tabular}\\ + + \begin{tabular}{p{4.2em}cp{4.2em}c} + \nju_coverbox_ug:n {年\hfill 级} + & \nju_cover_underline_ug:nn {90pt}{\nju_grade} + & \nju_coverbox_ug:n {学\hfill 号} + & \nju_cover_underline_ug:nn {90pt}{\nju_student_id}\\ + \end{tabular}\\ + + \begin{tabular}{p{4.2em}c} + \nju_coverbox_ug:n {学\hfill 生\hfill 姓\hfill 名} + & \nju_cover_underline_ug:nn {250pt}{\nju_student_name} + \end{tabular}\\ + \begin{tabular}{p{4.2em}cp{4.2em}c} + \nju_coverbox_ug:n {导\hfill 师} + & \nju_cover_underline_ug:nn {90pt}{\nju_mentor_a} + & \nju_coverbox_ug:n {职\hfill 称} + & \nju_cover_underline_ug:nn {90pt}{\nju_mentor_a_title}\\ + + % 第二导师 + \bool_if:NTF \nju_second_mentor + { + \nju_coverbox_ug:n {第\hfill 二\hfill 导\hfill 师} + & \nju_cover_underline_ug:nn {90pt}{\nju_mentor_b} + & \nju_coverbox_ug:n {职\hfill 称} + & \nju_cover_underline_ug:nn {90pt}{\nju_mentor_b_title}\\ + } + {} + \end{tabular}\\ + + \begin{tabular}{p{4.2em}c} + \nju_coverbox_ug:n {提\hfill 交\hfill 日\hfill 期} + & \nju_cover_underline_ug:nn {250pt}{\nju_submit_date}\\ + \end{tabular} +} + +% 封面信息栏 研究生 +\tl_new:N \nju_printcoverinfo_g +\tl_set:Nn \nju_printcoverinfo_g { + \begin{tabular}{p{6em}c} + % 标题换行 + \int_case:nn {\nju_titlelength} + { + { 1 } { + \nju_coverbox_g:n {论\hfill 文\hfill 题\hfill 目} + & \nju_cover_underline_g:n {\nju_title_a} \\ } + { 2 } { + \nju_coverbox_g:n {论\hfill 文\hfill 题\hfill 目} + & \nju_cover_underline_g:n {\nju_title_a} \\ + & \nju_cover_underline_g:n {\nju_title_b} \\ } + { 3 } { + \nju_coverbox_g:n {论\hfill 文\hfill 题\hfill 目} + & \nju_cover_underline_g:n {\nju_title_a} \\ + & \nju_cover_underline_g:n {\nju_title_b} \\ + & \nju_cover_underline_g:n {\nju_title_c} \\} + } + + \nju_coverbox_g:n {作\hfill 者\hfill 姓\hfill 名} + & \nju_cover_underline_g:n {\nju_student_name}\\ + \nju_coverbox_g:n {专\hfill 业\hfill 名\hfill 称} + & \nju_cover_underline_g:n {\nju_major}\\ + \nju_coverbox_g:n {研\hfill 究\hfill 方\hfill 向} + & \nju_cover_underline_g:n {\nju_field}\\ + \nju_coverbox_g:n {指\hfill 导\hfill 教\hfill 师} + & \nju_cover_underline_g:n {\nju_mentor_full}\\ + \end{tabular} +} + +% 绘制封面命令 +\tl_new:N \nju_printcover_ug % 本科封面 +\tl_new:N \nju_printcover_g % 研究生封面 + +% 本科封面 +\tl_set:Nn \nju_printcover_ug { + \thispagestyle{empty} + \pagenumbering{Roman} + % Start + \pdfbookmark{封面}{封面} % 将封面插入pdf书签 + \begin{spacing}{1.25} + \vskip 0mm + \hspace{-10mm} + \includegraphics[height=3cm]{njulogo}\smallskip + \begin{center} + \includegraphics[height=3.35cm]{njuname} + \vskip 10mm + {\zihao{1}\makebox[9em][s]{\bf{\songti\nju_type_name}}} + \vfill + \vskip\stretch{0} + {\bgroup + \kaishu\zihao{3} + \def\tabcolsep{1pt} + \def\arraystretch{1.5} + \nju_printcoverinfo_ug % 绘制信息框 + \egroup} + \vfill + \end{center} + \end{spacing} + \cleardoublepage + \vfill + % \newpage +} + +% 研究生封面 +\tl_set:Nn \nju_printcover_g { + \thispagestyle{empty} + \pagenumbering{Roman} + % Start + \pdfbookmark{封面}{封面} % 将封面插入pdf书签 + \begin{spacing}{1.25} + \begin{center} + \hspace{0pt} \vskip 5mm + \includegraphics[height=1.9cm]{njulogo} + \vskip 10mm + \includegraphics[height=1.9cm]{njuname-large} + \vskip 15mm + {\zihao{1}\makebox[10em][s]{\bf{\kaishu\nju_type_name}}} + \vskip 5mm + {\zihao{1}\bf{\kaishu{(申请\nju_degree_title 学位)}}} + \par\vfill + \vskip\stretch{0} + {\bgroup + \bf\kaishu\zihao{3} + \def\tabcolsep{1pt} + \def\arraystretch{1.5} + \vskip 10mm + \nju_printcoverinfo_g % 绘制信息框 + \egroup} + \vfill + \vskip 10mm + \bf\kaishu\zihao{4}\nju_submit_date + \vskip 15mm + \end{center} + \end{spacing} + + \newpage % 封面背面 + \thispagestyle{empty} + \begin{spacing}{1.625} + % TODO: 等待调整格式 + \hspace{0pt} \vfill + {\bgroup + \bf\kaishu\zihao{3} + \makebox[6em][s]{学\hfill 号}:\nju_student_id + \par + \makebox[6em][s]{论文答辩日期}:\nju_defense_date + \par + \makebox[6em][s]{指\hfill 导\hfill 教\hfill 师}:\hspace{50mm}(签字) + \par + \egroup} + \vskip 15mm + \end{spacing} + \cleardoublepage +} + +% 重定义maketitle生成封面 +\RenewDocumentCommand \maketitle {} {% + \str_if_eq:eeTF {\nju_degree} { ug } + { \nju_printcover_ug } % 本科封面 + { \nju_printcover_g } % 研究生封面 +} diff --git a/macros/unicodetex/latex/njuthesis/profile/font.sty b/macros/unicodetex/latex/njuthesis/profile/font.sty new file mode 100644 index 0000000000..d939fb4842 --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/profile/font.sty @@ -0,0 +1,219 @@ +\ProvidesExplPackage{profile/font}{2021-09-11}{0.7.0}{NJU Thesis font configuration} + +% \RequireXeTeX +% \RequireLuaTeX + +% 设置西文字体 +\NewDocumentCommand\set_latin_fontset_windows{}{ + \setmainfont{Times~New~Roman} + \setsansfont{Arial} + \setmonofont{Courier~New}[Scale=MatchLowercase] +} + +\NewDocumentCommand\set_latin_fontset_macos{}{ + \setmainfont{Times~New~Roman} + \setsansfont{Arial} + \setmonofont{Menlo}[Scale=MatchLowercase] +} + +\NewDocumentCommand\set_latin_fontset_gyre{}{ + \setmainfont{texgyretermes}[ + Extension=.otf, + UprightFont=*-regular, + BoldFont=*-bold, + ItalicFont=*-italic, + BoldItalicFont=*-bolditalic] + \setsansfont{texgyreheros}[ + Extension=.otf, + UprightFont=*-regular, + BoldFont=*-bold, + ItalicFont=*-italic, + BoldItalicFont=*-bolditalic] + \setmonofont{texgyrecursor}[ + Extension=.otf, + UprightFont=*-regular, + BoldFont=*-bold, + ItalicFont=*-italic, + BoldItalicFont=*-bolditalic, + Scale=MatchLowercase, + Ligatures=CommonOff] +} + +% 设置中文字体 +\NewDocumentCommand\set_chinese_fontset_windows{}{ + \setCJKmainfont{SimSun}[ + AutoFakeBold=2.17, + ItalicFont=KaiTi] + \setCJKsansfont{SimHei} + \setCJKmonofont{FangSong} + \setCJKfamilyfont{zhsong}{SimSun}[AutoFakeBold=2.17] + \setCJKfamilyfont{zhhei}{SimHei} + \setCJKfamilyfont{zhfs}{FangSong} + \setCJKfamilyfont{zhkai}{KaiTi}[AutoFakeBold=2.17] + \setCJKfamilyfont{zhnewhei}{Microsoft~YaHei}[BoldFont=Microsoft~YaHei~Bold] +} + +\NewDocumentCommand\set_chinese_fontset_macos{}{ + \msg_redirect_name:nnn {fontspec} {no-script} {info} % 移除 does not contain script "CJK" 警告 + \setCJKmainfont{Songti~SC~Light}[ + BoldFont=Songti~SC~Bold, + ItalicFont=Kaiti~SC, + BoldItalicFont=Kaiti~SC~Bold] + \setCJKsansfont{Heiti~SC~Light}[BoldFont=Heiti~SC~Medium] + \setCJKmonofont{STFangsong} + \setCJKfamilyfont{zhsong}{Songti~SC~Light}[BoldFont=Songti~SC~Bold] + \setCJKfamilyfont{zhhei}{Heiti~SC~Light}[BoldFont=Heiti~SC~Medium] + \setCJKfamilyfont{zhfs}{STFangsong} + \setCJKfamilyfont{zhkai}{Kaiti~SC}[BoldFont=Kaiti~SC~Bold] + \setCJKfamilyfont{zhnewhei}{PingFang~SC} +} + +\NewDocumentCommand\set_chinese_fontset_fandol{}{ + \msg_redirect_name:nnn {fontspec} {no-script} {info} % 移除 does not contain script "CJK" 警告 + \setCJKmainfont{FandolSong-Regular}[ + Extension=.otf, + BoldFont=FandolSong-Bold, + ItalicFont=FandolKai-Regular] + \setCJKsansfont{FandolHei-Regular}[ + Extension=.otf, + BoldFont=FandolHei-Bold] + \setCJKmonofont{FandolFang-Regular}[Extension=.otf] + \setCJKfamilyfont{zhsong}{FandolSong-Regular}[ + Extension=.otf, + BoldFont=FandolSong-Bold] + \setCJKfamilyfont{zhhei}{FandolHei-Regular}[ + Extension=.otf, + BoldFont=FandolHei-Bold] + \setCJKfamilyfont{zhfs}{FandolFang-Regular}[Extension=.otf] + \setCJKfamilyfont{zhkai}{FandolKai-Regular}[ + Extension=.otf, + AutoFakeBold=2.17] +} + +% 方正字符集 +\NewDocumentCommand\set_chinese_fontset_founder{}{ + % FZSSK 方正书宋(简繁扩展) http://www.foundertype.com/index.php/FontInfo/index/id/151 免费商用 + % FZXBSK 方正小标宋(简繁扩展) http://www.foundertype.com/index.php/FontInfo/index/id/164 设计师非商免费 + % FZKTK 方正楷体(简繁扩展) http://www.foundertype.com/index.php/FontInfo/index/id/137 免费商用 + \setCJKmainfont{FZSSK}[ + Extension=.ttf, + BoldFont=FZXBSK, + ItalicFont=FZKTK] + % FZXH1K 方正细黑一(简繁扩展) http://www.foundertype.com/index.php/FontInfo/index/id/161 设计师非商免费 + % FZHTK 方正黑体(简繁扩展) http://www.foundertype.com/index.php/FontInfo/index/id/131 免费商用 + \setCJKsansfont{FZXH1K}[ + Extension=.ttf, + BoldFont=FZHTK] + % FZFSK 方正仿宋(简繁扩展) http://www.foundertype.com/index.php/FontInfo/index/id/128 + \setCJKmonofont{FZFSK}[Extension=.ttf] + + \setCJKfamilyfont{zhsong}{FZSSK}[ + Extension=.ttf, + BoldFont=FZXBSK] + \setCJKfamilyfont{zhhei}{FZHTK}[ + Extension=.ttf, + AutoFakeBold=2.17] + \setCJKfamilyfont{zhfs}{FZFSK}[Extension=.ttf] + \setCJKfamilyfont{zhkai}{FZKTK}[Extension=.ttf] + % FZYouHK_508R 方正悠黑508R(简繁扩展) http://www.foundertype.com/index.php/FontInfo/index/id/244 设计师非商免费 + % FZYouHK_511M 方正悠黑511M(简繁扩展) http://www.foundertype.com/index.php/FontInfo/index/id/244 设计师非商免费 + \setCJKfamilyfont{zhnewhei}{FZYouHK_508R}[ + Extension=.ttf, + BoldFont=FZYouHK_511M] +} + +\NewDocumentCommand\set_chinese_fontset_noto{}{ + % 思源宋体 https://www.google.com/get/noto/#serif-hans + \setCJKmainfont[ + UprightFont=NotoSerifCJKsc-Regular, + BoldFont=NotoSerifCJKsc-Bold, + ItalicFont=NotoSerifCJKsc-Regular, + BoldItalicFont=NotoSerifCJKsc-Bold, + ItalicFeatures=FakeSlant, + BoldItalicFeatures=FakeSlant]{Noto~Serif~CJK~SC} + + % 思源黑体 https://www.google.com/get/noto/#sans-hans + \setCJKsansfont[ + UprightFont=NotoSansCJKsc-Regular, + BoldFont=NotoSansCJKsc-Bold, + ItalicFont=NotoSansCJKsc-Regular, + BoldItalicFont=NotoSansCJKsc-Bold, + ItalicFeatures=FakeSlant, + BoldItalicFeatures=FakeSlant]{Noto~Sans~CJK~SC} + + % 包含于上述思源黑体 + \setCJKmonofont[ + UprightFont=NotoSansMonoCJKsc-Regular, + BoldFont=NotoSansMonoCJKsc-Bold, + ItalicFont=NotoSansMonoCJKsc-Regular, + BoldItalicFont=NotoSansMonoCJKsc-Bold, + ItalicFeatures=FakeSlant, + BoldItalicFeatures=FakeSlant]{Noto~Sans~Mono~SC} + + \setCJKfamilyfont{zhsong}{Noto~Serif~CJK~SC} + \setCJKfamilyfont{zhhei}{Noto~Sans~CJK~SC} + + % 方正楷体、方正仿宋为免费商用字体,且支持CJK字符集 + % 方正仿宋 http://www.foundertype.com/index.php/FontInfo/index/id/128.html + % 方正楷体 http://www.foundertype.com/index.php/FontInfo/index/id/137.html + \setCJKfamilyfont{zhfs}{方正仿宋简体}[AutoFakeBold=2.17] + \setCJKfamilyfont{zhkai}{方正楷体简体}[AutoFakeBold=2.17] +} + +% 字体判断 +\bool_if:NTF \nju_systemfont +% 根据操作系统自动选择相应字体 +{ + % 检测是否是 Windows + \sys_if_platform_windows:TF + { + \set_latin_fontset_windows + \set_chinese_fontset_windows + } + { + % 检测是否是 macOS + \ctex_if_platform_macos:TF + { + \set_latin_fontset_macos + \set_chinese_fontset_macos + } + % 其余系统一律使用自由字体 + { + \set_latin_fontset_gyre + \set_chinese_fontset_fandol + } + } +} +{ + % 如果用户需要自定义字体 + % 此处需要使用\str_case_e而不是\str_case使宏展开为字符串 + \str_case_e:nn { \nju_customlatinfont } + { + { windows } { \set_latin_fontset_windows } + { macos } { \set_latin_fontset_macos } + { gyre } { \set_latin_fontset_gyre } + { null } {} + } + \str_case_e:nn { \nju_customchinesefont } + { + { windows } { \set_chinese_fontset_windows } + { macos } { \set_chinese_fontset_macos } + { gyre } { \set_chinese_fontset_gyre } + { founder } { \set_chinese_fontset_founder } + { noto } { \set_chinese_fontset_noto } + { null } {} + } +} +% 选择其他字体,请确保相应字体已安装 + +% 设置数学字体 (XITS, 或者 STIX, 与 Times New Roman 最为相近) +% \setmathfont{STIXTwoMath-Regular}[Extension = .otf] +\setmathfont{XITSMath-Regular}[ + BoldFont = XITSMath-Bold, + Extension = .otf] + +\NewDocumentCommand\songti{}{\CJKfamily{zhsong}} +\NewDocumentCommand\heiti{}{\CJKfamily{zhhei}} +\NewDocumentCommand\fangsong{}{\CJKfamily{zhfs}} +\NewDocumentCommand\kaishu{}{\CJKfamily{zhkai}} +% \NewDocumentCommand\lishu{}{\CJKfamily{zhli}} diff --git a/macros/unicodetex/latex/njuthesis/profile/packages.sty b/macros/unicodetex/latex/njuthesis/profile/packages.sty new file mode 100644 index 0000000000..029488b787 --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/profile/packages.sty @@ -0,0 +1,71 @@ +\ProvidesExplPackage{profile/packages}{2021-09-11}{0.6.0}{NJU Thesis packages used} + +\RequirePackage{expl3} +\RequirePackage{ifxetex} +\RequirePackage{fontspec} +\RequirePackage[ + top=2.5cm, + bottom=2.5cm, + left=3.2cm, + right=3.2cm +]{geometry} +\RequirePackage{ifthen} +\RequirePackage{xparse} +% \RequirePackage{etoolbox} +\RequirePackage{titlesec} % 修改章节标题功能由CTeX提供 +\RequirePackage{titletoc} +% \RequirePackage{appendix} % 定义附录样式 +\RequirePackage{fancyhdr} % 调整页眉页脚 +\RequirePackage[hyphens]{url} % generate better linebreaks in the url +% \RequirePackage[normalem]{ulem} % 绘制下划线 +% \RequirePackage{soul} % 用不起来 +% \RequirePackage{soulutf8} +\RequirePackage{dashundergaps} +\RequirePackage{setspace} +\RequirePackage{lastpage} +\RequirePackage{emptypage} % 清除空白页的页码 +\RequirePackage{listings} % 代码环境 +\RequirePackage{enumitem} % 用于修改列表环境 +\RequirePackage{caption} +\RequirePackage{floatrow} % 用于图表等页面元素的定位 +\RequirePackage{booktabs} % 用于绘制三线表 +\RequirePackage{multirow} % Cells occupying multiple rows in tables +\RequirePackage{multicol} % Multiple columns in dictionary +\RequirePackage{siunitx} % 用于书写单位符号 +\RequirePackage[version=4]{mhchem} % 用于绘制分子式 +\RequirePackage{hologo} % 用于生成可以被插入书签的LaTeX logo +% \RequirePackage{needspace} % Required to prevent page break right after a sectioning command +% \RequirePackage{xspace} % Better print trailing whitespace +\sys_if_engine_xetex:T{ + \RequirePackage{microtype}} +% \sys_if_engine_luatex:T{ +% \RequirePackage{emoji} +% \setemojifont{Segoe UI Emoji} % For windows. +% % Shipped with the best `grinning-face-with-sweat' support. +% % Use `Apple Color Emoji' for macos +% % or `Noto Color Emoji' if you prefer. +% } + +\RequirePackage{blindtext} % 生成用于测试的大段无意义英文文字 +\RequirePackage{zhlipsum} % 生成用于测试的大段无意义中文文字 +% \RequirePackage{showframe} % 加载以后展示内容边界 + +\RequirePackage{amsmath} % Must be loaded before unicode-math +\RequirePackage{amsthm} % Mathematical environments +\RequirePackage{mathtools} % Mathematical tools to use with amsmath +\RequirePackage{thmtools} % Theorem styles +\RequirePackage[ + warnings-off={% 消除与mathtools合用产生的警告 + mathtools-colon, + mathtools-overbracket} + ]{unicode-math} % Math fonts in xetex or luatex + +\RequirePackage{graphicx} +\DeclareGraphicsExtensions{.pdf,.eps,.jpg,.png} +\graphicspath{{figure/}} % 图片路径 +\RequirePackage{wrapfig} % Wrap text around figures + +% 必须以该顺序加载以下三个包 +% \RequirePackage{varioref} +\RequirePackage[hidelinks,bookmarksnumbered=true]{hyperref} +\RequirePackage[capitalise,nameinlink,noabbrev]{cleveref} diff --git a/macros/unicodetex/latex/njuthesis/profile/page.sty b/macros/unicodetex/latex/njuthesis/profile/page.sty new file mode 100644 index 0000000000..e926fa73ea --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/profile/page.sty @@ -0,0 +1,54 @@ +\ProvidesExplPackage{profile/page}{2021-09-11}{0.6.0}{NJU Thesis page layout} + +% 论文页码 页脚居中、五号阿拉伯数字(新罗马体)连续编码 +\fancypagestyle{njuplain}{% + \fancyhead{} + \fancyfoot[C]{\zihao{5}\thepage} +} +% the header line +\tl_set:Nn \headrulewidth {0pt} +% the footer line +\tl_set:Nn \footrulewidth {0pt} + +\AtBeginDocument{\pagestyle{njuplain}} % 无页眉页脚 + +% ctex格式设置 +% 目录标题 三号宋体加粗 +% 各部分标题 四号黑体 +\ctexset{ + contentsname = \songti\bfseries\zihao{3}目\hspace{2em} 录, + chapter/format = \zihao{4}\heiti\centering, + section/format = \zihao{4}\heiti\raggedright, + subsection/format = \zihao{4}\heiti\raggedright, + subsubsection/format = \zihao{4}\heiti\raggedright +} + +% 重定义目录中章节标题样式 +% 目录内容中章的标题 四号黑体 +% 目录中其他内容 小四号宋体 +\titlecontents{chapter}% 标题级别 + [5em]% 标题左间距 + {\heiti\zihao{4}\vspace{10pt}}% 标题格式 + {\contentslabel{4em}}% 标题标志 + {\hspace*{-4em}}% 无序号标题 + {~\titlerule*[0.6pc]{$.$}~\contentspage}% 指引线与页码 + +\titlecontents{section} + [5em] + {\zihao{-4}\vspace{0pt}} + {\contentslabel{2.5em}} + {\hspace*{-4em}} + {~\titlerule*[0.6pc]{$.$}~\contentspage} + +\titlecontents{subsection} + [8em] + {\zihao{-4}\vspace{0pt}} + {\contentslabel{3em}} + {\hspace*{-4em}} + {~\titlerule*[0.6pc]{$.$}~\contentspage} + +% 将目录页插入pdf书签 +\let\savedtableofcontents\tableofcontents +\renewcommand{\tableofcontents}{% + \pdfbookmark{目录}{目录} + \savedtableofcontents} diff --git a/macros/unicodetex/latex/njuthesis/profile/reference.sty b/macros/unicodetex/latex/njuthesis/profile/reference.sty new file mode 100644 index 0000000000..4087f9f561 --- /dev/null +++ b/macros/unicodetex/latex/njuthesis/profile/reference.sty @@ -0,0 +1,68 @@ +\ProvidesExplPackage{profile/reference}{2021-09-11}{0.6.0}{NJU Thesis bibliography and reference} + +% biblatex设置 +\RequirePackage[ + style=gb7714-2015, + %style=numeric-comp, + %citestyle=authortitle-icomp, + % citestyle=numeric-comp, + %bibstyle=authoryear, + % bibstyle=numeric, + sorting=none, + %sorting=nyt, + %sortcites=true, + %autocite=footnote, + backend=biber, % Compile the bibliography with biber + hyperref=true, + backref=false, + citecounter=true, + pagetracker=true, + citetracker=true, + ibidtracker=context, + autopunct=true, + autocite=plain, + % gbpub=false, % Uncomment if you do NOT want '[S.l. : s.n.]' in reference entries, GitHub Issue (#47) + % gbnamefmt=lowercase, % Uncomment if you do NOT want uppercase author names in reference entries, GitHub Issue (#23) +]{biblatex} + +% Remove some unwanted entries from the bibliography +\AtEveryBibitem{ + \clearfield{abstract} + \clearfield{issn} + \clearfield{isbn} + \clearfield{archivePrefix} + \clearfield{arxivId} + \clearfield{pmid} + \clearfield{eprint} + \ifentrytype{online}{}{\ifentrytype{misc}{}{\clearfield{url}}} + % \ifentrytype{book}{\clearfield{doi}}{} +} + +% 修改标签名称 +\crefdefaultlabelformat{#2#1#3\,} % 默认在名称后面添加空格 + +\crefname{figure}{图}{图} +\crefname{table}{表}{表} +% \crefname{equation}{公式}{公式} +\crefformat{equation}{公式~#2#1#3~} % 删除公式编号的括号 + +\crefformat{chapter}{第#2#1#3章} +\crefformat{section}{第~#2#1#3~节} +\crefformat{subsection}{第~#2#1#3~小节} +\crefformat{subsubsection}{第~#2#1#3~小节} +% \crefname{chapter}{§}{§} +% \crefname{section}{§}{§} +% \crefname{subsection}{§}{§} +% \crefname{subsubsection}{§}{§} +\crefname{appendix}{附录}{附录} + +% \crefname{definition}{定义}{定义} +% \crefname{axiom}{公理}{公理} +% \crefname{property}{性质}{性质} +% \crefname{proposition}{命题}{命题} +% \crefname{lemma}{引理}{引理} +% \crefname{corollary}{推论}{推论} +% \crefname{remark}{注解}{注解} +% \crefname{condition}{条件}{条件} +% \crefname{conclusion}{结论}{结论} +% \crefname{assumption}{假设}{假设} |