biblatex:句子大小写和嵌套引号

biblatex:句子大小写和嵌套引号

如果标题包含格式化命令,我们如何才能\MakeSentenceCase确保大小写正确,例如,引号嵌套?下面的示例不起作用;引号嵌套正确,但“引号”仍然是标题大小写。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{test.bib}
@article{ref,
  sorttitle = {Handle Quotation Marks within Article Titles},
  author = {Lastname, Firstname},
  title = {Handle \mkbibquote{Quotation Marks} within Article Titles},
  journal = {Journalname},
  volume = {10},
  date = {1},
  pages = {5--10}}
\end{filecontents}

\bibliography{test.bib}

\DeclareFieldFormat{sentencecase}{\MakeSentenceCase*{#1}}
\renewbibmacro{title}{%
    \ifthenelse{\iffieldundef{title}\AND\iffieldundef{subtitle}}{}
        {\ifthenelse{\ifentrytype{article}\OR\ifentrytype{inbook}%
            \OR\ifentrytype{incollection}\OR\ifentrytype{inproceedings}}
            {\printtext[title]{%
                \printfield[sentencecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[sentencecase]{subtitle}}%
                \newunit}%
            {\printtext[title]{%
                \printfield[titlecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[titlecase]{subtitle}}%
                \newunit}}%
    \printfield{titleaddon}}

\begin{document}
    \textcite{ref}
    \printbibliography
\end{document}

答案1

作为一种解决方法,您可以使用csquote\MakeAutoQuote宏来定义可以代替 的活动字符\mkbibquote。(在我的示例中,我使用«»。)

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\MakeAutoQuote{«}{»}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{test.bib}
@article{ref,
  sorttitle = {Handle Quotation Marks within Article Titles},
  author = {Lastname, Firstname},
  title = {Handle «Quotation Marks» within Article Titles},
  journal = {Journalname},
  volume = {10},
  date = {1},
  pages = {5--10}}
\end{filecontents}

\bibliography{test.bib}

\DeclareFieldFormat{sentencecase}{\MakeSentenceCase*{#1}}
\renewbibmacro{title}{%
    \ifthenelse{\iffieldundef{title}\AND\iffieldundef{subtitle}}{}
        {\ifthenelse{\ifentrytype{article}\OR\ifentrytype{inbook}%
            \OR\ifentrytype{incollection}\OR\ifentrytype{inproceedings}}
            {\printtext[title]{%
                \printfield[sentencecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[sentencecase]{subtitle}}%
                \newunit}%
            {\printtext[title]{%
                \printfield[titlecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[titlecase]{subtitle}}%
                \newunit}}%
    \printfield{titleaddon}}

\begin{document}
    \textcite{ref}
    \printbibliography
\end{document}

答案2

仅供记录之用,如果将引用宏嵌套在另一对括号中,它也会起作用:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{test.bib}
@article{ref,
  sorttitle = {Handle Quotation Marks within Article Titles},
  author = {Lastname, Firstname},
  title = {Handle {\mkbibquote{Quotation Marks}} within Article Titles},
  journal = {Journalname},
  volume = {10},
  date = {2018},
  pages = {5--10}}
\end{filecontents}

\bibliography{test.bib}

\DeclareFieldFormat{sentencecase}{\MakeSentenceCase*{#1}}
\renewbibmacro{title}{%
    \ifthenelse{\iffieldundef{title}\AND\iffieldundef{subtitle}}{}
        {\ifthenelse{\ifentrytype{article}\OR\ifentrytype{inbook}%
            \OR\ifentrytype{incollection}\OR\ifentrytype{inproceedings}}
            {\printtext[title]{%
                \printfield[sentencecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[sentencecase]{subtitle}}%
                \newunit}%
            {\printtext[title]{%
                \printfield[titlecase]{title}%
                \setunit{\subtitlepunct}%
                \printfield[titlecase]{subtitle}}%
                \newunit}}%
    \printfield{titleaddon}}

\begin{document}
    \textcite{ref}
    \printbibliography
\end{document}

请注意,这并不总是有效(标题的开头全部大写,在这样的引号中强制将名称等成分大写是不可能的)。

对于这些特殊情况,如果您不能按照@lockstep 的建议使用活动字符(例如,因为您需要使用 运行 biber )--output-safechars,您也可以使用 csquotes 文本宏(\textooquote\textcoquote和)。\textoiquote\textciquote

相关内容