我需要在条目内添加 \lstlisting。我有以下代码,但正如您将从输出中看到的那样,列表从条目标签后的行开始。有没有办法将它放在同一行上(我以为我之前问过这个问题或读过它,但我似乎找不到它——所以如果这是重复的话我深表歉意):
\documentclass{article}
\usepackage{listings}
\lstset{
language=SQL,
basicstyle=\small\ttfamily,
keywordstyle=\textbf,
showspaces=false,
showstringspaces=false,
deletekeywords={DOMAIN},
morekeywords={*,IF,DEFINE,OPTIONS, SERVER, MENTIONS, IN, CONTAINS, ANCHOR}, mathescape=true,
aboveskip=0pt,
belowskip=6pt,
literate={SUCH\ THAT}{\bfseries SUCH\ THAT}{9}
}
\newcounter{exlcal}
\newenvironment{exalist}{\begin{list}{\bf
(\alph{exlcal})}{\topsep 10pt\partopsep 0pt \labelwidth 12pt\labelsep
12pt\leftmargin 24pt
\itemsep 0pt\usecounter{exlcal}}}{\end{list}\addvspace{0pt}}
\begin{document}
Do the following:
\begin{exalist}
\item \begin{lstlisting}
SELECT B, COUNT(C)
FROM R
GROUP BYB
\end{lstlisting}
\end{exalist}
\end{document}