Skip to contentSkip to conversation

Add target for "Latin Modern Typewriter" font

PATCH In review Akira Yokosawa 2 participants 8 messages Mar 12, 2017 – Mar 20, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

cover Add target for "Latin Modern Typewriter" font

From 2f6614cdf5e1b0f7da9a5c05833dbc4a251eaa9c Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Mon, 13 Mar 2017 00:10:31 +0900
Subject: [PATCH 0/4] Add target for "Latin Modern Typewriter" font

So, this is a patch set to add yet another target for alternative monospace font. While preparing this set, I found a (not serious) bug in runlatex.sh. In fixing it, I refactored the script so that redundant code can be removed.

Latin Modern Typewriter font is based on "cmtt" (Computer Modern Typewrite) font. I see that some of your articles cited in Bibliography use it as monospace font, and they look quite good. cmtt is said to be not suited to Times Roman font because of its short x-height, but as we are using scaled courier font, it should not be a big deal.

Please try the target "mslm" and let me know what you think.

Thanks, Akira

Signature · 14 lines
Akira Yokosawa (4):
  runlatex.sh: Refactor by defining functions
  runlatex.sh: Fix typo in grep pattern
  runlatex.sh: Add more lines of grep output around warning/error log
  Add target 'mslm' for 'Latin Modern Typewriter' font

 Makefile                   | 11 ++++--
 perfbook.tex               |  3 +-
 utilities/runfirstlatex.sh |  3 +-
 utilities/runlatex.sh      | 87 +++++++++++++++++++++-------------------------
 4 files changed, 52 insertions(+), 52 deletions(-)

-- 
2.7.4
#1 lore raw

PATCH 1/4 runlatex.sh: Refactor by defining functions

From 74dd23d3ef2ea8f62339e33fb118845bfccb5cb6 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Sun, 12 Mar 2017 20:26:51 +0900
Subject: [PATCH 1/4] runlatex.sh: Refactor by defining functions

---
 utilities/runlatex.sh | 80 ++++++++++++++++++++++-----------------------------
 1 file changed, 34 insertions(+), 46 deletions(-)
utilities/runlatex.sh +34 -46
index a577a0c..0fa6633 100644
@@ -23,11 +23,37 @@
 # http://www.gnu.org/licenses/gpl-2.0.html.
 #
 # Copyright (C) IBM Corporation, 2012
-# Copyright (C) Akira Yokosawa, 2016
+# Copyright (C) Akira Yokosawa, 2016, 2017
 #
 # Authors: Paul E. McKenney <[email protected]>
 #          Akira Yokosawa <[email protected]>
 
+diff_warning () {
+	if diff -q $basename-warning.log $basename-warning-prev.log >/dev/null
+	then
+		echo "No more improvement is expected, giving up."
+		return 0 ;
+	else
+#		echo "Some improvements are observed, continuing."
+		return 1 ;
+	fi
+}
+
+iterate_latex () {
+	pdflatex $basename > /dev/null 2>&1 < /dev/null || :
+	if grep -q '! Emergency stop.' $basename.log
+	then
+		echo "----- Fatal latex error, see $basename.log for details. -----"
+		exit 1
+	fi
+	if test -r $basename-warning.log
+	then
+		mv -f $basename-warning.log $basename-warning-prev.log
+	fi
+	grep 'LaTex Warning:' $basename.log > $basename-warning.log
+	return 0 ;
+}
+
 if test -z "$1"
 then
 	echo No latex file specified, aborting.
@@ -43,75 +69,37 @@ then
 		exit 1
 	fi
 	echo "pdflatex 1 for $basename.pdf"
-	pdflatex $basename > /dev/null 2>&1 < /dev/null || :
-	if grep -q '! Emergency stop.' $basename.log
-	then
-		echo "----- Fatal latex error, see $basename.log for details. -----"
-		exit 1
-	fi
-	grep 'LaTex Warning:' $basename.log > $basename-warning.log
+	iterate_latex
 fi
 rm -f $basename-first.log
 iter=2
 echo "pdflatex 2 for $basename.pdf # for possible bib update"
-pdflatex $basename > /dev/null 2>&1 < /dev/null || :
-if grep -q '! Emergency stop.' $basename.log
-then
-    echo "----- Fatal latex error, see $basename.log for details. -----"
-    exit 1
-fi
-grep 'LaTex Warning:' $basename.log > $basename-warning.log
+iterate_latex
 while grep -q 'LaTeX Warning: There were undefined references' $basename.log
 do
 	if test -r $basename-warning-prev.log
 	then
