From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/44382 Path: news.gmane.org!not-for-mail From: Wolfgang Schuster Newsgroups: gmane.comp.tex.context Subject: Listings (was: Experience on writing a thesis with MKIV) Date: Sun, 28 Sep 2008 20:16:19 +0200 Message-ID: <55EB992D-5348-422A-8105-11A2B2726AF7@gmail.com> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v926) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1222625871 24912 80.91.229.12 (28 Sep 2008 18:17:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 28 Sep 2008 18:17:51 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Sep 28 20:18:48 2008 connect(): Connection refused Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by lo.gmane.org with esmtp (Exim 4.50) id 1Kk0r1-0001Hi-LL for gctc-ntg-context-518@m.gmane.org; Sun, 28 Sep 2008 20:18:47 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C9C001FDDB; Sun, 28 Sep 2008 20:17:42 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 00111-01-4; Sun, 28 Sep 2008 20:16:56 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 3843D1FDD2; Sun, 28 Sep 2008 20:16:56 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 85FC81FDCE for ; Sun, 28 Sep 2008 20:16:55 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 31302-06-3 for ; Sun, 28 Sep 2008 20:16:22 +0200 (CEST) Original-Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.152]) by ronja.ntg.nl (Postfix) with ESMTP id B9D6A1FDD7 for ; Sun, 28 Sep 2008 20:16:22 +0200 (CEST) Original-Received: by fg-out-1718.google.com with SMTP id l26so2261193fgb.8 for ; Sun, 28 Sep 2008 11:16:22 -0700 (PDT) Original-Received: by 10.86.23.17 with SMTP id 17mr3418545fgw.44.1222625782400; Sun, 28 Sep 2008 11:16:22 -0700 (PDT) Original-Received: from ?192.168.2.23? (p5B29525B.dip.t-dialin.net [91.41.82.91]) by mx.google.com with ESMTPS id l12sm2470401fgb.6.2008.09.28.11.16.20 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 28 Sep 2008 11:16:21 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.926) X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.9 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:44382 Archived-At: 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 ___________________________________________________________________________________