I use both \begin{verbatim} ... \end{verbatim} and \verb.something. in my document. I would like the contents of \begin{verbatim} ... \end{verbatim} to be displayed in a smaller font. I found this, which is kind of what I want.
In that answer, the verbatim font can be customized via this command:
\makeatletter
\newcommand{\verbatimfont}[1]{\renewcommand{\verbatim@font}{\ttfamily#1}}
\makeatother
But I would prefer this to be applied to every verbatim environment automatically.
Then I tried to transfer this answer to my problem, but this also makes the contents of \verb.someting. small, which is not what I want.
I also tried defining a custom verbatim environment like this:
\newenvironment{smallverbatim}{
\verbatimfont{\footnotesize}\noindent\ignorespaces\begin{verbatim}}%
{\par\noindent%
\ignorespacesafterend\end{verbatim}}
But this gave me:
! LaTeX Error: \begin{smallverbatim} on input line 526 ended by \end{itemize}.
Is there a way to do what I want to do?
What I need is some kind of macro that replaces every \begin{verbatim} with \verbatimfont{\footnotesize}\begin{verbatim}, so it shouldn't be impossible, but I have no idea how to do it.
\verbatimfontcommand sets the font for all subsequentverbratimenvironments. So simply putting it in the preamble will do what you want. – Mike May 09 '18 at 20:51\verb.foo.which is not what I want... – fifaltra May 09 '18 at 21:02\verb.foo.too, as far as I can see – fifaltra May 10 '18 at 10:40