-		if test "$iter" -gt 2 && diff -q $basename-warning.log $basename-warning-prev.log >/dev/null
+		if test "$iter" -gt 2 && diff_warning
 		then
-			echo "No more improvement is expected, giving up."
 			break
-#		else
-#			echo "Some improvements are observed, continuing."
 		fi
 	fi
 	iter=`expr $iter + 1`
 	echo "pdflatex $iter for $basename.pdf # remaining undefined refs"
-	pdflatex $basename > /dev/null 2>&1 < /dev/null || :
-	if grep -q '! Emergency stop.' $basename.log
-	then
-		echo "----- Fatal latex error, see $basename.log for details. -----"
-		exit 1
-	fi
-	if test -r $basename-warning.log
-	then
-		mv -f $basename-warning.log $basename-warning-prev.log
-	fi
-	grep 'LaTex Warning:' $basename.log > $basename-warning.log
+	iterate_latex
 done
 while grep -q 'LaTeX Warning: Label(s) may have changed' $basename.log
 do
-	if test -r $basename-warning-prev.log;
+	if test -r $basename-warning-prev.log
 	then
-		if test "$iter" -gt 3 && diff -q $basename-warning.log $basename-warning-prev.log >/dev/null
+		if test "$iter" -gt 3 && diff_warning
 		then
-			echo "No more improvement is expected, giving up."
 			break
-#		else
-#			echo "Some improvements are observed, continuing."
 		fi
 	fi
 	iter=`expr $iter + 1`
 	echo "pdflatex $iter for $basename.pdf # label(s) may have been changed"
-	pdflatex $basename > /dev/null 2>&1 < /dev/null || :
-	if grep -q '! Emergency stop.' $basename.log
-	then
-		echo "----- Fatal latex error, see $basename.log for details. -----"
-		exit 1
-	fi
-	if test -r $basename-warning.log
-	then
-		mv -f $basename-warning.log $basename-warning-prev.log
-	fi
-	grep 'LaTex Warning:' $basename.log > $basename-warning.log
+	iterate_latex
 done
 if grep "LaTeX Warning:" $basename.log
 then
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/4 runlatex.sh: Fix typo in grep pattern

In reply to Akira Yokosawa

From 2cfb4b536d30ff9a1f4ad1723d6ac6b8b663a12f Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Sun, 12 Mar 2017 20:27:51 +0900
Subject: [PATCH 2/4] runlatex.sh: Fix typo in grep pattern

There was a typo in grep pattern. This means we were giving up prematurely while there were still changes in warnings. We were lucky to have sufficient iterations of pdflatex to reduce remaining warnings.
This typo did not affect successful builds.

Also fix similar typo in runfirstlatex.sh.

---
 utilities/runfirstlatex.sh | 2 +-
 utilities/runlatex.sh      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
utilities/runfirstlatex.sh +1 -1
index 5060725..dc55cb7 100644
@@ -46,6 +46,6 @@ then
 	echo "----- Fatal latex error, see $basename.log for details. -----"
 	exit 1
 fi
-grep 'Latex Warning:' $basename.log > $basename-warning.log
+grep 'LaTeX Warning:' $basename.log > $basename-warning.log
 touch $basename-first.log
 exit 0
utilities/runlatex.sh +1 -1
index 0fa6633..da9e82d 100644
@@ -50,7 +50,7 @@ iterate_latex () {
 	then
 		mv -f $basename-warning.log $basename-warning-prev.log
 	fi
-	grep 'LaTex Warning:' $basename.log > $basename-warning.log
+	grep 'LaTeX Warning:' $basename.log > $basename-warning.log
 	return 0 ;
 }
 
Signature · 1 line
2.7.4
#3 lore raw

PATCH 3/4 runlatex.sh: Add more lines of grep output around warning/error log

In reply to Akira Yokosawa

From b3f6e0806f0d4ea46bb9885df572c0c31433a17f Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Sun, 12 Mar 2017 20:42:10 +0900
Subject: [PATCH 3/4] runlatex.sh: Add more lines of grep output around warning/error log

This change will make it mostly unnecessary to look up log file when build error occurred.

Also fix an iteration status message to match that in the log file.

---
 utilities/runfirstlatex.sh | 1 +
 utilities/runlatex.sh      | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)
utilities/runfirstlatex.sh +1 -0
index dc55cb7..8261238 100644
@@ -43,6 +43,7 @@ echo "pdflatex 1 for $basename.pdf"
 pdflatex $basename > /dev/null 2>&1 < /dev/null || :
 if grep -q '! Emergency stop.' $basename.log
 then
