【发布时间】:2021-04-15 17:51:45
【问题描述】:
SQL 注释字符由两个连字符组成,因此:
-- cannot create table if one already exists
drop table if exists mytable;
在源代码的包列表中使用 lstlisting 时,注释字符将转换为破折号。如果我在连字符之间插入一个空格,它看起来像 [hyphen][space][hyphen],而不是两个相邻的连字符。那么,在 SQL 源代码的包列表中使用 lstlistings,如何指定注释字符呢?
【问题讨论】:
-
嗯,这听起来像是一个用于包装未格式化源代码的包的非常糟糕的行为。你也可以分享你的 LaTeX 吗?
-
(而且,像往常一样,如果第一次不工作,编译两次,或三次!)
-
\documentclass{article} \usepackage{listings} \lstset{ breaklines = true, language = SQL, numbers = left, basicstyle = \footnotesize, escapeinside={} } \begin{document} \begin {lstlisting} .echo on .headers on -- 名称:您的姓名 -- 文件:您的文件名 -- 日期:今天的日期 -- SQL 代码 -- DROP 表 -- CREATE 表 -- INSERT 数据 -- SELECT 数据 \end {lstlisting} \end{document}
标签: sql latex comments listings