Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 biblatex 时,期刊名应保留大小写 #338

Closed
4 tasks done
ZH-ye opened this issue Apr 15, 2022 · 9 comments
Closed
4 tasks done

使用 biblatex 时,期刊名应保留大小写 #338

ZH-ye opened this issue Apr 15, 2022 · 9 comments
Labels

Comments

@ZH-ye
Copy link

ZH-ye commented Apr 15, 2022

检查

  • 已经阅读《研究生学位论文撰写手册》或《中国科学技术大学本科毕业论文(设计)格式》
  • 已经将模板升级到了最新版
  • 已经阅读使用说明文档 ustcthesis.pdf
  • 已经阅读 常见问题

编译环境

  • 编译的系统:Ubuntu 18.04
  • TeX 发行版:TeX Live 2021
  • 模板类型:doctor

描述问题

《研究生学位论文撰写手册》第 59 页给出的例子是
Screenshot from 2022-04-15 09-01-06

而模板编译的结果是……
Screenshot from 2022-04-15 09-05-05

截图:

复现上述问题的代码:
直接使用模板中的 ustcthesis-numeric 风格,选择 biblatex

workaround:
我目前把 ustcthesis-numeric.bbx 改为

\ProvidesFile{ustcthesis-numeric.bbx}[2021/01/19 v1.0 USTCThesis biblatex
  bibliography style]


\RequireBibliographyStyle{gb7714-2015}

\ExecuteBibliographyOptions{
  gbpub     = false,
  gbalign   = left,
}

