# Why font missing message shows up when using standalone and import packages only?

Took me long time to find the cause of this one. From some bizzar reason, when I use standlone package, the font changes in the lstlisting of my Matlab code due to Latex not finding some fonts.

I am not able to find why and how to resolve it. When I do not include standalone and use lstlisting the fonts are found and as I want them. Here is MWE, which has main.tex as the parent, and HW1.tex as the child which is loaded using import.

\documentclass[11pt,openany]{book}%
\usepackage[T1]{fontenc}
\usepackage{standalone}
\usepackage{import}
\usepackage[numbered,framed]{matlab-prettifier}
\lstset{
style              = Matlab-editor,
basicstyle=\ttfamily\small,
breaklines         = false,
escapechar         = ,
mlshowsectionrules = true
}
\begin{document}
\subimport*{./}{HW1}
\end{document}


Where the file HW1.tex is in the same folder and just lists some small Matlab code for illustration. Here it is

\documentclass[11pt]{article}%
\begin{document}
\begin{lstlisting}
function nma_HW1_problem2_ECE719
%function to evaluate J at corner of the cube and do
%some syms caluclations.

syms u1 u2 u3;
J = 8*u1*u2*u3-4*u1*u2-4*u1*u3-4*u2*u3+2*u1+2*u2+2*u3-1;

%first find J value at all the corners, the coordinates  are
a      = {[-1 1] [-1 1] [-1 1]};
coords = allcomb(a{:});
end
\end{lstlisting}
\end{document}


Now I compile main.tex using pdflatex, and this is what I get

Now when I do the same thing, but not use import and standalone, this is what I get. This is now the modified main.tex

\documentclass[11pt,openany]{book}%
\usepackage[T1]{fontenc}

\usepackage[numbered,framed]{matlab-prettifier}
\lstset{
style              = Matlab-editor,
basicstyle=\ttfamily\small,
breaklines         = false,
escapechar         = ,
mlshowsectionrules = true
}
\begin{document}
\begin{lstlisting}
function nma_HW1_problem2_ECE719
%function to evaluate J at corner of the cube and do
%some syms caluclations.

syms u1 u2 u3;
J = 8*u1*u2*u3-4*u1*u2-4*u1*u3-4*u2*u3+2*u1+2*u2+2*u3-1;

%first find J value at all the corners, the coordinates  are
a      = {[-1 1] [-1 1] [-1 1]};
coords = allcomb(a{:});
end
\end{lstlisting}
\end{document}


Same code. Difference is that I put the code in the parent file instead of the child. I compile the above with pdflatex, and this is what I get

Clearly it is different from the first case due to font missing issue.

I do see the font problems when I compile the case which has standalone and import in it. But I do not understand why it can't some fonts then, but it does find the fonts when I remove those packages. These are the warnings I get in the top case:

(/usr/local/texlive/2015/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty))
(/usr/local/texlive/2015/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(./HW1.tex

LaTeX Font Warning: Font shape T1/cmtt/m/n' undefined
(Font)              using T1/cmr/m/n' instead on input line 11.

) [1{/usr/local/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./main.aux)

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

){/usr/local/texlive/2015/texmf-dist/fonts/enc/dvips/cm-super/cm-super-t1.enc}
</usr/local/texlive/2015/texmf-dist/fonts/type1/public/cm-super/sfrm1000.pfb></


The above messages do NOT show up in the second case. But I do not know how to fix this.

TL 2015. Linux. Here is the file list from the first case compile.

 *File List*
book.cls    2014/09/29 v1.4h Standard LaTeX document class
bk11.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
fontenc.sty
t1enc.def    2005/09/27 v1.99g Standard LaTeX file
standalone.sty    2015/07/15 v1.2 Package to include TeX sub-files with preambl
es
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
xkeyval.sty    2014/12/03 v2.7a package option processing (HA)
xkeyval.tex    2014/12/03 v2.7a key=value parser (HA)
currfile.sty    2013/02/01 v0.7b Provides the file path elements of the current
input file
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
filehook.sty    2011/10/12 v0.5d Hooks for input files
gincltex.sty    2011/09/04 v0.3 Include external LaTeX files like graphics
svn-prov.sty    2010/04/24 v3.1862 Package Date/Version from SVN Keywords
ends (calc, etex, pgfmath)
trimclip.sty    2012/05/16 v1.0 Trim and clip general TeX material
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2014/10/28 v1.0p Standard LaTeX Graphics (DPC,SPQR)
trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
collectbox.sty    2012/05/17 v0.4b Collect macro arguments as boxes
tc-pdftex.def    2012/05/13 v1.0 Clipping driver for pdftex
ifoddpage.sty    2011/09/13 v1.0 Conditionals for odd/even page detection
varwidth.sty    2009/03/30 ver 0.92;  Variable-width minipages
filemod-expmin.sty    2011/09/19 v1.2 Get and compare file modification times (
expandable; minimal)
import.sty    2009/03/23  v 5.1
matlab-prettifier.sty    2014/06/19 v0.3 A package for prettyprinting Matlab so
urce code
textcomp.sty    2005/09/27 v1.99g Standard LaTeX package
ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
listings.sty    2015/06/04 1.6 (Carsten Heinz)
lstmisc.sty    2015/06/04 1.6 (Carsten Heinz)
listings.cfg    2015/06/04 1.6 listings configuration
ts1cmr.fd    2014/09/29 v2.5h Standard LaTeX font definitions
supp-pdf.mkii
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
grfext.sty    2010/08/19 v1.1 Manage graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
HW1.tex
***********


Question is: Why font missing message shows up when using standalone and import packages only?

• Looks like the difference between \rmfamily and \ttfamily. – Steven B. Segletes May 13 '16 at 17:59
• The 2nd code has basicstyle=\ttfamily\small which if you change to \rmfamily, it looks like the first output... But it would appear that the 1st version is not obeying the \ttfamily directive. Maybe you have to respecify the \lstset in the child document. – Steven B. Segletes May 13 '16 at 18:01
• @StevenB.Segletes I actually also did respecify the \lstset in the child document. But standalone any way, strips all preamble from child document any way, and I still get same problem. I my actual code, I do specify the \lstset in all child documents, since I also compile these as standalone documents, and fonts come out correct then. The problem happens only when I combine them. – Nasser May 13 '16 at 18:05
• I see. Some of my rambling is stream of consciousness as I slowly absorb what you did. So one can generally ignore me with no ill consequences. – Steven B. Segletes May 13 '16 at 18:07
• The issue does not show if the T1 encoding is not loaded, because the font is preloaded. – egreg May 13 '16 at 19:35

Make the \ttfamily font available to the main document, which I did by typing \setbox0=\hbox{\ttfamily} as the last thing in the preamble, which leaves the document in \rmfamily while loading the \ttfamily.

There may be more official ways of providing for a font family. With Xelatex for example, \usepackage{fontspec} \newfontfamily{\ttfamily}{Courier New} allows a tt font to be loaded without actually invoking the \ttfamily macro.

It would appear the \subimport can only work with a font if it is already available in the main document. Thus, one must insure that the needed fonts are made available prior to the \subimport invocation.

\documentclass[11pt,openany]{book}%
\usepackage[T1]{fontenc}
\usepackage{standalone}
\usepackage{import}
\usepackage[numbered,framed]{matlab-prettifier}
\lstset{
style              = Matlab-editor,
basicstyle=\ttfamily\small,
breaklines         = false,
escapechar         = ,
mlshowsectionrules = true
}
\setbox0=\hbox{\ttfamily}
\begin{document}
\subimport*{./}{HW1}
\end{document}


In conjunction with HW1.tex, this will now produce the listing in \ttfamily font.

The problem is not related to standalone. You need it as your input has a preamble but you would get a similar problem with a normal input.

The problem is the \subimport* command. It changes the search pathes and so files in the texmf-tree are no longer found. This is normally not really a problem as you seldom input files from there in the document body. But the exception are fd-files: there are loaded when the font is used the first time. And so in your document the tt-font can't be set up as t1cmtt.fd is not found.

To avoid the problem: Either use the non-starred command \subimport{./}{HW1}, or force Latex to read t1cmtt.fd earlier by issuing \ttfamily in the main document.

• Thank you for your answer. Both answers given solved the problem very well. – Nasser May 14 '16 at 22:15
• I wanted to mention, that I try to avoid the non-star version of subimport, since it has a bug. When doing \subimport and if the file happened to be called index then a latex error is generated. I have many files called index.tex. Only when the file is index. The problem goes away if the file is anything but index.tex` that is being imported. I found this bug long time ago, and it is still not fixed. – Nasser May 14 '16 at 22:37