hushidong / biblatex-gb7714-2015

A biblatex implementation of the GB/T7714-2015 bibliography style || GB/T 7714-2015 参考文献著录和标注的biblatex样式包
765 stars 84 forks source link

用法:作者年制引用标签中最后一个作者前面逗号变为“和” #125

Open hushidong opened 2 years ago

hushidong commented 2 years ago

示例:

% !Mode:: "TeX:UTF-8"
% 用于测试
\documentclass{article}
\usepackage{ctex}

\usepackage[backend=biber,style=gb7714-2015ay,maxcitenames=3,
    mincitenames=1,gbcitelocal=chinese]{biblatex}

\DeclareDelimFormat{finalnamedelim}{%
  \edef\userfieldabcde{userd}%
  \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
  \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
  \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
  \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
  \ifcase\value{gbcitelocalcase}%
    \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andincitecn}}{}%
    \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
    \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
    \iffieldequalstr{\userfieldabcde}{english}{\bibstring{andincite}}{}%
    \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
    \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
  \or%
  \bibstring{andincitecn}%\space%
  \or%
\bibstring{andincite}%
  \fi}

\DeclareDelimFormat[bib,biblist]{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace%
  \edef\userfieldabcde{userd}%
  \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
  \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
  \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
  \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
  \ifcase\value{gbbiblocalcase}%
    \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andcn}}{}%
    \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
    \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
    \iffieldequalstr{\userfieldabcde}{english}{\bibstring{and}}{}%
    \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
    \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
\space%
  \or%
  \bibstring{andcn}%
  \or%
  \bibstring{and}%
  \fi}    

\begin{filecontents}{\jobname.bib}
@ARTICLE{bernanke1989agency,
  AUTHOR = {Bernanke, Ben and Gertler, Mark},
  PUBLISHER = {JSTOR},
  DATE = {1989},
  JOURNALTITLE = {The American Economic Review},
  KEYWORDS = {bernanke1989agency},
  PAGES = {14--31},
  TITLE = {$P_a$ Agency costs, net worth, and business fluctuations},
}

@article{PhysRevB.62.7850,
  title = {$Z_2$ gauge theory of electron fractionalization in strongly correlated systems},
  author = {Senthil, T. and Fisher, Matthew P. A. and Gertler, Mark},
  journal = {Phys. Rev. B},
  volume = {62},
  issue = {12},
  pages = {7850--7881},
  numpages = {0},
  year = {2000},
  month = {Sep},
  publisher = {American Physical Society},
  doi = {10.1103/PhysRevB.62.7850},
  url = {https://link.aps.org/doi/10.1103/PhysRevB.62.7850}
}
\end{filecontents}
\addbibresource{\jobname.bib}
    %

\begin{document}

\cite{bernanke1989agency}

\textcite{bernanke1989agency}

\cite{PhysRevB.62.7850}

\textcite{PhysRevB.62.7850}

\printbibliography

\end{document}

结果为:

图片

hushidong commented 2 years ago
% !Mode:: "TeX:UTF-8"
% 用于测试
\documentclass{article}
\usepackage{ctex}

\usepackage[backend=biber,style=gb7714-2015ay,maxcitenames=3,
    mincitenames=1,gbcitelocal=chinese,uniquename=false]{biblatex}

\DeclareDelimFormat{finalnamedelim}{%
  \edef\userfieldabcde{userd}%
  \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
  \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
  \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
  \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
  \ifcase\value{gbcitelocalcase}%
    \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andincitecn}}{}%
    \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
    \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
    \iffieldequalstr{\userfieldabcde}{english}{\bibstring{andincite}}{}%
    \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
    \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
  \or%
  \bibstring{andincitecn}%\space%
  \or%
\bibstring{andincite}%
  \fi}

\DeclareDelimFormat[bib,biblist]{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace%
  \edef\userfieldabcde{userd}%
  \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
  \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
  \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
  \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
  \ifcase\value{gbbiblocalcase}%
    \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andcn}}{}%
    \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
    \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
    \iffieldequalstr{\userfieldabcde}{english}{\bibstring{and}}{}%
    \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
    \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
\space%
  \or%
  \bibstring{andcn}%
  \or%
  \bibstring{and}%
  \fi}  

\DeclareDelimFormat[cite,parencite,textcite]{multinamedelim}{、}%\addcomma\space

\begin{filecontents}{\jobname.bib}

