Marcus Harnisch | 2 Jul 22:32
X-Face
Picon

Framed boxes and listings

Hi all

For a presentation I would like to create framed code blocks using the
great listings package. With delightment I noticed that the
environments provided by listings work in almost every case. It
triggered only one case where things didn't work as expected.

History: Framed boxes in LaTeX suck when used on low-resolution
devices such as projectors. The piecewise assembly using ruleboxes and
other stuff I don't even want to think about, causes rounding errors
which is a pain in the eye. No matter whether anti-aliased diaplay is
used or not. Each way is equally bad, although in different respects.
Antialiased display suffers mostly from different line thickness,
while a normal display has overshoots in most corners of a box.

Given that I use PDF output only, my goal is to use a "native"
frame. I got excellent results from putting the listing into a
rectangular node. Since that seemed a bit to baroque I tried stripping
down the solution to using a framed `tikzpicture' and \pgftext with my
`lstlisting' as argument. Somehow, in the latter case, PGF did not get
the bounding box of the environment right.

My two questions are now:

1. What did I miss. What is the Right Way to achieve what I want?

2. Why does it not work with \pgftext? Was I completely off-track?

3. Ideally I'd have a solution that wraps all that into a new
environment. Potential users don't want to bother with PGF/TikZ just
(Continue reading)

Marcus Harnisch | 20 Jul 14:57
Picon

Using PGF/TikZ to create framed environments (was: Framed boxes and listings)

OK, so my original subject was silly and appeared to be off-topic.

Marcus Harnisch <marcus.harnisch <at> gmx.net> writes:
> For a presentation I would like to create framed code blocks using the
> great listings package. With delightment I noticed that the
> environments provided by listings work in almost every case. It
> triggered only one case where things didn't work as expected.
>
> History: Framed boxes in LaTeX suck when used on low-resolution
> devices such as projectors. The piecewise assembly using ruleboxes and
> other stuff I don't even want to think about, causes rounding errors
> which is a pain in the eye. No matter whether anti-aliased diaplay is
> used or not. Each way is equally bad, although in different respects.
> Antialiased display suffers mostly from different line thickness,
> while a normal display has overshoots in most corners of a box.
>
> Given that I use PDF output only, my goal is to use a "native"
> frame. I got excellent results from putting the listing into a
> rectangular node. Since that seemed a bit to baroque I tried stripping
> down the solution to using a framed `tikzpicture' and \pgftext with my
> `lstlisting' as argument. Somehow, in the latter case, PGF did not get
> the bounding box of the environment right.
>
> My two questions are now:
>
> 1. What did I miss. What is the Right Way to achieve what I want?
>
> 2. Why does it not work with \pgftext? Was I completely off-track?
>
> 3. Ideally I'd have a solution that wraps all that into a new
(Continue reading)

Marcus Harnisch | 6 Aug 16:11
Picon

Re: Using PGF/TikZ to create framed environments

Ping! Does anyone have an idea how to tackle that sort of issue?

Marcus Harnisch <marcus.harnisch <at> gmx.net> writes:
>> For a presentation I would like to create framed code blocks using the
>> great listings package. With delightment[sic] I noticed that the
>> environments provided by listings work in almost every case. It
>> triggered only one case where things didn't work as expected.
>>
>> History: Framed boxes in LaTeX suck when used on low-resolution
>> devices such as projectors. The piecewise assembly using ruleboxes and
>> other stuff I don't even want to think about, causes rounding errors
>> which is a pain in the eye. No matter whether anti-aliased diaplay is
>> used or not. Each way is equally bad, although in different respects.
>> Antialiased display suffers mostly from different line thickness,
>> while a normal display has overshoots in most corners of a box.
>>
>> Given that I use PDF output only, my goal is to use a "native"
>> frame. I got excellent results from putting the listing into a
>> rectangular node. Since that seemed a bit to baroque I tried stripping
>> down the solution to using a framed `tikzpicture' and \pgftext with my
>> `lstlisting' as argument. Somehow, in the latter case, PGF did not get
>> the bounding box of the environment right.
>>
>> My two questions are now:
>>
>> 1. What did I miss. What is the Right Way to achieve what I want?
>>
>> 2. Why does it not work with \pgftext? Was I completely off-track?
>>
>> 3. Ideally I'd have a solution that wraps all that into a new
(Continue reading)

Kjell Magne Fauske | 6 Aug 19:49
Picon

Re: Using PGF/TikZ to create framed environments

On 8/6/07, Marcus Harnisch <marcus.harnisch <at> gmx.net> wrote:
> Ping! Does anyone have an idea how to tackle that sort of issue?
>

> >>
> >> Given that I use PDF output only, my goal is to use a "native"
> >> frame. I got excellent results from putting the listing into a
> >> rectangular node. Since that seemed a bit to baroque

If putting it inside a node works, you could always hide the
"baroqueness" inside a custom macro or environment. Nodes are very
flexible and you can easily add shadows and other eye candy if you
want to (see for instance
http://www.fauskes.net/pgftikzexamples/tag/text-and-math/).

> >>
> >> 3. Ideally I'd have a solution that wraps all that into a new
> >> environment. Potential users don't want to bother with PGF/TikZ just
> >> to get a framed block of code. Any suggestions?

Users who use Beamer for presentations, also have PGF and TikZ
installed. The problem will be users with old versions of PGF.

- Kjell Magne

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
(Continue reading)


Gmane