Re: Formatting source code

2005-06-13 Thread Helge Hafting

Invisible Person wrote:

Hello list, 


I want to insert source code ( Java, Sql) into the document.
Can I insert it formatted (indent and/or colored) like in an IDE?
 


If you can live with some ERT, consider the listings package.
It lets you list source code files, it parses many programming
languages (including java). You can select how different
items (keywords, commands, separators, and so on) should
be highlighted, so you can have colors if you want that.

The colors won't be there on screen when you edit, but
they will appear in print as well as view->pdf.

Helge Hafting


RE : Formatting source code

2005-05-25 Thread EXT / TEAMLOG MELLERIN Pierrick
Yes, you can. The "listings" package is a good solution as for me ...

For example :

\usepackage{listings}

...

\lstinputlisting[language=Java, alsolanguage=SQL, label={mylabel},
caption={...}]{myfile.java}

...

To insert a hyperref (with the 'hyperref' package) :

\ref{mylabel}

-Message d'origine-
De : Invisible Person [mailto:[EMAIL PROTECTED] 
Envoyé : mercredi 25 mai 2005 16:55
À : lyx-users@lists.lyx.org
Objet : Formatting source code


Hello list, 

I want to insert source code ( Java, Sql) into the document. Can I insert it
formatted (indent and/or colored) like in an IDE?


thanks, 

Christian



Formatting source code

2005-05-25 Thread Invisible Person
Hello list, 

I want to insert source code ( Java, Sql) into the document.
Can I insert it formatted (indent and/or colored) like in an IDE?


thanks, 

Christian




Re: Formatting source code

2000-03-09 Thread Thierry Lemeunier

"Lars Gullik Bjønnes" wrote:
> 
> This is really a great package.
> I just tested with buffer.C in the LyX distribution and it worked
> flawlessly.
> 
> I think we should somehow create support for this in LyX.
> The listings package seems to be actively maintained too.
> 

I agree of course !

Thy

-
Thierry LEMEUNIER
Equipe Langue et Dialogue
-
Laboratoire d'Informatique de L'Universite du Maine
Institut d'Informatique Claude Chappe
rue Laennec
F72085 LE MANS CEDEX 9
-
Tel : 33/0 2 4383 3865  Fax : 33/0 2 4383 3868
mailto : [EMAIL PROTECTED]
webpage : http://www-ic2.univ-lemans.fr/~lemeunie/
-



Re: Formatting source code

2000-03-08 Thread Lars Gullik Bjønnes

Thierry Lemeunier <[EMAIL PROTECTED]> writes:

| When I need to insert some code in LyX I use the latex Listings package.
| There're about 38 recognized languages (C, C++, java, Lisp, csh, etc.)
| and you can define your own language if you need it.
| 
| You can :
|   - use line numbering in different styles
|   - use color package
|   - insert a source file code or just insert a part of a source file
|   - and more.
| 
| I think it's more simple than lgring (that I don't known well) because
| you don't
| need to do a preprocessing. You have to insert some ERT lines. For
| example :

This is really a great package.
I just tested with buffer.C in the LyX distribution and it worked
flawlessly.

I think we should somehow create support for this in LyX.
The listings package seems to be actively maintained too.

Lgb



Re: Formatting source code

2000-03-08 Thread Thierry Lemeunier

Gerald Gutierrez wrote:
> 
> Hello!
> 
> I'm currently writing my thesis and need to have some code snippets as part of
> it. Unfortunately, because I'll be using double spacing, simply putting the
> code in and changing it to a typewriter font, or using Lyx-Code causes the code
> to be double spaced as well, making it really hard to read (and fairly ugly).

Hello

When I need to insert some code in LyX I use the latex Listings package.
There're about 38 recognized languages (C, C++, java, Lisp, csh, etc.)
and you can define your own language if you need it.

You can :
- use line numbering in different styles
- use color package
- insert a source file code or just insert a part of a source file
- and more.

I think it's more simple than lgring (that I don't known well) because
you don't
need to do a preprocessing. You have to insert some ERT lines. For
example :

In the preambule :

\usepackage{listings}

In LyX :

% Select the language and set basic style
\lset{language=lisp,tabsize=2,basicstyle=\texttt{\tiny}}

% Set line numbering style
\lset{labelstyle=\tiny,labelstep=5,labelsep=5pt}

% Insert a whole file
\lstinputlisting{namefile.lsp}

% Insert inline code
\begin{lstlistings}{}
(defun foo ()
   "A good lisp example"
   (print "Hello world !"))
\end{lstlisting}

% Insert 5-10 lines from a file
\lstinputlisting[first=5,last=10]{namefile.lsp}

Go to your CTAN archive site, download it, and install it somewhere.
I use it under the TEXINPUTS path.

Best regards

Thy

-
Thierry LEMEUNIER
Equipe Langue et Dialogue
-
Laboratoire d'Informatique de L'Universite du Maine
Institut d'Informatique Claude Chappe
rue Laennec
F72085 LE MANS CEDEX 9
-
Tel : 33/0 2 4383 3865  Fax : 33/0 2 4383 3868
mailto : [EMAIL PROTECTED]
webpage : http://www-ic2.univ-lemans.fr/~lemeunie/
-



Re: Formatting source code

2000-03-07 Thread Jean-Pierre.Chretien


>>From: Gerald Gutierrez <[EMAIL PROTECTED]>
>>To: Lyx Users Mailinglist <[EMAIL PROTECTED]>
>>Subject: Formatting source code
>>Date: Tue, 7 Mar 2000 11:29:01 -0800
>>
>>
>>Hello!
>>
>>I'm currently writing my thesis and need to have some code snippets as part of
>>it. Unfortunately, because I'll be using double spacing, simply putting the
>>code in and changing it to a typewriter font, or using Lyx-Code causes the 
code
>>to be double spaced as well, making it really hard to read (and fairly ugly).
>>
>>Is there a way to separately control the spacing of Lyx-Code? Alternatively,
>>what is There are about 40 known languages.a good way to insert code so that 
it'll look proper? Also, is there
>>such a thing as a "code float" (like a figure float) ?
>>
>>Thanks.
>>
>>
I use the lgrind latex package, which can be used in LyX using ERT.
Works with preprocessing using a shell command (lgrind) which must
be installed in the bin directory of the LaTeX installation.
Provides pretty printing and line numbering of various languages,
and can be used standalone, e.g.
%lgrind -lC -o foo.tex foo.c 
%latex foo;dvips foo
provides a printed version of C code in foo.c.
There are about 40 recognised languages.
Does not fold long lines however, you have to format yourself.

So with LyX:
 - get the package from the nearest CTAN archive
 - install it in the LaTeX tree
 - make it available (texhash with teTeX)
 - preprocess the code for inline inclusion in a latex doc, e.g.
%lgrind -i -lC -o foo.c.tex foo.c
 - edit the premable in LyX, e.g.:
\usepackage[lineno5,leftno,norules]{lgrind}
 - at the right location in the doc, insert in ERT
\lgrindfile{foo.c.tex}

Should work OK, perhaps a bit sophisticated for simple pieces of code,
in which case a simple Lyx input of the code embedded between
\begin{verbatim}
...
\end{verbatim}
could be sufficient.

Regards

-- 
Jean-Pierre




Formatting source code

2000-03-07 Thread Gerald Gutierrez


Hello!

I'm currently writing my thesis and need to have some code snippets as part of
it. Unfortunately, because I'll be using double spacing, simply putting the
code in and changing it to a typewriter font, or using Lyx-Code causes the code
to be double spaced as well, making it really hard to read (and fairly ugly).

Is there a way to separately control the spacing of Lyx-Code? Alternatively,
what is a good way to insert code so that it'll look proper? Also, is there
such a thing as a "code float" (like a figure float) ?

Thanks.