我正在用 LaTeX 写一些 SQL 代码,但渲染效果不太令人满意。我会留下我写的代码
\begin{lstlisting}
create table Dipartimento
(
Codice char(3) primary key,
Nome varchar(50)
);
create table Impiegato
(
Matricola char(4) primary key,
Nome varchar(30),
Cognome varchar(30),
CodDip char(3)
references Dipartimento (Codice)
on update cascade
on delete set null
)
\end{lstlisting}
呈现为:
我实际使用的列出包的选项如下
\lstset{frame=false, %trblr, false, none
language=SQL,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle=\ttfamily,
numbers=left, %=left (numera le righe di codice)
numberstyle=\color{gray}, %\tiny per diminuire dimensione
keywordstyle=\bfseries,
%commentstyle=\color{dkgreen},
%stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=4,
captionpos=b,
backgroundcolor=\color{black!10},
morekeywords={references},
showstringspaces=false,
tab=$\bullet$\space,
showtabs=true,
%stringstyle=\rmfamily,
% vocali accentate
inputencoding=utf8,
extendedchars=true,
literate={à}{{\`a}}1 {°}{{\textdegree}}1
}
如下图所示(我设置了 showtabs=true 选项),垂直对齐有点不对,导致单词不对齐。我该如何解决这个问题?提前致谢
编辑:测试代码
\documentclass{article}
\usepackage{xcolor}
\usepackage{listings}
\lstset{frame=false, %trblr, false, none
language=SQL,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle=\ttfamily,
numbers=left, %=left (numera le righe di codice)
numberstyle=\color{gray}, %\tiny per diminuire dimensione
keywordstyle=\bfseries,
%commentstyle=\color{dkgreen},
%stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=4,
captionpos=b,
backgroundcolor=\color{black!10},
morekeywords={references},
showstringspaces=false,
tab=$\bullet$\space,
showtabs=true,
%stringstyle=\rmfamily,
% vocali accentate
inputencoding=utf8,
extendedchars=true,
literate={à}{{\`a}}1 {°}{{\textdegree}}1
}
\begin{document}
\begin{lstlisting}
create table Dipartimento
(
Codice char(3) primary key,
Nome varchar(50)
);
create table Impiegato
(
Matricola char(4) primary key,
Nome varchar(30),
Cognome varchar(30),
CodDip char(3)
references Dipartimento (Codice)
on update cascade
on delete set null
)
\end{lstlisting}
\end{document}
在空白文档中,使用相同的选项,我得到了我想要的结果...发生了什么?