![lstlisting - 加粗数字,删除行间间隙](https://linux22.com/image/363028/lstlisting%20-%20%E5%8A%A0%E7%B2%97%E6%95%B0%E5%AD%97%EF%BC%8C%E5%88%A0%E9%99%A4%E8%A1%8C%E9%97%B4%E9%97%B4%E9%9A%99.png)
我正在尝试用 制作一个彩色源代码框lstlisting
。除了两件事外,几乎所有东西都运行良好:
我花了 2 个小时在网上搜索如何使行前的小数字加粗,最后我放弃了。我试了,
\large
但\huge
没有成功(如下图所示)。然后我尝试了\textbf{}
,但我不知道该在括号里放什么。有没有办法让数字加粗?导出为 PDF 后,我注意到代码行之间有一些奇怪的白线(见下图)。它们是从哪里来的?可以将它们去除吗?
这是我的最小工作示例:
\documentclass[a4paper]{article}
%
% ----- basic setup -----
%
\usepackage{german}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\geometry{top=20mm, right=20mm, bottom=20mm, left=20mm}
\usepackage{lmodern}
\usepackage{listings}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
%
% ----- definitions -----
%
\lstdefinestyle{bashcode}{
language=bash,
backgroundcolor=\color{darkgray},
showspaces=false,
showstringspaces=false,
showtabs=false,
captionpos=b,
basicstyle=\color{white},
frame=tb,
framerule=0pt,
framesep=10pt,
framexleftmargin=20pt,
framexrightmargin=10pt,
numbers=left,
numbersep=10pt,
numberstyle=\color{cyan}
}
\lstdefinestyle{bashcode2}{
language=bash,
backgroundcolor=\color{darkgray},
showspaces=false,
showstringspaces=false,
showtabs=false,
captionpos=b,
basicstyle=\color{white},
frame=tb,
framerule=0pt,
framesep=10pt,
framexleftmargin=20pt,
framexrightmargin=10pt,
numbers=left,
numbersep=10pt,
numberstyle=\large\color{cyan}
}
\lstdefinestyle{bashcode3}{
language=bash,
backgroundcolor=\color{darkgray},
showspaces=false,
showstringspaces=false,
showtabs=false,
captionpos=b,
basicstyle=\color{white},
frame=tb,
framerule=0pt,
framesep=10pt,
framexleftmargin=20pt,
framexrightmargin=10pt,
numbers=left,
numbersep=10pt,
numberstyle=\huge\color{cyan}
}
%
% ===== begin of document =====
%
\begin{document}
\lstset{style=bashcode}
\begin{lstlisting}[caption={installing git}\label{src:install_git}]
sudo apt-get install git
\end{lstlisting}
\lstset{style=bashcode2}
\begin{lstlisting}[caption={installing git}\label{src:install_git2}]
sudo apt-get install git
\end{lstlisting}
\lstset{style=bashcode3}
\begin{lstlisting}[caption={installing git}\label{src:install_git3}]
sudo apt-get install git
\end{lstlisting}
\end{document}