lstlisting and bold keywords
I have the following MWE for SQL typesetting. What doesn't work for me and for which I need help are two things:
- I would like to add "SUCH AS" as a keyword (or make it bold in the text without defining it as a keyword); and
I need "domain" not to be bold, but it insists in typesetting it bold even when I include it in
deletekeywords. Don't know what is happening there.
documentclass[border=2pt]{standalone}
usepackage{newtxtext,newtxmath}
usepackage{listings}
lstset{language=SQL,basicstyle=ttfamily,keywordstyle=bfseries,
showspaces=false,showstringspaces=false,
morekeywords={*,IF,DEFINE,OPTIONS, SERVER, MENTIONS, SUCH THAT},
deletekeywords={domain}, mathescape=true, aboveskip=0pt, belowskip=6pt}
begin{document}
begin{lstlisting}
FROM Relation SUCH THAT domain-condition
end{lstlisting}
end{document}
Would appreciate any help. Here is what comes out when I typeset it.

lstlisting
add a comment |
I have the following MWE for SQL typesetting. What doesn't work for me and for which I need help are two things:
- I would like to add "SUCH AS" as a keyword (or make it bold in the text without defining it as a keyword); and
I need "domain" not to be bold, but it insists in typesetting it bold even when I include it in
deletekeywords. Don't know what is happening there.
documentclass[border=2pt]{standalone}
usepackage{newtxtext,newtxmath}
usepackage{listings}
lstset{language=SQL,basicstyle=ttfamily,keywordstyle=bfseries,
showspaces=false,showstringspaces=false,
morekeywords={*,IF,DEFINE,OPTIONS, SERVER, MENTIONS, SUCH THAT},
deletekeywords={domain}, mathescape=true, aboveskip=0pt, belowskip=6pt}
begin{document}
begin{lstlisting}
FROM Relation SUCH THAT domain-condition
end{lstlisting}
end{document}
Would appreciate any help. Here is what comes out when I typeset it.

lstlisting
Sorry -- I don't know why the MWE is coming out this way... I did enter it as a code fragment but it is not being typeset as such.
– ozsu
Mar 21 at 1:45
add a comment |
I have the following MWE for SQL typesetting. What doesn't work for me and for which I need help are two things:
- I would like to add "SUCH AS" as a keyword (or make it bold in the text without defining it as a keyword); and
I need "domain" not to be bold, but it insists in typesetting it bold even when I include it in
deletekeywords. Don't know what is happening there.
documentclass[border=2pt]{standalone}
usepackage{newtxtext,newtxmath}
usepackage{listings}
lstset{language=SQL,basicstyle=ttfamily,keywordstyle=bfseries,
showspaces=false,showstringspaces=false,
morekeywords={*,IF,DEFINE,OPTIONS, SERVER, MENTIONS, SUCH THAT},
deletekeywords={domain}, mathescape=true, aboveskip=0pt, belowskip=6pt}
begin{document}
begin{lstlisting}
FROM Relation SUCH THAT domain-condition
end{lstlisting}
end{document}
Would appreciate any help. Here is what comes out when I typeset it.

lstlisting
I have the following MWE for SQL typesetting. What doesn't work for me and for which I need help are two things:
- I would like to add "SUCH AS" as a keyword (or make it bold in the text without defining it as a keyword); and
I need "domain" not to be bold, but it insists in typesetting it bold even when I include it in
deletekeywords. Don't know what is happening there.
documentclass[border=2pt]{standalone}
usepackage{newtxtext,newtxmath}
usepackage{listings}
lstset{language=SQL,basicstyle=ttfamily,keywordstyle=bfseries,
showspaces=false,showstringspaces=false,
morekeywords={*,IF,DEFINE,OPTIONS, SERVER, MENTIONS, SUCH THAT},
deletekeywords={domain}, mathescape=true, aboveskip=0pt, belowskip=6pt}
begin{document}
begin{lstlisting}
FROM Relation SUCH THAT domain-condition
end{lstlisting}
end{document}
Would appreciate any help. Here is what comes out when I typeset it.

lstlisting
lstlisting
edited Mar 21 at 2:36
Kurt
40.2k850164
40.2k850164
asked Mar 21 at 1:21
ozsuozsu
1,13111126
1,13111126
Sorry -- I don't know why the MWE is coming out this way... I did enter it as a code fragment but it is not being typeset as such.
– ozsu
Mar 21 at 1:45
add a comment |
Sorry -- I don't know why the MWE is coming out this way... I did enter it as a code fragment but it is not being typeset as such.
– ozsu
Mar 21 at 1:45
Sorry -- I don't know why the MWE is coming out this way... I did enter it as a code fragment but it is not being typeset as such.
– ozsu
Mar 21 at 1:45
Sorry -- I don't know why the MWE is coming out this way... I did enter it as a code fragment but it is not being typeset as such.
– ozsu
Mar 21 at 1:45
add a comment |
1 Answer
1
active
oldest
votes
To get rid of the domain keyword, you have to spell it in uppercase in deletekeywords because that's how it is defined in the drivers file.
Additionally, spaces may not occur in keywords. You could perhaps make the space a letter or other character and define keywords based on that, but this would likely cause problems with the word-breaking mechanism.
An easy solution is to use the literate option to replace each literal occurrence of SUCH THAT by the same string with the corresponding style being applied.
In sum, the new listings setup would look like this (modified options are highlighted):
lstset{
language=SQL,
basicstyle=ttfamily,
keywordstyle=bfseries,
showspaces=false,
showstringspaces=false,
morekeywords={*,IF,DEFINE,OPTIONS,SERVER,MENTIONS},
deletekeywords={DOMAIN},
mathescape=true,
aboveskip=0pt,
belowskip=6pt,
literate={SUCH THAT}{bfseries SUCH THAT}{9}
}

