This can be considered a bug in listings
; in lstdvrs.dtx
, more specifically.
The lstdvrs.dtx
file is where all listings
languages and dialects are defined. In particular, a language called Basic
(together with only one dialect, Visual
) is defined there.
The problem is that, even though the Basic
language comes with only one dialect (Visual
), the default dialect for Basic is defined nowhere in lstdvrs.dtx
. Therefore, if you simply specify
language=Basic
listings
has no clue which language you're referring to! The same problem arises, for the same reason, if you try to load the Assembler
language without also specifying a dialect.
To fix the problem, you have two options:
Whenever you want to use Basic, specify its only dialect (Visual
) also:
language={[Visual]Basic}
Fix that bug in listings
yourself by defining the default dialect for Basic
:
\lstset{defaultdialect=[Visual]Basic}
(As Peter notes, this should preferably be done in your preamble. You should endeavour to separate style from content; the former should go in the preamble, whereas the latter should go in the body of your document.)
Then you should be able to use the Basic
language without mishap. No need to use \lstloadlanguages
at all (although, as pointed out by Peter, you may still want to load the languages you use right after loading the listings
package, for efficiency reasons; see the note at the bottom of section 2.2 in the documentation).

\documentclass[11pt,letterpaper]{book}
\usepackage{listings}
\lstset{
defaultdialect=[Visual]Basic
,frameround=fttt
,language=SQL
,numbers=left
,breaklines=true
,showstringspaces=false
,basicstyle=\small
}
\begin{document}
\begin{lstlisting}[language=Basic,label={lst:ssrscurmon}]
=MonthName(DatePart(DateInterval.Month, Today()))
\end{lstlisting}
\end{document}
Basic
is missing in the list of available languages for some reason. Also, I recommend you move the\lstloadlanguages
and the\lstset{ to the preamble _before_
\begin{document}`. – Peter Grill Nov 13 '14 at 19:14\lstset
inside the document body. Why do you recommend putting it in the preamble? – ajeh Nov 13 '14 at 19:43lstset
after\begin{document}
. My recommendation was more about\lstloadlanguages
as I can not see any reason to load that in the main documents. Evenlstset
, IMHO, should be used only for document wide settings andstyle=
settings be used for customization, although it is possible to uselstset
to change the settings mid-document. – Peter Grill Nov 13 '14 at 21:10