% redefine the titlecase of gb7714-2015 as titletitlecase
% 对期刊文章和析出的文献,使用 句首大写 
\DeclareFieldFormat{titletitlecase}{\iftoggle{bbx:titlelink}{%
\iffieldundef{url}{\MakeSentenceCase{#1}}{%
\href{\thefield{url}}{#1}}}{\MakeSentenceCase{#1}}}

\DeclareFieldFormat{maintitlecase}{\iftoggle{bbx:titlelink}{%
\iffieldundef{url}{\MakeSentenceCase{#1}}{%
\href{\thefield{url}}{#1}}}{\MakeSentenceCase{#1}}}


\DeclareFieldFormat[inbook,inproceedings,incollection]{maintitlecase}{\iftoggle{bbx:titlelink}{%
\iffieldundef{url}{#1}{%
\href{\thefield{url}}{#1}}}{#1}}

\renewbibmacro*{maintitle}{%
  \ifboolexpr{
    test {\iffieldundef{maintitle}}
    and
    test {\iffieldundef{mainsubtitle}}
  }
    {}
    {\printtext[maintitle]{%
       \printfield[maintitlecase]{maintitle}%
       \setunit{\subtitlepunct}%
       \printfield[maintitlecase]{mainsubtitle}}%
     \newunit}%
  \printfield{maintitleaddon}}

% redefine the title macro based on gb7714-2015.bbx, change the format to titletitlecase 
\renewbibmacro*{title}{%
  \ifboolexpr{%
    test{\iffieldundef{title}}%
    and
    test{\iffieldundef{subtitle}}%
  }%
    {}%
    {\printtext[title]{\bibtitlefont%增加字体控制命令
       \printfield[titletitlecase]{title}%
       \ifboolexpr{test {\iffieldundef{subtitle}}}%这里增加了对子标题的判断,解决不判断多一个点的问题
       {}{\setunit{\subtitlepunct}%
       \printfield[titletitlecase]{subtitle}}%
       \iffieldundef{titleaddon}{}%判断一下titleaddon,否则直接加可能多一个空格
        {\setunit{\subtitlepunct}\printfield{titleaddon}}%
        \iftoggle{bbx:gbtype}{%
         \iffieldundef{note}{\printfield[gbtypeflag]{usera}}%在标题后直接给出文献标识字母,判断一下,是否是报纸和标准
        {\iffieldequalstr{note}{standard}{\printfield[gbtypeflags]{usera}}%判断是否为标准
                                         {\iffieldequalstr{note}{news}{\printfield[gbtypeflagn]{usera}}%判断是否为报纸
                                                                      {\printfield[gbtypeflag]{usera}}}%其它
        }}{}%
     %\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点
     %\newunit
}%
}}


%
%   重设专利title的输出,将文献类型标识符输出出去
%
\renewbibmacro*{patenttitle}{%原输出来自biblatex.def文件
  \ifboolexpr{%
    test{\iffieldundef{title}}%
    and%
    test{\iffieldundef{subtitle}}%
  }%
    {}%
    {\printtext[title]{\bibtitlefont%
       \printfield[titletitlecase]{title}%
       \ifboolexpr{test {\iffieldundef{subtitle}}}
       {}{\setunit{\subtitlepunct}%
       \printfield[titletitlecase]{subtitle}}%
       \iffieldundef{titleaddon}{}
        {\setunit{\subtitlepunct}\printfield{titleaddon}}%
       % \setunit{\subtitlepunct}\printfield{number}%写专利号
       \setunit{\subtitlepunct}%
       \iflistundef{location}{}
        {\printlist{location}\setunit{\addcomma\space}}% 专利国别
       \printfield{number}%写专利号
       \iftoggle{bbx:gbtype}{\printfield[gbtypeflag]{usera}}{}%
     %\iffieldundef{booktitle}{\newunit}{}%当title是析出时,不要标点
     %\newunit
     }%
}%
\clearlist{location}\clearlist{address}%
}
@zepinglee
Copy link
Member

确实,这里把错误地将所有的 titlecase 改成 sentence case 了,包括 journal title。

\DeclareFieldFormat{titlecase}{\iftoggle{bbx:titlelink}{%
\iffieldundef{url}{\MakeSentenceCase{#1}}{%
\href{\thefield{url}}{#1}}}{\MakeSentenceCase{#1}}}

@zepinglee zepinglee added the bug label Apr 15, 2022
@zepinglee
Copy link
Member

不过这个 titletitlecasemaintitlecase 有点让人混淆啊,我还是改成 sentencecasetitlecase 的名字吧。

@ZH-ye
Copy link
Author

ZH-ye commented Apr 15, 2022

要点在于避免修改 titlecase 这个默认 format。大多数的可称为 title 的域 (title,booktitle,maintitle ,journal, etc.) 都在用这个 format。
例如默认的期刊的题注中,文章的名字 ( title) 和期刊的名字 (journal ) 的 format 都是 titlecase, 直接修改 titlecase 无法区分两者。
由于 maintitlecase 就是 maintitlesubmaintitle 的 format, 这个名字似乎还好。
titletitlecase 换个名字倒是可以,但务必避开 titlecase 这个名字。

@zepinglee
Copy link
Member

@ZH-ye 你试一下 issue#338 分支的修复。

@ZH-ye
Copy link
Author

ZH-ye commented Apr 15, 2022

经测试,在两种风格下,模板中的引文看起来都符合要求了。谢谢。

记录一下为何我的 workaround 中更改了 maintitle 的格式:按照 biblatex 文档,maintitle 域为多卷的作品而引入。
gb7714-2015.bbx 中, book 类型的 driver 的书名部分为

\usebibmacro{maintitle+title}%

maintitle 为书名的一部分。

鉴于 maintitle 域用的很少,目前的方案能应对大多数情况。

@ZH-ye ZH-ye closed this as completed Apr 15, 2022
@zepinglee
Copy link
Member

记录一下为何我的 workaround 中更改了 maintitle 的格式:按照 biblatex 文档,maintitle 域为多卷的作品而引入。 gb7714-2015.bbx 中, book 类型的 driver 的书名部分为

原来你的意思是“‘main title‘ case”,我理解成“main ‘title case’”了,难怪读不懂。其实按照《手册》的示例,maintitle+title 使用 sentence case,但是 maintitle+booktitle 使用 title case。

我觉得可以根据 booktitle 是否为空选择 \printfield{maintitle}\printfield{mainsubtitle} 的 case。

@zepinglee
Copy link
Member

6997e02 中增加了 maintitle 的处理。另外吐槽一下 biblatex 的代码缩进简直是坨*。

@ZH-ye
Copy link
Author

ZH-ye commented Apr 16, 2022

我看了一下 standard.bbxgb7714-2015.bbx, maintitle+booktitle 只在 inbook,incollection, 和 inproceedings 这三个 driver 中出现,maintitle+titlebook,collectionproceedings 中使用,通过 entry 的类型判断应该也可以。

@zepinglee
Copy link
Member

我看了一下 standard.bbxgb7714-2015.bbx, maintitle+booktitle 只在 inbook,incollection, 和 inproceedings 这三个 driver 中出现,maintitle+titlebook,collectionproceedings 中使用,通过 entry 的类型判断应该也可以。

国标的 standardreport 也可以像 inproceedings 的格式一样有 booktitle,所以还是直接用 bookttitle 判断更合适。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants