I would like to use math symbols (such as ∀ and ∃) in a scaled verbatim environment, using a typewriter font. The current answer to Proper typewriter font for math symbols (∀, ∃, →), e.g. in verbatim environment does not work for a scaled verbatim environment with \scalefont
from the scalefnt
package. And I also want to stick to pdflatex (not xetex).
Here's a test case based on this answer:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pmboxdraw}
\usepackage{newunicodechar}
\usepackage{fancyvrb}
\usepackage{scalefnt}
\DeclareFontFamily{U}{cmtex}{}
\DeclareFontShape{U}{cmtex}{m}{n}{
<-> cmtex10
}{}
\newcommand{\cmtex}[1]{{%
\usefont{U}{cmtex}{m}{n}\symbol{#1}%
}}
\newcommand{\ttexists}{\cmtex{"15}}
\newcommand{\ttforall}{\cmtex{"14}}
\newunicodechar{∃}{\ifmmode\exists\else\ttexists\fi}
\newunicodechar{∀}{\ifmmode\forall\else\ttforall\fi}
\begin{SaveVerbatim}{AlignTest}
│∃∀∃∀∃∀∃∀∃∀∃∀∃∀∃∀│
│1234567812345678│
\end{SaveVerbatim}
\begin{document}
\UseVerbatim{AlignTest}
{\scalefont{0.75}
\UseVerbatim{AlignTest}
}
\end{document}
When compiling this, I get warnings, such as:
LaTeX Font Warning: Font shape `T1/cmr/m/n' in size <7.5> not available
(Font) size <7> substituted on input line 32.
and here's what I get:
showing a bad alignment only when the font is scaled. Using a \makebox
can solve the alignment issue:
\newcommand{\ttexists}{\makebox[0pt][l]{\cmtex{"15}} }
\newcommand{\ttforall}{\makebox[0pt][l]{\cmtex{"14}} }
but this can mean that the characters are closer to each other than expected as they don't have the right size in the first place.
How can one properly solve the font size issue (and the alignment issue as a consequence)?
\usepackage{lmodern}
\usepackage{graphicx}
and\scalebox{0.75}{\BUseVerbatim{AlignTest}}
(mind the B(oxed) command).\usepackage{lmodern}
reduces the alignment issue, but doesn't solve it completely.