I am not able to find how i can highlight a particular line of code in program listings.
Syntax highlighting seems to work but I dont need particular language keywords to be highlighted.
e.g.
for the code below how can i highlight/bold face char j=malloc……line
public static void function(){
int i=0;
char j = malloc(sizeof(char));
/.......some code....
return;
}
Best Answer
Like this:
Adapted from an answer by Juanjo on latex-community.org.
You can see the result on writeLaTeX.
To achieve the same result in LyX, go to
Document->Settings
and navigate to thePreamble
tab. Paste everything from\usepackage{listings}
to the end of the\begin{document}
block into the preamble and save it.To insert the program listing into the document, go to
Insert -> Program Listing
in the menu. Paste the code into the listing environment. Then holdCtrl
and right-click on the environment and open theSettings
dialog. Go to theAdvanced
tab in the dialog and pasteescapechar={\%}
into the text area. Configure the other settings however you want them to look.There is an example LyX file you can download [here] (https://dl.dropbox.com/s/9dfqtsc0fnftggc/hilite_example.lyx).