使用 biblatex-ieee 有选择地引用完整月份名称?

使用 biblatex-ieee 有选择地引用完整月份名称?

考虑一下这个MWE:

\documentclass{article}
\usepackage[
  bibencoding=utf8,
  backend=biber,
  natbib,
  style=ieee, % this abbreviates month always!
  dateabbrev=true, % but this (alone) seems to have no effect on month abbreviation?
  isbn=true,
  url=true,
  defernumbers=true,
]{biblatex}
\usepackage{filecontents}
\usepackage{hyperref}

\begin{filecontents*}{\jobname.bib}
@article {jo-audm08,
  author = {Some Author},
  title = {{Testing the title of a paper}},
  url = {http://example.com/paper.pdf},
  journal={Proceedings of Some Conference},
  pages={123--127},
  publisher = {example.com},
  year={2008},
  month={jun},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\makeatletter
\DeclareCiteCommand{\citemonth}
  {\usebibmacro{prenote}}
  {%
    \let\oldabx@bibmonth\abx@bibmonth%
    %\let\abx@bibmonth\blx@imc@biblstring\typeout{CHG: abx@bibmonth \meaning\abx@bibmonth}% false: not abbreviated; but nowork
    \setkeys{blx@opt@pre}{dateabbrev=false}% nowork
    \mkbibmonth{\thefield{month}}%
    \let\abx@bibmonth\oldabx@bibmonth% restore
  }
  {\multicitedelim}
  {\usebibmacro{postnote}}
\makeatother


\begin{document}

Testing month: \citemonth{jo-audm08};

% \printbibliography[sorting=none]

\end{document}

我使用 进行编译pdflatex test.tex && biber test && pdflatex test.tex && pdflatex test.tex。无论我做什么,输出都是“ Testing month: Jun.;”;我希望得到“ Testing month: June;”。

我在上面的 MWE 中的尝试是基于这样的假设:缩写是由于选项 而引起的biblatexdateabbrev=false但后来我研究了texlive/2014/texmf-dist/tex/latex/biblatex-ieee/ieee.bbx,我看到了什么:

\DefineBibliographyStrings{english}{  
  june      = Jun\adddot ,
  july      = Jul\adddot ,
  september = Sep\adddot ,
}

所以,显然这就是六月被缩写的原因——但是为什么仅有的这三个月缩短了??!

所以原则上我可以覆盖\DefineBibliographyStrings序言中的,这将产生全局影响 - 但假设我想保留这种默认行为(这三个月缩写),并且只有在使用时才输出完整的月份名称\citemonth;这可能吗?如果可以,该怎么做?


编辑:呃,这会很复杂:在 biblatex 中重新定义“引用”字符串(及其他)

原始定义(完整版和缩写版)可在特定语言的 .lbx 文件中找到。... 这些字符串使用\DeclareBibliographyStrings仅在 .lbx 文件中可用的命令声明。在这些文件之外,您必须使用\DefineBibliographyStrings“覆盖字符串的完整版和缩写版”的命令(biblatex 手册,第 3.8 节)。

如果我可以\DeclareBibliographyStrings在序言中使用,我就可以june = {{June}{Jun\adddot}},按照english.lbx-- 来写,但我不能在那里使用它,而且我不想破解english.lbx;所以否则我必须使用\DefineBibliographyStrings覆盖两种形式的。该怎么办?

答案1

我想我明白了;首先,为什么只重新声明了这三个月?如果你看一下english.lbx-\DeclareBibliographyStrings所有缩写的月份都缩写为前三个字母 + 点,除了这三个;而 IEEE 样式显然要求缩写为三个字符。

就修复而言:基本上,我制作了一个“浅”副本,\DeclareBibliographyStrings跳过任何名为的检查\ReDeclareBibliographyStringsEnglish;这里的技巧是,如果\ReDeclareBibliographyStringsEnglish在序言中运行,它将被延迟的biblatex设置覆盖 - 因此任何使用的设置\ReDeclareBibliographyStringsEnglish都必须在开始文档之后运行。否则,本地更改dateabbrev可以正常工作:例如,下面修复的 MWE 现在输出:

测试月份:6月;
测试日期:2008年6月;

\documentclass{article}
\usepackage[
  bibencoding=utf8,
  backend=biber,
  natbib,
  style=ieee, % this abbreviates month always!
  dateabbrev=true, % but this (alone) seems to have no effect on month abbreviation?
  isbn=true,
  url=true,
  defernumbers=true,
]{biblatex}
\usepackage{filecontents}
\usepackage{hyperref}

\begin{filecontents*}{\jobname.bib}
@article {jo-audm08,
  author = {Some Author},
  title = {{Testing the title of a paper}},
  url = {http://example.com/paper.pdf},
  journal={Proceedings of Some Conference},
  pages={123--127},
  publisher = {example.com},
  year={2008},
  month={jun},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\makeatletter
\def\ReDeclareBibliographyStringsEnglish#1{% from \DeclareBibliographyStrings in \blx@lbxinput@ii, biblatex2.sty; skipping any checks
 %\begingroup % works if not wrapped in begin/end group!
 \let\blx@defstring\blx@lbx@defstring
 \blx@defbibstrings{english}{#1}%
 %\endgroup%
}%
\def\RunReDeclare{%
  \ReDeclareBibliographyStringsEnglish{% only in preamble!
    june             = {{June}{Jun\adddot}},
    july             = {{July}{Jul\adddot}},
    september        = {{September}{Sep\adddot}}, % orig english.lbx has Sept\adddot; IEEE is Sep\adddot
  }%
}%
\DeclareCiteCommand{\citemonth}
  {\usebibmacro{prenote}}
  {%
    \let\oldabx@bibmonth\abx@bibmonth%
    %\DefineBibliographyStrings{english}{% only in preamble!
    %  june      = June,%
    %  july      = July,%
    %  september = September,%
    %}%
    %\let\abx@bibmonth\blx@imc@biblstring\typeout{CHG: abx@bibmonth \meaning\abx@bibmonth}% false: not abbreviated; but nowork
    \setkeys{blx@opt@pre}{dateabbrev=false}% nowork; actually, work for true!
    \mkbibmonth{\thefield{month}}%
    \let\abx@bibmonth\oldabx@bibmonth% restore
  }
  {\multicitedelim}
  {\usebibmacro{postnote}}
\makeatother


\begin{document}

% NOTE: the \def of \ReDeclareBibliographyStringsEnglish can
% NOT sit in preamble; apparently its effect will be overridden
% by deferred setups of biblatex running at \begin{document}
% so must execute this after the \begin{document}!
\RunReDeclare

Testing month: \citemonth{jo-audm08};

Testing date: \citedate{jo-audm08};


% \printbibliography[sorting=none]

\end{document}

相关内容