Исправить файл .bst для отображения «Автор и др. (год)», если запись .bib содержит более 2 авторов?

Исправить файл .bst для отображения «Автор и др. (год)», если запись .bib содержит более 2 авторов?

Этот вопрос очень связан с вопросом здесь:

Ссылка "et al." только для четырех и более авторов с natbib и jf.bst

В ответе на этот вопрос Мико показал, как заменить функцию format.lab.names в jf.str, чтобы запись .bib отображалась как "Автор и др. (год)" всякий раз, когда в записи присутствует более 4 авторов. Однако это сделано для версии jf.str, найденной на сайте nyu.edu. Я хочу иметь возможность добиться того же поведения с файлом .str, найденным здесь

http://pages.stern.nyu.edu/~dbackus/GE_asset_pricing/BGTZ/jf.bst

который, несмотря на то, что имеет то же название, имеет некоторые изменения, необходимые для соответствия библиографическим требованиям Econometrica.

Итак, вопрос в том, может ли кто-нибудь объяснить мне, почему, когда я заменяю FUNCTION {format.lab.names} на

FUNCTION {format.lab.names}
{'s :=
 "" 't :=
  #1 'nameptr :=
  s num.names$ 'numnames :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr
      "{vv~}{ll}" format.name$
      't :=
      nameptr #1 >
        {
          nameptr #2 =
          numnames #2 > and
            { "others" 't :=
              #1 'namesleft := }
            'skip$
          if$
          namesleft #1 >
            { ", " * t * }
            {
              s nameptr "{ll}" format.name$ duplicate$ "others" =
                { 't := }
                { pop$ }
              if$
              t "others" =
                { " et~al." * }
                {
                  numnames #2 >
                    { "," * }
                    'skip$
                  if$
                  bbl.and
                  space.word * t *
                }
              if$
            }
          if$
        }
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$
}

Я не получаю «Автор и др. (год)», когда в записи .bib указано более 2 авторов. (Я понимаю, что это может быть что-то очень простое, и начал читать «Укрощение зверя» наhttp://www.lsv.ens-cachan.fr/~markey/BibTeX/doc/ttb_en.pdf). Спасибо.

Вот файл .tex для тестирования:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{abd:2007,
  author      = "Torben G. Andersen and Tim Bollerslev and Francis X. Diebold",
  title       = "Roughing it up: {Including} jump components in the
                measurement, modeling and forecasting of return volatility",
  journal     = "Review of Economics and Statistics",
  year        = 2007,
  volume      = 89,
  number      = 4,
  month       = "November",
  pages       = "701--720",
}

@article{abde:2001,
  author      = "Torben G. Andersen and Tim Bollerslev and Francis X. Diebold
                and Heiko Ebens",
  title       = "The distribution of realized stock return volatility",
  journal     = "Journal of Financial Economics",
  year        = 2001,
  volume      = 61,
  number      = 1,
  month       = "July",
  pages       = "43--76",
}

@unpublished{gavazzoni-santacreu-2015,
    Author = {Gavazzoni, Federico and Ana Maria Santacreu},
    Note = {manuscript, December},
    Title = {International R\&D spillovers and Asset prices},
    Year = {2015}
}

@article{segal-shaliastovich-yaron-2013,
    Author = {Gill, Segal and Ivan Shaliastovich and Amir Yaron},
    Journal = {Journal of Financial Economics},
    Title = {Good and bad uncertainty: macroeconomic and financial market implications},
    Volume={117},
    Pages={369-397},
    Year = {2015}
}

\end{filecontents*}
\usepackage[round,authoryear,comma]{natbib}
\bibliographystyle{jf_nyu}  % or: jf3
\begin{document}
Here's the output \\
\cite{abd:2007}\\
\cite{abde:2001}\\
\cite{gavazzoni-santacreu-2015}\\
\cite{segal-shaliastovich-yaron-2013}\\
\bibliography{\jobname}
\end{document}

решение1

Теперь, когда вы указали нам правильный bibстиль для изменения, вот гораздо более короткая замена для format.lab.names:

FUNCTION {format.lab.names}
{ 's :=
  s num.names$ 'numnames :=
  s #1 "{vv~}{ll}" format.name$
  numnames #1 >
    { s #2 "{vv~}{ll}" format.name$ 't :=
      numnames #2 >
      t "others" =
      or
        { " et~al." * }
        { " and " * t * }
      if$
    }
    'skip$
  if$
}

На вашем образце файла (слегка подправленном, см. ниже) он выдает

Пример вывода

Функция работает следующим образом. Сначала сохраните список авторов в s. Сохраните количество авторов в numnames. Отформатируйте первую ( #1) запись и выведите ее. Затем, если есть более одного имени, отформатируйте следующее имя и присвойте его t. Если tбыло "others"или на самом деле есть более двух авторов, выведите et al.остальных, выведите второго (последнего) автора, которому предшествует and.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{abd:2007,
  author      = "Torben G. Andersen and Tim Bollerslev and Francis X. Diebold",
  title       = "Roughing it up: {Including} jump components in the
                measurement, modeling and forecasting of return volatility",
  journal     = "Review of Economics and Statistics",
  year        = 2007,
  volume      = 89,
  number      = 4,
  month       = "November",
  pages       = "701--720",
}

@article{abde:2001,
  author      = "Torben G. Andersen and Tim Bollerslev and Francis X. Diebold
                and Heiko Ebens",
  title       = "The distribution of realized stock return volatility",
  journal     = "Journal of Financial Economics",
  year        = 2001,
  volume      = 61,
  number      = 1,
  month       = "July",
  pages       = "43--76",
}

@unpublished{gavazzoni-santacreu-2015,
    Author = {Gavazzoni, Federico and Ana Maria Santacreu},
    Note = {manuscript, December},
    Title = {International R\&D spillovers and Asset prices},
    Year = {2015}
}

@article{segal-shaliastovich-yaron-2013,
    Author = {Gill, Segal and Ivan Shaliastovich and Amir Yaron},
    Journal = {Journal of Financial Economics},
    Title = {Good and bad uncertainty: macroeconomic and financial market implications},
    Volume={117},
    Pages={369-397},
    Year = {2015}
}

\end{filecontents*}
\usepackage[round,authoryear,comma]{natbib}

\bibliographystyle{jf1}  % or: jf3

\begin{document}
Here's the output

\cite{abd:2007}

\cite{abde:2001}

\cite{gavazzoni-santacreu-2015}

\cite{segal-shaliastovich-yaron-2013}

\bibliography{\jobname}

\end{document}

Связанный контент