hushidong / biblatex-gb7714-2015

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

在通过 Pandoc 转换的 LaTeX 文档中使用 biblatex-gb7714-2015 时,\autocites 多重引用产生了多余的括号 #187

Closed TomBener closed 7 months ago

TomBener commented 7 months ago

问题描述

通过 Pandoc 从 Markdown 转换到 LaTeX 并使用 biblatex-gb7714-2015 宏包(样式设置为 gb7714-2015ay)时,\autocites 命令生成的多重引用中出现了不需要的额外括号。这个问题在直接使用 biblatex 宏包时没有出现。

复现步骤

  1. 使用 biblatex-gb7714-2015 宏包时的 LaTeX 代码:
\documentclass{article}
\usepackage{ctex}
\usepackage[backend=biber, style=gb7714-2015ay]{biblatex}

\begin{filecontents}[force,noheader]{\jobname.bib}
  @book{hickman2016,
  title = {Space {{Is Power}}: {{The Seven Rules}} of {{Territory}}},
  author = {Hickman, John},
  date = {2016},
  publisher = {Lexington Books},
  location = {Lanham}
  }

  @book{latham2000,
  title = {Modernization as {{Ideology}}: {{American Social Science}} and “{{Nation Building}}” in the {{Kennedy Era}}},
  author = {Latham, Michael E.},
  date = {2000-05-15},
  publisher = {The University of North Carolina Press},
  location = {Chapel Hill}
  }

  @book{guoshuanglin2006,
  title = {中国近代史读本(下册)},
  author = {{郭双林}},
  editor = {{王续添}},
  date = {2006-07},
  publisher = {北京大学出版社},
  location = {北京}
  }

  @book{aimaniuaier2007,
  title = {蒙塔尤:1294–1324年奥克西坦尼的一个山村},
  author = {埃马纽埃尔·勒华拉杜里},
  translator = {许明龙 and 马胜利},
  date = {2007-05},
  publisher = {商务印书馆},
  location = {北京}
  }

  @book{guojianlong2017,
  title = {中央帝国的财政密码},
  author = {{郭建龙}},
  date = {2017-04},
  publisher = {鹭江出版社},
  location = {厦门}
  }
  \end{filecontents}
  \addbibresource{\jobname.bib}

\begin{document}

\textcite[20, 100]{hickman2016}
测试多个引用
\autocites[85]{latham2000}[2]{guoshuanglin2006}[10--20]{aimaniuaier2007},以及单个行内引用
\autocite[1-3]{guojianlong2017}。

\printbibliography[heading=bibliography]
\end{document}

CleanShot 2024-03-06 at 12 32 05@2x

  1. 使用 biblatex 默认 authoryear 样式时的 LaTeX 代码(作为对照):
\documentclass{article}
\usepackage{ctex}
\usepackage[backend=biber, style=authoryear]{biblatex}

\begin{filecontents}[force,noheader]{\jobname.bib}
  @book{hickman2016,
  title = {Space {{Is Power}}: {{The Seven Rules}} of {{Territory}}},
  author = {Hickman, John},
  date = {2016},
  publisher = {Lexington Books},
  location = {Lanham}
  }

  @book{latham2000,
  title = {Modernization as {{Ideology}}: {{American Social Science}} and “{{Nation Building}}” in the {{Kennedy Era}}},
  author = {Latham, Michael E.},
  date = {2000-05-15},
  publisher = {The University of North Carolina Press},
  location = {Chapel Hill}
  }

  @book{guoshuanglin2006,
  title = {中国近代史读本(下册)},
  author = {{郭双林}},
  editor = {{王续添}},
  date = {2006-07},
  publisher = {北京大学出版社},
  location = {北京}
  }

  @book{aimaniuaier2007,
  title = {蒙塔尤:1294–1324年奥克西坦尼的一个山村},
  author = {埃马纽埃尔·勒华拉杜里},
  translator = {许明龙 and 马胜利},
  date = {2007-05},
  publisher = {商务印书馆},
  location = {北京}
  }

  @book{guojianlong2017,
  title = {中央帝国的财政密码},
  author = {{郭建龙}},
  date = {2017-04},
  publisher = {鹭江出版社},
  location = {厦门}
  }
  \end{filecontents}
  \addbibresource{\jobname.bib}

\begin{document}

