Skip to contentSkip to conversation

Update preamble and build scripts

PATCH Applied Akira Yokosawa 2 participants 9 messages Jul 7, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Update preamble and build scripts

Hi Paul,

This patch set has two goals.

1. Get rid of warnings in .log files as much as possible.

2. Improve messages printed when fatal/major errors/warnings are found in .log files.

Patches 1/7 -- 4/7 take care of warning messages by updating commands/ options in the preamble.

Patch 1/7 removes twocolumn option from \documentclass{} which became redundant when the geometry package was employed for page layout settings, especially since commit dad8d409e0b1 ("Delegate geometry settings to 'geometry' package"). To keep the sloppy behavior for 2c layout, an explicit \sloppy is added. On the other hand, 1c layouts permit occasional horizontal overfulls now.

Patch 2/7 suppresses a warning on title page in ebook-size builds.

Patch 3/7 improves the definition of \ebresizeverb, which is used for resizing tall code snippets for ebook-size builds. In commit 63c1b9f80996 ("perfbook-lt: Add macros to shrink floats for ebook"), I used varwidth inside lrbox. It turns out that varwidth causes a lot of "Failed to reprocess entire contents on input line xxx." warnings. Using plain minipage there is the right thing to do.

Patch 4/7 takes care of font warnings with regard to a missing font shape in sf (sans-serif) builds. For sans-serif font family, using italic shape as a fallback to slanted shape is reasonable. To suppress those warnings, use a package named "silence" and register that particular message pattern to be filtered out.

Patch 5/7 improves build scripts. When there is a missing package, current runfirstlatex.sh fails to print the name of missing package. This is due to the fatal error condition is tested before those for emitting pin-point logs.

Reorder the tests so that the fatal condition is tested as late as possible.

Patch 6/7 is an obvious typo fix.

Patch 7/7 reflects the recent change of TeX Live requirement.

Thanks, Akira
--
Akira Yokosawa (7):
Get rid of 'twocolumn' option in \documentclass
Prevent warning of duplicate page identifier in Ebook-size builds Use minipage environment in \ebresizeverb
Silence font warning in sf (sans serif) builds run{first}latex.sh: Reorder checks of fatal error/warning messages runlatex.sh: Fix typo (exerpt -> excerpt)
runlatex.sh: Amend message on out-of-date cleveref

 .gitignore                 |  1 +
 Makefile                   |  1 +
 perfbook-lt.tex            | 26 ++++++++++++++++----------
 utilities/runfirstlatex.sh | 34 +++++++++++++++++++++-------------
 utilities/runlatex.sh      | 28 +++++++++++-----------------
 5 files changed, 50 insertions(+), 40 deletions(-)

base-commit: f78aed35958ba9e0e90df68574be2c7cc40c1396

Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/7 Get rid of 'twocolumn' option in \documentclass

There is a lingering warning from the multicol package (indirectly required by the idxlayout package) which reads:

Package multicol Warning: May not work with the twocolumn option on input line 143.

This is due to the twocolumn option in \documentclass at the top of preamble.

It turns out that it can be removed with minor tweaks.

One is the setting of \twocolumnwidth using \columnwidth for 2c builds. Column width set by geometry becomes accessible after \begin{document}. Previously, the twocolumn option at \documentclass permitted its use in the middle of preamble.

Instead, always set it using the value of 3.125in.

Another is the use of \sloppy. It is implied in the book class when the twocolumn option is specified. Its effect is to prefer wide inter-word white spaces to horizontal overfulls. For perfbook, \sloppy is used explicitly for eb builds. Do the same for 2c builds.

For 1c builds, as they have wider margins, occasional overfulls should look better than wide inter-word spaces.

Get rid of the warning by removing the twocolumn option and applying those minor tweaks.

---
 perfbook-lt.tex | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
perfbook-lt.tex +7 -6
index 61b7a3b34fe1..af60f6f2388f 100644
@@ -1,4 +1,4 @@
-\documentclass[10pt,twocolumn,letterpaper]{pfbook} % book class customized for perfbook
+\documentclass[10pt,letterpaper]{pfbook} % book class customized for perfbook
 % For arxiv.org, must be on or before line 5:
 \pdfoutput=1
 
@@ -464,8 +464,8 @@
 \newlength{\twocolumnwidth}
 \newlength{\onecolumntextwidth}
 \setlength{\onecolumntextwidth}{4.75in}
