Sidebar for the book: another approach.

Results in this (temporary image): http://lucs.net:8888/sidebar.png

A few notes:
- Requires additional LaTeX package 'calc'.
- Has some UTF-8 characters in the perl code.
- Introduced a main() sub (personal preference -- it bothers me to have
  floating top level code).
- I hope the produced patch is correctly formatted in this
  email (new to git and its patches).

Comments appreciated.

Thanks.

---
 bin/book-to-latex |  130 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 117 insertions(+), 13 deletions(-)

diff --git a/bin/book-to-latex b/bin/book-to-latex
index a909a46..70dabfb 100644
--- a/bin/book-to-latex
+++ b/bin/book-to-latex
@@ -2,7 +2,48 @@
 use strict;
 use Pod::PseudoPod::LaTeX 1.101050;
 
-print <<'HEADER';
+# --------------------------------------------------------------------
+package Perl6BookLaTeX;
+
+use base 'Pod::PseudoPod::LaTeX';
+
+sub start_sidebar {
+    my ( $self, $flags ) = @_;
+    $self->{scratch} .= << 'EOT';
+\begin{figure}[!h]
+\footnotesize
+\sidebartop
+EOT
+    if ( $flags->{title} ) {
+        my $title = $self->encode_text( $flags->{title} );
+        $self->{scratch} .= << "EOT";
+\\begin{center}
+\\vspace{-\\baselineskip}
+\\vspace{-\\baselineskip}
+\\normalsize{\\bfseries{$title}}
+\\end{center}
+EOT
+    }
+    $self->{scratch} .= "\\vspace{-5pt}%\n";
+}
+
+# --------------------------------------------------------------------
+sub end_sidebar {
+    my $self = shift;
+    $self->{scratch} .= << 'EOT';
+\sidebarbottom
+\end{figure}
+EOT
+}
+
+# --------------------------------------------------------------------
+package main;
+
+main();
+
+# --------------------------------------------------------------------
+sub main {
+    print << 'HEADER';
 \documentclass[11pt,a4paper,oneside]{report}
 \usepackage{graphics,graphicx}
 \usepackage{colortbl}
@@ -12,29 +53,92 @@ print <<'HEADER';
 \usepackage[utf8]{inputenc}
 \usepackage{makeidx}
 \usepackage[colorlinks=true,pagebackref]{hyperref}
+\usepackage{calc}
 
 \makeindex
 
 \title{Using Perl~6}
 \author{Jonathan S. Duff, Moritz Lenz, Carl M�sak, Patrick R. Michaud, Jonathan Worthington}
- 
-\begin{document}
+HEADER
 
-\maketitle
+        # Sidebar Info. Units are points.
+    my %SI = (
+        rule_indent => 40,
+        text_indent => 50,
+        vert_thick  => 1,
+        big_thick   => 1.5,
+        gap_thick   => 1,
+        sml_thick   => 0.6,
+        tub_thick   => 2,
+    );
+    $SI{vert_height} =
+      $SI{big_thick} + $SI{gap_thick} + $SI{sml_thick} + $SI{tub_thick};
+    $SI{rule_padding} = ($SI{rule_indent} + $SI{vert_thick}) * 2;
+    $SI{top_big_elev} = $SI{gap_thick} + $SI{sml_thick} + $SI{tub_thick};
+    $SI{top_sml_elev} = $SI{tub_thick};
+    $SI{bot_sml_elev} = $SI{big_thick} + $SI{gap_thick};
 
-\tableofcontents
-HEADER
+    print subst_tokens(\%SI, << 'EOT');
+\newcommand{\sidebartop}{%
+    \nointerlineskip\vspace{\baselineskip}%
+    \hskip �rule_indent�pt%
+    \rule[0pt]{�vert_thick�pt}{�vert_height�pt}%
+    \rule[�top_big_elev�pt]{\linewidth-�rule_padding�pt}{�big_thick�pt}%
+    \rule[0pt]{�vert_thick�pt}{�vert_height�pt}%
+    \par%
+    \vspace{-\baselineskip}%
+    \hskip �rule_indent�pt%
+    \hskip �vert_thick�pt%
+    \rule[�top_sml_elev�pt]{\linewidth-�rule_padding�pt}{�sml_thick�pt}%
+    \par%
+    \vspace{\baselineskip}%
+    \begingroup%
+    \leftskip �text_indent�pt%
+    \rightskip\leftskip%
+}
+EOT
 
-for (@ARGV) {
-    my $parser = Pod::PseudoPod::LaTeX->new();
-    $parser->codes_in_verbatim(1);
-    $parser->output_fh( *STDOUT );
-    $parser->parse_file( $_ );
+    print subst_tokens(\%SI, << 'EOT');
+\newcommand{\sidebarbottom}{%
+    \endgroup%
+    \nointerlineskip\vspace{\baselineskip}%
+    \hskip �rule_indent�pt%
+    \rule[0pt]{�vert_thick�pt}{�vert_height�pt}%
+    \rule[0pt]{\linewidth-�rule_padding�pt}{�big_thick�pt}%
+    \rule[0pt]{�vert_thick�pt}{�vert_height�pt}%
+    \par%
+    \vspace{-\baselineskip}%
+    \hskip �rule_indent�pt%
+    \hskip �vert_thick�pt%
+    \rule[�bot_sml_elev�pt]{\linewidth-�rule_padding�pt}{�sml_thick�pt}%
+    \par%
+    \vspace{\baselineskip}%
 }
+EOT
 
-print <<'FOOTER';
+    print << 'START_DOC';
+\begin{document}
+\maketitle
+\tableofcontents
+START_DOC
 
-\printindex
+    for (@ARGV) {
+        my $parser = Perl6BookLaTeX->new();
+        $parser->codes_in_verbatim(1);
+        $parser->output_fh( *STDOUT );
+        $parser->parse_file( $_ );
+    }
 
+    print << 'FOOTER';
+\printindex
 \end{document}
 FOOTER
+}
+
+# --------------------------------------------------------------------
+sub subst_tokens {
+    my ($tokens_ref, $text) = @_;
+    $text =~ s/�([^�]*)�/$tokens_ref->{$1}/g;
+    return $text;
+}
+
-- 
1.6.5

0
lucs
6/12/2010 5:35:21 AM
perl.perl6.compiler 1237 articles. 0 followers. Follow

0 Replies
791 Views

Similar Articles

[PageSpeed] 9

Reply:

Similar Artilces:

Address Book
Name: P Warren Product: Thunderbird Summary: Address Book - dragging from one book to another for multiple address book entries Comments: In the earlier version of Thunderbird it was possible to drag an address from one address book to another and it would remain in both books. This saved so much time but is not availble in later versions. Now an address has to be typed out again and again for each address book to which it is being allocated. There is also no "copy/paste" mechanism for transferring to another address book which would be another way of overco...

[svn:parrot-pdd] r22180
Author: allison Date: Wed Oct 17 12:33:17 2007 New Revision: 22180 Modified: trunk/docs/pdds/pdd15_objects.pod trunk/docs/pdds/pdd17_pmc.pod Changes in other areas also in this revision: Added: trunk/include/parrot/oo.h - copied unchanged from r22176, /branches/pdd15oo/include/parrot/oo.h trunk/include/parrot/oo_private.h - copied unchanged from r22176, /branches/pdd15oo/include/parrot/oo_private.h trunk/src/oo.c - copied unchanged from r22176, /branches/pdd15oo/src/oo.c trunk/t/oo/isa.t - copied unchanged from r22176, /branches/pdd1...

compiling own class that imports another compiled own class
Hi everybody, I have this problem: I have my first class, extWebControl, that inherits WebControl and it's compiled. Then I have another class, CForm, that would be imports extWebControl namespace and should be compiled either, but I can't do that 'cause I get this error: Namespace or type 'extWebControl' for the imports 'extWebControl' cannot be found. How can I solve my problem? bye and thanks in advance. P.S. the extWebControl.dll file is in "/bin" directory of the application....

[svn:parrot-pdd] r32407
Author: coke Date: Thu Nov 6 14:41:14 2008 New Revision: 32407 Modified: trunk/docs/pdds/pdd19_pir.pod Changes in other areas also in this revision: Modified: trunk/DEPRECATED.pod trunk/compilers/imcc/imcc.y trunk/compilers/imcc/imcparser.c trunk/compilers/pct/src/POST/Compiler.pir trunk/docs/art/pp003-oop.pod trunk/docs/book/ch04_pir_subroutines.pod trunk/docs/book/ch05_pasm.pod trunk/t/compilers/imcc/syn/objects.t Log: RT #48549 [DEPRECATED] [PDD19] .namespace requires brackets Force .namespace to require brackets instead of allowing a bare ...

*Move* address book cards from one address book to another?
http://bugzilla.mozilla.org/show_bug.cgi?id=35837 It just copies now... ...

to compile or not to compile ?
Hi I've been dabbling with  .net but am now trying to bite the bullet and learn it moving from classic asp I am a bit confused as to wether it is 'standard' practise to 'build' your project into dll's and upload these to the server or wether to simply use script and upload as you would classic asp to the server. what is 'standard' practise is there an advantage or disadvantage to using script / compiling thanks What is "Standard" depends a bit upon the tool you are using. For VS.NET 2003, compiling into a dll placed in the bin folder is the default behavior.  Othe...

perl6 book
Hello, is there a book "learning perl6" released or prepare to be released? Thanks. I know that some ppl want to do that in future, but as far as I know these projects are not in a state "planned" or even "started". And since the semantics might change a little especially until Christmas, I would not trust a book that is already in the works. Am 22.10.2015 um 07:55 schrieb Wah Peng: > Hello, > > is there a book "learning perl6" released or prepare to be released? > Thanks. That's nice. thanks. 2015-10-22 14:55 GMT...

perl6-compiler
perl6-compiler is missing at http://dev.perl.org/perl6/lists/ and it seems not to be gatewayed to nntp.perl.org. OTOH a lot of unused perl6 lists and newsgroups are there. Finally I tried to subscribe already twice and got no answer. Thanks, leo http://www.nntp.perl.org/group/perl.perl6.compiler -- It's there. Correct, though, that it's not listed on the lists page... On Thu, 21 Oct 2004 09:02:23 +0200, Leopold Toetsch <lt@toetsch.at> wrote: > perl6-compiler is missing at http://dev.perl.org/perl6/lists/ and it > seems not to be gatewayed to nntp.perl...

perl6 compiler
Hello, I had just began looking at the perl6 raduko compiler and have a question. Is perl6 actually compiled then ran similar to java or is the script ran and then compiled at run time? -Wendell On Mar 14, 2010, at 11:09 AM, dell wrote: > Is perl6 actually compiled then ran similar to java > or is the script ran and then compiled at run time? It supports either, but defaults to single-step compile-run (like Perl 5). I think that a transparent cache is envisioned for the future, so that a compiled version is silently saved during the first compil...

Re: Definitions: compiler vs interpreter [was: Rationale for a VM + compiler approach instead of an interpreter?]
How about an interpreter interprets input directly into action (even if t= here is some optimization going on), while a compiler converts instructions fr= om one set to another set to be interpreted later. Which would make perl both at the perl source level, and an interpreter a= t the bytecode level. Thinking of execution as interpretation, this allows for the transmeta concept, where the CPU was just an interpreter / just in time compiler th= at interpreted x86 instructions. Although modern CISC CPU's have a step where the input to the chip was st= ill converted to mi...

Address Book Sidebar
The Address Book allows me to browse through my contacts via a number of fields displayed in columns: i.e. name, email, nickname, etc. However, when I am sending an email and bring up the address book in the sidebar, I have but two column choices: name and email. Since NICKNAME identifies categories of contacts to which I want to send a group email, it would be better if I could selected NICKNAME as column in the sidebar. Any ideas? kenmcentee@gmail.com keyboarded, On 6/16/2008 2:31 PM : > The Address Book allows me to browse through my contacts via a number > of fields ...

Another approach entirely
Gang... Thanks for all your testing work. Whatever is going on now, it's clear that there's some sort of video driver based weirdness. I'm going to take an entirely different approach toward capturing the proper background color. More shortly... -- ________________________________________________________________ Steve. Working on: GRC's DNS Benchmark utility: http://www.grc.com/dev/dnsbench.exe ...

[book] Compiling with Continuations
Can someone comment on that book? Is this a good buy? Compiling with Continuations by Andrew W. Appel (Author) Hardcover: 262 pages ; Dimensions (in inches): 0.79 x 10.04 x 7.10 Publisher: Cambridge University Press; (March 1992) ISBN: 0521416957 http://www.amazon.com/exec/obidos/tg/detail/-/0521416957/ref=lib_rd_ss_TBCV/102-4446948-2213769?v=glance&s=books&vi=reader&img=17#reader-link -- stef I would check it out from the library (and have), but I probably wouldn't buy it. It's interesting, but has a sort of niche market -- (1) are you reasonably f...

Another approach to vtables
I have some thoughts on vtables and I actually think they should be pretty different from what was proposed. Well, I'll tell you my ideas on vtables. Please note that I'm not doing this as an intent to confront the other proposal, or to create discordance and divergence. I'm presenting this because I think the other presented approach has some weak points, and I think this proposal here could solve them someway. I'm writing it under these assumptions: 1. There should be different vtables for scalars, arrays and hashes. In every use of a variable in the languag...

Web resources about - Sidebar for the book: another approach. - perl.perl6.compiler

Instrument approach - Wikipedia, the free encyclopedia
Publications depicting instrument approach procedures are called Terminal Procedures, but are commonly referred to by pilots as approach plates ...

How Facebook Marketers Should Approach Optimists, Explorers and Realists Aged 13-24
Facebook released the second part of its study of users aged 13 through 24 in 13 countries, with culture experts Crowd DNA , and it found that ...

LinkedIn takes Facebook approach and opens ad platform to developers
LinkedIn is creating an advertising platform that developers can build upon using an API similar to what Facebook has done to scale its business, ...

Focus Pomodoro Timer – A New Approach to Focus on Your Tasks
My thanks to Focus for sponsoring The Loop’s RSS feed this week. Focus is a beautiful and easy to use pomodoro timer. Built exclusively for iOS ...

Our approach to Trust & Safety and private information
We want to take a moment to explain some of our general Trust and Safety policies and procedures, and address the specific case at hand that ...

News: The crane is turning, a clever approach to dismantling it.
Remember the crane that blew over in the storm on Monday? Apparently it still works, and they're solving the problem by turning it, so that ...

Will software-as-a-service become the dominant approach?
Major shift in Microsoft's approach to licences.

Is "social proof" a rational approach to investment selection?
Answer (1 of 11): depends on who you trust for social proof. if you think your friends are smarter than you are, then it's obviously a good strategy. ...

Parts Of Animals (Vertebrates) LITE - A Montessori Approach to Zoology HD on the App Store on iTunes
Get Parts Of Animals (Vertebrates) LITE - A Montessori Approach to Zoology HD on the App Store. See screenshots and ratings, and read customer ...

DARPA Warrior Web — The Harvard Approach. Video: http://youtu.be/uyt5Hm8nTD8
jurvetson posted a photo: The Harvard team uses linear actuators on the side of the backpack (instead of twisting filaments with the SRI team) ...

Resources last updated: 12/28/2015 12:34:42 AM