将字体样式设置为 Courier New,并将字体大小设置为 10pt

将字体样式设置为 Courier New,并将字体大小设置为 10pt

我想将framed环境中的字体从 Times New Roman 更改为 Courier New,并且字体大小应为 10pt。

这是我当前的编码:

\begin{lstlisting}
define("USE_PCONNECT", false);
####### LOCAL CONFIGARATION  #######
define("SERVER","localhost");
define("USER","root");
define("PASSWORD","");
define("DB","learning");
\end{lstlisting}   

在我的文档文件中:

\usepackage{listings}
\lstset{
numberstyle=\small, 
numbersep=10pt, 
frame = single, 
language=PHP
}

答案1

除了有关如何提问的提示之外,这里还有一个可能的解决方案:

\documentclass[a4paper,10pt]{article}

\usepackage[T1]{fontenc}

\usepackage{listings}
\lstset{%
  basicstyle  = \fontfamily{pcr}\fontsize{10pt}{12pt}\selectfont ,
  numberstyle = \small , 
  numbersep   = 10pt   , 
  frame       = single , 
  language    = PHP
}

\begin{document}

\begin{lstlisting}
define("USE_PCONNECT", false);
####### LOCAL CONFIGARATION  #######
define("SERVER","localhost");
define("USER","root");
define("PASSWORD","");
define("DB","learning");
\end{lstlisting}

\end{document}

相关内容