hushidong / biblatex-gb7714-2015

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

用法:作者年制下标注的标点由英文改为中文 #69

Open yihuang995 opened 4 years ago

yihuang995 commented 4 years ago

\cite指令下 (Ermes 等., 2008; Lester 等., 2006) 希望改成 (Ermes 等.,2008; Lester 等.,2006) 变化的是,中文的括号、逗号和分号

此外,能否同时满足\textcite指令下,依然保持英文括号不变

感谢~

hushidong commented 4 years ago

当然是可以的,这种定制正是biblatex的优点之一。稍等。

hushidong commented 4 years ago

加两句即可:

\DeclareDelimFormat[cite,parencite,pagescite]{nameyeardelim}{,}%\addcomma\space
\DeclareDelimFormat[textcite]{nameyeardelim}{\addthinspace}%\addcomma\space
hushidong commented 4 years ago

示例见:


% !Mode:: "TeX:UTF-8"
% 用于测试ucasthesis中应用biblatex-gb7714-2015的情况
%

\documentclass[twoside]{article}
    \usepackage{ctex}
    \usepackage{fontspec}
\setmainfont{CMU Serif}
    \IfFileExists{SourceHanSerifSC-Regular.otf}
    {\setCJKmainfont{SourceHanSerifSC-Regular.otf}}{}
    %\IfFontExistsTF{⟨font name⟩}{⟨true branch⟩}{⟨false branch⟩}
    \usepackage{xcolor}
    \usepackage{toolbox}
    \usepackage[colorlinks,citecolor=blue]{hyperref}
    \usepackage{lipsum}
    \usepackage{geometry}%,showframe,showcrop
\geometry{paper=a4paper,left=31.7mm,right=31.7mm,top=25.4mm,bottom=25.4mm}
\usepackage{bicaption}
\captionsetup[bi-first]{name={图},labelsep=period}
\captionsetup[bi-second]{name={Fig},labelsep=period}
\usepackage[backend=biber,style=gb7714-2015ay,%citestyle=authoryear-comp,%
maxcitenames=2,mincitenames=1,gbcitelocal=gb7714-2015,mergedate=none]{biblatex}%,sortcites=false,mergedate=none

\DefineBibliographyStrings{english}{
        andincite         = {和},
        andincitecn       = {和},
        andothersincitecn = {等},
        andothersincite   = {等{\adddot}},%adddot才能避开标点追踪
}

