I found this useful for LaTeX documents where all of the
section headers are in a single file.
_______________
D a m n D i r t y A p e
Home Node | Email
#! /usr/bin/perl -w # # LaTeX Outline Generator # use strict ; use warnings ; $|++ ; # Define the symbols to use to denote organizational levels. my @symbol_list = ( '*', '-', '+' ) ; # Set some defaults for the page header. my $title = 'LaTeX Document' ; my $author = 'Unknown Author' ; my $date = (localtime)[3] . ' ' . qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec )[(localtime)[4] +] . ' ' . ( (localtime)[5] + 1900 ) ; print '-' x 70 . "\n" ; while ( <> ) { # Grab doc titles, converting newlines to hyphens. if ( m/title\{(.*)\}/ ) { $title = $1 ; $title =~ s/\\\\/-/g ; } # Grab author names, converting \and's to commas. elsif ( m/author\{(.*)\}/ ) { $author = $1 ; $author =~ s/\s*\\and\s*/, /g ; } # Grab document dates. elsif ( m/date\{(.*)\}/ ) { $date = $1 ; } # Once the preamble's been processed, print the page header. elsif ( m/begin\{document\}/ ) { print "$title\n$author\n$date\n" . '-' x 70 . "\n" ; } # When a section tag is encountered, check it's # depth and print apprpriately. elsif ( m/section\{(.*)\}/ ) { my $name = $1 ; my $level = 0 ; $level++ while s/\\sub/\\/g ; my $symbol = $symbol_list[ $level ] ; print " " x ( ( $level * 4 ) + 2 ) . "$symbol_list[ $level ] $name\n" ; } } print '-' x 70 . "\n" ; exit( 0 ) ;
_______________
D a m n D i r t y A p e
Home Node | Email
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: LaTeX Outline Generator
by aersoy (Scribe) on Mar 22, 2002 at 05:43 UTC |
Back to
Cool Uses for Perl