@ARTICLE{bernanke1989agency1,
  AUTHOR = {Bernanke, Ben},
  PUBLISHER = {JSTOR},
  DATE = {1989},
  JOURNALTITLE = {The American Economic Review},
  KEYWORDS = {bernanke1989agency},
  PAGES = {14--31},
  TITLE = {$P_a$ Agency costs, net worth, and business fluctuations1},
}

@ARTICLE{bernanke1989agency,
  AUTHOR = {Bernanke, Ben and Gertler, Mark},
  PUBLISHER = {JSTOR},
  DATE = {1989},
  JOURNALTITLE = {The American Economic Review},
  KEYWORDS = {bernanke1989agency},
  PAGES = {14--31},
  TITLE = {$P_a$ Agency costs, net worth, and business fluctuations},
}

@article{PhysRevB.62.7850,
  title = {$Z_2$ gauge theory of electron fractionalization in strongly correlated systems},
  author = {Senthil, T. and Fisher, Matthew P. A. and Gertler, Mark},
  journal = {Phys. Rev. B},
  volume = {62},
  issue = {12},
  pages = {7850--7881},
  numpages = {0},
  year = {2000},
  month = {Sep},
  publisher = {American Physical Society},
  doi = {10.1103/PhysRevB.62.7850},
  url = {https://link.aps.org/doi/10.1103/PhysRevB.62.7850}
}

@article{PhysRevB.62.7851,
  title = {$Z_2$ gauge theory of electron fractionalization in strongly correlated systems1},
  author = {Senthil, T. and Fisher, Matthew P. A. and Gertler, Mark and Bernanke, Ben},
  journal = {Phys. Rev. B},
  volume = {62},
  issue = {12},
  pages = {7850--7881},
  numpages = {0},
  year = {2000},
  month = {Sep},
  publisher = {American Physical Society},
  doi = {10.1103/PhysRevB.62.7850},
  url = {https://link.aps.org/doi/10.1103/PhysRevB.62.7850}
}

\end{filecontents}
\addbibresource{\jobname.bib}
    %

\begin{document}

\cite{bernanke1989agency1}

\cite{bernanke1989agency}

\cite{PhysRevB.62.7850}

\cite{PhysRevB.62.7851}

\printbibliography

\end{document}
hushidong commented 2 years ago
% !Mode:: "TeX:UTF-8"
% 用于测试
\documentclass{article}
\usepackage{ctex}

\usepackage[backend=biber,style=gb7714-2015ay,maxcitenames=3,
   mincitenames=1,gbcitelocal=chinese]{biblatex}

\makeatletter
\DefineBibliographyStrings{english}{
andincitecn = {\mbox{}和\mbox{}},%
andincite   = { and },%
%andothers   = {et al.},%将超过3个人名的省略,et al.改成为 等
andotherscn   = {\str@andotherscn},%将超过3个人名的省略,et al.改成为 等
andothersincitecn={\mbox{}\str@andotherscn},%将标注中的分开,便于与文献表中的区分
andothersincite={et al\adddot},
}
\makeatother

\DeclareDelimFormat[textcite]{andothersdelim}{\iffieldequalstr{userf}{chinese}{}{}}%
\AtEveryCitekey{%
\iffieldequalstr{userf}{chinese}{\renewcommand*{\andothersdelim}{}}%\addthinspace
  {\renewcommand*{\andothersdelim}{}}%
}

\DeclareDelimFormat{finalnamedelim}{%
 \edef\userfieldabcde{userd}%
 \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
 \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
 \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
 \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
 \ifcase\value{gbcitelocalcase}%
   \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andincitecn}}{}%
   \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
   \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
   \iffieldequalstr{\userfieldabcde}{english}{\bibstring{andincite}}{}%
   \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
   \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
 \or%
 \bibstring{andincitecn}%\space%
 \or%
\bibstring{andincite}%
 \fi}

\DeclareDelimFormat[bib,biblist]{finalnamedelim}{%
 \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
 \addspace%
 \edef\userfieldabcde{userd}%
 \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
 \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
 \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
 \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
 \ifcase\value{gbbiblocalcase}%
   \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andcn}}{}%
   \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
   \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
   \iffieldequalstr{\userfieldabcde}{english}{\bibstring{and}}{}%
   \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
   \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
\space%
 \or%
 \bibstring{andcn}%
 \or%
 \bibstring{and}%
 \fi}

