Ruby & LaTeX

Dear Ruby Experts,
I’m new to Ruby notwithstanding that I have the following silly problem:
I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.

Any one of you have already provided a specification for the Ruby
language? And above all does he want to share his work with us?

Any other solution is welcome.

TIA Walter

···


Walter Cazzola, PhD - Assistant Professor, DICo, University of Milano
E-mail cazzola@disi.unige.it Ph.: +39 010 353 6637 Fax: +39 010 353 6699
· · · --------------------------- · · · --------------------------- · · ·
… recursive: adjective, see recursive …
· · · --------------------------- · · · --------------------------- · · ·

What about lout. Lout is similar in concept to Latex. It generates
postcript documents from plain text with a good and easy syntax.

It has too a tool, prg2lout that transforms code in various languages
(including Ruby) into lout source for pretty printing.

Lout is advanced and object oriented. It is enought for me. I don’t
know if serves to you.

Greets.

···

El viernes 21 de marzo, Walter Cazzola escribió:

I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.

Any other solution is welcome.


David Espada, a.k.a. |)a/inci

Debian GNU/Linux Sid

I haven’t got into LaTeX yet myself, but there are one or two other
options listed here:
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=codelist

Whether:

The tiny_c2l system is more recent: users are encouraged to generate
their own driver files for languages it doesn’t already deal with.

means they are encouraging this because it is easy, or because it is
far too much work for the authors (and therefore not easy!) I
couldn’t say.

    Hugh
···

On Fri, 21 Mar 2003, Walter Cazzola wrote:

Dear Ruby Experts,
I’m new to Ruby notwithstanding that I have the following silly problem:
I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.

Are you looking for syntax color highlighting? I haven’t had the need for
a Ruby pretty print tool that arranged {} or do/ends, unlike what
is common with {} in C.

If you don’t need syntax highlighting, then you may want to check
out fancyverbatim.

···

On Friday, 21 March 2003 at 18:06:56 +0900, Walter Cazzola wrote:

Dear Ruby Experts,
I’m new to Ruby notwithstanding that I have the following silly problem:
I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.


Jim Freeze

If God had meant for us to be in the Army, we would have been born with
green, baggy skin.

Walter,

I’m not an expert, but I did recently write a Ruby specification for the
listings package in order to include code for a paper. It’s available at
http://aries.etree.org/brian/files/ruby_def.tex – forgive me if it’s
incomplete, but I only spent a few minutes on it.

Hope that helps.

BS

···
  • Walter Cazzola (cazzola@disi.unige.it) wrote:

I’m new to Ruby notwithstanding that I have the following silly problem:
I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.


Brian Smyth
bsmyth@acm.org || http://aries.etree.org/brian/

I have never used lout, but I have to write the paper in LaTeX because
the editor/publisher require so. Therefore it is possible to use lout
with LaTeX. I wouldn’t insert code as eps picture so what I need is that
lout convert its code in LaTeX code.

TIA, Walter

···

On Fri, 21 Mar 2003, David Espada wrote:

I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.

Any other solution is welcome.

What about lout. Lout is similar in concept to Latex. It generates
postcript documents from plain text with a good and easy syntax.

It has too a tool, prg2lout that transforms code in various languages
(including Ruby) into lout source for pretty printing.

Lout is advanced and object oriented. It is enought for me. I don’t
know if serves to you.


Walter Cazzola, PhD - Assistant Professor, DICo, University of Milano
E-mail cazzola@disi.unige.it Ph.: +39 010 353 6637 Fax: +39 010 353 6699
· · · --------------------------- · · · --------------------------- · · ·
… recursive: adjective, see recursive …
· · · --------------------------- · · · --------------------------- · · ·

Also, the author of listings suggests the user to fill his own syntax
but the problem is that I’m too new to ruby to be able to write such a
syntax by myself.

Therefore, I’m looking for a syntax already made for the listings
package or a package already supporting ruby.

I’ll give a look to your link

thanks a lot
Walter

···

On Fri, 21 Mar 2003, Hugh Sasse Staff Elec Eng wrote:

Dear Ruby Experts,
I’m new to Ruby notwithstanding that I have the following silly problem:
I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.

I haven’t got into LaTeX yet myself, but there are one or two other
options listed here:
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=codelist

Whether:

The tiny_c2l system is more recent: users are encouraged to generate
their own driver files for languages it doesn’t already deal with.

means they are encouraging this because it is easy, or because it is
far too much work for the authors (and therefore not easy!) I
couldn’t say.


