I found this useful for LaTeX documents where all of the section headers are in a single file.
#! /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

In reply to LaTeX Outline Generator by DamnDirtyApe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.