# Determine width of verbatim characters

I would like to determine how many characters of the verbatim font that fits on a text line. Consider:

\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\noindent\hrulefill
\begin{Verbatim}[fontfamily=tt,fontsize=\small]
1234567890123456789012345678901234567890123456789012345678901234567890123456789012456789012345678901234567890123456789
\end{Verbatim}
\noindent\hrulefill\\
\end{document}


This gives me the following screenshot:

from which I can infer that there are approximately 73 characters on a line. How can I determine this number programmatically from within LaTeX?

Compute the number by dividing the text width by the width of one character:

\documentclass{article}
\newcommand{\computenumber}[1]{%
Lines contain
{\begingroup\count255=\textwidth
\settowidth{\dimen0}{\ttfamily#1A}%
\divide\count255 by\dimen0
\number\count255\endgroup}
characters in \texttt{\string#1}}

\begin{document}
\computenumber{\normalsize}

\computenumber{\small}

\computenumber{\footnotesize}
\end{document}


• rounded or truncated ;-) – Marco Daniel May 10 '13 at 19:22
• @MarcoDaniel Truncated: we want to see how many really fit. ;-) – egreg May 10 '13 at 19:30