Inspired by my question How to create a PDF presentation for each available Beamer theme automatically?, now I want to compile my input file for each available LaTeX font package installed in my machine.
Listing each font name in \foreach
as follows does not seem a good idea as it will not accommodate all available packages as well as it is not up-to-date.
% the file name of this code is inputfile.tex
% compile it with pdflatex -shell-escape inputfile.tex
\documentclass[preview,border=12pt,multi]{standalone}
\usepackage{filecontents}
\begin{filecontents*}{template.tex}
\documentclass[preview,border=12pt,12pt]{standalone}
\usepackage{\loadfont}
\usepackage{pgffor}
\usepackage{amsmath}
\usepackage{mathrsfs}
\begin{document}
\foreach \x in {1,...,26}{\char\numexpr\x+64\relax\char\numexpr\x+96\relax\space}
\begin{align*}
\sin (\alpha \pm\beta) &=\sin\alpha \cos \beta \pm \cos\alpha \sin\beta\\
\mathscr{L}\left\{f(t)\right\} &= F(s)\\
\vec{F} &= m\frac{\textrm{d}\vec{v}(t)}{\textrm{d}t}\\
\int_a^b f(x)\, \textrm{d}x &= F(b) -F(a)\\
\vec \nabla \cdot \vec \nabla \times A &= \vec\nabla \times \nabla U
\end{align*}
\end{document}
\end{filecontents*}
\usepackage{graphicx}
\usepackage{pgffor}
\def\dojob#1{\immediate\write18{pdflatex -jobname=template-#1 "\def\noexpand\loadfont{#1} \noexpand\input{template}"}}
\begin{document}
\foreach \x in {bera,palatino,mathpazo,helvet,libertine}
{%
\dojob{\x}%
\preview
\section{\x}
\includegraphics{template-\x}
\endpreview
}
\end{document}
A list of all installed packages (the list includes not only font packages but also other packages) can be done easily with this method How to print the list of packages installed on TeX Live to a file?. However, I have no idea to filter the list and remove the non-font packages.
How to compile the same input file for each of LaTeX font packages installed in our machine?
Best Answer
Here is my solution, assuming you have access to a UNIX¹ system with a TeX installation.
Inside the working directory of your project
main
subdirectory holding the files of your document.input{fontsetup}
.fontsetup.tex
responsible for setting up the font you want.build.sh
shell script that you will run to produce your outputs, as described below.The
build.sh
script may look like, where I assume your main document file isgalley.tex
and that your packages are 'lmodern mathpple'Depending on your system, you may replace the
pkg_list
assignment bywhich saves you the trouble from maintaining the list.
Now you still have to prepare directories for each package you want to test—and update the
pkg_list
variable. To help you create the followingfontsetup.sh
script in your project directory:Give the execute bit to the scripts and give it a try with
The first command creates a directory for each package and a canonical
fontsetup.tex
file. The second command processes each package.Having a different file for each font package is nice, because it allows you to add font-specific customisations.
¹ I mean FreeBSD of course!