\n", "This document was generated using the ", "LaTeX2HTML", " translator Version $TEX2HTMLVERSION Copyright © 1993, 1994,", " Nikos Drakos,", " Computer Based Learning Unit, University of Leeds.
\n", "With local hacks by sss.
\n",
" The command line arguments were:
",
"latex2html $argv.
",
"The translation was initiated by $address_data[0] on $address_data[1]");
system "cp ../local.perl .";
##################################################################################
#
# LaTeX2html doesn't expand input's in .aux files, such are are produced
# if the document is segmented with \include.
# Redefine process_ext_file to expand those `by hand'.
#
sub read_ext_file {
local($fname) = @_;
local($found) = 0;
print "\nReading $fname ...";
local($file) = &fulltexpath("$fname");
$global{'warnings'} .=
"\n$FILE.tex is newer than $fname: Please rerun latex" .
(($fname =~ /.*\.bbl/) ? " and bibtex.\n" : ".\n")
if ( ($found = (-f $file)) &&
&newer(&fulltexpath("$FILE.tex"), $file));
if ( $found ) {
&slurp_input($file);
}
$found;
}
sub expand_ext_includes {
local($save) = $_;
$save =~ s/\\\@input{(.*)}/&read_ext_file($1); $_/eog;
$_ = $save;
}
sub process_ext_file {
local($ext) = @_;
local($found) = 0;
$found = &read_ext_file("$FILE.$ext");
if ( $found ) {
&expand_ext_includes;
&pre_process;
# Hack: get rid of the contents of any \@setckpt's.
# Otherwise, any \setcounter's they contain will end up at the
# start of images.tex and screw up the numbering.
s/\\\@setckpt$any_next_pair_rx()$any_next_pair_rx4//go;
&substitute_meta_cmds if /$meta_cmd_rx/;
&wrap_shorthand_environments;
$_ = &translate_commands(&translate_environments($_));
};
$found;
}
##################################################################################
#
# Modify this latex2html routine so more forms of equation can be translated
# directly into html, rather than changing them to bitmaps.
#
sub translate_math_hack {
local($s) = @_;
&translate_environments (&make_new_math_wrap ($s));
}
sub special_env {
local($unit);
local($changed) = 0;
local($not_really_changed) = 0;
local($savemat);
local($pat) = "^\\\$[\\s%]*" . $any_next_pair_rx . "\\\$";
# Modifies $contents in its caller
$changed =
($contents =~ s/^\$(\s*([\d\.]+)\s*)\$/$1/igo ||
$contents =~ s/^\$(\s*([a-zA-Z]+)\s*)\$/$1<\/i>/igo ||
$contents =~ s/^\$(\s*($html_specials_inv_rx|[\da-z<>|=\-+,\s])+\s*)\$/$1/igo ||
# Local idioms.
$contents =~ s/^\$\s*([\d\.]+)\s*\\%\s*\$/$1\\%/igo ||
$contents =~ s/^\$\s*\\jets\s*\$/jets/igo ||
$contents =~ s/^\$\s*([\d\.]+)\s*\\(gev|gevc|gevcc|mev|kev|tev|Hz|m|s|cm|MHz|mm|kV|ns|kHz|MB|gev\/c|um|us|ps|pb)\s*\$/$savemat=$1;$unit=&translate_unit($2);"$savemat $unit"/igoe ||
# Strip off braces surrounding the entire expression.
$contents =~ s/$pat/$unit=&translate_math_hack($2);"$unit"/igoe ||
$contents =~ s/^\$\s*(|[^{}<>\$]*[^^])\s*([\/=+-]|;SPM_(lt|gt);|\\pm |\\approx |\\rightarrow )\s*([^{}<>\$]*)\s*\$/$unit=&hack_relation($1,$2,$4);"$unit"/igoe
);
if ($not_really_changed) {
$changed = 0;
}
$changed;
}
sub translate_unit {
local($unit) = @_;
local($newunit);
if ($unit eq "gev") {
$newunit = "GeV";
}
elsif ($unit eq "mev") {
$newunit = "MeV";
}
elsif ($unit eq "kev") {
$newunit = "keV";
}
elsif ($unit eq "tev") {
$newunit = "TeV";
}
elsif ($unit eq "gev/c") {
$newunit = "GeV/c";
}
elsif ($unit eq "gevc") {
$newunit = "GeV/c";
}
elsif ($unit eq "gevcc") {
$newunit = ("GeV/" . &make_new_math_wrap("c^2"));
$newunit = &translate_environments ($newunit);
}
elsif ($unit eq "us" || $unit eq "um") {
$newunit = (&make_new_math_wrap("\\mu") . substr ($unit, 1));
$newunit = &translate_environments ($newunit);
}
else {
$newunit = $unit;
}
$newunit;
}
sub is_cached {
local($x) = @_;
$x = "\\begin{tex2html_wrap_inline}\$$x\$\\end{tex2html_wrap_inline}";
$cached_env_img{&encode($x)};
}
$likely_to_expand_rx = "^\\s*([\\d\\.]+\\s*(\\\\gev|\\\\gevcc|\\\\pb|\\\\%)?|[a-zA-Z]+)\\s*\$";
sub hack_relation {
local($lhs, $rel, $rhs) = @_;
if (($lhs || $rhs) &&
($lhs =~ /$likely_to_expand_rx/o ||
$rhs =~ /$likely_to_expand_rx/o ||
&is_cached($lhs) ||
&is_cached($rhs))) {
# A bit of a gamble, this.
if ($rel =~ /^\\/) {
$rel = join ('', &make_math_beg_wrapper, $rel, &make_math_end_wrapper);
}
local($new) = "";
if (!($lhs eq "")) {
$new = join ('', $new,
&make_math_beg_wrapper, $lhs, &make_math_end_wrapper);
}
$new = $new . " $rel ";
if (!($rhs eq "")) {
$new = join ('', $new,
&make_math_beg_wrapper, $rhs, &make_math_end_wrapper);
}
&translate_environments ($new);
}
else {
$not_really_changed = 1;
join ('', '$', $lhs, $rel, $rhs, '$');
}
}
sub make_new_math_wrap {
local($stuff) = @_;
local($wrapper) = "tex2html_wrap_inline";
join ('', &make_math_beg_wrapper, $stuff, &make_math_end_wrapper);
}
sub make_math_beg_wrapper {
&make_any_wrapper(1,"tex2html_wrap_inline") . '$';
}
sub make_math_end_wrapper {
'$' . &make_any_wrapper(0,"tex2html_wrap_inline");
}
##################################################################################
#
# These patches to latex2html cause it to reuse images for duplicated
# equations within a document, rather than generating a separate image
# for each.
#
sub process_undefined_environment {
local($env, $id, $contents) = @_;
local($name,$cached,$raw_contents,$uucontents) = ("$env$id");
$contents = "% latex2html id marker $id\n$contents" if
$contents =~ /$order_sensitive_rx/;
$contents = "\\begin{$env}$contents\\end{$env}";
$latex_body{$name} = $contents;
$uucontents = &encode($contents);
if ($NOLATEX) {
$id_map{$name} = "[$name]";}
elsif ($cached = $cached_env_img{$uucontents}) {
if ($cached =~ /(img\d+)\.gif/ && -r "$1.old") {
++$global_page_num;
($cached =~ s/(img\d+)\.gif/img$global_page_num.gif/o);
rename("$1.old", "img$global_page_num.gif");
$cached_env_img{$uucontents} = $cached;
}
if (! defined $id_map{$name}) {
$id_map{$name} = $cached;
#!1$orig_name_map{$new_id_map{$name}} = $cached;
}
}
else {
&clear_images_dbm_database unless $new_page_num;
$new_id_map{$name} = $id_map{$name} = ++$global_page_num . "#" . ++$new_page_num;
$orig_name_map{$id_map{$name}} = $name;
$img_params{$name} = join('#', &extract_parameters($contents));
$raw_contents = &revert_to_raw_tex($contents);
if ($env =~ /inline/) {
$raw_contents = &make_box("$name", $raw_contents);
}
$raw_contents =~ s/\\pagebreak/\\\\/go;
$latex_body .= "{\\newpage\n\\clearpage\n\\samepage $raw_contents\n}\n\n";
$cached_env_img{$uucontents} = "sameas_$name";
}
&do_labels($contents,"$image_mark#$name#"); # Anchor the labels and put a marker in the text;
}
sub make_images {
local($name, $contents, $raw_contents, $uucontents, $page_num,
$uucontents, %page_map, $img);
# It is necessary to run LaTeX this early because we need the log file
# which contains information used to determine equation alignment
if ( $latex_body =~ /newpage/) {
print "\n";
system("$LATEX images.tex");
&process_log_file("images.log"); # Get eqn size info
}
if ($NO_IMAGES) {
system("cp $LATEX2HTMLDIR/icons/image.gif .")
if (-e "$LATEX2HTMLDIR/icons/image.gif")
}
elsif ((!$NOLATEX) && ($latex_body =~ /newpage/)) {
print "\nGenerating postscript images using dvips ...\n";
system("$DVIPS -M -S 1 -i -o $$\_image images.dvi") &&
print "Error: $!\n";
open(IMAGE, "echo $$\_image* | tr -s ' \t\r\f' '\\012\\012\\012\\012'|");
while ( ",$after);
$before .= " ";
if ($env eq 'figure') {
$type = "Figure";
$list = "\$figure_captions";
}
elsif ($env eq 'table') {
$type = "Table";
$list = "\$table_captions";
}
foreach $key (sort {$b <=> $a;} keys %captions){ # Sort numerically
$caption = &translate_commands(&translate_environments($captions{$key}));
$optional_caption = &translate_commands(&translate_environments($optional_captions{$key}));
$item .= " //g; # Remove newlines
$after;}
1;
$type",
($number ? " $number:" : ":"),
" $caption
\n", $after);
}
eval "$list .= \$item";
}
# Handle my `captionplus' macro.
{
local($id) = ++$global{'max_id'};
$new_command{"captionplus"} = "2:!:\\caption[#1]$O$id$C#1 #2$O$id$C";
}
##################################################################################
#
# latex2html will nuke inlined math in section titles.
# But i use math in some section headings, so i don't really want that to happen.
# Try removing the call to extract_pure_text from here. This sort of works,
# but of course the inlined bitmaps are not bolded/scaled up to match the
# style of the section headings. Still better than nothing, though.
#
sub do_cmd_section_helper {
local($H,$key) = @_;
local($section_number, @tmp);
# if we have a $key the current section is not of the *-form, so we need
# to update the counters.
do {
$latex_body .= "\\stepcounter{$key}\n";
} if $key;
# Ignore optional toc entry
local($_) = $after; &get_next_optional_argument; $after = $_;
$after =~ s/$next_pair_rx/do {$TITLE = $2; ''}/eo;
$TITLE =~ s/\\(label|index)$any_next_pair_rx//;
$TITLE = &translate_commands(&translate_environments($TITLE));
$_ = $TITLE; ##&extract_pure_text;
$TITLE = $_ ;
# This is the LaTeX section number read from the $FILE.aux file
@tmp = split(/$;/,$encoded_section_number{&encode_title($_)});
$section_number = shift(@tmp);
$section_number = "" if ($section_number eq "-1");
$encoded_section_number{&encode_title($_)} = join($;, @tmp);
$TITLE = "$section_number " . $_;
$after = join('', &make_section_heading($TITLE, $H), $after);
$TITLE =~ s/