\DeclareDelimFormat[cite,parencite,pagescite]{nameyeardelim}{,}%\addcomma\space
\DeclareDelimFormat[textcite]{nameyeardelim}{\addthinspace}%\addcomma\space
\renewcommand*{\multicitedelim}{;}%\addsemicolon\addspace;
%添加前后空格
\DeclareCiteCommand{\cite}%[\mkbibparens]
  {\usebibmacro{cite:init}%
   \printtext{(}\usebibmacro{prenote}}%)\addspace
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{postnote}%(
  )}%\addspace

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
%---------------------------------------------------------------------------%
%-                                                                         -%
%-                             Bibliography                                -%
%-                                                                         -%
%---------------------------------------------------------------------------%
@book{wikibook2014latex,
    title={http://en.wikibooks.org/wiki/LaTeX},
    author={Wikibook},
    year={2014},
    publisher={On-line Resources}
}
@book{lamport1986document,
    title={Document Preparation System},
    author={Lamport, Leslie},
    year={1986},
    publisher={Addison-Wesley Reading, MA}
}
@article{chen2005zhulu,
    title={著录文后参考文献的规则及注意事项},
    author={陈浩元},
    journal={编辑学报},
    volume={17},
    number={6},
    pages={413--415},
    year={2005}
}
@book{chu2004tushu,
    title={图书馆数字参考咨询服务研究},
    author={初景利 and 陈浩元},
    year={2004},
    address={北京},
    publisher={北京图书馆出版社}
}
@article{stamerjohanns2009mathml,
    title={{MathML}-aware article conversion from {LaTeX}},
    author={Stamerjohanns, Heinrich and Ginev, Deyan and David, Catalin and Misev, Dimitar and Zamdzhiev, Vladimir and Kohlhase, Michael},
    journal={Towards a Digital Mathematics Library},
    volume={16},
    number={2},
    pages={109--120},
    year={2009},
    publisher={Masaryk University Press}
}
@article{betts2005aging,
    title={Aging reduces center-surround antagonism in visual motion processing},
    author={Betts, Lisa R and Taylor, Christopher P},
    journal={Neuron},
    volume={45},
    number={3},
    pages={361--366},
    year={2005},
    publisher={Elsevier}
}

@article{bravo1990comparative,
    title={Comparative study of visual inter and intrahemispheric cortico-cortical connections in five native Chilean rodents},
    author={Bravo, Hermes and Olavarria, Jaime},
    journal={Anatomy and embryology},
    volume={181},
    number={1},
    pages={67--73},
    year={1990},
    publisher={Springer}
}
@book{hls2012jinji,
    author       = {哈里森·沃尔德伦},
    translator   = {谢远涛},
    title        = {经济数学与金融数学},
    address      = {北京},
    publisher    = {中国人民大学出版社},
    year         = {2012},
    pages        = {235--236},
}
@proceedings{niu2013zonghe,
    editor       = {牛志明 and 斯温兰德 and 雷光春},
    title        = {综合湿地管理国际研讨会论文集},
    address      = {北京},
    publisher    = {海洋出版社},
    year         = {2013},
}
@incollection{chen1980zhongguo,
    author       = {陈晋镳 and 张惠民 and 朱士兴 and 赵震 and
        王振刚},
    title        = {蓟县震旦亚界研究},
    editor       = {中国地质科学院天津地质矿产研究所},
    booktitle    = {中国震旦亚界},
    address      = {天津},
    publisher    = {天津科学技术出版社},
    year         = {1980},
    pages        = {56--114},
}
@article{yuan2012lana,
    author       = {袁训来 and 陈哲 and 肖书海},
    title        = {蓝田生物群: 一个认识多细胞生物起源和早期演化的新窗口--篇一},
    journal      = {科学通报},
    year         = {2012},
    volume       = {57},
    number       = {34},
    pages        = {3219},
}
@article{yuan2012lanb,
    author       = {袁训来 and 陈哲 and 肖书海},
    title        = {蓝田生物群: 一个认识多细胞生物起源和早期演化的新窗口--篇二},
    journal      = {科学通报},
    year         = {2012},
    volume       = {57},
    number       = {34},
    pages        = {3219},
}
@article{yuan2012lanc,
    author       = {袁训来 and 陈哲 and 肖书海},
    title        = {蓝田生物群: 一个认识多细胞生物起源和早期演化的新窗口--篇三},
    journal      = {科学通报},
    year         = {2012},
    volume       = {57},
    number       = {34},
    pages        = {3219},
}

@article{walls2013drought,
    author       = {Walls, Susan C. and Barichivich, William J. and Brown, Mary
        E.},
    title        = {Drought, deluge and declines: the impact of precipitation
        extremes on amphibians in a changing climate},
    journal      = {Biology},
    year         = {2013},
    volume       = {2},
    number       = {1},
    pages        = {399-418},
    urldate      = {2013-11-04},
    url          = {http://www.mdpi.com/2079-7737/2/1/399},
    doi          = {10.3390/biology2010399},
}

@article{Bohan1928,
    author = { ボハン, デ},
    title = { 過去及び現在に於ける英国と会 },
    journal = { 日本時報 },
    year = { 1928 },
    volume = { 17 },
    pages = { 5-9 },
    edition = { 9 },
    hyphenation = { japanese },
}

@article{Dubrovin1906,
    author = { Дубровин, А. И },
    title = { Открытое письмо Председателя Главного Совета Союза Русского Народа Санкт-Петербургскому Антонию, Первенствующему члену Священного Синода },
    journal = { Вече },
    year = { 1906 },
    volume = {  },
    edition = { 97 },
    month = { 7 дек. 1906 },
    pages = { 1-3 },
    hyphenation = { russian },
}
%---------------------------------------------------------------------------%

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

    \begin{document}

    \section*{UCASTHESIS-A}
\setcounter{section}{1}

\subsection{标注中的标点变化}

见\cite{chu2004tushu}

见\textcite{chu2004tushu}

见\cite{chen1980zhongguo},\cite{walls2013drought}

见\textcite{chen1980zhongguo},\textcite{walls2013drought}

    \printbibliography

    \end{document} 

结果为: 图片

图片

hushidong commented 4 years ago

类似的修改见:

https://github.com/hushidong/biblatex-gb7714-2015/blob/master/chinese-erj.cbx

https://github.com/hushidong/biblatex-gb7714-2015/blob/master/egthesis/thesis-nwafu-ay.tex

hushidong commented 4 years ago

关于文献表中的修改,可见:

https://github.com/hushidong/biblatex-gb7714-2015/issues/61

yihuang995 commented 4 years ago

加两句即可:

\DeclareDelimFormat[cite,parencite,pagescite]{nameyeardelim}{,}%\addcomma\space
\DeclareDelimFormat[textcite]{nameyeardelim}{\addthinspace}%\addcomma\space

谢谢,逗号生效了,请问可以改(分号,;)和括号吗,找不到关键字

yihuang995 commented 4 years ago

类似的修改见:

https://github.com/hushidong/biblatex-gb7714-2015/blob/master/chinese-erj.cbx

https://github.com/hushidong/biblatex-gb7714-2015/blob/master/egthesis/thesis-nwafu-ay.tex

这两个文件里面包含分号和括号的修改,已找到,再次感谢

hushidong commented 4 years ago

是的,我漏看了你的需求,你自己完成那是最好了。

Tang-Haojin commented 2 years ago

抱歉,想再问一下,如果要把textcite里的英文括号也改为中文括号,需要怎么办呢?

Youguang commented 2 years ago

加两句即可:

\DeclareDelimFormat[cite,parencite,pagescite]{nameyeardelim}{,}%\addcomma\space
\DeclareDelimFormat[textcite]{nameyeardelim}{\addthinspace}%\addcomma\space

@hushidong 相同作者不同年份参考文献压缩到一起时年份间的逗号如何改成全角逗号?

hushidong commented 2 years ago

能麻烦给个小例子么,最近比较忙,要做个例子出来展示,也挺麻烦的。给给例子,然后说明清楚需求。

hushidong commented 2 years ago

都用mwe说话会比较方法,也节省我的时间。

hushidong commented 2 years ago

主要这个改中文标点还是比较繁琐的,后面有时间,我会全面的总结一次,然后可以做一个方便的接口。限制chinese-erj和ccnu那里面有一些设置,可能是你需要的。

Youguang commented 2 years ago

目的: 正文中的引用统一使用中文标点。最理想的情况是,在中文段落中引用文献都使用中文字符(Weiskopf 等(2021,2013));在英文段落/图注中使用英文字符(Weiskopf et al. (2021, 2013))。实际情况我实现不了,所以把目标改成了都统一用中文标点(因为英文段落少,手动输入的引用文献)。

MWE:

\documentclass{article}
\usepackage{ctex}
\usepackage[backend=biber,style=gb7714-2015ay]{biblatex}
\DeclareDelimFormat[cite,parencite,pagescite]{nameyeardelim}{,}
\DeclareDelimFormat[textcite]{nameyeardelim}{\addthinspace}
\renewcommand*{\multicitedelim}{;}
\renewcommand*{\bibleftparen}{\hspace{-0.25em}(}
\renewcommand*{\bibrightparen}{)}

\DefineBibliographyStrings{english}{
        andincite         = {和},
        andincitecn       = {和},
        andothersincitecn = {等},
        andothersincite   = {等},%adddot才能避开标点追踪
}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}

@article{Aaa_2021,
author = {Aaa, A. A. and Bbb, B. B. and Ccc, C. C.},
title = {Title title title title title},
journal = {Nature},
volume = {11},
number = {1},
pages = {11-12},
year = {2021},
type = {Journal Article}
}

@article{Aaa_2018,
author = {Aaa, A. A. and Bcc, B. B. and Caa, C. C.},
title = {Title title title title title},
journal = {Science},
volume = {11},
number = {1},
pages = {11-12},
year = {2018},
type = {Journal Article}
}

@article{Bbb_2019,
author = {Bbb, A. A. and Bcc, B. B. and Ccc, C. C.},
title = {Title title title title title},
journal = {Cell},
volume = {11},
number = {1},
pages = {11-12},
year = {2018},
type = {Journal Article}
}

\end{filecontents}
\addbibresource[location=local]{\jobname.bib}

\begin{document}

\textcite{Aaa_2021,Aaa_2018} 发现 \parencite{Aaa_2018,Bbb_2019}

\printbibliography
\end{document}

问题: 压缩到一起的两个年份之间的逗号跟作者-年份之间的逗号不一致。

Screen Shot 2022-05-08 at 22 07 16

实际的情况这里是英文逗号,使用的ucas模版,MWE没有复现出来。

Screen Shot 2022-05-08 at 22 05 51
hushidong commented 2 years ago

好的,我现在先弄个ppt,完了再来解决你的这个问题,你可以明早来看。

hushidong commented 2 years ago

比如

\documentclass{article}
\usepackage{ctex}
\usepackage[backend=biber,style=gb7714-2015ay,gbcitelocal=chinese]{biblatex}

\DeclareDelimFormat[cite,parencite,pagescite]{nameyeardelim}{\ifnumcomp{\value{gbcitelocalcase}}{=}{2}{\addcomma\addspace}{,}}
\DeclareDelimFormat[textcite]{nameyeardelim}{\addthinspace}
\renewcommand*{\multicitedelim}{;}
\renewcommand*{\compcitedelim}{,}
\renewcommand*{\bibleftparen}{\hspace{-0.25em}(}
\renewcommand*{\bibrightparen}{)}

\DefineBibliographyStrings{english}{
        andincitecn       = {和},
        andothersincitecn = {等},
}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}

