citeproc-lua
citeproc-lua copied to clipboard
Error compiling example.tex in TeX4ht
Describe the bug Compiling example.tex in TeX4ht fails and produces the following error:
! Undefined control sequence.
<argument> ...y@tempb {cite.ITEM-1\@extra@b@citeb
}\ifx \Hy@tempa \ltx@empty...
l.23 \cite{ITEM-1}
?
! Emergency stop.
<argument> ...y@tempb {cite.ITEM-1\@extra@b@citeb
}\ifx \Hy@tempa \ltx@empty...
l.23 \cite{ITEM-1}
Additional information
- TeX distribution: TeX Live 2023
- Package
citation-style-languageversion: 0.4.2 - LaTeX engine: htlatex
To Reproduce
If you have a full texlive installation, compile example.tex with the commands:
pdflatex example
citeproc-lua example
make4ht -a debug example
Alternatively, if you have docker installed:
docker run \
--rm \
texlive/texlive \
/bin/sh -c '
git clone https://github.com/zepinglee/citeproc-lua.git && \
cd citeproc-lua/examples && \
pdflatex example && \
citeproc-lua example && \
make4ht -a debug example \
'
Yes, I can reproduce the error.
I'm not familiar with tex4ht. The \@extra@b@citeb is provided in the hyperref package but tex4ht doesn't seem to read it. It still produces another undefined command error (\@skiphyperreftrue) after I patch \providecommand\@extra@b@citeb.
I just find the documentation https://www.kodymirus.cz/tex4ht-doc/ForDevelopers.html but it's not trivial to provide support for tex4t. It should take time to resolve this.
I've created a basic configuration file for citeproc-lua, citation-style-language.4ht
% fix problems with \bibitem in the bibliography
\def\setb:anc#1{\def\bib:anc{\def\bib:anc{#1}\ifx \bib:anc\empty \else
\a:bibitem{}{\a:bibanchor#1}\b:bibitem\fi \gdef\bib:anc{}}%
\def\AnchorLabel{\bib:anc}
}
\ExplSyntaxOn
% add links to bibliography around citations
\cs_set:Npn \__csl_print_citation:N #1
{
\bool_if:NT \l__csl_regression_test_bool
{ \tl_show:N #1 }
\bool_if:NTF \l__csl_note_bool
{ \footnote {\a:cite\cIteLink{X\l__csl_cite_keys_tl}{bk-\l__csl_citation_id_tl}#1\EndcIteLink\b:cite} }
{\a:cite\cIteLink{X\l__csl_cite_keys_tl}{bk-\l__csl_citation_id_tl}#1\EndcIteLink\b:cite}
}
\ExplSyntaxOff
\Hinput{citation-style-language}
\endinput
It resuses the default bibliography support in TeX4ht and fixes two things: the compilation error reported in this bug report, and it also inserts links pointing to the bibliography around citations.