summaryrefslogtreecommitdiff
path: root/biblio/bibtex/contrib/gbt7714/gbt7714.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'biblio/bibtex/contrib/gbt7714/gbt7714.dtx')
-rw-r--r--biblio/bibtex/contrib/gbt7714/gbt7714.dtx349
1 files changed, 179 insertions, 170 deletions
diff --git a/biblio/bibtex/contrib/gbt7714/gbt7714.dtx b/biblio/bibtex/contrib/gbt7714/gbt7714.dtx
index 4721ba99d6..57254acc42 100644
--- a/biblio/bibtex/contrib/gbt7714/gbt7714.dtx
+++ b/biblio/bibtex/contrib/gbt7714/gbt7714.dtx
@@ -2,7 +2,7 @@
% GB/T 7714-2015 BibTeX Style
% https://github.com/CTeX-org/gbt7714-bibtex-style
%
-% Copyright (C) 2016-2019 by Zeping Lee <zepinglee AT gmail.com>
+% Copyright (C) 2016-2020 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.3c
@@ -12,90 +12,45 @@
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
-%<*internal>
-\iffalse
-\fi
-\begingroup
- \def\nameoflatex{LaTeX2e}
-\expandafter\endgroup\ifx\nameoflatex\fmtname\else
-\csname fi\endcsname
-%</internal>
-%<*install>
-\input docstrip.tex
-\keepsilent
-\askforoverwritefalse
-\preamble
--------------------------------------------------------------------
-GB/T 7714-2015 BibTeX Style
-https://github.com/CTeX-org/gbt7714-bibtex-style
-Version: 2019/11/20 v1.1.2
--------------------------------------------------------------------
-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.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
-\nopostamble
-\generate{
- \file{\jobname.sty}{\from{\jobname.dtx}{package}}
- \file{\jobname-plain.bst}{\from{\jobname.dtx}{2015,authoryear}}
- \file{\jobname-unsrt.bst}{\from{\jobname.dtx}{2015,numerical}}
-}
-\endbatchfile
-%</install>
-%<*internal>
-\fi
-%</internal>
-%<*driver>
-\ProvidesFile{\jobname.dtx}
-%</driver>
+% \fi
+%
+% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{gbt7714}
-%<*package>
- [2019/11/20 v1.1.2 GB/T 7714-2015 BibTeX Style]
-%</package>
+%<package> [2020/03/04 v2.0 GB/T 7714-2015 BibTeX Style]
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
-\usepackage[paper=a4paper,margin=1in,left=1.25in]{geometry}
\usepackage{hypdoc}
-\hypersetup{allcolors=blue}
\usepackage[UTF8]{ctex}
+\usepackage{caption}
+\usepackage{booktabs}
+\usepackage{gbt7714}
+\usepackage{listings}
+\makeatletter
+\hypersetup{allcolors=blue}
\IfFileExists{/System/Library/Fonts/Times.ttc}{
\setmainfont{Times}
\setsansfont[Scale=MatchLowercase]{Helvetica}
\setmonofont[Scale=MatchLowercase]{Menlo}
}{}
-\usepackage{caption}
-\usepackage{booktabs}
-\usepackage{gbt7714}
-\usepackage{listings}
+\citestyle{super}
\lstnewenvironment{latex}{%
- \lstset{%
+ \lstset{
basicstyle = \ttfamily\small,
language = [LaTeX]TeX,
- gobble = 2,
- frame = single,}}{}
+ gobble = 4,
+ frame = single,
+ }%
+}{}
\lstnewenvironment{pseudocode}{%
- \lstset{%
+ \lstset{
basicstyle=\ttfamily\small,
language=bash,
gobble=2,
- frame=single,}}{}
-\makeatletter
-\def\DescribeOption{\leavevmode\@bsphack\begingroup\MakePrivateLetters
- \Describe@Option}
-\def\Describe@Option#1{\endgroup
- \marginpar{\raggedleft\PrintDescribeOption{#1}}%
- \SpecialEnvIndex{#1}\@esphack\ignorespaces}
-\@ifundefined{PrintDescribeOption}
- {\def\PrintDescribeOption#1{\strut \MacroFont #1\ }}{}
+ frame=single,
+ }%
+}{}
\DeclareRobustCommand\file{\nolinkurl}
\DeclareRobustCommand\env{\texttt}
\DeclareRobustCommand\pkg{\textsf}
@@ -121,7 +76,7 @@ version 2005/12/01 or later.
%
%
%
-% \GetFileInfo{\jobname.dtx}
+% \GetFileInfo{gbt7714.sty}
%
% \title{GB/T 7714-2015 \BibTeX{} style}
% \author{Zeping Lee\thanks{zepinglee AT gmail.com}}
@@ -155,45 +110,52 @@ version 2005/12/01 or later.
%
% \section{使用方法}
%
-% \DescribeOption{super}
-% \DescribeOption{numbers}
-% \DescribeOption{authoryear}
% 按照国标的规定,参考文献的标注体系分为“顺序编码制”和
-% “著者-出版年制”(\opt{authoryear}),
-% 其中顺序编码制根据引用标注样式的不同分为角标数字式(\opt{super})和
-% 与正文平排的数字式(\opt{numbers})。
+% “著者-出版年制”。
+% 用户应在导言区调用宏包 \pkg{gbt7714},并且使用 \cs{bibliographystyle}
+% 命令选择参考文献表的样式,比如:
+% \begin{latex}
+% \bibliographystyle{gbt7714-numerical} % 顺序编码制
+% \end{latex}
+% 或者
+% \begin{latex}
+% \bibliographystyle{gbt7714-author-year} % 著者-出版年制
+% \end{latex}
%
-% 用户应在导言区调用宏包 \pkg{gbt7714},并在参数中选择参考文献的标注样式。
-% 默认的参数是 \opt{super},额外的参数会传递给 \pkg{natbib} 宏包,比如:
+% 注意,版本 v2.0 更改了设置参考文献表样式的方法,
+% 要求直接使用 \cs{bibliographystyle},不再使用宏包的参数,
+% 而且更改了 \file{bst} 的文件名。
+%
+% 顺序编码制的引用标注默认使用角标式,
+% 如“张三\textsuperscript{[2]}提出”。
+% 如果要使用正文模式,如“文献 [3] 中说明”,
+% 可以使用 \cs{citestyle} 命令进行切换:
% \begin{latex}
-% \usepackage[authoryear]{gbt7714}
+% \citestyle{numbers}
% \end{latex}
-% 然后\emph{不再}需要调用 \cs{bibliographystyle} 命令设置参考文献列表风格。
+%
+% 同一处引用多篇文献时,应当将各篇文献的 key 一同写在 \cs{cite} 命令中。
+% 如遇连续编号,默认会自动转为起讫序号并用短横线连接
+% (见\pkg{natbib} 的 \opt{compress} 选项)。
+% 如果要对引用的编号进行自动排序,需要在调用 \pkg{gbt7714} 时加
+% \opt{sort\&compress} 参数:
+% \begin{latex}
+% \usepackage[sort&compress]{gbt7714}
+% \end{latex}
+% 这些参数会传给 \pkg{natbib} 处理。
+%
+% 若需要标出引文的页码,可以标在 \cs{cite} 的可选参数中,如
+% |\cite[42]{knuth84}|。
+% 更多的引用标注方法可以参考 \pkg{natbib} 宏包的使用说明\cite{natbib}。
%
% 使用时需要注意以下几点:
% \begin{itemize}
-% \item \emph{不}再需要调用 \cs{bibliographystyle} 命令选择参考文献表的格式。
-% \item bib 数据库应使用 UTF-8 编码。
+% \item \file{.bib} 数据库应使用 UTF-8 编码。
% \item 使用著者-出版年制参考文献表时,中文的文献\emph{必须}
% 在 key 域填写作者姓名的拼音,才能按照拼音排序,
% 详见第~\ref{sec:sort}~节。
% \end{itemize}
%
-% \DescribeMacro{\cite}
-% 在正文中引用文献时应使用 \cs{cite} 命令。
-% 同一处引用多篇文献时,应将各篇文献的 key 一同写在 \cs{cite} 命令中,
-% 如 |\cite{knuth84,lamport94,mittelbach04}|。
-% 如遇连续编号,可以自动转为起讫序号并用短横线连接。
-% 它可以自动排序并用处理连续编号。
-% 若需要标出引文的页码,可以标在 \cs{cite} 的可选参数中,如
-% |\cite[42]{knuth84}|。
-% 更多的引用标注方法可以参考 \pkg{natbib} 宏包的使用说明\cite{natbib}。
-%
-% \DescribeMacro{\bibliography}
-% 参考文献表可以在文中使用 \cs{bibliography} 命令调用。
-% 注意文献列表的样式已经在模板中根据选项设置,
-% 用户\emph{不再}需要使用 \cs{bibliographystyle} 命令。
-%
%
% \section{文献类型}
%
@@ -270,11 +232,12 @@ version 2005/12/01 or later.
% 本宏包默认情况下可以自动识别文献语言,并自动处理文献类型和载体类型标识,
% 但是在少数情况下需要用户手动指定,如:
% \begin{latex}
-% @misc{citekey,
-% language = {japanese},
-% mark = {Z},
-% medium = {DK},
-% ...
+% @misc{citekey,
+% language = {japanese},
+% mark = {Z},
+% medium = {DK},
+% ...
+% }
% \end{latex}
% 可选的语言有 english, chinese, japanese, russian。
%
@@ -288,11 +251,14 @@ version 2005/12/01 or later.
% 然而由于 \BibTeX{} 功能的局限性,无法自动获取著者姓名的拼音或笔画笔顺,
% 所以\emph{必须}在 bib 数据库中的 key 域手动录入著者姓名的拼音,如:
% \begin{latex}
-% @book{capital,
-% author = {马克思 and 恩格斯},
-% key = {ma3 ke4 si1 en1 ge2 si1},
-% ...
+% @book{capital,
+% author = {马克思 and 恩格斯},
+% key = {ma3 ke4 si1 en1 ge2 si1},
+% ...
+% }
% \end{latex}
+% 注意名字之间需要额外的空格,比如“张三, 李四”要排在
+% “张三丰”前面。
%
%
% \section{自定义样式}
@@ -320,6 +286,7 @@ version 2005/12/01 or later.
% sentence.case.title & |#1| & 将西文的题名转为 sentence case \\
% link.title & |#0| & 在题名上添加 url 的超链接 \\
% show.mark & |#1| & 显示文献类型标识 \\
+% show.medium.type & |#1| & 显示载体类型标识 \\
% italic.jounal & |#0| & 西文期刊名使用斜体 \\
% show.missing.address.publisher & |#1| & 出版项缺失时显示“出版者不详” \\
% show.url & |#1| & 显示 url \\
@@ -445,28 +412,56 @@ version 2005/12/01 or later.
%
% \section{宏包的代码实现}
%
-% 下面声明和处理宏包的选项,有 \opt{authoryear} 和 \opt{numbers}。
+% 兼容过时的接口
% \begin{macrocode}
%<*package>
-\newif\if@gbt@mmxv
-\newif\if@gbt@numerical
-\newif\if@gbt@super
-\DeclareOption{2015}{\@gbt@mmxvtrue}
-\DeclareOption{2005}{\@gbt@mmxvfalse}
-\DeclareOption{super}{\@gbt@numericaltrue\@gbt@supertrue}
-\DeclareOption{numbers}{\@gbt@numericaltrue\@gbt@superfalse}
-\DeclareOption{authoryear}{\@gbt@numericalfalse}
+\newif\ifgbt@legacy@interface
+\newif\ifgbt@mmxv
+\newif\ifgbt@numerical
+\newif\ifgbt@super
+\newcommand\gbt@obselete@option[1]{%
+ \PackageWarning{gbt7714}{The option "#1" is obselete}%
+}
+\DeclareOption{authoryear}{}
+
+\DeclareOption{2015}{%
+ \gbt@obselete@option{2015}%
+ \gbt@legacy@interfacetrue
+ \gbt@mmxvtrue
+}
+\DeclareOption{2005}{%
+ \gbt@obselete@option{2005}%
+ \gbt@legacy@interfacetrue
+ \gbt@mmxvfalse
+}
+\DeclareOption{super}{%
+ \gbt@obselete@option{super}%
+ \gbt@legacy@interfacetrue
+ \gbt@numericaltrue
+ \gbt@supertrue
+}
+\DeclareOption{numbers}{%
+ \gbt@obselete@option{numbers}%
+ \gbt@legacy@interfacetrue
+ \gbt@numericaltrue
+ \gbt@superfalse
+}
+\DeclareOption{authoryear}{%
+ \gbt@obselete@option{authoryear}%
+ \gbt@legacy@interfacetrue
+ \gbt@numericalfalse
+}
+% \end{macrocode}
+%
+% 将选项传递给 \pkg{natbib}
+% \begin{macrocode}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{natbib}}
-\ExecuteOptions{2015,super}
\ProcessOptions\relax
% \end{macrocode}
%
-% 只在顺序编码时使用 \opt{sort\&compress}。
+% 调用宏包,注意只需要 \opt{compress} 不需要 \opt{sort}。
% \begin{macrocode}
-\if@gbt@numerical
- \PassOptionsToPackage{sort&compress}{natbib}
-\fi
-\RequirePackage{natbib}
+\RequirePackage[compress]{natbib}
\RequirePackage{url}
% \end{macrocode}
%
@@ -477,51 +472,16 @@ version 2005/12/01 or later.
\newcommand\bibstyle@super{\bibpunct{[}{]}{,}{s}{,}{\textsuperscript{,}}}
\newcommand\bibstyle@numbers{\bibpunct{[}{]}{,}{n}{,}{,}}
\newcommand\bibstyle@authoryear{\bibpunct{(}{)}{;}{a}{,}{,}}
+\newcommand\bibstyle@inline{\bibstyle@numbers}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\gbtbibstyle}
-% 定义接口切换参考文献表的风格,可选 \opt{authoryear} 和 \opt{numerical},
-% 这个仅用于\pkg{chapterbib}。
+% 在使用 \cs{bibliographystyle} 时自动切换引用文献的标注的样式。
% \begin{macrocode}
-\newcommand\gbtbibstyle[1]{%
- \@ifundefined{gbt@bib@#1}{%
- \PackageError{gbt7714}{Invalid argument #1}{}%
- }{%
- \@nameuse{gbt@bib@#1}
- }%
-}
-\newcommand\gbt@bib@numerical{%
- \if@gbt@mmxv
- \bibliographystyle{gbt7714-unsrt}%
- \else
- \bibliographystyle{gbt7714-2005-unsrt}%
- \fi
-}
-\newcommand\gbt@bib@authoryear{%
- \if@gbt@mmxv
- \bibliographystyle{gbt7714-plain}%
- \else
- \bibliographystyle{gbt7714-2005-plain}%
- \fi
-}
-% \end{macrocode}
-% \end{macro}
-%
-% 处理宏包选项。
-% \begin{macrocode}
-\if@gbt@numerical
- \if@gbt@super
- \citestyle{super}%
- \gbtbibstyle{numerical}%
- \else
- \citestyle{numbers}
- \gbtbibstyle{numerical}%
- \fi
-\else
- \citestyle{authoryear}
- \gbtbibstyle{authoryear}%
-\fi
+\@namedef{bibstyle@gbt7714-numerical}{\bibstyle@super}
+\@namedef{bibstyle@gbt7714-author-year}{\bibstyle@authoryear}
+\@namedef{bibstyle@gbt7714-2005-numerical}{\bibstyle@super}
+\@namedef{bibstyle@gbt7714-2005-author-year}{\bibstyle@authoryear}
% \end{macrocode}
%
% \begin{macro}{\cite}
@@ -572,8 +532,6 @@ version 2005/12/01 or later.
%
% 在顺序编码制下,\pkg{natbib} 只有在三个以上连续文献引用才会使用连接号,
% 这里修改为允许两个引用使用连接号。
-% \changes{v1.0.3}{2018/03/29}{顺序编码制连续两个文献引用之间使用连接号}
-% \changes{v1.0.4}{2018/04/12}{页码的连接号由 en dash 改为 hyphen}
% \begin{macrocode}
% \ifx\NAT@last@yr\relax
% \def@NAT@last@yr{\@citea}%
@@ -762,10 +720,44 @@ version 2005/12/01 or later.
\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
}
\Urlmuskip=0mu plus 0.1mu
-%</package>
% \end{macrocode}
% \end{macro}
%
+% 兼容 v2.0 前过时的接口:
+% \begin{macrocode}
+\newif\ifgbt@bib@style@written
+\@ifpackageloaded{chapterbib}{}{%
+ \def\bibliography#1{%
+ \ifgbt@bib@style@written\else
+ \bibliographystyle{gbt7714-numerical}%
+ \fi
+ \if@filesw
+ \immediate\write\@auxout{\string\bibdata{\zap@space#1 \@empty}}%
+ \fi
+ \@input@{\jobname.bbl}}
+ \def\bibliographystyle#1{%
+ \gbt@bib@style@writtentrue
+ \ifx\@begindocumenthook\@undefined\else
+ \expandafter\AtBeginDocument
+ \fi
+ {\if@filesw
+ \immediate\write\@auxout{\string\bibstyle{#1}}%
+ \fi}%
+ }%
+}
+\ifgbt@legacy@interface
+ \ifgbt@numerical
+ \ifgbt@super\else
+ \citestyle{numbers}
+ \fi
+ \bibliographystyle{gbt7714-numerical}
+ \else
+ \bibliographystyle{gbt7714-author-year}
+ \fi
+\fi
+%</package>
+% \end{macrocode}
+%
%
%
% \section{BibTeX 样式的代码实现}
@@ -787,6 +779,7 @@ INTEGERS {
sentence.case.title
link.title
show.mark
+ show.medium.type
slash.for.extraction
in.booktitle
italic.jounal
@@ -864,6 +857,14 @@ FUNCTION {load.config}
%</nomark>
% \end{macrocode}
%
+% 是否显示载体类型标识(比如“/OL“):
+% \begin{macrocode}
+ #1 'show.medium.type :=
+%<*no.medium.type>
+ #0 'show.medium.type :=
+%</no.medium.type>
+% \end{macrocode}
+%
% 使用“//”表示析出文献
% \begin{macrocode}
#1 'slash.for.extraction :=
@@ -2186,14 +2187,20 @@ FUNCTION {format.mark}
medium empty$ not or entry.is.electronic or
and
%</thu>
- { medium empty$ not
- { entry.mark "/" * medium * 'entry.mark := }
- { entry.is.electronic
- { entry.mark "/OL" * 'entry.mark := }
- 'skip$
+ { entry.mark
+ show.medium.type
+ { medium empty$ not
+ { "/" * medium * }
+ { entry.is.electronic
+ { "/OL" * }
+ 'skip$
+ if$
+ }
if$
}
+ 'skip$
if$
+ 'entry.mark :=
%<*!thu>
"\allowbreak[" entry.mark * "]" *
%</!thu>
@@ -3914,14 +3921,16 @@ FUNCTION {begin.bib}
write$ newline$
"\providecommand{\url}[1]{#1}"
write$ newline$
- "\expandafter\ifx\csname urlstyle\endcsname\relax\relax\else"
+ "\expandafter\ifx\csname urlstyle\endcsname\relax\else"
write$ newline$
" \urlstyle{same}\fi"
write$ newline$
show.doi
- { "\providecommand{\href}[2]{\url{#2}}"
+ { "\expandafter\ifx\csname href\endcsname\relax"
+ write$ newline$
+ " \def\doi#1{#1}\else"
write$ newline$
- "\providecommand{\doi}[1]{\href{https://doi.org/#1}{#1}}"
+ " \def\doi#1{\href{https://doi.org/#1}{#1}}\fi"
write$ newline$
}
'skip$