# additional keywords in lstlisting

I have the following code where I am attempting to add SUCH THAT to the keywords. According to my lstset, this should be typeset as bold, but it is not. I can't figure out why and would appreciate suggestions.

\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,for,REFERENCES,DETERMINES}, mathescape=true,
literate={SUCH\ THAT}{\bfseries SUCH\ THAT}{9}
}

\begin{document}
\begin{lstlisting}
FROM Relation SUCH THAT domain-condition
\end{lstlisting}
\end{document}


## 2 Answers

\documentclass[a4paper,12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{color}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{ltgray}{rgb}{0.5,0.5,0.5}

\usepackage{listings}
\lstset{%
backgroundcolor=\color{white},
basicstyle=\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
commentstyle=\color{dkgreen},
deletekeywords={...},
escapeinside={\%*}{*)},
extendedchars=true,
frame=single,
keepspaces=true,
keywordstyle=\color{blue},
language=SQL,
morekeywords={*,modify,MODIFY,...},
numbers=left,
numbersep=15pt,
numberstyle=\tiny,
rulecolor=\color{ltgray},
showspaces=false,
showstringspaces=false,
showtabs=false,
stepnumber=1,
tabsize=4,
title=\lstname
}

\begin{document}

\begin{lstlisting}[language=sql]
ALTER TABLE country
MODIFY capital SET NOT NULL;
-- There is no MODIFY CONSTRAINT, so first remove than create anew:
ALTER TABLE country
DROP CONSTRAINT country_capital_fkey;
ALTER TABLE country
ADD CONSTRAINT country_capital_fkey FOREIGN KEY (capital) REFERENCES city(id) ON DELETE CASCADE;
\end{lstlisting}

\end{document}


Your typewriter font has no bold version. With e.g. luximono it works fine:

\documentclass{article}
\usepackage{listings}
\usepackage[T1]{fontenc}
\usepackage{luximono}
\lstset{
language=SQL,
basicstyle=\small\ttfamily,
keywordstyle=\textbf,
showspaces=false,
showstringspaces=false,
deletekeywords={DOMAIN},
morekeywords={*,IF,DEFINE,OPTIONS, SERVER, MENTIONS, IN, CONTAINS, ANCHOR,for,REFERENCES,DETERMINES}, mathescape=true,
literate={SUCH\ THAT}{\bfseries SUCH\ THAT}{9}
}

\begin{document}
\begin{lstlisting}
FROM Relation SUCH THAT domain-condition
\end{lstlisting}
\end{document}


• Thank you. I will try that. – ozsu Jun 20 at 14:20
• Well, ran into a problem. I don't have luximono and trying to install it, I get an error in running the texlua install-getnonfreefonts that it cannot create the directory /usr/local/texlive/2019/texmf-dist/scripts/getnonfreefont (I am on a Mac). So, this does not exactly work. Is there possibly a similar font included in the tex live distribution that I can use? – ozsu Jun 20 at 15:25
• search the site for typewriter bold or something like that. – Ulrike Fischer Jun 20 at 15:28