"Fossies" - the Fresh Open Source Software Archive

Member "hevea-2.35/examples/listings.tex" (16 Jan 2021, 1844 Bytes) of package /linux/www/hevea-2.35.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TeX and LaTeX source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 \documentclass{article}
    2 \usepackage{listings}
    3 \usepackage{color}
    4 
    5 \title{Listings}
    6 \author{}
    7 
    8 \newstyle{.clisting}{border-left:solid green 2px;white-space:pre;padding-left:4px;font-family:monospace}
    9 \newstyle{.camllisting}{border:double red 10px;white-space:pre;padding:4px;
   10   font-family:monospace;border-radius:300px;padding-left:60px}
   11 
   12 \begin{document}
   13 
   14 \maketitle
   15 
   16 \lstdefinestyle{colors}{keywordstyle={\bf\color{blue}}, commentstyle={\em\color{magenta}}}
   17 
   18 \lstnewenvironment{clisting}
   19   {\setenvclass{lstlisting}{clisting}\lstset{language=C, style=colors}}
   20   {}
   21 
   22 \lstnewenvironment{camllisting}
   23   {\setenvclass{lstlisting}{camllisting}\lstset{language=caml, style=colors}}
   24   {}
   25 
   26 C code, with a green left border :
   27 
   28 \begin{clisting}
   29 /* Compute, guess what! */
   30 int fact(int n) {
   31   int r = 1 ;
   32   for ( ; n > 0 ; n--) {
   33     r *= n ;
   34   }
   35   return r ;
   36 }
   37 \end{clisting}
   38 
   39 OCaml code, with a double red round border (ugly!):
   40 
   41 \begin{camllisting}
   42 (* Hello there *)
   43 module MyList (E : sig type t end) : sig
   44   type t
   45   val nil : t
   46   val cons : E.t -> t -> t
   47 end
   48   = 
   49 struct
   50   type t = E.t list
   51   let nil = []
   52   let cons x xs = x :: xs
   53 end
   54 \end{camllisting}
   55 
   56 Listing in a listing, no style :
   57 
   58 \lstset{style=colors}
   59 
   60 \begin{lstlisting}
   61 \documentclass{article}
   62 \usepackage{listings}
   63 \usepackage{color}
   64 
   65 \title{Listings}
   66 \author{}
   67 
   68 \newstyle{.clisting}{border-left:solid green 2px;white-space:pre;padding-left:4px;font-family:monospace}
   69 \newstyle{.camllisting}{border:ridge red 10px;white-space:pre;padding:4px;
   70   font-family:monospace;border-radius:300px;padding-left:60px}
   71 
   72 \begin{document}
   73 
   74 \begin{camllisting}
   75 (* Hello there *)
   76 module MyList (E : sig type t end) : sig
   77   type t
   78   val nil : t
   79   val cons : E.t -> t -> t
   80 end
   81   = 
   82 struct
   83   type t = E.t list
   84   let nil = []
   85   let cons x xs = x :: xs
   86 end
   87 \end{camllisting}
   88 \end{lstlisting}
   89 
   90 \end{document}