summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/bibtex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-05-22 20:58:47 +0000
committerKarl Berry <karl@freefriends.org>2018-05-22 20:58:47 +0000
commit12cab12548df582e0a7816b48aae10f79bdf430f (patch)
treea859df308620415524d29b0a40b0b2aa3e1693fb /Master/texmf-dist/source/bibtex
parent8877a03ea3c158d7a486d14c9cc37dc2134731ef (diff)
gbt7714 (22may18)
git-svn-id: svn://tug.org/texlive/trunk@47792 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/bibtex')
-rw-r--r--Master/texmf-dist/source/bibtex/gbt7714/gbt7714.dtx396
1 files changed, 236 insertions, 160 deletions
diff --git a/Master/texmf-dist/source/bibtex/gbt7714/gbt7714.dtx b/Master/texmf-dist/source/bibtex/gbt7714/gbt7714.dtx
index 42d50b170d5..d2003e067ad 100644
--- a/Master/texmf-dist/source/bibtex/gbt7714/gbt7714.dtx
+++ b/Master/texmf-dist/source/bibtex/gbt7714/gbt7714.dtx
@@ -3,17 +3,12 @@
% Copyright (C) 2016-2018 by Zeping Lee <zepinglee AT gmail.com>
%
% This file may be distributed and/or modified under the
-% conditions of the LaTeX Project Public License, either
-% version 1.2 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.2 or later is part of all distributions of
-% LaTeX version 1999/12/01 or later.
-%
-% This file is derived from both `btxbst.doc' by Oren Patashnik and
-% `plainnat.bst' by Patrick W Daly.
+% conditions of the LaTeX Project Public License, either version 1.3c
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+% https://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
%
%<*internal>
\iffalse
@@ -30,40 +25,34 @@
Copyright (C) 2016-\the\year by Zeping Lee <zepinglee AT gmail.com>
This file may be distributed and/or modified under the
-conditions of the LaTeX Project Public License, either
-version 1.2 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.2 or later is part of all distributions of
-LaTeX version 1999/12/01 or later.
-
-This BibTeX style file is derived from `plainnat.bst' by Patrick W Daly,
-which was designed for use with the `natbib.sty' package.
+conditions of the LaTeX Project Public License, either version 1.3c
+of this license or (at your option) any later version.
+The latest version of this license is in
+ https://www.latex-project.org/lppl.txt
+and version 1.3c or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
\endpreamble
\keepsilent
\askforoverwritefalse
\nopostamble
\generate{
- \file{\jobname.sty}{\from{\jobname.dtx}{package}}
- \file{\jobname-plain.bst}{\from{\jobname.dtx}{authoryear}}
- \file{\jobname-unsrt.bst}{\from{\jobname.dtx}{numerical}}
+ \file{\jobname.sty}{\from{\jobname.dtx}{package}}
+ \file{\jobname-plain.bst}{\from{\jobname.dtx}{authoryear}}
+ \file{\jobname-unsrt.bst}{\from{\jobname.dtx}{numerical}}
}
-\Msg{* Happy TeXing!}
\endbatchfile
%</install>
%<*internal>
\fi
%</internal>
%<*driver>
-\ProvidesFile{gbt7714.dtx}
+\ProvidesFile{\jobname.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{gbt7714}
%<*package>
- [2018/03/16 v1.0.3 GB/T 7714-2015 BibTeX Style]
+ [2018/05/12 v1.0.7 GB/T 7714-2015 BibTeX Style]
%</package>
%
%<*driver>
@@ -99,13 +88,30 @@ which was designed for use with the `natbib.sty' package.
\renewcommand\glossaryname{版本历史}
\GlossaryPrologue{\section*{\glossaryname}}
\renewcommand\indexname{命令索引}
+\makeatletter
+\renewcommand*{\changes@}[3]{%
+ \protected@edef\@tempa{%
+ \noexpand\glossary{#1 (#2)\levelchar
+ \ifx\saved@macroname\@empty
+ \space\actualchar\generalname
+ \else
+ \expandafter\@gobble\saved@macroname
+ \actualchar
+ \string\verb\quotechar*\verbatimchar\saved@macroname\verbatimchar
+ \fi
+ :\levelchar #3}}%
+ \@tempa
+ \endgroup
+ \@esphack
+}
+\makeatother
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\OnlyDescription
\begin{document}
- \DocInput{gbt7714.dtx}
+ \DocInput{\jobname.dtx}
\PrintChanges
\PrintIndex
\end{document}
@@ -130,19 +136,9 @@ which was designed for use with the `natbib.sty' package.
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
-% \DoNotIndex{%
-% \a,\b,\c,\d,\e,\f,\g,\h,\i,\j,%
-% \k,\l,\m,\n,\o,\p,\q,\r,\s,\t,%
-% \u,\v,\w,\x,\y,\z,%
-% \A,\B,\C,\D,\E,\F,\G,\H,\I,\J,%
-% \K,\L,\M,\N,\O,\P,\Q,\R,\S,\T,%
-% \U,\V,\W,\X,\Y,\Z,%
-% \1,\2,\3,\4,\5,\6,\7,\8,\9,\0,%
-% }
-%
%
%
-% \GetFileInfo{gbt7714.dtx}
+% \GetFileInfo{\jobname.dtx}
%
% \title{GB/T 7714-2015 \BibTeX{} style}
% \author{Zeping Lee\thanks{zepinglee AT gmail.com}}
@@ -150,6 +146,14 @@ which was designed for use with the `natbib.sty' package.
% \maketitle
%
% \changes{v1.0}{2018/01/01}{Initial release.}
+% \changes{v1.0.1}{2018/03/09}{著者出版年制的文献引用不再排序}
+% \changes{v1.0.2}{2017/03/16}{正确识别姓名中的“others”}
+% \changes{v1.0.3}{2018/03/29}{顺序编码制连续两个文献引用之间使用连接号}
+% \changes{v1.0.4}{2018/04/12}{页码的连接号由 en dash 改为 hyphen}
+% \changes{v1.0.5}{2018/04/18}{允许著录多个 DOI}
+% \changes{v1.0.6}{2018/05/10}{不再处理中文标题的英文单词的大小写}
+% \changes{v1.0.6}{2018/05/10}{文献列表的数字标签左对齐}
+% \changes{v1.0.7}{2018/05/12}{修正了检测 Unicode 语言}
%
%
% \section{简介}
@@ -164,12 +168,7 @@ which was designed for use with the `natbib.sty' package.
% \end{itemize}
%
%
-% \section{相关工作}
-%
-% TeX 社区一直在努力实现国家的参考文献推荐标准。2005 年
-%
-%
-% \section{使用宏包}
+% \section{使用方法}
%
% 首先应在导言区调用宏包 \pkg{gbt7714} ,可以选择的参数如
% 表~\ref{tab:options}。
@@ -244,7 +243,7 @@ which was designed for use with the `natbib.sty' package.
%
% \section{著录项目}
%
-% 以下列出了本宏包支持的全部著录项目。
+% 表~\ref{tab:fields} 列出了本宏包支持的全部著录项目。
%
% \begin{table}[htbp]
% \centering
@@ -275,16 +274,18 @@ which was designed for use with the `natbib.sty' package.
% 引用日期 & urldate* \\
% 获取和访问路径 & url \\
% 数字对象唯一标识符 & doi \\
-% 拼音(用于排序) & key \\
% 语言 & language* \\
+% 拼音(用于排序) & key \\
% \bottomrule
% \end{tabular}
-% \caption{全部著录项目,其中带星号的不是 \BibTeX{}/natbib 的标准著录项目。}
+% \caption{全部著录项目,其中带星号的不是 \BibTeX{}/natbib 的标准著录项目。
+% 不支持的 \BibTeX{} 标准著录项目有 annote, chapter, crossref,
+% howpublished, month, note, type。}
% \label{tab:fields}
% \end{table}
%
-% 由于《规则》中要的著录项目比 \BibTeX{} 支持的要多,新增的项目尽可能同
-% BibLaTeX 一致,如 date 和 urldate。
+% 由于《规则》中要求的著录项目比 \BibTeX{} 支持的要多,必须新增一些著录项目,
+% 这些新增的类型在设计时参考了 BibLaTeX,如 date 和 urldate。
%
% 本宏包默认情况下可以自动识别文献语言,并自动处理文献类型和载体类型标识,
% 但是在少数情况下需要用户手动指定,如:
@@ -298,6 +299,7 @@ which was designed for use with the `natbib.sty' package.
% 可选的语言有 english, chinese, japanese, russian,
% 目前对日语和俄语的支持较为有限。
%
+%
% \section{参考文献列表的排序}
%
% 在使用著者-出版年制时,需要将中文参考文献按照拼音或者笔画排序,然而 Unicode
@@ -311,6 +313,8 @@ which was designed for use with the `natbib.sty' package.
% ...
% \end{latex}
%
+%
+%
% \StopEventually{}
%
% \section{Package}
@@ -328,25 +332,6 @@ which was designed for use with the `natbib.sty' package.
\ProcessOptions\relax
% \end{macrocode}
%
-% 需要 \pkg{url} 宏包。
-% \begin{macrocode}
-\RequirePackage{url}
-% \end{macrocode}
-%
-% 增加 URL 可断行的位置。
-% \begin{macrocode}
-\g@addto@macro\UrlBreaks{%
- \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
- \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
- \do\u\do\v\do\w\do\x\do\y\do\z%
- \do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J%
- \do\K\do\L\do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T%
- \do\U\do\V\do\W\do\X\do\Y\do\Z%
- \do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\0%
-}
-% \end{macrocode}
-%
-% \changes{v1.0.1}{2018/03/09}{在 author-year 模式下不再对引用排序。}
% 只在顺序编码时使用 \opt{sort\&compress}。
% \begin{macrocode}
\if@gbt@numerical
@@ -444,7 +429,8 @@ which was designed for use with the `natbib.sty' package.
#1\NAT@@close\if*#3*\else\textsuperscript{#3}\fi\else#1\fi\endgroup}
% \end{macrocode}
%
-% \changes{v1.0.3}{2018/03/29}{顺序编码制连续两个文献引用之间使用连接号}
+% 在顺序编码制下,\pkg{natbib} 只有在三个以上连续文献引用才会使用连接号,
+% 这里修改为允许两个引用使用连接号。
% \begin{macrocode}
\patchcmd{\NAT@citexnum}{%
\ifx\NAT@last@yr\relax
@@ -453,11 +439,35 @@ which was designed for use with the `natbib.sty' package.
\def@NAT@last@yr{--\NAT@penalty}%
\fi
}{%
- \def@NAT@last@yr{--\NAT@penalty}%
+ \def@NAT@last@yr{-\NAT@penalty}%
}{}{}
+% \end{macrocode}
+%
+% 参考文献列表的标签左对齐
+% \begin{macrocode}
+\renewcommand\@biblabel[1]{[#1]\hfill}
+% \end{macrocode}
+%
+% 需要 \pkg{url} 宏包显示 URL。
+% \begin{macrocode}
+\RequirePackage{url}
+% \end{macrocode}
+%
+% 增加 URL 可断行的位置。
+% \begin{macrocode}
+\g@addto@macro\UrlBreaks{%
+ \do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j%
+ \do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t%
+ \do\u\do\v\do\w\do\x\do\y\do\z%
+ \do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J%
+ \do\K\do\L\do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T%
+ \do\U\do\V\do\W\do\X\do\Y\do\Z%
+ \do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\0%
+}
%</package>
% \end{macrocode}
%
+%
% \section{BibTeX style implementation}
%
% \subsection{Fields and entry strings}
@@ -663,7 +673,7 @@ INTEGERS { output.state before.all mid.sentence after.sentence after.block after
INTEGERS { lang.zh lang.ja lang.en lang.ru lang.other }
-INTEGERS { charptr stringlength }
+INTEGERS { charptr len }
FUNCTION {init.state.consts}
{ #0 'before.all :=
@@ -1023,27 +1033,7 @@ FUNCTION {emphasize}
if$
}
-INTEGERS { ascii }
-
-FUNCTION {get.char.lang}
-{ chr.to.int$ 'ascii :=
- ascii #64 > ascii #91 < and ascii #96 > ascii #123 < and or
- { lang.en }
- { ascii #227 > ascii #234 < and
- { lang.zh }
- { ascii #227 =
- { lang.ja }
- { ascii #207 > ascii #212 < and
- { lang.ru }
- { lang.en }
- if$
- }
- if$
- }
- if$
- }
- if$
-}
+INTEGERS { byte second.byte }
INTEGERS { char.lang tmp.lang }
@@ -1052,29 +1042,88 @@ STRINGS { tmp.str }
FUNCTION {get.str.lang}
{ 'tmp.str :=
lang.other 'tmp.lang :=
- tmp.str empty$
- { "Empty string!" warning$ }
- { #1 'charptr :=
- tmp.str text.length$ #1 + 'stringlength :=
- { charptr stringlength < }
- { tmp.str charptr #1 substring$ get.char.lang 'char.lang :=
- char.lang tmp.lang >
- { char.lang 'tmp.lang := }
- 'skip$
+ #1 'charptr :=
+ tmp.str text.length$ #1 + 'len :=
+ { charptr len < }
+ { tmp.str charptr #1 substring$ chr.to.int$ 'byte :=
+ byte #128 <
+ { charptr #1 + 'charptr :=
+ byte #64 > byte #91 < and byte #96 > byte #123 < and or
+ { lang.en 'char.lang := }
+ { lang.other 'char.lang := }
if$
-
- char.lang lang.zh = char.lang lang.ja = or
- { charptr #3 + 'charptr := }
- { char.lang lang.ru =
- { charptr #2 + 'charptr := }
- { charptr #1 + 'charptr := }
+ }
+ { tmp.str charptr #1 + #1 substring$ chr.to.int$ 'second.byte :=
+ byte #224 <
+% \end{macrocode}
+% 俄文西里尔字母:U+0400 到 U+052F,对应 UTF-8 从 D0 80 到 D4 AF。
+% \begin{macrocode}
+ { charptr #2 + 'charptr :=
+ byte #207 > byte #212 < and
+ byte #212 = second.byte #176 < and or
+ { lang.ru 'char.lang := }
+ { lang.other 'char.lang := }
+ if$
+ }
+ { byte #240 <
+% \end{macrocode}
+% CJK Unified Ideographs: U+4E00--U+9FFF; UTF-8: E4 B8 80--E9 BF BF.
+% \begin{macrocode}
+ { charptr #3 + 'charptr :=
+ byte #227 > byte #234 < and
+ { lang.zh 'char.lang := }
+% \end{macrocode}
+% CJK Unified Ideographs Extension A: U+3400--U+4DBF; UTF-8: E3 90 80--E4 B6 BF.
+% \begin{macrocode}
+ { byte #227 =
+ { second.byte #143 >
+ { lang.zh 'char.lang := }
+% \end{macrocode}
+% 日语假名:U+3040--U+30FF, UTF-8: E3 81 80--E3 83 BF.
+% \begin{macrocode}
+ { second.byte #128 > second.byte #132 < and
+ { lang.ja 'char.lang := }
+ { lang.other 'char.lang := }
+ if$
+ }
+ if$
+ }
+% \end{macrocode}
+% CJK Compatibility Ideographs: U+F900--U+FAFF, UTF-8: EF A4 80--EF AB BF.
+% \begin{macrocode}
+ { byte #239 =
+ second.byte #163 > second.byte #172 < and and
+ { lang.zh 'char.lang := }
+ { lang.other 'char.lang := }
+ if$
+ }
+ if$
+ }
+ if$
+ }
+% \end{macrocode}
+% CJK Unified Ideographs Extension B--F: U+20000--U+2EBEF,
+% UTF-8: F0 A0 80 80--F0 AE AF AF.
+% CJK Compatibility Ideographs Supplement: U+2F800--U+2FA1F,
+% UTF-8: F0 AF A0 80--F0 AF A8 9F.
+% \begin{macrocode}
+ { charptr #4 + 'charptr :=
+ byte #240 = second.byte #159 > and
+ { lang.zh 'char.lang := }
+ { lang.other 'char.lang := }
+ if$
+ }
if$
}
if$
}
- while$
+ if$
+ char.lang tmp.lang >
+ { char.lang 'tmp.lang := }
+ 'skip$
+ if$
}
- if$
+ while$
tmp.lang
}
@@ -1098,11 +1147,6 @@ FUNCTION {format.anonymous}
INTEGERS { nameptr namesleft numnames name.lang }
-% \end{macrocode}
-%
-% \changes{v1.0.2}{2017/03/16}{修正参考文献姓名的“others”}
-%
-% \begin{macrocode}
FUNCTION {format.names}
{ 's :=
#1 'nameptr :=
@@ -1192,27 +1236,61 @@ FUNCTION {format.url}
%
% \begin{macrocode}
FUNCTION {is.doi.in.url}
-{ url empty$
- { #0 }
- { doi text.length$ 'stringlength :=
- url text.length$ 'charptr :=
- { url charptr stringlength substring$ doi = not
- charptr #0 >
- and
+{ 's :=
+ s empty$
+ { #1 }
+ { url empty$
+ { #0 }
+ { s text.length$ 'len :=
+ url text.length$ 'charptr :=
+ { url charptr len substring$ s = not
+ charptr #0 >
+ and
+ }
+ { charptr #1 - 'charptr := }
+ while$
+ charptr
}
- { charptr #1 - 'charptr := }
- while$
- charptr
+ if$
}
if$
}
FUNCTION {format.doi}
-{ doi empty$
- { "" }
- { is.doi.in.url
+{ ""
+ doi empty$
+ 'skip$
+ { "" 's :=
+ doi 't :=
+ #0 'numnames :=
+ { t empty$ not}
+ { t #1 #1 substring$ 'tmp.str :=
+ tmp.str "," = tmp.str " " = or t #2 #1 substring$ empty$ or
+ { t #2 #1 substring$ empty$
+ { s tmp.str * 's := }
+ 'skip$
+ if$
+ s empty$ s is.doi.in.url or
+ 'skip$
+ { numnames #1 + 'numnames :=
+ numnames #1 >
+ { ", " * }
+ { "DOI: " * }
+ if$
+ "\doi{" s * "}" * *
+ }
+ if$
+ "" 's :=
+ }
+ { s tmp.str * 's := }
+ if$
+ t #2 global.max$ substring$ 't :=
+ }
+ while$
+ 's :=
+ s empty$ not
+ { new.block s }
{ "" }
- { new.block "\doi{" doi * "}" * }
if$
}
if$
@@ -1230,7 +1308,12 @@ FUNCTION {format.doi}
FUNCTION {format.title}
{ title empty$
{ "" }
- { title "t" change.case$ }
+ { title
+ entry.lang lang.en =
+ { "t" change.case$ }
+ 'skip$
+ if$
+ }
if$
}
@@ -1390,23 +1473,18 @@ FUNCTION {output.bibitem}
% END
% \end{pseudocode}
%
+% 《规则》里页码范围的连接号使用 hyphen,需要将 dash 转为 hyphen。
+%
% \begin{macrocode}
-FUNCTION {n.dashify}
+FUNCTION {hyphenate}
{ 't :=
""
{ t empty$ not }
{ t #1 #1 substring$ "-" =
- { t #1 #2 substring$ "--" = not
- { "--" *
- t #2 global.max$ substring$ 't :=
- }
- { { t #1 #1 substring$ "-" = }
- { "-" *
- t #2 global.max$ substring$ 't :=
- }
- while$
- }
- if$
+ { "-" *
+ { t #1 #1 substring$ "-" = }
+ { t #2 global.max$ substring$ 't := }
+ while$
}
{ t #1 #1 substring$ *
t #2 global.max$ substring$ 't :=
@@ -1431,8 +1509,8 @@ FUNCTION {extract.before.dash}
{ pop$ "" }
{ 's :=
#1 'charptr :=
- s text.length$ #1 + 'stringlength :=
- { charptr stringlength <
+ s text.length$ #1 + 'len :=
+ { charptr len <
s charptr #1 substring$ "-" = not
and
}
@@ -1448,14 +1526,14 @@ FUNCTION {extract.after.dash}
{ pop$ "" }
{ 's :=
#1 'charptr :=
- s text.length$ #1 + 'stringlength :=
- { charptr stringlength <
+ s text.length$ #1 + 'len :=
+ { charptr len <
s charptr #1 substring$ "-" = not
and
}
{ charptr #1 + 'charptr := }
while$
- { charptr stringlength <
+ { charptr len <
s charptr #1 substring$ "-" =
and
}
@@ -1640,7 +1718,7 @@ FUNCTION {format.volume}
{ "" }
{ volume is.number
{ is.in.chinese
- { "第" volume * "卷" * }
+ { "第 " volume * " 卷" * }
{ "volume" volume tie.or.space.connect }
if$
}
@@ -1655,7 +1733,7 @@ FUNCTION {format.number}
{ "" }
{ number is.number
{ is.in.chinese
- { "第" number * "册" * }
+ { "第 " number * " 册" * }
{ "number" number tie.or.space.connect }
if$
}
@@ -1689,7 +1767,10 @@ FUNCTION {format.series.vol.num.title}
if$
}
if$
- "t" change.case$
+ entry.lang lang.en =
+ { "t" change.case$ }
+ 'skip$
+ if$
}
FUNCTION {format.series.vol.num.booktitle}
@@ -1740,7 +1821,7 @@ FUNCTION {format.edition}
{ "" }
{ edition is.number
{ is.in.chinese
- { edition "版" * }
+ { edition " 版" * }
{ edition num.to.ordinal " ed." * }
if$
}
@@ -1771,12 +1852,9 @@ FUNCTION {format.sine.loco}
if$
}
-FUNCTION {format.address}
-{ address }
-
FUNCTION {format.sine.nomine}
{ is.in.chinese
- { "[出版地不详]" }
+ { "[出版者不详]" }
{ "[s.n.]" }
if$
}
@@ -1844,7 +1922,7 @@ FUNCTION {format.address.publisher}
FUNCTION {format.pages}
{ pages empty$
{ "" }
- { pages n.dashify }
+ { pages hyphenate }
if$
}
@@ -2645,8 +2723,6 @@ FUNCTION {sortify}
% We need the chop.word stuff for the dubious unsorted-list-with-labels case.
%
% \begin{macrocode}
-INTEGERS { len }
-
FUNCTION {chop.word}
{ 's :=
'len :=
@@ -3127,7 +3203,7 @@ FUNCTION {begin.bib}
write$ newline$
"\providecommand{\href}[2]{\url{#2}}"
write$ newline$
- "\providecommand{\doi}[1]{DOI: \href{http://dx.doi.org/#1}{#1}}"
+ "\providecommand{\doi}[1]{\href{https://doi.org/#1}{#1}}"
write$ newline$
"\expandafter\ifx\csname urlstyle\endcsname\relax\relax\else"
write$ newline$