Walter Cazzola, PhD - Assistant Professor, DICo, University of Milano
E-mail cazzola@disi.unige.it Ph.: +39 010 353 6637 Fax: +39 010 353 6699
· · · --------------------------- · · · --------------------------- · · ·
… recursive: adjective, see recursive …
· · · --------------------------- · · · --------------------------- · · ·

Unfortunately, I’m looking for syntax highlighting and not for
keywordis/blocks alignment. I want something that automatically prints
ruby keywords in boldface, comments in italics and so on.

Of course inside LaTeX documents, do you know a script that do that
without writing it by myself?

Walter

···

On Sat, 22 Mar 2003, Jim Freeze wrote:

Dear Ruby Experts,
I’m new to Ruby notwithstanding that I have the following silly problem:
I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.

Are you looking for syntax color highlighting? I haven’t had the need for
a Ruby pretty print tool that arranged {} or do/ends, unlike what
is common with {} in C.

If you don’t need syntax highlighting, then you may want to check
out fancyverbatim.


Walter Cazzola, PhD - Assistant Professor, DICo, University of Milano
E-mail cazzola@disi.unige.it Ph.: +39 010 353 6637 Fax: +39 010 353 6699
· · · --------------------------- · · · --------------------------- · · ·
… recursive: adjective, see recursive …
· · · --------------------------- · · · --------------------------- · · ·

Brian,
thanks a lot this one was exactly what I was looking for.

don’t worry for the completeness I’ll try to complete it if necessary

thank you again
Walter

···

On Sat, 22 Mar 2003, Brian Smyth wrote:

  • Walter Cazzola (cazzola@disi.unige.it) wrote:

I’m new to Ruby notwithstanding that I have the following silly problem:
I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.

Walter,

I’m not an expert, but I did recently write a Ruby specification for the
listings package in order to include code for a paper. It’s available at
http://aries.etree.org/brian/files/ruby_def.tex – forgive me if it’s
incomplete, but I only spent a few minutes on it.


Walter Cazzola, PhD - Assistant Professor, DICo, University of Milano
E-mail cazzola@disi.unige.it Ph.: +39 010 353 6637 Fax: +39 010 353 6699
· · · --------------------------- · · · --------------------------- · · ·
… recursive: adjective, see recursive …
· · · --------------------------- · · · --------------------------- · · ·

\begin{verbatim}
\end{verbatim}

The only thing I can think of is to use vim’s conversion to html,
then a html2latex converter. I have not done the latter recently, but
vim does a good job and supports ruby.

···

On Saturday, 22 March 2003 at 2:15:41 +0900, Walter Cazzola wrote:

On Sat, 22 Mar 2003, Jim Freeze wrote:

Dear Ruby Experts,
I’m new to Ruby notwithstanding that I have the following silly problem:
I have to list some ruby code in a paper I’m writing by using LaTeX, I
would like to pretty print such a code but both listings.sty and
lgrinds.sty (two LaTeX styles for pretty printing list of code) do not
support the ruby language.

Are you looking for syntax color highlighting? I haven’t had the need for
a Ruby pretty print tool that arranged {} or do/ends, unlike what
is common with {} in C.

If you don’t need syntax highlighting, then you may want to check
out fancyverbatim.

Unfortunately, I’m looking for syntax highlighting and not for
keywordis/blocks alignment. I want something that automatically prints
ruby keywords in boldface, comments in italics and so on.

Of course inside LaTeX documents, do you know a script that do that
without writing it by myself?


Jim Freeze

It looks like blind screaming hedonism won out.

Walter,

Unfortunately, I’m looking for syntax highlighting and not for
keywordis/blocks alignment. I want something that automatically prints
ruby keywords in boldface, comments in italics and so on.

What I did is keep the Ruby in a separate file. I then wrote a script to
read the Ruby and generate LaTeX, surrounding the code with verbatim tags,
key words with \keyword{}, etc. The main LaTeX file included the generated
file and defined those commands so that keywords were bolded, etc.

Jim

···


Jim Menard, jimm@io.com, http://www.io.com/~jimm/
“Abraham Lincoln didn’t die in vain. He died in Washington, D.C.”
– Firesign Theatre

vim can export ruby code to html - doing all of the above. i’m guessing that
there is something which could convert html to latex.

for f in *.rb; do gvim -f +“syn on” +“run! syntax/2html.vim” +“wq” +“q” $f; done

the results are really nice.

-a

···

On Sat, 22 Mar 2003, Walter Cazzola wrote:

Unfortunately, I’m looking for syntax highlighting and not for
keywordis/blocks alignment. I want something that automatically prints
ruby keywords in boldface, comments in italics and so on.