+	grep -B 15 -A 5 '! Emergency stop.' $basename.log
 	echo "----- Fatal latex error, see $basename.log for details. -----"
 	exit 1
 fi
utilities/runlatex.sh +5 -2
index da9e82d..e6b3938 100644
@@ -43,6 +43,7 @@ iterate_latex () {
 	pdflatex $basename > /dev/null 2>&1 < /dev/null || :
 	if grep -q '! Emergency stop.' $basename.log
 	then
+		grep -B 15 -A 5 '! Emergency stop.' $basename.log
 		echo "----- Fatal latex error, see $basename.log for details. -----"
 		exit 1
 	fi
@@ -98,11 +99,13 @@ do
 		fi
 	fi
 	iter=`expr $iter + 1`
-	echo "pdflatex $iter for $basename.pdf # label(s) may have been changed"
+	echo "pdflatex $iter for $basename.pdf # label(s) may have changed"
 	iterate_latex
 done
-if grep "LaTeX Warning:" $basename.log
+if grep -q "LaTeX Warning:" $basename.log
 then
+	echo "----- Excerpt around remaining warning messages -----"
+	grep -B 8 -A 5 "LaTeX Warning:" $basename.log | tee $basename-warning.log
 	echo "----- You can see $basename-warning.log for the warnings above. -----"
 	echo "----- If you need to, see $basename.log for details. -----"
 	rm -f $basename-warning-prev.log
Signature · 1 line
2.7.4
#4 lore raw

PATCH 4/4 Add target 'mslm' for 'Latin Modern Typewriter' font

In reply to Akira Yokosawa

From 2f6614cdf5e1b0f7da9a5c05833dbc4a251eaa9c Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Sun, 12 Mar 2017 23:28:39 +0900
Subject: [PATCH 4/4] Add target 'mslm' for 'Latin Modern Typewriter' font

"Latin Modern" family font[1] is an enhanced version of Computer Modern font.

Although perfbook uses Times Roman clone for main text, "cmtt" (Computer Modern Typewriter font) is a reasonable option for monospace font despite its x-height is shorter than Times Roman. As cmtt doesn't cover bold face, use "Latin Modern Typewriter" font instead. By loading "lmodern" package first and "mathptmx", etc., later, only monospace font can be switched.

To do this, a comment of the form "%\usepackage{lmodern}" is added in perfbook.tex. This comment will be substituted on the fly.

Also add a comment in help message on target "msn" to mention that the monospace font (nimbusmononarrow) does not cover bold face.

Also add explicit version requirements of "mathastext" and "inconsolata" packages in perfbook.tex and substituting string in Makefile for target "1csf".

[1] http://ctan.org/pkg/lm

---
 Makefile     | 11 +++++++++--
 perfbook.tex |  3 ++-
 2 files changed, 11 insertions(+), 3 deletions(-)
Makefile +9 -2
index e953842..2c88e6c 100644
@@ -9,7 +9,7 @@ LATEXSOURCES = \
 
 LATEXGENERATED = autodate.tex qqz.tex contrib.tex origpub.tex
 
-ABBREVTARGETS := 1c hb msns mstx msr msn msnt 1csf
+ABBREVTARGETS := 1c hb msns mstx msr msn msnt mslm 1csf
 
 PDFTARGETS := perfbook.pdf $(foreach v,$(ABBREVTARGETS),perfbook-$(v).pdf)
 
@@ -124,9 +124,13 @@ perfbook-msnt.tex: perfbook.tex
 	sed -e 's/\[scaled=\.94\]{couriers}/[zerostyle=a]{newtxtt}/' < $< > $@
 	@echo "## This target requires font package newtxtt. ##"
 
+perfbook-mslm.tex: perfbook.tex
+	sed -e 's/%\\usepackage{lmodern}/\\usepackage{lmodern}/' \
+	    -e 's/\\usepackage\[scaled=\.94\]{couriers}/%\\usepackage[scaled=.94]{couriers}/' < $< > $@
+
 perfbook-1csf.tex: perfbook-1c.tex
 	sed -e 's/setboolean{sansserif}{false}/setboolean{sansserif}{true}/' \
-	    -e 's/\[scaled=\.94\]{couriers}/[var0]{inconsolata}/' < $< > $@
+	    -e 's/\[scaled=\.94\]{couriers}/[var0]{inconsolata}[2013\/07\/17]/' < $< > $@
 	@echo "## This target requires recent version (>= 1.3i) of mathastext. ##"
 
 # Rules related to perfbook_html are removed as of May, 2016
@@ -181,9 +185,12 @@ help:
 	@echo "  perfbook-msn.pdf,  msn:  2c with narrow courier clone"
 	@echo "  perfbook-mstx.pdf, mstx: 2c with txtt as monospace"
 	@echo "  perfbook-msnt.pdf, msnt: 2c with newtxtt as monospace (non-slashed 0)"
+	@echo "  perfbook-mslm.pdf, mslm: 2c with lmtt (Latin Modern Typewriter) as monospace"
+	@echo "       (Latin Modern is a clone of Computer Modern with additional type faces)"
 	@echo "  perfbook-1csf.pdf, 1csf: 1c with sans serif font"
 	@echo "  perfbook-msns.pdf, msns: 2c with non-scaled courier"
 	@echo "  \"msr\" and \"msn\" require \"nimbus15\"."
+	@echo "  \"msn\" doesn't cover bold face for monospace."
 	@echo "  \"msnt\" requires \"newtxtt\"."
 	@echo "  \"1csf\" requires recent version (>=1.3i) of \"mathastext\"."
 
perfbook.tex +2 -1
index a999705..e8234c4 100644
@@ -5,6 +5,7 @@
 % standard packages
 
 % A more pleasant font
+%\usepackage{lmodern}
 \usepackage[T1]{fontenc} % use postscript type 1 fonts
 \usepackage{textcomp} % use symbols in TS1 encoding
 \usepackage{mathptmx} % use nice, standard fonts for roman,
@@ -69,7 +70,7 @@
 \IfSansSerif{
 \renewcommand{\familydefault}{\sfdefault}
 \normalfont
-\usepackage[italic]{mathastext}
+\usepackage[italic]{mathastext}[2016/01/06]
 \renewcommand{\path}[1]{\nolinkurl{#1}} % workaround of interference with mathastext
 }{}
 
Signature · 1 line
2.7.4
#5 lore raw
In reply to Akira Yokosawa
Quoted 9 lines · Akira Yokosawa
Quoted 1 line

From 2f6614cdf5e1b0f7da9a5c05833dbc4a251eaa9c Mon Sep 17 00:00:00 2001

From: Akira Yokosawa <[email protected]>
Date: Mon, 13 Mar 2017 00:10:31 +0900
Subject: [PATCH 0/4] Add target for "Latin Modern Typewriter" font

So, this is a patch set to add yet another target for alternative monospace font. While preparing this set, I found a (not serious) bug in runlatex.sh. In fixing it, I refactored the script so that redundant code can be removed.

Quoted 7 lines

Latin Modern Typewriter font is based on "cmtt" (Computer Modern Typewrite) font. I see that some of your articles cited in Bibliography use it as monospace font, and they look quite good. cmtt is said to be not suited to Times Roman font because of its short x-height, but as we are using scaled courier font, it should not be a big deal.

Please try the target "mslm" and let me know what you think.

I do like the better display of error messages -- especially now with the list of undefined references being printed, much nicer than editing perfbook.log and searching for them!

I very like the more narrow fixed-width font. I -think- I like the mslm variant even better, but let's see what others think.

Thanx, Paul

Quoted 17 lines

Thanks, Akira

Signature · 14 lines
Akira Yokosawa (4):
  runlatex.sh: Refactor by defining functions
  runlatex.sh: Fix typo in grep pattern
  runlatex.sh: Add more lines of grep output around warning/error log
  Add target 'mslm' for 'Latin Modern Typewriter' font

 Makefile                   | 11 ++++--
 perfbook.tex               |  3 +-
 utilities/runfirstlatex.sh |  3 +-
 utilities/runlatex.sh      | 87 +++++++++++++++++++++-------------------------
 4 files changed, 52 insertions(+), 52 deletions(-)

-- 
2.7.4
#6 lore raw
Quoted 16 lines · Paul E. McKenney
Quoted 15 lines · Akira Yokosawa
Quoted 1 line

From 2f6614cdf5e1b0f7da9a5c05833dbc4a251eaa9c Mon Sep 17 00:00:00 2001

From: Akira Yokosawa <[email protected]>
Date: Mon, 13 Mar 2017 00:10:31 +0900
Subject: [PATCH 0/4] Add target for "Latin Modern Typewriter" font

So, this is a patch set to add yet another target for alternative monospace font. While preparing this set, I found a (not serious) bug in runlatex.sh. In fixing it, I refactored the script so that redundant code can be removed.

Latin Modern Typewriter font is based on "cmtt" (Computer Modern Typewrite) font. I see that some of your articles cited in Bibliography use it as monospace font, and they look quite good. cmtt is said to be not suited to Times Roman font because of its short x-height, but as we are using scaled courier font, it should not be a big deal.

Quoted 8 lines
Quoted 1 line

Please try the target "mslm" and let me know what you think.

I do like the better display of error messages -- especially now with the list of undefined references being printed, much nicer than editing perfbook.log and searching for them!

I very like the more narrow fixed-width font. I -think- I like the mslm variant even better, but let's see what others think.

As I've using mslm for a week, I think it is nicer than mstx or msnt in verbatim code snippets.
Howerver, when mixed used with Times Roman (clone) font in the main text, I prefer the look of newtxtt font because of it is slightly thicker, and it has mostly the same degree of serif as Times Roman.

One idea is to use cmtt (or lmtt) for code snippet, and use newtxtt (or txtt as a fallback on older LaTeX environment). I'll try this direction and prepare an RFC patch for you to try.

If it looks good for you, we might want to modify font selection for default targets 2c, 1c and hb. Otherwise, we can expect few feedback if any. When we do the change, current defaults' behaviors should be provided in alternative targets for people to compare.

Thanks, Akira

Quoted 22 lines

Thanx, Paul

Quoted 17 lines

Thanks, Akira

Signature · 14 lines
Akira Yokosawa (4):
  runlatex.sh: Refactor by defining functions
  runlatex.sh: Fix typo in grep pattern
  runlatex.sh: Add more lines of grep output around warning/error log
  Add target 'mslm' for 'Latin Modern Typewriter' font

 Makefile                   | 11 ++++--
 perfbook.tex               |  3 +-
 utilities/runfirstlatex.sh |  3 +-
 utilities/runlatex.sh      | 87 +++++++++++++++++++++-------------------------
 4 files changed, 52 insertions(+), 52 deletions(-)

-- 
2.7.4
#7 lore raw
Quoted 32 lines · Akira Yokosawa
Quoted 16 lines · Paul E. McKenney
Quoted 15 lines · Akira Yokosawa
Quoted 1 line

From 2f6614cdf5e1b0f7da9a5c05833dbc4a251eaa9c Mon Sep 17 00:00:00 2001

From: Akira Yokosawa <[email protected]>
Date: Mon, 13 Mar 2017 00:10:31 +0900
Subject: [PATCH 0/4] Add target for "Latin Modern Typewriter" font

So, this is a patch set to add yet another target for alternative monospace font. While preparing this set, I found a (not serious) bug in runlatex.sh. In fixing it, I refactored the script so that redundant code can be removed.

Latin Modern Typewriter font is based on "cmtt" (Computer Modern Typewrite) font. I see that some of your articles cited in Bibliography use it as monospace font, and they look quite good. cmtt is said to be not suited to Times Roman font because of its short x-height, but as we are using scaled courier font, it should not be a big deal.

Quoted 8 lines
Quoted 1 line

Please try the target "mslm" and let me know what you think.

I do like the better display of error messages -- especially now with the list of undefined references being printed, much nicer than editing perfbook.log and searching for them!

I very like the more narrow fixed-width font. I -think- I like the mslm variant even better, but let's see what others think.

As I've using mslm for a week, I think it is nicer than mstx or msnt in verbatim code snippets.
Howerver, when mixed used with Times Roman (clone) font in the main text, I prefer the look of newtxtt font because of it is slightly thicker, and it has mostly the same degree of serif as Times Roman.

Quoted 8 lines

One idea is to use cmtt (or lmtt) for code snippet, and use newtxtt (or txtt as a fallback on older LaTeX environment). I'll try this direction and prepare an RFC patch for you to try.

If it looks good for you, we might want to modify font selection for default targets 2c, 1c and hb. Otherwise, we can expect few feedback if any. When we do the change, current defaults' behaviors should be provided in alternative targets for people to compare.

Sounds good -- all for trying it and seeing what people think!

Thanx, Paul

Quoted 25 lines

Thanks, Akira

Quoted 22 lines

Thanx, Paul

Quoted 17 lines

Thanks, Akira

Signature · 14 lines
Akira Yokosawa (4):
  runlatex.sh: Refactor by defining functions
  runlatex.sh: Fix typo in grep pattern
  runlatex.sh: Add more lines of grep output around warning/error log
  Add target 'mslm' for 'Latin Modern Typewriter' font

 Makefile                   | 11 ++++--
 perfbook.tex               |  3 +-
 utilities/runfirstlatex.sh |  3 +-
 utilities/runlatex.sh      | 87 +++++++++++++++++++++-------------------------
 4 files changed, 52 insertions(+), 52 deletions(-)

-- 
2.7.4