\begin{filecontents}{\jobname.bib}
@ARTICLE{bernanke1989agency,
 AUTHOR = {Bernanke, Ben and Gertler, Mark},
 PUBLISHER = {JSTOR},
 DATE = {1989},
 JOURNALTITLE = {The American Economic Review},
 KEYWORDS = {bernanke1989agency},
 PAGES = {14--31},
 TITLE = {$P_a$ Agency costs, net worth, and business fluctuations},
}

@article{PhysRevB.62.7850,
 title = {$Z_2$ gauge theory of electron fractionalization in strongly correlated systems},
 author = {Senthil, T. and Fisher, Matthew P. A. and Gertler, Mark },
 journal = {Phys. Rev. B},
 volume = {62},
 issue = {12},
 pages = {7850--7881},
 numpages = {0},
 year = {2000},
 month = {Sep},
 publisher = {American Physical Society},
 doi = {10.1103/PhysRevB.62.7850},
 url = {https://link.aps.org/doi/10.1103/PhysRevB.62.7850}
}

@article{PhysRevC,
 title = {$Z_2$ gauge theory of electron fractionalization in strongly correlated systems},
 author = {Senthil, T. and Fisher, Matthew P. A. and Gertler, Mark and Bernanke, Ben},
 journal = {Phys. Rev. B},
 volume = {62},
 issue = {12},
 pages = {7850--7881},
 numpages = {0},
 year = {2000},
 month = {Sep},
 publisher = {American Physical Society},
 doi = {10.1103/PhysRevB.62.7850},
 url = {https://link.aps.org/doi/10.1103/PhysRevB.62.7850}
}
\end{filecontents}
\addbibresource{\jobname.bib}
   %

\begin{document}

使用ctex编写中文文章的时候,如果句末是一个长单词的话似乎不能自动换行然后
用连接符连接使用ctex编写中文文章的时候,如果句末是一个长单词的话似乎不能自动换行然后
用连接符连接行然后接行然\cite{bernanke1989agency}

{\sloppy
使用ctex编写中文文章的时候,如果句末是一个长单词的话似乎不能自动换行然后
用连接符连接使用ctex编写中文文章的时候,如果句末是一个长单词的话似乎不能自动换行然后
用连接符连接行然后接行然\cite{bernanke1989agency}

}

Peking University HSBC Business School Peking University HSBC Business School Peking University HSBC Business School School \cite{bernanke1989agency}

{\sloppy
Peking University HSBC Business School Peking University HSBC Business School Peking University HSBC Business School School \cite{bernanke1989agency}

}

Peking University HSBC Business School Peking University HSBC Business School Peking University HSBC Business School School \cite{PhysRevB.62.7850}

{\sloppy
Peking University HSBC Business School Peking University HSBC Business School Peking University HSBC Business School School \cite{PhysRevB.62.7850}

}

\cite{PhysRevB.62.7850,PhysRevC}

\textcite{PhysRevB.62.7850,PhysRevC}

\printbibliography

\end{document} 
hushidong commented 2 years ago
% !Mode:: "TeX:UTF-8"
% 用于测试
\documentclass{article}
\usepackage{ctex}

\usepackage[backend=biber,style=gb7714-2015ay,maxcitenames=3,
   mincitenames=1,gbcitelocal=chinese]{biblatex}

\makeatletter
\DefineBibliographyStrings{english}{
andincitecn = {\allowbreak{}和\allowbreak},%
andincite   = { and },%
%andothers   = {et al.},%将超过3个人名的省略,et al.改成为 等
andotherscn   = {\str@andotherscn},%将超过3个人名的省略,et al.改成为 等
andothersincitecn={\allowbreak\str@andotherscn},%将标注中的分开,便于与文献表中的区分
andothersincite={et al\adddot},
}
\makeatother

\DeclareDelimFormat[textcite]{andothersdelim}{\iffieldequalstr{userf}{chinese}{}{}}%
\AtEveryCitekey{%
\iffieldequalstr{userf}{chinese}{\renewcommand*{\andothersdelim}{}}%\addthinspace
  {\renewcommand*{\andothersdelim}{}}%
}

\DeclareDelimFormat{finalnamedelim}{%
 \edef\userfieldabcde{userd}%
 \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
 \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
 \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
 \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
 \ifcase\value{gbcitelocalcase}%
   \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andincitecn}}{}%
   \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
   \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
   \iffieldequalstr{\userfieldabcde}{english}{\bibstring{andincite}}{}%
   \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
   \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
 \or%
 \bibstring{andincitecn}%\space%
 \or%
\bibstring{andincite}%
 \fi}