\textcite[20, 100]{hickman2016}
测试多个引用
\autocites[85]{latham2000}[2]{guoshuanglin2006}[10--20]{aimaniuaier2007},以及单个行内引用
\autocite[1-3]{guojianlong2017}。

\printbibliography[heading=bibliography]
\end{document}

CleanShot 2024-03-06 at 12 31 19@2x

预期行为

即使是在经过 Pandoc 转换的 LaTeX 文档中,使用 biblatex-gb7714-2015 宏包时,\autocites 生成的多重引用也应该避免包含多余的括号,与直接使用 biblatexauthoryear 样式时相一致。

实际行为

使用 biblatex-gb7714-2015 时,输出结果包含了多余的括号:

Hickman (2016, pp. 20, 100) 测试多个引用 ((Latham, 2000, p. 85)(; 郭双林, 2006, p. 2)(; 埃马纽埃尔·勒华拉杜里, 2007, pp. 10-20)),以及单个行内引用 (郭建龙, 2017, pp. 1-3)。

相比之下,使用 biblatex 默认 authoryear 样式时则没有此问题。

由于 Pandoc 默认转换多重引用为 \autocites 命令,不方便直接修改 LaTeX 代码,请问该怎么解决这个问题?谢谢!

hushidong commented 7 months ago

主要是gb7714-2015ay没有调整parencites所导致的,调整一下就可好了:

\DeclareMultiCiteCommand{\parencites}{\parencite}{\multicitedelim}

比如:

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

\DeclareMultiCiteCommand{\parencites}{\parencite}{\multicitedelim}

\begin{filecontents}[force,noheader]{\jobname.bib}
  @book{hickman2016,
  title = {Space {{Is Power}}: {{The Seven Rules}} of {{Territory}}},
  author = {Hickman, John},
  date = {2016},
  publisher = {Lexington Books},
  location = {Lanham}
  }

  @book{latham2000,
  title = {Modernization as {{Ideology}}: {{American Social Science}} and “{{Nation Building}}” in the {{Kennedy Era}}},
  author = {Latham, Michael E.},
  date = {2000-05-15},
  publisher = {The University of North Carolina Press},
  location = {Chapel Hill}
  }

  @book{guoshuanglin2006,
  title = {中国近代史读本(下册)},
  author = {{郭双林}},
  editor = {{王续添}},
  date = {2006-07},
  publisher = {北京大学出版社},
  location = {北京}
  }

  @book{aimaniuaier2007,
  title = {蒙塔尤:1294–1324年奥克西坦尼的一个山村},
  author = {埃马纽埃尔·勒华拉杜里},
  translator = {许明龙 and 马胜利},
  date = {2007-05},
  publisher = {商务印书馆},
  location = {北京}
  }

  @book{guojianlong2017,
  title = {中央帝国的财政密码},
  author = {{郭建龙}},
  date = {2017-04},
  publisher = {鹭江出版社},
  location = {厦门}
  }
  \end{filecontents}
  \addbibresource{\jobname.bib}

\begin{document}

单个行内引用 \autocite[1-3]{guojianlong2017}。

多个引用\autocites[85]{latham2000}[2]{guoshuanglin2006}[10--20]{aimaniuaier2007},以及

单个行内引用 \textcite[20, 100]{hickman2016}

多个引用 \textcites[85]{latham2000}[2]{guoshuanglin2006}[10--20]{aimaniuaier2007},

\printbibliography[heading=bibliography]
\end{document}

结果为:

图片

hushidong commented 7 months ago

或者:

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

\DeclareCiteCommand{\parencite}[\mkbibparens]%
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{postnote}}

\begin{filecontents}[force,noheader]{\jobname.bib}
  @book{hickman2016,
  title = {Space {{Is Power}}: {{The Seven Rules}} of {{Territory}}},
  author = {Hickman, John},
  date = {2016},
  publisher = {Lexington Books},
  location = {Lanham}
  }

  @book{latham2000,
  title = {Modernization as {{Ideology}}: {{American Social Science}} and “{{Nation Building}}” in the {{Kennedy Era}}},
  author = {Latham, Michael E.},
  date = {2000-05-15},
  publisher = {The University of North Carolina Press},
  location = {Chapel Hill}
  }

  @book{guoshuanglin2006,
  title = {中国近代史读本(下册)},
  author = {{郭双林}},
  editor = {{王续添}},
  date = {2006-07},
  publisher = {北京大学出版社},
  location = {北京}
  }

  @book{aimaniuaier2007,
  title = {蒙塔尤:1294–1324年奥克西坦尼的一个山村},
  author = {埃马纽埃尔·勒华拉杜里},
  translator = {许明龙 and 马胜利},
  date = {2007-05},
  publisher = {商务印书馆},
  location = {北京}
  }

  @book{guojianlong2017,
  title = {中央帝国的财政密码},
  author = {{郭建龙}},
  date = {2017-04},
  publisher = {鹭江出版社},
  location = {厦门}
  }
  \end{filecontents}
  \addbibresource{\jobname.bib}

