I created a \lstdefinelanguage command for some JSON blocks I'd like to add into my document, I followed the answer to this question:
How to improve listings display of JSON files?
In the answer the answerer defines the language like so:
\usepackage{bera}% optional: just to have a nice mono-spaced font
\usepackage{listings}
\usepackage{xcolor}
\colorlet{punct}{red!60!black}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\lstdefinelanguage{json}{
basicstyle=\normalfont\ttfamily,
numbers=left,
numberstyle=\scriptsize,
stepnumber=1,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
frame=lines,
backgroundcolor=\color{background},
literate=
*{0}{{{\color{numb}0}}}{1}
{1}{{{\color{numb}1}}}{1}
{2}{{{\color{numb}2}}}{1}
{3}{{{\color{numb}3}}}{1}
{4}{{{\color{numb}4}}}{1}
{5}{{{\color{numb}5}}}{1}
{6}{{{\color{numb}6}}}{1}
{7}{{{\color{numb}7}}}{1}
{8}{{{\color{numb}8}}}{1}
{9}{{{\color{numb}9}}}{1}
{:}{{{\color{punct}{:}}}}{1}
{,}{{{\color{punct}{,}}}}{1}
{\{}{{{\color{delim}{\{}}}}{1}
{\}}{{{\color{delim}{\}}}}}{1}
{[}{{{\color{delim}{[}}}}{1}
{]}{{{\color{delim}{]}}}}{1},
}
The answerer uses the bera font, which makes the JSON look far more visually appealing. I'd like to copy this. The only problem is that when I add the \usepackage{bera} command all the text in my entire document is changed to this font, which I don't want. I only want the bera font to be used when I create a listing using the JSON language. What is the best way to do this?
UPDATE:
When I try \usepackage{beramono} as suggested by @Davislor I get this output:
The output I'd like looks like this, which I get when I use \usepackage{bera}:
EDIT 2 MWE:
\documentclass[a4paper,pdf]{article}
% \usepackage{bera}
\usepackage{listings}
\usepackage{xcolor}
\colorlet{punct}{red!60!black}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\lstdefinelanguage{json}{
basicstyle=\normalfont\ttfamily,
numbers=left,
numberstyle=\scriptsize,
stepnumber=1,
numbersep=8pt,
showstringspaces=false,
breaklines=true,
frame=lines,
backgroundcolor=\color{background},
literate=
*{0}{{{\color{numb}0}}}{1}
{1}{{{\color{numb}1}}}{1}
{2}{{{\color{numb}2}}}{1}
{3}{{{\color{numb}3}}}{1}
{4}{{{\color{numb}4}}}{1}
{5}{{{\color{numb}5}}}{1}
{6}{{{\color{numb}6}}}{1}
{7}{{{\color{numb}7}}}{1}
{8}{{{\color{numb}8}}}{1}
{9}{{{\color{numb}9}}}{1}
{:}{{{\color{punct}{:}}}}{1}
{,}{{{\color{punct}{,}}}}{1}
{\{}{{{\color{delim}{\{}}}}{1}
{\}}{{{\color{delim}{\}}}}}{1}
{[}{{{\color{delim}{[}}}}{1}
{]}{{{\color{delim}{]}}}}{1},
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{lstlisting}[language=json]
{
"type": "request-action",
"content": {
"id": 2,
"time": 1556636930397,
"deadline": 1556636934400,
"step": 27,
"percept": {
...
}
}
}
\end{lstlisting}
\caption{Example of a REQUEST-ACTION message.}
\label{fig:request-action}
\end{figure}
\end{document}



\usepackage{beramono}, which sets only\ttfamily, possibly\usepackage[scaled=0.9]{beramono}if you want it slightly bigger or smaller. You could also use DejaVu Sans Mono, which is another fork of Bitstream Vera Mono. – Davislor Jun 07 '20 at 18:26berapackage does is set the encoding to T1, loadberaserif,berasansandberamono, and loadtextcomp. Since it was written in 2004, you no longer needtextcomp; it’s now in the LaTeX kernel. – Davislor Jun 07 '20 at 20:07\ttfamily, it should be sufficient to\usepackage{beramono}and\usepackage[T1]{fontenc}, but you might be using a bit of\berasanstoo. – Davislor Jun 07 '20 at 20:08fontspec,\setsansfont{DejaVu Sans}, and\setmonofont{DejaVu Sans Mono}. – Davislor Jun 07 '20 at 20:09