书目从不同领域获取具体信息

书目从不同领域获取具体信息

我希望我搜索得当,因为我什么也没找到。我正在寻找一种从字符串中获取特定信息的方法。如下所示,字段“usera”[(01.01.2009)] 中有一个日期,字段“userb”[(..., 2009)] 中有一个年份,这是相同的信息。如何才能摆脱“userb”,从“usera”中获取信息并在我的参考书目中同时显示两者。所以我只想在 usera 中添加完整日期并显示它,而 latex 应该只从 usera 中提取年份并显示它。

举例

@online{kapselung,
  title = "Rheinwerk Computing :: Objektorientierte Programmierung – 2.2 Die Kapselung von Daten",
  shorttitle = "Kapselung von Daten",
  author = "Lahres, Bernhard and Rayman, Gregor",
  url = "http://openbook.rheinwerk-verlag.de/oop/oop_kapitel_02_002.htm",
  userb = 2009,
  usera = {01.01.2009},
  note = "13:21", 
  year = "28.04.2020"
}


\DeclareBibliographyDriver{online}{%
  \textit{\printnames{author}}%
  \newunit\space
  \printtext{$($}%
  \printfield{shorttitle}%
  \setunit*{\addcomma\addspace}%
  \printfield{userb}%
  \printtext{$)$}%
  \setunit*{\addcolon\space}%
  \printfield{title}%
  \setunit*{\addcomma\space<}%
  \textit{\printfield{url}>\space}%
  \printtext{$($}%
  \printfield{usera}%
  \printtext{$)$}%
  \setunit*{\space{[Zugriff}\space}%
  \printfield{year}%
  \setunit*{\space}%
  \printfield{note}%
  \printtext{\space{Uhr}}%
  \printtext{$]$}%
}
´´´

答案1

对于日期,我建议您使用biblatex的日期字段。据我所知,您甚至不需要定义新的日期字段(这是可能的,例如askdate参见如何使用 BibLaTeX/Biber 创建全新的数据类型?),您可以只使用date发布日期(date = {2009-01-01},在示例中)和urldate访问日期(urldate = {2020-04-28T13:21:00},在示例中)。

\printdate然后您可以使用和打印日期,并可以使用和选项\printurldate设置日期格式。dateurldate


问题中显示的书目驱动程序有点不符合习惯。

常见的做法是将逻辑代码块分离为可重复使用的 bibmacro,这样驱动程序代码会更清晰(也更短),更容易修改(您可能只需要更改 bibmacro,而不必更改驱动程序)。当然,这绝不是一项要求,但它非常常见。

格式化命令\textit不应该出现在驱动程序中,也几乎不应该出现在 bibmacro 级别

\textit{\printnames{author}}%

相反,应该通过字段(或列表或名称)格式应用格式。例如,要在条目开头获取作者/编辑者的斜体名称,您可以使用