\begin{document}

单个行内引用 \autocite[1-3]{guojianlong2017}。

多个引用\autocites[85]{latham2000}[2]{guoshuanglin2006}[10--20]{aimaniuaier2007}

单个行内引用 \textcite[20, 100]{hickman2016}

多个引用 \textcites[85]{latham2000}[2]{guoshuanglin2006}[10--20]{aimaniuaier2007},

\printbibliography[heading=bibliography]
\end{document} 

结果为: 图片

hushidong commented 7 months ago

你看需要选择即可。

hushidong commented 7 months ago

里面的有个book,除了author还有editor,简单处理,可以看下面的例子:

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

\DeclareCiteCommand{\parencite}[\mkbibparens]%
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{postnote}}

\DefineBibliographyStrings{english}{
byeditor={\iffieldequalstr{userd}{chinese}{编}{Ed. by}}
}

\newbibmacro*{byeditor+others}{%
  \ifnameundef{editor}
    {}
    {\iffieldequalstr{userd}{chinese}{}{\usebibmacro{byeditor+othersstrg}%
     \setunit{\addspace}}%
     \printnames[byeditor]{editor}%
     \iffieldequalstr{userd}{chinese}{\usebibmacro{byeditor+othersstrg}}{}%
     \clearname{editor}%
     \newunit}%
  \usebibmacro{byeditorx}%
  \usebibmacro{bytranslator+others}}

\begin{filecontents}[force,noheader]{\jobname.bib}
  @book{hickman2016,
  title = {Space {{Is Power}}: {{The Seven Rules}} of {{Territory}}},
  author = {Hickman, John},
  editor={Latham, Michael E.},
  date = {2016},
  publisher = {Lexington Books},
  location = {Lanham}
  }

  @book{latham2000,
  title = {Modernization as {{Ideology}}: {{American Social Science}} and “{{Nation Building}}” in the {{Kennedy Era}}},
  author = {Latham, Michael E.},
  date = {2000-05-15},
  publisher = {The University of North Carolina Press},
  location = {Chapel Hill}
  }

  @book{guoshuanglin2006,
  title = {中国近代史读本(下册)},
  author = {{郭双林}},
  editor = {{王续添}},
  date = {2006-07},
  publisher = {北京大学出版社},
  location = {北京}
  }

  @book{aimaniuaier2007,
  title = {蒙塔尤:1294–1324年奥克西坦尼的一个山村},
  author = {埃马纽埃尔·勒华拉杜里},
  translator = {许明龙 and 马胜利},
  date = {2007-05},
  publisher = {商务印书馆},
  location = {北京}
  }

  @book{guojianlong2017,
  title = {中央帝国的财政密码},
  author = {{郭建龙}},
  date = {2017-04},
  publisher = {鹭江出版社},
  location = {厦门}
  }
  \end{filecontents}
  \addbibresource{\jobname.bib}

\begin{document}

单个行内引用 \autocite[1-3]{guojianlong2017}。

多个引用\autocites[85]{latham2000}[2]{guoshuanglin2006}[10--20]{aimaniuaier2007}

单个行内引用 \textcite[20, 100]{hickman2016}

多个引用 \textcites[85]{latham2000}[2]{guoshuanglin2006}[10--20]{aimaniuaier2007},

\printbibliography[heading=bibliography]
\end{document} 

结果为:

图片

TomBener commented 7 months ago

\DeclareCiteCommand{\parencite}[\mkbibparens]% {\usebibmacro{cite:init}% \usebibmacro{prenote}}% {\usebibmacro{citeindex}% \usebibmacro{cite}} {} {\usebibmacro{postnote}}

