michal-h21 / linebreaker

Some excersises with luatex's line breaking callback
15 stars 1 forks source link

Error with \cite inside footnotes #4

Closed antoineppetit closed 2 years ago

antoineppetit commented 2 years ago

Linebreaker gives an error (and no output) when using a biblatex \cite command inside of a footnote (I tested \footcite as well as an explicit \footnote{\cite{}} and they give the same result). Here is the error message I get: (node lib): lua expected, not an object with type nil Weirdly enough, linebreaker works perfectly if \cite is in the body text, or if the footnote only contains regular text. The issue only arises when combining both commands. Linebreaker also worked perfectly with \sidenote{\cite{}} (using the snotez package). Any idea of what causes this behavior?

michal-h21 commented 2 years ago

Could you please add a full MWE? I cannot reproduce this error with the following test file:


\documentclass{article}
\usepackage{biblatex}
\usepackage{linebreaker}
\linebreakersetup{debug=true}
\addbibresource{biblatex-examples.bib}
\begin{document}
Hello\footnote{\cite{westfahl:space}}
\end{document}
antoineppetit commented 2 years ago

I think I found the culprit: there seems to be a clash with certain biblatex styles. Here is a MWE that produces this error, using the philosophy-verbose style from the biblatex-philosophy package (the style is based on verbose-trad2, which also produces the error).

\documentclass{article} \usepackage[style=philosophy-verbose]{biblatex} \usepackage{linebreaker} \linebreakersetup{debug=true} \addbibresource{biblatex-examples.bib} \begin{document} Hello\footnote{\cite{westfahl:space}} \end{document}

michal-h21 commented 2 years ago

I think that I've found the issue. The glue_set in the linebreaker.last_line_width function is nil in this case. I am not sure why, but I've added condition to stop the calculation before it is used. I've updated the repo with the fixed code.

antoineppetit commented 2 years ago

The code compiles correctly now. Thank you for the quick fix!

michal-h21 commented 2 years ago

That's good to hear! If you don't find other errors, I will update the package on CTAN.

antoineppetit commented 2 years ago

With the fix, nothing unexpected has happened. I'll open another issue later should I stumble upon something else, but linebreaker is working great for me so far!

michal-h21 commented 2 years ago

Great! SO I will update immediately, as this is potentially fatal error, and deadline for TeX Live 2021 code freeze is approaching.