@article{Aaa_2021,
author = {Aaa, A. A. and Bbb, B. B. and Ccc, C. C.},
title = {Title title title title title},
journal = {Nature},
volume = {11},
number = {1},
pages = {11-12},
year = {2021},
type = {Journal Article}
}

@article{Aaa_2018,
author = {Aaa, A. A. and Bcc, B. B. and Caa, C. C.},
title = {Title title title title title},
journal = {Science},
volume = {11},
number = {1},
pages = {11-12},
year = {2018},
type = {Journal Article}
}

@article{Bbb_2019,
author = {Bbb, A. A. and Bcc, B. B. and Ccc, C. C.},
title = {Title title title title title},
journal = {Cell},
volume = {11},
number = {1},
pages = {11-12},
year = {2018},
type = {Journal Article}
}

\end{filecontents}
\addbibresource[location=local]{\jobname.bib}

\begin{document}

中文段落\textcite{Aaa_2021,Aaa_2018} 发现 \parencite{Aaa_2018,Bbb_2019}

{
\defcounter{gbcitelocalcase}{2}
\renewcommand*{\multicitedelim}{\addsemicolon\addspace}
\renewcommand*{\compcitedelim}{\addcomma\addspace}
\renewcommand*{\bibleftparen}{(}
\renewcommand*{\bibrightparen}{)}
english paragraph \textcite{Aaa_2021,Aaa_2018} find \parencite{Aaa_2018,Bbb_2019}

}

