Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
4  
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
add comment

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

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.

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
add comment