Of course inside LaTeX documents, do you know a script that do that
without writing it by myself?

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

:frowning:

I think that is not possible. Bad news. Sorry.

···

El viernes 21 de marzo, Walter Cazzola escribió:

Lout is advanced and object oriented. It is enought for me. I don’t
know if serves to you.

I have never used lout, but I have to write the paper in LaTeX because
the editor/publisher require so. Therefore it is possible to use lout
with LaTeX. I wouldn’t insert code as eps picture so what I need is that
lout convert its code in LaTeX code.


David Espada, a.k.a. |)a/inci

Debian GNU/Linux Sid

this one looks as the better solution to my problem.

thanks a lot to you and to Jim that gives me analogous answer and to the
other that tried to help me.

Walter

···

On Fri, 21 Mar 2003, ahoward wrote:

Unfortunately, I’m looking for syntax highlighting and not for
keywordis/blocks alignment. I want something that automatically prints
ruby keywords in boldface, comments in italics and so on.

Of course inside LaTeX documents, do you know a script that do that
without writing it by myself?

vim can export ruby code to html - doing all of the above. i’m
guessing that there is something which could convert html to latex.

for f in *.rb; do gvim -f +“syn on” +“run! syntax/2html.vim” +“wq” +“q” $f; done

the results are really nice.


Walter Cazzola, PhD - Assistant Professor, DICo, University of Milano
E-mail cazzola@disi.unige.it Ph.: +39 010 353 6637 Fax: +39 010 353 6699
· · · --------------------------- · · · --------------------------- · · ·
… recursive: adjective, see recursive …
· · · --------------------------- · · · --------------------------- · · ·

:frowning:

I think that is not possible. Bad news. Sorry.

But Lout can produce an EPS file. Perhaps that could help (assuming
the produced EPS is a sort of figure).

···

El viernes 21 de marzo, Walter Cazzola escribió:

Lout is advanced and object oriented. It is enought for me. I don’t
know if serves to you.

I have never used lout, but I have to write the paper in LaTeX because
the editor/publisher require so. Therefore it is possible to use lout
with LaTeX. I wouldn’t insert code as eps picture so what I need is that
lout convert its code in LaTeX code.

Basile STARYNKEVITCH Basile STARYNKEVITCH
email: basilestarynkevitchnet
aliases: basiletunesorg = bstarynknerimnet
8, rue de la Faïencerie, 92340 Bourg La Reine, France

Don’t worry I have already solved, Brian Smyth has written the
Ruby definition for the listings package and he has shared his code with
me.

Walter

···

On Mon, 24 Mar 2003, David Espada wrote:

El viernes 21 de marzo, Walter Cazzola escribió:

Lout is advanced and object oriented. It is enought for me. I don’t
know if serves to you.

I have never used lout, but I have to write the paper in LaTeX because
the editor/publisher require so. Therefore it is possible to use lout
with LaTeX. I wouldn’t insert code as eps picture so what I need is that
lout convert its code in LaTeX code.

:frowning:

I think that is not possible. Bad news. Sorry.


Walter Cazzola, PhD - Assistant Professor, DICo, University of Milano
E-mail cazzola@disi.unige.it Ph.: +39 010 353 6637 Fax: +39 010 353 6699
· · · --------------------------- · · · --------------------------- · · ·
… recursive: adjective, see recursive …
· · · --------------------------- · · · --------------------------- · · ·

google(“html2latex”)[0] is http://html2latex.sourceforge.net/

That is ruby pseudocode BYW, I don’t have a tool to do that. :slight_smile:

html2latex is Perl based. It is left as an exercise for the reader
to translate it into ruby :slight_smile:

    Hugh
···

On Sat, 22 Mar 2003, Walter Cazzola wrote:

On Fri, 21 Mar 2003, ahoward wrote:

Unfortunately, I’m looking for syntax highlighting and not for
keywordis/blocks alignment. I want something that automatically prints
ruby keywords in boldface, comments in italics and so on.

Of course inside LaTeX documents, do you know a script that do that
without writing it by myself?

vim can export ruby code to html - doing all of the above. i’m
guessing that there is something which could convert html to latex.

for f in *.rb; do gvim -f +“syn on” +“run! syntax/2html.vim” +“wq” +“q” $f; done

the results are really nice.

Hugh Sasse Staff Elec Eng hgs@dmu.ac.uk wrote in message news:Pine.GSO.4.53.0303211733490.7195@neelix

google(“html2latex”)[0] is http://html2latex.sourceforge.net/

That is ruby pseudocode BYW, I don’t have a tool to do that. :slight_smile:

Ruby/Google :wink:

Regards,

Tom