[NTG-context] Experience on writing a thesis with MKIV

Mohamed Bana m.bana.lists at gmail.com
Sun Sep 28 19:34:25 CEST 2008


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}


Thanks guys



More information about the ntg-context mailing list
http://www.ntg.nl/pipermail/ntg-context/2008/034975.html
www.ntg.nl
crawl=CC-MAIN-2015-18
5609
application/http; msgtype=response
sha1:N6AFFXNJTWGQKCQ4DYSQBLYOI5PU4IIJ
<urn:uuid:e0f2089a-2d78-42b3-b123-0f7522e07584>
2015-04-25T19:48:32Z
5.39.185.229
sha1:XZCASM4DWG7C4VF6X32YUQ4N5IUOHEMB
<urn:uuid:87c06cc7-0694-4f47-b2b1-7e7e06de872c>
http://www.ntg.nl/pipermail/ntg-context/2008/034975.html
response
<urn:uuid:52ac9a6a-0c50-40ed-9390-4fd9ccabf8f7>
robots: classic
hostname: ip-10-235-10-82.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2015-18
operator: CommonCrawl Admin
description: Wide crawl of the web for April 2015
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf