TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

closed as unclear what you're asking by Jubobs, Martin Schröder, Fran, mafp, Speravir Jan 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

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

           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.

share|improve this answer
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