+\setlength{\twocolumnwidth}{3.125in}
 \IfTwoColumn{
-  \setlength{\twocolumnwidth}{\columnwidth}
   \renewcommand\floatpagefraction{.75}
   \IfHardCover{
     \usepackage[papersize={8.25in,10.75in},body={6.5in,8.25in},twocolumn,columnsep=0.25in]{geometry}
@@ -473,14 +473,15 @@
     \IfAfourPaper{
       \usepackage[a4paper,body={6.5in,8.25in},twocolumn,columnsep=0.25in]{geometry}
     }{
-      \usepackage[letterpaper,body={6.5in,8.25in},twocolumn,columnsep=0.25in]{geometry}      
-}}}{ % One Column
-  \setlength{\twocolumnwidth}{3.125in}
+      \usepackage[letterpaper,body={6.5in,8.25in},twocolumn,columnsep=0.25in]{geometry}
+    }}
+  \sloppy % prefer wide inter-word spaces to occasional horizontal overfulls
+}{ % One Column
   \IfEbookSize {
     % From https://tex.stackexchange.com/questions/16735/latex-options-for-kindle
     \usepackage[papersize={4.5in,6.3in},margin=0.2in,footskip=0.2in,
       headsep=0.0335in,headheight=0.1665in,onecolumn,twoside=false]{geometry}
-    \sloppy
+    \sloppy % prefer wide inter-word spaces to occasional horizontal overfulls
     \setlength{\onecolumntextwidth}{4.1in}
     \usepackage{fancyhdr}
     \fancypagestyle{plain}{%
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/7 Prevent warning of duplicate page identifier in Ebook-size builds

In reply to Akira Yokosawa

In Ebook-size builds, pdfTeX complains:

pdfTeX warning (ext4): destination with the same identifier (name{page.i}) has been already used, duplicate ignored

As a workaround, disable pageanchor of hyperef for titlepage in Ebook-size builds.

---
 perfbook-lt.tex | 3 +++
 1 file changed, 3 insertions(+)
perfbook-lt.tex +3 -0
index af60f6f2388f..4c8870a135d9 100644
@@ -641,7 +641,10 @@
 
 \frontmatter
 
+\IfEbookSize{\hypersetup{pageanchor=false}}{}
 \maketitle
+\IfEbookSize{\hypersetup{pageanchor=true}}{}
+
 \IfTwoColumn{
   \onecolumn\begin{adjustwidth*}{.95in}{.8in}
   \addtolength{\parindent}{6pt}
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/7 Use minipage environment in \ebresizeverb

In reply to Akira Yokosawa

In Ebook-size builds, tens of warnings from varwidth are emitted:

Package varwidth Warning: Failed to reprocess entire contents on input line xxx.

It turns out that this is due to the wrong use of varwidth package. Instead, the bare minipage environment suffices in \ebresizeverb.

Stop using varwidth and get rid of those warnings. As a bonus, we no longer need ad-hoc \vspace*{} command at the bottom of its definition.

---
 perfbook-lt.tex | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
perfbook-lt.tex +2 -4
index 4c8870a135d9..842e0fc6b924 100644
@@ -35,7 +35,6 @@
 \captionsetup[listing]{font=small,labelsep=colon}
 \captionsetup[subfloat]{font=small}
 % \usepackage{breakurl}
-\usepackage{varwidth}
 \usepackage{graphicx}
 \usepackage{rotating}
 \usepackage{setspace}
@@ -541,12 +540,11 @@
 \newcommand{\ebresizewidthsw}[1]{\resizebox{.95\textheight}{!}{#1}}
 \newcommand{\ebresizeverb}[2]{%
   \begin{lrbox}{\ebbox}%
-    \begin{varwidth}{\textwidth}%
+    \begin{minipage}{\textwidth}%
       {#2}%
-    \end{varwidth}%
+    \end{minipage}%
   \end{lrbox}%
   \resizebox{#1\textwidth}{!}{\usebox{\ebbox}}%
-  \vspace*{-7pt}%
 }
 \newcommand\ebFloatBarrier{\FloatBarrier}
 }{
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/7 Silence font warning in sf (sans serif) builds

In reply to Akira Yokosawa

There are a couple of warnings in sf (sans serif) builds:

LaTeX Font Warning: Font shape `T1/qhv/m/sl' in size <7.3> not available
(Font) Font shape `T1/qhv/m/it' tried instead on input line 367.

This is because the qhv (Helvetica clone) font family doesn't provide slanted shape to be used in the header area of the page (chapter and section title) and LaTeX uses its italic shape as a fallback.

This is OK as italic and slanted shapes would look mostly the same for sans-serif font families.

Suppress the warning by using the silence package.

Giving "save" option to silence makes it save filtered-out warnings in $basename.sil. This is better than discarding silenced warnings.

Add $basename.sil to .gitignore and Makefile's "clean" target.

---
 .gitignore      | 1 +
 Makefile        | 1 +
 perfbook-lt.tex | 4 ++++
 3 files changed, 6 insertions(+)
.gitignore +1 -0
index 1604a4d8c5b1..fa20ccb5de94 100644
@@ -45,6 +45,7 @@ autodate.tex
 /perfbook*.gls
 /perfbook*.glsdefs
 /perfbook*.ist
+/perfbook*.sil
 extraction
 embedfonts
 CodeSamples/snippets.d
Makefile +1 -0
index 6a389089e38c..bffdd2da1f4d 100644
@@ -597,6 +597,7 @@ clean:
 	rm -f perfbook*.idx perfbook*.ind perfbook*.ilg perfbook*.ist
 	rm -f perfbook*.acn perfbook*.acr perfbook*.alg
 	rm -f perfbook*.glg perfbook*.glo perfbook*.gls perfbook*.glsdefs
+	rm -f perfbook*.sil
 	rm -f CodeSamples/snippets.d
 	rm -f *.synctex*
 	@rm -f $(OBSOLETE_FILES) $(EPSSOURCES_TMP)
perfbook-lt.tex +4 -0
index 842e0fc6b924..fdfde1953225 100644
@@ -330,6 +330,10 @@
 \renewcommand{\familydefault}{\sfdefault}
 \normalfont
 \usepackage[slantedGreek,scaled=.96]{newtxsf}
+% Silence inevitable warnings on missing slanted shape
+\RequirePackage[save]{silence}
+\WarningFilter[sansslant]{latexfont}{Font shape `T1/qhv/m/sl'}
+\ActivateWarningFilters[sansslant]
 }{
 \usepackage[slantedGreek]{newtxmath} % math package to be used with newtxtext
 % Poor person's slanted shape for roman --- newtxtext lacks slanted shape
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/7 run{first}latex.sh: Reorder checks of fatal error/warning messages

In reply to Akira Yokosawa

Testing $exitcode and "!pdfTeX error:" or "Emergency stop" early may ignore an earlier warning that tells the reason of such an error.

Reorder the checks and make the relevant part of the log file be printed.

$exitcode should be tested as late as possible.

This improves output when a necessary .sty file is missing:

before:

or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.
<read *>

l.332 \renewcommand
{\sfdefault}{qhv}
End of file on the terminal!

Here is how much of TeX's memory you used:
[...]

after:

LaTeX Info: Redefining \Bbbk on input line 2810. LaTeX Info: Redefining \not on input line 2959. )

! LaTeX Error: File `biolinum.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:
! Emergency stop.
[...]

Subsequent runs of latex can also abort due to, e.g., a typo in .bib. Keep tests of "Emergency stop." and $exitcode in runlatex.sh to catch such errors.

---
 utilities/runfirstlatex.sh | 34 +++++++++++++++++++++-------------
 utilities/runlatex.sh      | 18 ++++++------------
 2 files changed, 27 insertions(+), 25 deletions(-)
utilities/runfirstlatex.sh +21 -13
index f12f14886747..a89e8a70ab69 100644
@@ -22,7 +22,7 @@
 #
 # Copyright (C) IBM Corporation, 2012-2019
 # Copyright (C) Facebook, 2019
-# Copyright (C) Akira Yokosawa, 2016
+# Copyright (C) Akira Yokosawa, 2016, 2023
 #
 # Authors: Paul E. McKenney <[email protected]>
 #          Akira Yokosawa <[email protected]>
@@ -72,11 +72,6 @@ basename=`echo $1 | sed -e 's/\.tex$//'`
 echo "$LATEX 1 for $basename.pdf"
 $LATEX $LATEX_OPT $basename > /dev/null 2>&1 < /dev/null
 exitcode=$?
-if [ $exitcode -ne 0 ]; then
-	tail -n 20 $basename.log
-	echo "\n!!! $LATEX aborted !!!"
-	exit $exitcode
-fi
 if grep -q 'LaTeX Warning: You have requested' $basename.log
 then
 	grep -A 4 'LaTeX Warning: You have requested' $basename.log
@@ -84,21 +79,34 @@ then
 	echo "### See items 9 and 10 in FAQ-BUILD.txt for how to update.          ###"
 	exit 1
 fi
-if [ $DETECTED_BUGGY -eq 1 ]; then
-	exit 1
+if grep -q 'LaTeX Error:' $basename.log
+then
+	echo "----- !!! Fatal latex error !!! -----"
+	grep -B 5 -A 8 'LaTeX Error:' $basename.log
+	echo "----- See $basename.log for the full log. -----"
+	exit 2
 fi
-if grep -q '! Emergency stop.' $basename.log
+if grep -q 'pdfTeX error:' $basename.log
 then
-	grep -B 15 -A 5 '! Emergency stop.' $basename.log
-	echo "----- Fatal latex error, see $basename.log for details. -----"
+	echo "----- !!! Fatal pdfTeX error !!! -----"
+	grep -B 10 -A 8 '!pdfTeX error:' $basename.log
+	echo "----- See $basename.log for the full log. -----"
 	exit 2
 fi
-if grep -q '!pdfTeX error:' $basename.log
+if grep -q '! Emergency stop.' $basename.log
 then
-	grep -A 2 '!pdfTeX error:' $basename.log
+	grep -B 10 -A 5 '! Emergency stop.' $basename.log
 	echo "----- Fatal latex error, see $basename.log for details. -----"
 	exit 2
 fi
+if [ $exitcode -ne 0 ]; then
+	tail -n 20 $basename.log
+	echo "\n!!! $LATEX aborted !!!"
+	exit $exitcode
+fi
+if [ $DETECTED_BUGGY -eq 1 ]; then
+	exit 1
+fi
 grep 'LaTeX Warning:' $basename.log > $basename-warning.log
 touch $basename-first.log
 exit 0
utilities/runlatex.sh +6 -12
index e23bc87ba978..b146da20559f 100644
@@ -24,7 +24,7 @@
 #
 # Copyright (C) IBM Corporation, 2012-2019
 # Copyright (C) Facebook, 2019
-# Copyright (C) Akira Yokosawa, 2016, 2017
+# Copyright (C) Akira Yokosawa, 2016, 2017, 2023
 #
 # Authors: Paul E. McKenney <[email protected]>
 #          Akira Yokosawa <[email protected]>
@@ -78,22 +78,16 @@ iterate_latex () {
 	makeglossaries $basename > /dev/null 2>&1
 	$LATEX $LATEX_OPT $basename > /dev/null 2>&1 < /dev/null
 	exitcode=$?
-	if [ $exitcode -ne 0 ]; then
-		tail -n 20 $basename.log
-		echo "\n!!! $LATEX aborted !!!"
-		exit $exitcode
-	fi
 	if grep -q '! Emergency stop.' $basename.log
 	then
-		grep -B 15 -A 5 '! Emergency stop.' $basename.log
+		grep -B 10 -A 5 '! Emergency stop.' $basename.log
 		echo "----- Fatal latex error, see $basename.log for details. -----"
 		exit 2
 	fi
-	if grep -q '!pdfTeX error:' $basename.log
-	then
-		grep -A 2 '!pdfTeX error:' $basename.log
-		echo "----- Fatal latex error, see $basename.log for details. -----"
-		exit 2
+	if [ $exitcode -ne 0 ]; then
+		tail -n 20 $basename.log
+		echo "\n!!! $LATEX aborted !!!"
+		exit $exitcode
 	fi
 	if test -r $basename-warning.log
 	then
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/7 runlatex.sh: Fix typo (exerpt -> excerpt)

In reply to Akira Yokosawa
---
 utilities/runlatex.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
utilities/runlatex.sh +3 -3
index b146da20559f..dd62327a0b4d 100644
@@ -53,7 +53,7 @@ identical_warnings () {
 	return 1 ;
 }
 
-exerpt_warnings () {
+excerpt_warnings () {
 	if grep -q "LaTeX Warning:" $basename.log
 	then
 		echo "----- Excerpt around remaining warning messages -----"
@@ -123,7 +123,7 @@ do
 	if test $undefined_refs
 	then
 		echo "Undefined refs remain, giving up."
-		exerpt_warnings
+		excerpt_warnings
 	fi
 	if identical_warnings
 	then
@@ -145,7 +145,7 @@ do
 	echo "$LATEX $iter for $pdfname # label(s) may have changed"
 	iterate_latex
 done
-exerpt_warnings
+excerpt_warnings
 rm -f $basename-warning.log $basename-warning-prev.log
 echo "'$basename.pdf' is ready."
 # cleveref version check (Ubuntu 18.04 LTS has buggy one
Signature · 1 line
2.25.1
#7 lore raw

PATCH 7/7 runlatex.sh: Amend message on out-of-date cleveref

In reply to Akira Yokosawa

Now that we have forget about Ubuntu bionic, reword the message on too old cleveref.

---
 utilities/runlatex.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
utilities/runlatex.sh +2 -2
index dd62327a0b4d..ec2114afec12 100644
@@ -154,8 +154,8 @@ then
 	echo "############################################################"
 	echo "### Buggy version of LaTeX package 'cleveref' detected!! ###"
 	echo "### (Known issue on Ubuntu 18.04 LTS)                    ###"
-	echo "### Please consider installing a stable version.         ###"
-	echo "### See item 10 in FAQ-BUILD.txt for further info.       ###"
+	echo "### Required TeX Live is 2019/Debian or later.           ###"
+	echo "### Consider upgrading to Ubuntu 20.04 LTS or later.     ###"
 	echo "############################################################"
 fi
 # to avoid redundant run of bibtex and pdflatex
Signature · 1 line
2.25.1
#8 lore raw
In reply to Akira Yokosawa
Quoted 39 lines · Akira Yokosawa

Hi Paul,

This patch set has two goals.

1. Get rid of warnings in .log files as much as possible.

2. Improve messages printed when fatal/major errors/warnings are found in .log files.

Patches 1/7 -- 4/7 take care of warning messages by updating commands/ options in the preamble.

Patch 1/7 removes twocolumn option from \documentclass{} which became redundant when the geometry package was employed for page layout settings, especially since commit dad8d409e0b1 ("Delegate geometry settings to 'geometry' package"). To keep the sloppy behavior for 2c layout, an explicit \sloppy is added. On the other hand, 1c layouts permit occasional horizontal overfulls now.

Patch 2/7 suppresses a warning on title page in ebook-size builds.

Patch 3/7 improves the definition of \ebresizeverb, which is used for resizing tall code snippets for ebook-size builds. In commit 63c1b9f80996 ("perfbook-lt: Add macros to shrink floats for ebook"), I used varwidth inside lrbox. It turns out that varwidth causes a lot of "Failed to reprocess entire contents on input line xxx." warnings. Using plain minipage there is the right thing to do.

Patch 4/7 takes care of font warnings with regard to a missing font shape in sf (sans-serif) builds. For sans-serif font family, using italic shape as a fallback to slanted shape is reasonable. To suppress those warnings, use a package named "silence" and register that particular message pattern to be filtered out.

Patch 5/7 improves build scripts. When there is a missing package, current runfirstlatex.sh fails to print the name of missing package. This is due to the fatal error condition is tested before those for emitting pin-point logs.

Quoted 6 lines

Reorder the tests so that the fatal condition is tested as late as possible.

Patch 6/7 is an obvious typo fix.

Patch 7/7 reflects the recent change of TeX Live requirement.

Very nice!!!

Queued and pushed, thank you!!!

Thanx, Paul

Quoted 23 lines

Thanks, Akira
--
Akira Yokosawa (7):
Get rid of 'twocolumn' option in \documentclass
Prevent warning of duplicate page identifier in Ebook-size builds Use minipage environment in \ebresizeverb
Silence font warning in sf (sans serif) builds run{first}latex.sh: Reorder checks of fatal error/warning messages runlatex.sh: Fix typo (exerpt -> excerpt)
runlatex.sh: Amend message on out-of-date cleveref

 .gitignore                 |  1 +
 Makefile                   |  1 +
 perfbook-lt.tex            | 26 ++++++++++++++++----------
 utilities/runfirstlatex.sh | 34 +++++++++++++++++++++-------------
 utilities/runlatex.sh      | 28 +++++++++++-----------------
 5 files changed, 50 insertions(+), 40 deletions(-)

base-commit: f78aed35958ba9e0e90df68574be2c7cc40c1396

Signature · 1 line
2.25.1