emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: How to get pretty printed source code in PDFLaTeX


From: Sébastien Vauban
Subject: [Orgmode] Re: How to get pretty printed source code in PDFLaTeX
Date: Mon, 09 Aug 2010 22:30:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Hi Dan,

Dan Davison wrote:
> Sébastien Vauban <address@hidden> writes:
>> Sebastian Rose wrote:
>>> Dan Davison <address@hidden> writes:
>>>> Can you point me to an example that shows how to make source code in
>>>> latex look (almost) as nice as html?
>>>
>>> That is supposed to work with the `listings' package. I havent tried that
>>> yet.
>>
>> If I understand you right, here's such an example you're after:
>>
>> * Much better code
>>
>> For that, you need to customize =listings=:
>>
>> #+begin_LaTeX
>> % typeset source code listings
>> \usepackage{listings} % must be loaded after `babel'
>> \lstloadlanguages{C}
>> address@hidden % light yellow
>> address@hidden % blue
>> address@hidden % black
>> address@hidden % red
>> address@hidden % dark green
>> \lstset{%
>>     basicstyle=\ttfamily\scriptsize, % the font that is used for the code
>>     tabsize=4, % sets default tabsize to 4 spaces
>>     numbers=left, % where to put the line numbers
>>     numberstyle=\tiny, % line number font size
>>     stepnumber=0, % step between two line numbers
>>     breaklines=false, %!! don't break long lines of code
>>     showtabs=false, % show tabs within strings adding particular underscores
>>     showspaces=false, % show spaces adding particular underscores
>>     showstringspaces=false, % underline spaces within strings
>>     address@hidden,
>>     address@hidden,
>>     address@hidden,
>>     address@hidden,
>>     address@hidden, % sets the background color
>>     captionpos=b, % sets the caption position to `bottom'
>>     extendedchars=false %!?? workaround for when the listed file is in UTF-8
>> }
>> #+end_LaTeX
>>
>> #+SRCNAME: srcModifyDB2.sql
>> #+BEGIN_SRC sql :tangle srcModifyDB.sql
>>     -- add column `DossierSentToSecteur' (if column does not exist yet)
>>     IF NOT EXISTS (SELECT *
>>                    FROM INFORMATION_SCHEMA.COLUMNS
>>                    WHERE TABLE_NAME = 'dossier'
>>                    AND COLUMN_NAME = 'DossierSentToSecteur')
>>     BEGIN
>>         ALTER TABLE dossier
>>         ADD DossierSentToSecteur smalldatetime NULL
>>     END
>>     GO
>> #+END_SRC
>>
>> I've put the PDF (for easy access) onto my Web site:
>>
>> http://www.mygooglest.com/sva/ECM-Listings.pdf
>
> Wow, that's really nice. Thanks for sharing that.

I really thought that you used such a thing for a long time, having done so
much for Org-Babel. Maybe you were more interested by the execution stuff,
rather than its printing? For me, the opposite: I was much interested by the
printing, now by accessing all the power of Babel.

> I think we should aim to get to a point where org-mode can produce such
> nicely formatted source code out-of-the-box.

I share your point. I'm willing to participate, or even begin, such a page on
Worg, with the above info.

> Maybe we could even make latex inherit the colours and fonts that emacs is
> currently using for source code mark up?

For sure, that'd be nice. You mean the way htmlize works, and keeps my colors,
right?

Dunno what it implies for Org-LaTeX... Generating your own class customization,
and having it loaded by default (in the list of LaTeX packages)?

> I was going to suggest doing this with listings but then came across minted,
> and I wonder whether that's even more suitable? (See the other post I just
> made.)

Never heard about it before, while I'm trying to follow info about TeX as
well.

I'm very impressed by the quality and reaction time of
french.computers.text.tex. So, I decided to ask them what they thought about
Listings vs Minted.

See on 
[[http://groups.google.com/groups/search?as_umsgid%3D87lj8gp4rr.fsf%40mundaneum.com][Email
 from Sébastien Vauban: Listings vs Minted]]

What's interesting is that 2 brilliant people of that list responded on that.
I could try to translate the whole, but there already is a lot. Just
highlighting that they don't trust that much all the facts that have been used
against Listings (and prove what they say): about Utf-8, or the number of
languages, etc.

They agree with one inconvenient of Listings: the fact that, by default, it
uses bad settings (like no color, and proportional font).

On the other hand, they don't like implying the use of an external language to
LaTeX. Impacts on shell-escape.

The discussion is going on. I'll keep you posted.

For sure, the objective of getting better out-of-the-box is a goal we can
reach.

Best regards,
  Seb

-- 
Sébastien Vauban




reply via email to

[Prev in Thread] Current Thread [Next in Thread]