圖書館員中的“\AbbreviateFirstname”使編譯掛起

圖書館員中的“\AbbreviateFirstname”使編譯掛起

librarian軟體包無需運行 bibtex 或 biber 即可解析 bibfile。但是,如果一組\AbbreviateFirstname且 bibfile 中的名稱僅包含一個單詞,則編譯將掛起。

最小(非)工作範例:

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

在不更改 bibfile 的情況下,我該怎麼做才能獲得正確的編譯(例如,使用空\Firstname)或至少獲得錯誤訊息?

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}

在此輸入影像描述

相關內容