fvextra versions from v1.11.0 to v1.13.2 (latest) have a minor regression
which ignores fancyvrb's "samepage=true" key.  It is used in perfbook to
prevent short snippets from broken across columns/pages.  This is a minor
regression but affects reproducible build of perfbook.

Unfortunately, distro texlive packages based on upstream TeX Live since
early March 2025 are all affected by this regression, including debian
trixie and opensuse/leap 16.0 (Long Term Support); and ubuntu plucky
and questing (Rolling release); as well as archlinux and
opensuse/tumbleweed (Rapid release) as of this writing.

This issue was reported upstream and a tentative one-liner fix was
provied by Yukai Chou at [1].

Add code in autodate.sh to detect buggy fvextra and have a boolean
"buggyfvextra" set "true" in autodate.tex.

In the preamble, conditionally load fixfvextra.ltx which contains the
tentative patch to be applied on-the-fly.

Link: https://github.com/gpoore/fvextra/issues/32 [1]
Signed-off-by: Akira Yokosawa <[email protected]>
---
 Makefile              |  1 +
 fixfvextra.ltx        | 11 +++++++++++
 perfbook-lt.tex       |  7 +++++++
 utilities/autodate.sh | 17 +++++++++++++++++
 4 files changed, 36 insertions(+)
 create mode 100644 fixfvextra.ltx

diff --git a/Makefile b/Makefile
index 29d7c99f..1e63c0b5 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,7 @@ LATEXSOURCES = \
        pfbook.cls \
        ushyphex.tex pfhyphex.tex \
        ack.tex \
+       *.ltx \
        */*.tex \
        */*/*.tex
 
diff --git a/fixfvextra.ltx b/fixfvextra.ltx
new file mode 100644
index 00000000..b79411c5
--- /dev/null
+++ b/fixfvextra.ltx
@@ -0,0 +1,11 @@
+\makeatletter
+\AtBeginDocument
+{
+  \def\FV@bgcoloroverlap{%
+    \ifx\FV@backgroundcolorboxoverlap\relax
+    \else
+      \nopagebreak  % <<< added
+      \vspace{-\FV@backgroundcolorboxoverlap}%
+  \fi}
+} %
+\makeatother
diff --git a/perfbook-lt.tex b/perfbook-lt.tex
index e1dcd03f..6dc698d1 100644
--- a/perfbook-lt.tex
+++ b/perfbook-lt.tex
@@ -108,6 +108,9 @@
 \setboolean{noqqz}{false}
 \newcommand{\IfNoQqz}[2]{\ifthenelse{\boolean{noqqz}}{#1}{#2}}
 
+\newboolean{buggyfvextra}
+\setboolean{buggyfvextra}{false}
+
 \input{autodate} % need to input here to reflect tag state
 \usepackage{qqz}
 \usepackage{origpub}
@@ -583,6 +586,10 @@
 % Glossaries dictionary and custom settings
 \input{glsdict}
 
+\ifthenelse{\boolean{buggyfvextra}}{
+  \input{fixfvextra.ltx}
+}{}
+
 \begin{document}
 
 %%HTMLSKIP
diff --git a/utilities/autodate.sh b/utilities/autodate.sh
index 1efdbdee..839db7f3 100644
--- a/utilities/autodate.sh
+++ b/utilities/autodate.sh
@@ -133,3 +133,20 @@ if [ $(echo $tcbversion $tcbold | awk '{if ($1 > $2) print 
1;}') ] ;
 then
        env printf '\\tcbsetforeverylayer{autoparskip}\n' >> $fn
 fi
+
+# check if fvextra is buggy ("samepage=true")
+FVEXTRA_BUGGY_SINCE=v1.11.0
+FVEXTRA_BUGGY_UNTIL=v1.13.2
+
+fvextra_sty=`kpsewhich fvextra.sty`
+if [ "x$fvextra_sty" != "x" ] ; then
+       fvextra_ver=`grep -E -e 'v[0-9\.]+ fvextra' $fvextra_sty | \
+                       sed -e 's/.* \(v.*\) fv.*/\1/'`
+       fvextra_since=`env printf "$FVEXTRA_BUGGY_SINCE\n$fvextra_ver" | sort 
-V | head -n 1`
+       fvextra_until=`env printf "$FVEXTRA_BUGGY_UNTIL\n$fvextra_ver" | sort 
-V | tail -n 1`
+fi
+
+if [ $fvextra_since = $FVEXTRA_BUGGY_SINCE -a $fvextra_until = 
$FVEXTRA_BUGGY_UNTIL ] ; then
+       env printf '%% fvextra buggy: %s\n' $fvextra_ver >> $fn
+       env printf '\\setboolean{buggyfvextra}{true}\n' >> $fn
+fi
-- 
2.43.0



Reply via email to