\DefineBibliographyStrings{english}{ byeditor={\iffieldequalstr{userd}{chinese}{编}{Ed. by}} }

\newbibmacro*{byeditor+others}{% \ifnameundef{editor} {} {\iffieldequalstr{userd}{chinese}{}{\usebibmacro{byeditor+othersstrg}% \setunit{\addspace}}% \printnames[byeditor]{editor}% \iffieldequalstr{userd}{chinese}{\usebibmacro{byeditor+othersstrg}}{}% \clearname{editor}% \newunit}% \usebibmacro{byeditorx}% \usebibmacro{bytranslator+others}}

感谢回复,我加上了这段代码,确实没有了多余的括号。但是还有一个关于页码连接符号的问题,通过以上 biblatex-gb7714-2015 生成的 PDF 中,连接页码的符号是 hyphen,比如 埃马纽埃尔·勒华拉杜里, 2007, pp. 10-20,而不是采用 biblatex 时的 en-dash,即 埃马纽埃尔·勒华拉杜里, 2007, pp. 10–20

hushidong commented 7 months ago

加上

\DefineBibliographyExtras{english}{\renewcommand*{\bibrangedash}{{\textendash}}}
TomBener commented 7 months ago

可以了,非常感谢!

TomBener commented 6 months ago

请问上面这个 \autocites 的设置可以更新到宏包的默认设置中吗?在某些情况,比如使用 Quarto 自定义 LaTeX 代码不是很方便,感谢!

hushidong commented 6 months ago

可以,今天更新一下。

TomBener commented 6 months ago

@hushidong 感谢!

hushidong commented 6 months ago

已更新,ctan需要两三天后才能通告。 要现在就用的话,你可以直接在github上下载bbx/cbx文件替代你系统中texlive里面的就可以了。

TomBener commented 6 months ago

更新了,非常感谢。

不过现在出现了一个新问题,如下图红色标注所示,某些引用与正文之间缺少一个空格,之前的版本不存在这样的问题,可以修复一下吗?另外页码连接符号看起来像是 hyphen - 而不是 en-dash ,是因为没有更新吗?

CleanShot 2024-03-28 at 08 52 32@2x

MWE:

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

\begin{filecontents}[force,noheader]{\jobname.bib}
  @book{hickman2016,
  title = {Space {{Is Power}}: {{The Seven Rules}} of {{Territory}}},
  author = {Hickman, John},
  date = {2016},
  publisher = {Lexington Books},
  location = {Lanham}
  }

  @book{latham2000,
  title = {Modernization as {{Ideology}}: {{American Social Science}} and “{{Nation Building}}” in the {{Kennedy Era}}},
  author = {Latham, Michael E.},
  date = {2000-05-15},
  publisher = {The University of North Carolina Press},
  location = {Chapel Hill}
  }

  @book{guoshuanglin2006,
  title = {中国近代史读本(下册)},
  author = {{郭双林}},
  editor = {{王续添}},
  date = {2006-07},
  publisher = {北京大学出版社},
  location = {北京}
  }

  @book{aimaniuaier2007,
  title = {蒙塔尤:1294–1324年奥克西坦尼的一个山村},
  author = {埃马纽埃尔·勒华拉杜里},
  translator = {许明龙 and 马胜利},
  date = {2007-05},
  publisher = {商务印书馆},
  location = {北京}
  }

  @book{guojianlong2017,
  title = {中央帝国的财政密码},
  author = {{郭建龙}},
  date = {2017-04},
  publisher = {鹭江出版社},
  location = {厦门}
  }
  \end{filecontents}
  \addbibresource{\jobname.bib}

\begin{document}

The United Nations invites each person of any age, plus every classroom
\textcite[20, 100]{hickman2016},
business and government to join in celebration of the International Day of Happiness
\autocite[85]{latham2000}.

联合国邀请无论男女老少的每一个人
\autocites[85]{latham2000}[2]{guoshuanglin2006}[10--20]{aimaniuaier2007}
一同庆祝国际幸福日
\autocite[85]{latham2000},
以及每个课堂、每家企业、每个政府
\autocite[1-3]{guojianlong2017}。

\printbibliography[heading=bibliography]
\end{document}
hushidong commented 6 months ago

已更新,github上的你下载覆盖一下就好了。

昨天多放了一个unspace。

TomBener commented 6 months ago

好的,没问题了,非常感谢!