\printbibliography
\end{document} 

结果为:

图片

hushidong commented 2 years ago

@Tang-Haojin 参考上面例子 @Youguang 的关于括号的修改。

hushidong commented 2 years ago

或者

\documentclass{article}
\usepackage{ctex}
\usepackage[backend=biber,style=gb7714-2015ay,gbcitelocal=chinese]{biblatex}

\DeclareDelimFormat[cite,parencite,pagescite]{nameyeardelim}{\ifnumcomp{\value{gbcitelocalcase}}{=}{2}{\addcomma\addspace}{,}}
\DeclareDelimFormat[textcite]{nameyeardelim}{\addthinspace}
\renewcommand*{\multicitedelim}{\ifnumcomp{\value{gbcitelocalcase}}{=}{2}{\addsemicolon\addspace}{;}}
\renewcommand*{\compcitedelim}{\ifnumcomp{\value{gbcitelocalcase}}{=}{2}{\addcomma\addspace}{,}}
\renewcommand*{\bibleftparen}{\ifnumcomp{\value{gbcitelocalcase}}{=}{2}{(}{\hspace{-0.25em}(}}
\renewcommand*{\bibrightparen}{\ifnumcomp{\value{gbcitelocalcase}}{=}{2}{)}{)}}

\DefineBibliographyStrings{english}{
        andincitecn       = {和},
        andothersincitecn = {等},
}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}

@article{Aaa_2021,
author = {Aaa, A. A. and Bbb, B. B. and Ccc, C. C.},
title = {Title title title title title},
journal = {Nature},
volume = {11},
number = {1},
pages = {11-12},
year = {2021},
type = {Journal Article}
}

@article{Aaa_2018,
author = {Aaa, A. A. and Bcc, B. B. and Caa, C. C.},
title = {Title title title title title},
journal = {Science},
volume = {11},
number = {1},
pages = {11-12},
year = {2018},
type = {Journal Article}
}

@article{Bbb_2019,
author = {Bbb, A. A. and Bcc, B. B. and Ccc, C. C.},
title = {Title title title title title},
journal = {Cell},
volume = {11},
number = {1},
pages = {11-12},
year = {2018},
type = {Journal Article}
}

\end{filecontents}
\addbibresource[location=local]{\jobname.bib}

\begin{document}

中文段落\textcite{Aaa_2021,Aaa_2018} 发现 \parencite{Aaa_2018,Bbb_2019}

{
\defcounter{gbcitelocalcase}{2}
english paragraph \textcite{Aaa_2021,Aaa_2018} find \parencite{Aaa_2018,Bbb_2019}

}

\printbibliography
\end{document} 
Youguang commented 2 years ago

谢谢

\setlocalbibstring{andothersincite}{et al.}\setlocalbibstring{andincite}{and} 局部设置能不能也加入到 \defcounter{gbcitelocalcase}{2} 的判断里?

hushidong commented 2 years ago

这个不应该加入了,gbcitelocalcase实际就是标记了三种情况 0,使用区分的andothersincite,andothersincitecn 1,使用andothersincitecn 2,使用andothersincite 所以你只要设置好了andothersincite,andothersincitecn那么正常就不用调整。除非局部要调整这种本地化字符串,那么你就setlocalbibstring来设置新的本地化字符串。

Youguang commented 2 years ago

好的 谢谢

Tang-Haojin commented 2 years ago

谢谢