定制 bst:版本号

定制 bst:版本号

请参阅下面我的替代问题。:)


我目前正在为一本多卷本的配套书籍(总共约 1800 页)制作一个 bst 文件。通过使用makebst,我尝试应用出版商给我的指导方针。然而,生成的 bst 文件并不能满足我的所有需求。

以下是指导原则:

专著:
Alpha, B.(版本号年份)。书名。出版商。Gamma
, D./Epsilon, Z.(编辑,年份)。书名。出版商。
文章:
Iota,K.(年份)。文章标题,期刊名称卷:页。
同伴中的文章:
Ny,L.(年份)。文章标题,“在:”E. Ditor(编辑,年份),书名。出版商。页数。

我已经在年份前插入了“ed., / eds., ”。现在,我不知道版本号应该放在年份前面的上标。版本号前面还有一个“, ”。此外,它应该出现在文内引用中(例如,“Alpha(版本号年份,页码)”)。

如果你们能看一下 bst 文件,我将不胜感激。也许能告诉我如何去掉多余的“,”以及如何将版本号添加到文内引用中。


我敢打赌,使用 可以更轻松地解决我的问题biblatex。我已经自定义了一个 bbx 文件,它满足上述指导原则。但是,出版商想要不同的文内引用样式:

文内引用:Alpha(版本号年份,页码)
脚注引用:Alpha(版本号年份)页面

目前(因为我正在使用 bibtex 和 natbib),我修改了命令\footnote以将布尔变量设置为true。这样,我修改后的\citet命令会检查引用是在普通文本中还是脚注中。(我预计这会导致编译时间大大增加,因为在每个 处将布尔变量设置为true和,并检查每个 处的变量。)此修改尚不完善。(参见=> “Alpha (2002, )”)false\footnote\citet\citet{Alpha:2002}

非常感谢您的帮助。rsa-krypto


bst-测试.tex:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[]{natbib}
    \bibpunct[:\ ]{(}{)}{;}{a}{}{;}

