图书管理员中的“\AbbreviateFirstname”使编译挂起

图书管理员中的“\AbbreviateFirstname”使编译挂起

librarian软件包无需运行 bibtex 或 biber 即可解析 bibfile。但是,如果设置了\AbbreviateFirstnamebibfile 中的名称仅由一个单词组成,则编译会挂起。

最小(非)工作示例:

\documentclass{article}

\usepackage{librarian}
\AbbreviateFirstname

\begin{filecontents}{bar.bib}
@article{foo1,
 author ={Anton Nonym},
 title  ={A title},
 journal={Top Journal},
 number ={42},
 year   ={2000}
}
@article{foo2,
 author ={Batman},
 title  ={Yet Another Title},
 journal={Flop Journal},
 number ={23},
 year   ={1999}
}
\end{filecontents}


\begin{document}

A paper by
\Cite{foo1}{foo}{\ReadName{\Firstname\ \Lastname}}{??} % works always
and
\Cite{foo2}{foo}{\ReadName{\Firstname\ \Lastname}}{??}.% hangs for \AbbreviateFirstname

\BibFile{bar.bib}
\end{document}

如果我注释掉\AbbreviateFirstname第二个\Cite,MWE 就会起作用。第二次引用 \AbbreviateFirstname,编译1没有结束(在第二次运行中)。只有在手动中止后,我才会收到消息:

! Interruption.
\lb@temp ->\lb@eoe 
                   \spacefactor 1000.
l.28 ...{foo}{\ReadName{\Firstname \Lastname}}{??}

\Firstname我该怎么做才能在不改变 bibfile 的情况下获得正确的编译(例如,使用空的)或至少是错误消息?

1使用 TeX Live 2022、latex、pdflatex 或 lualatex 执行

答案1

或许是这样的

\documentclass{article}

\usepackage{librarian,etoolbox}
\AbbreviateFirstname
\makeatletter
\def\lb@@loopovernames#1#2#3#4{%
  \iflb@abbreviate
    \def\Firstname{}%
    \ifblank{#1}{}{\lb@abbreviate#1 lb@end }% add test for emptyness
  \else
    \def\Firstname{#1}%
  \fi
  \def\Von{#2}\def\Lastname{#3}\def\Junior{#4}%
  \lb@makerefname
  }
\makeatother
\begin{filecontents}{bar.bib}
@article{foo1,
 author ={Anton Nonym},
 title  ={A title},
 journal={Top Journal},
 number ={42},
 year   ={2000}
}
@article{foo2,
 author ={Batman},
 title  ={Yet Another Title},
 journal={Flop Journal},
 number ={23},
 year   ={1999}
}
\end{filecontents}


\begin{document}

A paper by
\Cite{foo1}{foo}{\ReadName{\Firstname\ \Lastname}}{??} % works always
and
\Cite{foo2}{foo}{\ReadName{\ifdefempty\Firstname{}{\Firstname\ }\Lastname}}{??}.% hangs for \AbbreviateFirstname

\BibFile{bar.bib}
\end{document}

在此处输入图片描述

相关内容