![如何在 \tldatelabelcventry 中调用宏](https://linux22.com/image/291206/%E5%A6%82%E4%BD%95%E5%9C%A8%20%5Ctldatelabelcventry%20%E4%B8%AD%E8%B0%83%E7%94%A8%E5%AE%8F.png)
编辑:添加了 MWE。
编辑2:提供工作中间MWE。
我在用moderncv
和moderntimeline
包裹。
我想加入一个 hackhttps://tex.stackexchange.com/a/85981/6908以与简历其他部分相同的格式显示出版物。这很好用,只是我希望它与软件包一起使用moderntimeline
。
然而,我无法成功。我认为这与扩展问题有关。
这是 MWE。
\documentclass[11pt,a4paper,sans]{moderncv}
\usepackage[firstyear=1996,lastyear=2018]{moderntimeline}
\tlwidth{0.8ex}
\usepackage{xpatch}
\usepackage[url=false,backend=biber,
style=authoryear,
doi=false,
isbn=false,
backref=false,
sorting=ydnt]{biblatex}
%remove brackets from year
\xpatchbibmacro{date+extrayear}{%
\printtext[parens]}{\printtext}{}{}
% remove year from the author bibmacro
\xpatchbibmacro{author}{%
\usebibmacro{date+extrayear}}
{}{}{}
%change order and wrap into \cvline
\DeclareBibliographyDriver{article}{%
\cvline{\usebibmacro{date+extrayear}}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
\usebibmacro{in:}%
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{byeditor+others}%
\newunit
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\usebibmacro{related}%
\usebibmacro{finentry}}%
}
\addbibresource{biblatex-examples.bib}
% personal data
\name{Joe}{Smith}
\moderncvstyle{classic}
\moderncvcolor{blue}
\begin{document}
\nocite{bertram}
\printbibliography[title={Publications}]
\end{document}
将包中的\cvline
to更改为如下\tldatelabelcventry
moderntimeline
\documentclass[11pt,a4paper,sans]{moderncv}
\usepackage[firstyear=1996,lastyear=2018]{moderntimeline}
\tlwidth{0.8ex}
\usepackage{xpatch}
\usepackage[url=false,backend=biber,
style=authoryear,
doi=false,
isbn=false,
backref=false,
sorting=ydnt]{biblatex}
%remove brackets from year
\xpatchbibmacro{date+extrayear}{%
\printtext[parens]}{\printtext}{}{}
% remove year from the author bibmacro
\xpatchbibmacro{author}{%
\usebibmacro{date+extrayear}}
{}{}{}
%change order and wrap into \cvline
\DeclareBibliographyDriver{article}{%
\tldatelabelcventry{
2006 % actual year from bibitem
}{
2006 % Label of year (should be the same)
}{
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
%\usebibmacro{author/translator+others}
%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
\usebibmacro{in:}%
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{byeditor+others}%
\newunit
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\usebibmacro{related}%
\usebibmacro{finentry}}{}{}{}%
}
\addbibresource{biblatex-examples.bib}
% personal data
\name{Joe}{Smith}
\moderncvstyle{classic}
\moderncvcolor{blue}
\begin{document}
\nocite{bertram}
\printbibliography
\end{document}
得到以下结果
除了年份是硬编码外,其他都很好。
我需要做哪些更改才能使其与 bibitem 的实际年份相符?
我尝试使用,\usebibmacro{date+extrayear}
但没有成功。
答案1
查看这里应该一起工作的软件包biblatex
和moderntimeline
,乍一看这似乎是一个无望的情况。
所有biblatex
用户宏都是尽可能不可扩展的,而pgfmath
时间线所需的计算似乎需要可扩展性。
我通过以下方法获得了看似可以接受的结果:
%change order and wrap into \cvline
\DeclareBibliographyDriver{article}{%
\tldatelabelcventry{
\thefield{year}% actual year from bibitem
}{
\thefield{year}% Label of year (should be the same)
}{
得出
\nocite{bertram}
\nocite{doody}
\nocite{shore}
结果
观察 bib 条目
@article{doody,
author = {Doody, Terrence},
title = {Hemingway's Style and Jake's Narration},
year = 1974,
@article{shore,
author = {Shore, Bradd},
title = {Twice-Born, Once Conceived},
journaltitle = {American Anthropologist},
date = {1991-03},
已经显示出相对于“年份”字段的来源的一定程度的变化,因此这种方法似乎提供了一定的稳健性。
免责声明:biber
我对或一无所知,biblatex
所以moderntimeline
可能存在我不知道的隐藏陷阱。
更新:由于最后一个.
确实是硬编码的\cventry
,因此需要在之后添加此补丁来将其删除\moderncvstyle{classic}
:
\moderncvstyle{classic}
\moderncvcolor{blue}
\xpatchcmd\cventry{.\strut}{\strut}{}{}