如何在 \tldatelabelcventry 中调用宏

如何在 \tldatelabelcventry 中调用宏

编辑:添加了 MWE。

编辑2:提供工作中间MWE。

我在用moderncvmoderntimeline包裹。

我想加入一个 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}

将包中的\cvlineto更改为如下\tldatelabelcventrymoderntimeline

\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

查看这里应该一起工作的软件包biblatexmoderntimeline,乍一看这似乎是一个无望的情况。

所有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}{}{}

在此处输入图片描述

相关内容