1

please see my alternative question below. :)


I'm currently working on a bst file for a multivolume companion (approx. 1800 pages in total). By using makebst, I tried to apply the guidelines that my publisher gave to me. Yet, the resulting bst file is not satisfying all my needs.

These are the guidelines:

Monographs:
Alpha, B. (edition numberyear). book title. publisher.
Gamma, D./Epsilon, Z. (eds., year). booktitle. publisher.
Articles:
Iota, K. (year). article title, journal name volume: pages.
Articles in companions:
Ny, L. (year). article title, "in:" E. Ditor (ed., year), book title. publisher. pages.

I have already inserted the "ed., "/"eds., " before the year. Now I'm struggling with the edition number that should be superscripted right in front of the year. There ist still a ", " before the edition number. Also, it should appear in the in-text citation (e.g., "Alpha (edition numberyear, page)").

I would appreciate if some of you could have a look at the bst file. And maybe tell me how to get rid of the extra ", ", and how to add the edition number to the in-text citation.


I bet my problems are way easier to fix with biblatex. I have already customized a bbx file, that satisfyies the guidelines from above. But, the publisher wants to diferent in-text citation styles:

in-text citation: Alpha (edition numberyear, page)
footnote citation: Alpha (edition numberyear) page

At the moment (as I'm using bibtex with natbib), I modified the \footnote command to set a boolean variable to true. This way, my modified \citet command checks if the citation is inside the normal text or a footnote. (I exspect this to end up in a much higher compilation time due to setting the boolean variavble to true and false at each \footnote and to check the variable at each \citet.) This modification is not perfect yet. (Cf. \citet{Alpha:2002} => "Alpha (2002, )")

Thank you so much or your help. rsa-krypto


bst-test.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}

test-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}}

EDIT:
test-companion.bst
https://pastebin.com/TnFxFwXq

EDIT2:
babelbst.tex
https://pastebin.com/k1p1TkZ2

2

You'll need to hack your .bst file a bit. See https://gist.github.com/moewew/ac72ac1c5194b146afb5ba5f6b55f928/revisions, the diff is

--- 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$ "" }

Additionally, you'll need to make sure that postnotes are recognised properly. The footnote detection is more idiomatic with a boolean/\if... instead of a string variable.

\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}

enter image description here


Normally I would suggest to use biblatex for complex custom styles as these, but (1) even these days publishers can rarely accept biblatex submissions (see Biblatex: submitting to a journal) - except if they take the PDF directly -, furthermore (2) you seem to have gotten quite far with BibTeX already and lastly (3) the combined editor/year brackets looks like it would need quite a bit of code restructuring (not impossible, but a lot of work).

For the fun of it, here is a suggestion for a biblatex solution.

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.