\DeclareNameWrapperFormat{sortname}{\mkbibemph{#1}}

采用authoryear- 和 -authortitle为基础的标准风格。

类似地,括号和尖括号通常应用于字段格式而不是通过\setunit

理想情况下,应该用 bibstring 替换“Zugriff”和“Uhr”等硬编码文本,无论如何,它也应该在字段格式中使用。


正如评论中所猜测和确认的,这是德国 FOM 大学书目样式的一个版本。FOM 学期论文/毕业论文的模板可在以下网址获取:https://github.com/andygrunwald/FOM-LaTeX-Template但显然人们的需求和要求之间往往存在细微的差异。德国 goLaTeX 论坛上也有很多关于这种风格的讨论:https://golatex.de/viewtopic,p,104643.htmlhttps://golatex.de/viewtopic,p,104202.htmlhttp://golatex.de/viewtopic,p,92889.htmlhttp://golatex.de/viewtopic,p,98865.htmlhttp://golatex.de/viewtopic,p,99465.html

以下代码来自我的回答https://golatex.de/viewtopic.php?p=109679#p109679应该非常接近您显示的书目条目。如您所见,不需要重写书目驱动程序。可以通过重新定义 bibmacros 和修补驱动程序来实现所需的结果。

请注意,此代码用于usera“Stichwort”。

\documentclass[ngerman]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[autostyle, german=guillemets]{csquotes}
\usepackage[backend=biber, style=ext-authoryear,
  isbn=false,
  maxcitenames=2, maxbibnames=999,
  mergedate=false,
  innamebeforetitle, dashed=false,
  autocite=footnote, mincrossrefs=1,
  alldates=comp, labeldate=year,]{biblatex}


\setlength{\bibinitsep}{.5\baselineskip}

\setlength\bibhang{1cm}

\DeclareLabeldate{%
  \field{date}
  \field{year}
  \field{eventdate}
  \field{origdate}
  \literal{nodate}
}

\renewcommand*{\finentrypunct}{}

\renewcommand*{\newunitpunct}{\addcomma\space}
\DeclareDelimFormat[bib,biblist]{nametitledelim}{\addcolon\space}
\DeclareDelimFormat{titleyeardelim}{\newunitpunct}

\renewcommand*{\mkbibcompletename}{\mkbibemph}

\DeclareDelimAlias{finalnamedelim}{multinamedelim}

\DeclareNameFormat{family-given:init}{%
  \usebibmacro{name:family-given}
    {\namepartfamily}
    {\namepartgiveni}
    {\namepartprefix}
    {\namepartsuffix}%
  \usebibmacro{name:andothers}}

\DeclareNameAlias{default}{family-given}
\DeclareNameAlias{sortname}{default}
\DeclareNameAlias{labelname}{family-given:init}

\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\DeclareDelimFormat{editortypedelim}{\addspace}
\DeclareFieldFormat{translatortype}{\mkbibparens{#1}}
\DeclareDelimFormat{translatortypedelim}{\addspace}

\DeclareDelimFormat[bib,biblist]{innametitledelim}{\addcomma\space}

\DeclareFieldFormat*{citetitle}{#1}
\DeclareFieldFormat*{title}{#1}
\DeclareFieldFormat*{booktitle}{#1}
\DeclareFieldFormat*{journaltitle}{#1}

\newbibmacro*{organization+location}[1]{%
  \printlist{location}%
  \setunit*{\locdatedelim}%
  \printlist{organization}%
  \newunit}

\usepackage{xpatch}
\xpatchbibdriver{online}
  {\usebibmacro{organization+location+date}}
  {\usebibmacro{organization+location}}
  {}{}

\DeclareFieldFormat[online]{date}{\mkbibparens{#1}}

\DeclareFieldFormat{url}{<\url{#1}>}% oder {$\langle$\url{#1}$\rangle$} oder \textlangle/\textrangle
\DeclareFieldFormat{urldate}{\mkbibbrackets{\bibstring{urlseen}\addcolon\space#1}}
\renewbibmacro*{url+urldate}{%
  \usebibmacro{url}%
  \ifentrytype{online}
    {\setunit{\addspace}%
     \usebibmacro{date}}
    {}%
  \iffieldundef{urlyear}
    {}
    {\setunit*{\addspace}%
     \usebibmacro{urldate}}}

\renewbibmacro*{date+extradate}{%
  \printtext[parens]{%
    \printfield{usera}%
    \setunit{\printdelim{titleyeardelim}}%
    \printlabeldateextra}}

\renewbibmacro*{date}{%
  \usebibmacro{bbx:ifmergeddate}
    {}
    {\iffieldundef{year}
       {\printtext[date]{\bibstring{nodate}}}
       {\printdate}}}

\DefineBibliographyStrings{german}{
  nodate    = {{}o.\adddot \addabbrvspace J\adddot},
  andothers = {et\addabbrvspace al\adddot},
  urlseen   = {Zugriff},
}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \pernottype{set}
      \step[notfield=translator, final]
      \step[notfield=editor, final]
      \step[fieldset=author, fieldvalue={\string{o.\noexpand\,V\noexpand\adddot\string}}, final]
      \step[fieldset=sortname, fieldvalue={zzzzzzzzz}]
    }
    \map{
      \pernottype{online}
      \step[fieldset=location, fieldvalue={o.\noexpand\,O\noexpand\adddot}]
    }
  }
}

\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\printdelim{nonametitledelim}}}
       {\printnames{labelname}%
        \setunit{\printdelim{nametitledelim}}}%
     \printfield{usera}%
     \setunit{\printdelim{titleyeardelim}}%
     \usebibmacro{cite:labeldate+extradate}}
    {\usebibmacro{cite:shorthand}}}

\renewbibmacro*{postnote}{%
  \setunit{\postnotedelim}%
  \iffieldundef{postnote}
    {\printtext{o\adddot\addabbrvspace S\adddot}}
    {\printfield{postnote}}}


\begin{filecontents*}{\jobname.bib}
@online{test1Mit,
  author  = {Artur Autor},
  title   = {Internetquelle mit Datum},
  url     = {http://example.edu/~elk/bronto.pdf},
  urldate = {2018-03-26},
  date      = {2000-06-09},
  usera   = {Test Stichwort1} ,
}
@online{test1Ohne,
  author  = {Artur Autor},
  title   = {Internetquelle ohne Datum},
  url     = {http://example.edu/~elk/bronto.pdf},
  urldate = {2018-03-26},
  usera   = {Test Stichwort2},
}
@book{test2Mit,
  author    = {Artur Autor},
  title     = {Buch mit Datum},
  edition   = {1},
  usera     = {Test Stichwort3},
  publisher = {FOMVerlag},
  location  = {Essen},
  date      = {2000}
}
@book{test2Ohne,
  author    = {Artur Autor},
  title     = {Buch ohne Datum},
  edition   = {1},
  usera     = {Test Stichwort4},
  publisher = {FOMVerlag},
  location  = {Essen},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\cite{test1Mit}
\cite{test1Ohne}
\cite{test2Mit}
\cite{test2Ohne}
\printbibliography[nottype=online]
\printbibliography[type=online,title={Internetquellen}]
\end{document}

作者,Artur (Test Stichwort1, 2000b): Internetquelle mit Datum, <http://example.edu/~elk/bronto.pdf> (2000 年 6 月 9 日) [发布日期:2018 年 3 月 26 日]

相关内容