lstlisting and bold keywords












1















I have the following MWE for SQL typesetting. What doesn't work for me and for which I need help are two things:




  1. I would like to add "SUCH AS" as a keyword (or make it bold in the text without defining it as a keyword); and


  2. 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.



enter image description here










share|improve this question

























  • 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
















1















I have the following MWE for SQL typesetting. What doesn't work for me and for which I need help are two things:




  1. I would like to add "SUCH AS" as a keyword (or make it bold in the text without defining it as a keyword); and


  2. 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.



enter image description here










share|improve this question

























  • 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














1












1








1








I have the following MWE for SQL typesetting. What doesn't work for me and for which I need help are two things:




  1. I would like to add "SUCH AS" as a keyword (or make it bold in the text without defining it as a keyword); and


  2. 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.



enter image description here










share|improve this question
















I have the following MWE for SQL typesetting. What doesn't work for me and for which I need help are two things:




  1. I would like to add "SUCH AS" as a keyword (or make it bold in the text without defining it as a keyword); and


  2. 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.



enter image description here







lstlisting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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










1 Answer
1






active

oldest

votes


















2














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}
}


enter image description here






share|improve this answer
























  • Many thanks. I'll try these.

    – ozsu
    Mar 21 at 11:43












Your Answer








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
});


}
});














draft saved

draft discarded


















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









2














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}
}


enter image description here






share|improve this answer
























  • Many thanks. I'll try these.

    – ozsu
    Mar 21 at 11:43
















2














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}
}


enter image description here






share|improve this answer
























  • Many thanks. I'll try these.

    – ozsu
    Mar 21 at 11:43














2












2








2







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}
}


enter image description here






share|improve this answer













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}
}


enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 21 at 3:23









siracusasiracusa

5,16511429




5,16511429













  • 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





Many thanks. I'll try these.

– ozsu
Mar 21 at 11:43


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

How to send String Array data to Server using php in android

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Is anime1.com a legal site for watching anime?