\let\svfootnote\footnote
\renewcommand{\footnote}[2][\thefootnote]{%
    \stepcounter{footnote}%
    \gdef\infootnote{T}%
    \svfootnote[#1]{#2\gdef\infootnote{F}}%
}
\gdef\infootnote{F}

\makeatletter
\newcommand{\citefoot}[2][]{%
    \@ifnextchar[%
    {\citeauthor{#2} (\citeyear{#2})}%  w
    {\citeauthor{#2} (\citeyear{#2}) #1}%   w/o
}
\newcommand{\citetxt}[2][]{%
    \@ifnextchar[%
    {\citeauthor{#2} (\citeyear{#2})}%  w
    {\citeauthor{#2} (\citeyear{#2}, #1)}%  w/o
}
\renewcommand{\citet}[2][]{%
    \if T\infootnote%
        \citefoot[#1]{#2}%
    \else%
        \citetxt[#1]{#2}%
    \fi%
}
\makeatother

\begin{document}
    Dies ist ein Testdokument zum Prüfen der bst-Datei.

    \infootnote

    \footnote{Cf. \citet[12]{Alpha:2002}.}

    \citet{Alpha:2002};
    \citet[13]{Gamma:2015};
    \citet[14]{Iota:1998};
    \citet[15]{Ny:2018}

    \bibliographystyle{test-companion}
    \bibliography{test-companion}
\end{document}

测试-companion.bib:

@book{Alpha:2002,
    Author = {Beta Alpha},
    Note = {(= optional note)},
    Publisher = {Chicago},
    Title = {Book title},
    Year = {2002},
    edition = {2}}

@book{Gamma:2015,
    editor = {Delta Gamma and Zeta Epsilon},
    Publisher = {Berlin},
    Title = {Another book},
    Year = {2015}}

@article{Iota:1998,
    Author = {Kappa Iota},
    Journal = {journal name},
    Volume = {24},
    Pages = {11--18},
    Title = {article title},
    Year = {1998}}

@incollection{Ny:2018,
    Author = {Lambda Ny},
    Booktitle = {book title},
    Editor = {E. Ditor},
    Pages = {93--129},
    Publisher = {London},
    Title = {article title},
    Year = {2018}}

编辑:
test-companion.bst
https://pastebin.com/TnFxFwXq

编辑2:
babelbst.tex
https://pastebin.com/k1p1TkZ2

答案1

你需要对.bst文件进行一些修改。参见https://gist.github.com/moewew/ac72ac1c5194b146afb5ba5f6b55f928/revisions,差异是

--- test-companion.bst  2018-06-26 10:08:57.485028100 +0200
+++ test-companion.bst  2018-06-26 09:52:36.723647200 +0200
@@ -683,16 +683,26 @@
   if$
 }

-FUNCTION {format.edition}
+FUNCTION {format.superedition}
 { edition duplicate$ empty$
+    { pop$ "" }
+    { superscript }
+  if$
+}
+
+FUNCTION {format.edition}
+{ edition duplicate$ empty$ 'skip$
     {
-      pop$ ""
-    }
-    {
-      superscript
+      output.state mid.sentence =
+        { "l" }
+        { "t" }
+      if$ change.case$
+      "edition" bibinfo.check
+      " " * bbl.edition *
     }
   if$
 }
+
 INTEGERS { multiresult }
 FUNCTION {multi.page.check}
 { 't :=
@@ -931,7 +941,7 @@
       if$
     }
   if$
-  format.edition output
+  format.superedition swap$ write$
   format.date "year" output.check
   date.block
   format.btitle "title" output.check
@@ -1294,6 +1304,12 @@
   short.list
   "("
   *
+  edition duplicate$ empty$
+  short.list key field.or.null = or
+     { pop$ "" }
+     { "$^{" swap$ * "}$" * }
+  if$
+  *
   year duplicate$ empty$
   short.list key field.or.null = or
      { pop$ "" }

此外,您还需要确保正确识别后记。使用布尔值/\if...而不是字符串变量来检测脚注更为惯用。

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[]{natbib}
    \bibpunct[:\ ]{(}{)}{;}{a}{}{;}

\newif\ifinfootnote
\let\svfootnote\footnote
\renewcommand{\footnote}[2][\thefootnote]{%
    \stepcounter{footnote}%
    \svfootnote[#1]{\infootnotetrue#2}%
}

\makeatletter
\newcommand*{\rsacitenopost}[1]{\citeauthor{#1} (\citeyear{#1})}
\newcommand*{\rsacitepost}[2][]{\citeauthor{#2} (\citeyear{#2}\ifinfootnote) #1\else, #1)\fi}

\renewcommand*{\citet}{%
  \@ifnextchar[%]
    {\rsacitepost}
    {\rsacitenopost}}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Alpha:2002,
    Author = {Beta Alpha},
    Note = {(= optional note)},
    Publisher = {Chicago},
    Title = {Book title},
    Year = {2002},
    edition = {2}}

@book{Gamma:2015,
    editor = {Delta Gamma and Zeta Epsilon},
    Publisher = {Berlin},
    Title = {Another book},
    Year = {2015}}

@article{Iota:1998,
    Author = {Kappa Iota},
    Journal = {journal name},
    Volume = {24},
    Pages = {11--18},
    Title = {article title},
    Year = {1998}}

@incollection{Ny:2018,
    Author = {Lambda Ny},
    Booktitle = {book title},
    Editor = {E. Ditor},
    Pages = {93--129},
    Publisher = {London},
    Title = {article title},
    Year = {2018}}
\end{filecontents}

\begin{document}
    Dies ist ein Testdokument zum Prüfen der bst-Datei.

    \footnote{Cf. \citet[12]{Alpha:2002}.}

    \footnote{Cf. \citet{Alpha:2002}.}

    \citet{Alpha:2002};
    \citet[13]{Gamma:2015};
    \citet[14]{Iota:1998};
    \citet[15]{Ny:2018}

    \bibliographystyle{test-companion}
    \bibliography{\jobname}
\end{document}

在此处输入图片描述


通常我建议使用biblatex复杂的自定义样式,例如(1)即使到了现在,出版商也很少能接受biblatex投稿(见Biblatex:向期刊投稿) - 除非他们直接采用 PDF - 此外 (2) 你似乎已经在 BibTeX 方面取得了很大进展,最后 (3) 组合的编辑/年份括号看起来需要相当多的代码重组(并非不可能,但需要大量工作)。

为了好玩,这里有一个biblatex解决的建议。

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=ext-authoryear, giveninits=true, uniquename=init, innamebeforetitle, articlein=false]{biblatex}

\renewcommand*{\newunitpunct}{\addcomma\space}

\DeclareNameAlias{sortname}{family-given}
\DeclareDelimFormat{multinamedelim}{\addslash}
\DeclareDelimAlias{finalnamedelim}{multinamedelim}

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

% this is tricky, we want to merge the round brackets around
% the "ed."/"eds." and the year
% the idea is to only open the brackets in the editor string
% and the close it in the labelyear
% since editortype might also be used for editors of @in...
% types where this can't happen, we need a test
\newtoggle{bbx@editor@sortname}
\makeatletter
\renewbibmacro*{bbx:editor}[1]{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\toggletrue{bbx@editor@sortname}%
     \usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\printnames{editor}%
        \setunit{\printdelim{editortypedelim}}%
        \usebibmacro{bbx:savehash}}%
     \usebibmacro{#1}%
     \clearname{editor}%
     \setunit{\printdelim{nameyeardelim}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\printdelim{nonameyeardelim}}}%
  \usebibmacro{date+extradate}%
  \togglefalse{bbx@editor@sortname}}
\makeatother

\DeclareFieldFormat{superedition}{\textsuperscript{#1}}

\DeclareFieldFormat{editortype}{%
  \iftoggle{bbx@editor@sortname}
    {\bibopenparen #1}
    {\mkbibparens{#1}}}
\DeclareFieldFormat{biblabeldate}{%
  \iftoggle{bbx@editor@sortname}
    {\addcomma\space
     \iffieldnum{edition}
       {\printfield[superedition]{edition}%
        \csgundef{abx@field@edition}}
       {}%
     #1\bibcloseparen}
    {\mkbibparens{%
       \iffieldnum{edition}
         {\printfield[superedition]{edition}%
          \csgundef{abx@field@edition}}
         {}%
       #1}}}
\DeclareDelimFormat{editortypedelim}{\addspace}
%% tricky bit END

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

\renewbibmacro*{pubinstorg+location+date}[1]{%
  \setunit{\addperiod\space}%
  \printlist{location}%
  \iflistundef{#1}
    {\setunit*{\locdatedelim}}
    {\setunit*{\locpubdelim}}%
  \printlist{#1}%
  \setunit*{\pubdatedelim}%
  \usebibmacro{date}%
  \newunit}

\renewcommand*{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod}\space}
\DeclareFieldFormat{pages}{#1}

% some trickery is needed to get the parentheses right
% but biblatex already has a toggle to check for footnotes
\newtoggle{cbx:rsaparens}

\newbibmacro*{rsacite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\printdelim{nonameyeardelim}%
          \global\toggletrue{cbx:rsaparens}%
          \bibopenparen}}
       {\printnames{labelname}%
        \setunit{\printdelim{nameyeardelim}%
          \global\toggletrue{cbx:rsaparens}%
          \bibopenparen}}%
     \usebibmacro{rsacite:labeldate+extradate}}
    {\usebibmacro{cite:shorthand}}}

\newbibmacro*{rsacite:labeldate+extradate}{%
  \iffieldundef{labelyear}
    {}
    {\printtext[bibhyperref]{%
       \iffieldnum{edition}
         {\printfield[superedition]{edition}}
         {}%
       \printlabeldateextra}}}

\newbibmacro*{rsacite:postnote}{%
  \iftoggle{blx@footnote}
    {\iftoggle{cbx:rsaparens}
       {\global\togglefalse{cbx:rsaparens}%
        \bibcloseparen}
       {}}
    {}%
  \iffieldundef{postnote}
    {}
    {\iftoggle{cbx:rsaparens}
       {\setunit{\postnotedelim}}
       {\setunit{\extpostnotedelim}}%
     \printfield{postnote}}%
  \iftoggle{cbx:rsaparens}
    {\global\togglefalse{cbx:rsaparens}%
     \bibcloseparen}
    {}}

\RegisterCiteDelims{outer}{rsacite}
\DeclareCiteCommand{\rsacite}[\mkouterrsacitedelims]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{rsacite}}
  {\iftoggle{cbx:rsaparens}
    {\global\togglefalse{cbx:rsaparens}%
     \bibcloseparen}
    {}%
   \multicitedelim}
  {\usebibmacro{rsacite:postnote}}

\DeclareMultiCiteCommand{\rsacites}[\mkouterrsacitedelims]
  {\rsacite}{\multicitedelim}

\DeclareAutoCiteCommand{rsa}{\rsacite}{\rsacites}
\ExecuteBibliographyOptions{autocite=rsa}

\DeclareFieldFormat{postnote}{\mknormrange{#1}}
\DeclareFieldFormat{volcitepages}{\mknormrange{#1}}
\DeclareFieldFormat{multipostnote}{\mknormrange{#1}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Alpha:2002,
    Author = {Beta Alpha},
    Note = {(= optional note)},
    Publisher = {Chicago},
    Title = {Book title},
    Year = {2002},
    edition = {2}}

@book{Gamma:2015,
    editor = {Delta Gamma and Zeta Epsilon},
    Publisher = {Berlin},
    Title = {Another book},
    Year = {2015}}

@article{Iota:1998,
    Author = {Kappa Iota},
    Journal = {journal name},
    Volume = {24},
    Pages = {11--18},
    Title = {article title},
    Year = {1998}}

@incollection{Ny:2018,
    Author = {Lambda Ny},
    Booktitle = {book title},
    Editor = {E. Ditor},
    Pages = {93--129},
    Publisher = {London},
    Title = {article title},
    Year = {2018}}
\end{filecontents}

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}


\begin{document}
  Lorem\footnote{\autocite[Cf.][12]{Alpha:2002}.}
  ipsum\footnote{\autocite[Cf.][]{Alpha:2002}.}
  dolor\footnote{\autocites(Cf.)()[12]{Alpha:2002}[380]{sigfridsson}.}
  sit\footnote{\autocite[Cf.][]{Alpha:2002,sigfridsson}.}
  amet.

  \autocite[12]{sigfridsson,worman}

  \autocites[12]{sigfridsson}[13]{worman}

  \autocite{Alpha:2002};
  \autocite[13]{Gamma:2015}
  \autocite[14]{Iota:1998};
  \autocite[15]{Ny:2018}

  \cite{sigfridsson}
  \printbibliography
\end{document}

在此处输入图片描述

相关内容