[Tex/LaTex] Using same font for \texttt and \Verb

fancyvrbfontsizetypewriter

I would like to configure my document to use exactly the same font for \texttt and \Verb. I got as far as this, which still misses making \ttdefault smaller:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{fancyvrb}
\usepackage{relsize}
\fvset{fontfamily=fvm}
\fvset{fontsize=\relsize{-2}}
\renewcommand{\ttdefault}{fvm} % needs to be smaller...
\begin{document}

$\langle$ \Verb!foobar123! $\rangle$

$\langle \texttt{foobar123} \rangle$

\end{document}

enter image description here

So how to I apply the relsize{-2} by default to \texttt?

Best Answer

Instead of using low level \fontsize and \fontfamily commands or \relsize, you should load the package beramono that provides a scaled option for deciding the height of the characters.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[scaled=.75]{beramono}
\usepackage{fancyvrb}

\begin{document}

Some text $\langle$\Verb!foobar123!$\rangle$ end.

Some text $\langle\texttt{foobar123}\rangle$ end.

\end{document}

Change the fraction .75 to what really suits you. In any case, since \texttt and \Verb by default use the same font, this will ensure the same result in both cases.

enter image description here