Many thanks. I'll try these.
– ozsu
Mar 21 at 11:43
add a comment |
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480607%2flstlisting-and-bold-keywords%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To get rid of the domain keyword, you have to spell it in uppercase in deletekeywords because that's how it is defined in the drivers file.
Additionally, spaces may not occur in keywords. You could perhaps make the space a letter or other character and define keywords based on that, but this would likely cause problems with the word-breaking mechanism.
An easy solution is to use the literate option to replace each literal occurrence of SUCH THAT by the same string with the corresponding style being applied.
In sum, the new listings setup would look like this (modified options are highlighted):
lstset{
language=SQL,
basicstyle=ttfamily,
keywordstyle=bfseries,
showspaces=false,
showstringspaces=false,
morekeywords={*,IF,DEFINE,OPTIONS,SERVER,MENTIONS},
deletekeywords={DOMAIN},
mathescape=true,
aboveskip=0pt,
belowskip=6pt,
literate={SUCH THAT}{bfseries SUCH THAT}{9}
}

Many thanks. I'll try these.
– ozsu
Mar 21 at 11:43
add a comment |
To get rid of the domain keyword, you have to spell it in uppercase in deletekeywords because that's how it is defined in the drivers file.
Additionally, spaces may not occur in keywords. You could perhaps make the space a letter or other character and define keywords based on that, but this would likely cause problems with the word-breaking mechanism.
An easy solution is to use the literate option to replace each literal occurrence of SUCH THAT by the same string with the corresponding style being applied.
In sum, the new listings setup would look like this (modified options are highlighted):
lstset{
language=SQL,
basicstyle=ttfamily,
keywordstyle=bfseries,
showspaces=false,
showstringspaces=false,
morekeywords={*,IF,DEFINE,OPTIONS,SERVER,MENTIONS},
deletekeywords={DOMAIN},
mathescape=true,
aboveskip=0pt,
belowskip=6pt,
literate={SUCH THAT}{bfseries SUCH THAT}{9}
}

Many thanks. I'll try these.
– ozsu
Mar 21 at 11:43
add a comment |
To get rid of the domain keyword, you have to spell it in uppercase in deletekeywords because that's how it is defined in the drivers file.
Additionally, spaces may not occur in keywords. You could perhaps make the space a letter or other character and define keywords based on that, but this would likely cause problems with the word-breaking mechanism.
An easy solution is to use the literate option to replace each literal occurrence of SUCH THAT by the same string with the corresponding style being applied.
In sum, the new listings setup would look like this (modified options are highlighted):
lstset{
language=SQL,
basicstyle=ttfamily,
keywordstyle=bfseries,
showspaces=false,
showstringspaces=false,
morekeywords={*,IF,DEFINE,OPTIONS,SERVER,MENTIONS},
deletekeywords={DOMAIN},
mathescape=true,
aboveskip=0pt,
belowskip=6pt,
literate={SUCH THAT}{bfseries SUCH THAT}{9}
}

To get rid of the domain keyword, you have to spell it in uppercase in deletekeywords because that's how it is defined in the drivers file.
Additionally, spaces may not occur in keywords. You could perhaps make the space a letter or other character and define keywords based on that, but this would likely cause problems with the word-breaking mechanism.
An easy solution is to use the literate option to replace each literal occurrence of SUCH THAT by the same string with the corresponding style being applied.
In sum, the new listings setup would look like this (modified options are highlighted):
lstset{
language=SQL,
basicstyle=ttfamily,
keywordstyle=bfseries,
showspaces=false,
showstringspaces=false,
morekeywords={*,IF,DEFINE,OPTIONS,SERVER,MENTIONS},
deletekeywords={DOMAIN},
mathescape=true,
aboveskip=0pt,
belowskip=6pt,
literate={SUCH THAT}{bfseries SUCH THAT}{9}
}

answered Mar 21 at 3:23
siracusasiracusa
5,16511429
5,16511429
Many thanks. I'll try these.
– ozsu
Mar 21 at 11:43
add a comment |
Many thanks. I'll try these.
– ozsu
Mar 21 at 11:43
Many thanks. I'll try these.
– ozsu
Mar 21 at 11:43
Many thanks. I'll try these.
– ozsu
Mar 21 at 11:43
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f480607%2flstlisting-and-bold-keywords%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown

Sorry -- I don't know why the MWE is coming out this way... I did enter it as a code fragment but it is not being typeset as such.
– ozsu
Mar 21 at 1:45