ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Listings (was: Experience on writing a thesis with MKIV)
Date: Sun, 28 Sep 2008 20:16:19 +0200	[thread overview]
Message-ID: <55EB992D-5348-422A-8105-11A2B2726AF7@gmail.com> (raw)
In-Reply-To: <gbof76$egp$1@ger.gmane.org>


Am 28.09.2008 um 19:34 schrieb Mohamed Bana:

> Aditya Mahajan wrote:
>> Hi everyone,
>>
>> I finished my thesis, writing both my thesis and my presentation  
>> using
>> ConTeXt.
>>
>> Aditya
>
> :).  But there's a still something missing that I need before I even
> thinking of typesetting an msc thesis in ConTeXt.   I'd like to have
> something equivelant to the *listings.sty* package;
> http://thread.gmane.org/gmane.comp.tex.context/15591/focus=15592 or
> http://vega.soi.city.ac.uk/~abbg770/listing-sample.pdf.
>
>
> I setup listing first;
>
> \lstset{breaklines=true,
> showlines=true,		% showing line numbers
> numbers=left,		% where to show line numbers
> numberstyle=\tiny\color{gray},	
> numbersep=10pt,		%
> stepnumber=1,		% how often to show the line number on the left
> language=Java,		% specifiy the language
> basicstyle=\ttfamily\small,          % print whole listing small
> keywordstyle=\color{eclipsekeyword}\ttfamily\underbar, % underlined  
> bold
> black keywords
> identifierstyle=,           % nothing happens
> commentstyle=\color{eclipsecomment}, % white comments, if you use
> commentstyle=\color{white},
> stringstyle=\ttfamily,  % typewriter type for strings
> showstringspaces=false,	% no special string spaces
> frame=single,
> backgroundcolor=\color{white},
> tabsize=4,
> showspaces=false,
> showstringspaces=false}			
>
> \lstset{morecomment=[s][\color{eclipsejavadoc}]{/**}{*/}}
>
>
> Includes a file, look at Listing B.2 on the pdf I posted.  This should
> be self explanatory;
>
> \lstinputlisting[
> caption={SpreadsheetParser.java},
> label=lst:SpreadsheetParser.java]
> {source/SpreadsheetParser.java}
>
>
>
> I can also list inline using the same settings defined in \lstset -  
> but
> it doesn't break across lines.  The choice of charater is arbitrary
> i.e., I could have chosen to use | instead of !;
>
> \lstinline!matcher(CharSequence input)!
>
>
>
> Similar to preceeding, with line breaking.  Also I can refer to it
> using; \ref{lst:freeformlogfile}
>
> \begin{lstlisting}[frame=,label={lst:freeformlogfile},caption={Log  
> File}]
> import java.util.Arrays;
>
> public class ArrayReallocationDemo {
>
>   public static void main(String[] args) {
>     int[] data1 = new int[] { 1, 3, 5, 7, 9 };
>
>     printArray(data1);
>     int[] data2 = Arrays.copyOf(data1, 6);
>     data2[5] = 11;
>     printArray(data2);
>
>     int[] data3 = Arrays.copyOfRange(data1, 2, 10);
>     printArray(data3);
>   }
>
>   // print array elements
>   private static void printArray(int[] data) {
>     StringBuilder stringBuilder = new StringBuilder("[");
>     for (int i = 0; i < data.length; i++) {
>       stringBuilder.append(data[i]);
>       if (i < data.length - 1)
>         stringBuilder.append(", ");
>     }
>     stringBuilder.append("]");
>     System.out.println(stringBuilder);
>   }
> }
> \end{lstlisting}

\setupcolors[state=start]

\definetyping[JAVA][option=JV]

\setuptyping
   [JAVA]
   [numbering=line]

\starttext

\startJAVA
...
\stopJAVA

\stoptext

or

same preamble as above plus

\definefloat[listing][listings]

\starttext

\placelisting
    [split]
    [lst:freeformlogfile]
    {Log File}
    {\startJAVA
     ...
     \stopJAVA}

\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2008-09-28 18:16 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-27 16:35 Experience on writing a thesis with MKIV Aditya Mahajan
2008-09-28 13:59 ` Hans Hagen
2008-09-28 15:45 ` Mikael Persson
2008-09-28 18:23   ` Hans Hagen
2008-09-28 19:06     ` Mikael Persson
2008-09-28 19:21       ` Aditya Mahajan
2008-09-28 19:34         ` Utopia and Fourier fonts (was: Experience on writing a thesis with MKIV) Wolfgang Schuster
2008-09-29  9:31           ` Mikael Persson
2008-09-29  9:56             ` Utopia and Fourier fonts Wolfgang Schuster
2008-09-29 13:34               ` Mikael Persson
2008-09-29 13:49                 ` Mojca Miklavec
2008-09-29 18:35               ` Mikael Persson
2008-09-29 20:22                 ` Wolfgang Schuster
2008-09-30  6:43                   ` Mikael Persson
2008-10-01 15:43                     ` Mikael Persson
2008-09-29  9:26     ` Experience on writing a thesis with MKIV Mikael Persson
2008-09-28 17:34 ` Mohamed Bana
2008-09-28 18:16   ` Wolfgang Schuster [this message]
2008-09-28 20:42     ` Listings Mohamed Bana
2008-09-28 21:23       ` Listings Wolfgang Schuster
2008-09-28 22:04         ` Listings Wolfgang Schuster
2008-09-30 16:37     ` Listings (was: Experience on writing a thesis with MKIV) Chen Shen
2008-09-30 17:15       ` Wolfgang Schuster
2008-10-01  3:44         ` Chen Shen
2008-10-02 17:38           ` Chen Shen
2008-09-30 20:35       ` Listings Hans Hagen
2008-10-02 21:27     ` Listings Mohamed Bana
2008-10-03  5:49       ` Listings Peter Münster
2008-10-04  1:11         ` Listings Mojca Miklavec
2008-12-07  2:28 ` Experience on writing a thesis with MKIV Mohamed Bana
2008-12-07  2:50   ` Aditya Mahajan
2008-12-08 23:19     ` Mohamed Bana
2008-12-09  0:40       ` Aditya Mahajan
2008-12-09  1:22         ` Sorting bug in context-alpha (was: Experience on writing a thesis with MKIV) Aditya Mahajan
2008-12-09  2:59         ` Experience on writing a thesis with MKIV Mohamed Bana
2008-12-09  3:26           ` Aditya Mahajan
2008-12-09 18:17             ` Mohamed Bana
2008-12-09 19:36               ` Aditya Mahajan
2008-12-09 21:23                 ` Taco Hoekwater
2008-12-09 21:49                   ` Aditya Mahajan
2008-12-10  9:24                     ` Taco Hoekwater
2008-12-11  2:20                     ` Mohamed Bana
2008-12-11  3:17                       ` Aditya Mahajan
2008-12-15  3:52                         ` Mohamed Bana
2008-12-09 14:18           ` Mojca Miklavec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55EB992D-5348-422A-8105-11A2B2726AF7@gmail.com \
    --to=schuster.wolfgang@googlemail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).