\DeclareDelimFormat[bib,biblist]{finalnamedelim}{%
 \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
 \addspace%
 \edef\userfieldabcde{userd}%
 \ifcurrentname{translator}{\edef\userfieldabcde{usere}}{}%
 \ifcurrentname{editor}{\edef\userfieldabcde{userc}}{}%
 \ifcurrentname{author}{\edef\userfieldabcde{userf}}{}%
 \ifcurrentname{bookauthor}{\edef\userfieldabcde{userb}}{}%
 \ifcase\value{gbbiblocalcase}%
   \iffieldequalstr{\userfieldabcde}{chinese}{\bibstring{andcn}}{}%
   \iffieldequalstr{\userfieldabcde}{korean}{\bibstring{andkr}}{}%
   \iffieldequalstr{\userfieldabcde}{japanese}{\bibstring{andjp}}{}%
   \iffieldequalstr{\userfieldabcde}{english}{\bibstring{and}}{}%
   \iffieldequalstr{\userfieldabcde}{french}{\bibstring{and}}{}%
   \iffieldequalstr{\userfieldabcde}{russian}{\bibstring{and}}{}%
\space%
 \or%
 \bibstring{andcn}%
 \or%
 \bibstring{and}%
 \fi}

\begin{filecontents}{\jobname.bib}
@ARTICLE{bernanke1989agency,
 AUTHOR = {Bernanke, Ben and Gertler, Mark},
 PUBLISHER = {JSTOR},
 DATE = {1989},
 JOURNALTITLE = {The American Economic Review},
 KEYWORDS = {bernanke1989agency},
 PAGES = {14--31},
 TITLE = {$P_a$ Agency costs, net worth, and business fluctuations},
}

@article{PhysRevB.62.7850,
 title = {$Z_2$ gauge theory of electron fractionalization in strongly correlated systems},
 author = {Senthil, T. and Fisher, Matthew P. A. and Gertler, Mark },
 journal = {Phys. Rev. B},
 volume = {62},
 issue = {12},
 pages = {7850--7881},
 numpages = {0},
 year = {2000},
 month = {Sep},
 publisher = {American Physical Society},
 doi = {10.1103/PhysRevB.62.7850},
 url = {https://link.aps.org/doi/10.1103/PhysRevB.62.7850}
}

@article{PhysRevC,
 title = {$Z_2$ gauge theory of electron fractionalization in strongly correlated systems},
 author = {Senthil, T. and Fisher, Matthew P. A. and Gertler, Mark and Bernanke, Ben},
 journal = {Phys. Rev. B},
 volume = {62},
 issue = {12},
 pages = {7850--7881},
 numpages = {0},
 year = {2000},
 month = {Sep},
 publisher = {American Physical Society},
 doi = {10.1103/PhysRevB.62.7850},
 url = {https://link.aps.org/doi/10.1103/PhysRevB.62.7850}
}
\end{filecontents}
\addbibresource{\jobname.bib}
   %

\begin{document}

使用ctex编写中文文章的时候,如果句末是一个长单词的话似乎不能自动换行然后
用连接符连接使用ctex编写中文文章的时候,如果句末是一个长单词的话似乎不能自动换行然后
用连接符连接行然后接行然\cite{bernanke1989agency}

{\sloppy
使用ctex编写中文文章的时候,如果句末是一个长单词的话似乎不能自动换行然后
用连接符连接使用ctex编写中文文章的时候,如果句末是一个长单词的话似乎不能自动换行然后
用连接符连接行然后接行然\cite{bernanke1989agency}

}

Peking University HSBC Business School Peking University HSBC Business School Peking University HSBC Business School School \cite{bernanke1989agency}

{\sloppy
Peking University HSBC Business School Peking University HSBC Business School Peking University HSBC Business School School \cite{bernanke1989agency}

}

Peking University HSBC Business School Peking University HSBC Business School Peking University HSBC Business School School \cite{PhysRevB.62.7850}

{\sloppy
Peking University HSBC Business School Peking University HSBC Business School Peking University HSBC Business School School \cite{PhysRevB.62.7850}

}

\cite{PhysRevB.62.7850,PhysRevC}

\textcite{PhysRevB.62.7850,PhysRevC}

\printbibliography

\end{document}