Tell me more ×
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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.