# change font color in a lstset [closed]

Hi I need put java code to latex. I use \lstset and \begin{lstlisting}. I need change color of font in SOME part of code. How I can do this? Help pls

## closed as unclear what you're asking by jub0bs, Martin Schröder, Fran, mafp, SperavirJan 16 '14 at 0:50

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Do you want to change the color of some keywords or do you want to highlight some code lines? It would help us if you provide a little example... – Matten Dec 8 '10 at 13:45

## 1 Answer

Here is an example of settings. Please modify as you wish for your language:

\lstnewenvironment{teX}[1][]
{\lstset{language=[LaTeX]TeX}\lstset{escapeinside={(*@}{@*)},
numbers=left,numberstyle=\normalsize,stepnumber=1,numbersep=5pt,
%firstnumber=last,
%frame=tblr,
framesep=5pt,
basicstyle=\normalsize\ttfamily,
showstringspaces=false,
keywordstyle=\itshape\color{blue},
%identifierstyle=\ttfamily,
stringstyle=\color{maroon},
commentstyle=\color{black},
rulecolor=\color{Gray},
xleftmargin=5pt,
xrightmargin=5pt,
aboveskip=\bigskipamount,
belowskip=\bigskipamount,
backgroundcolor=\color{LightGray!.50}, #1
}}
{}


I personally find it easier to define environments for lstlistings rather than using the other style commands (saves time on typing).

Hope this is answers your question. If I misunderstood your question please clarify with a minimal example, is always so much easier on people answering.

• The OP did ask about java, rather than TeX... – Seamus Dec 8 '10 at 16:12
• @Seamus OP needs to edit [LaTeX]Tex to Java, also need to add \lstloadlanguages{Java} – Yiannis Lazarides Dec 8 '10 at 19:13