######################################################################## # SGMLSPL script originated using the script sgmlspl.pl # # Document Type: article (gellmu) # Output Type: text/x-tex (LaTeX) # Author: William F. Hammond # Begun: 19980923 # With-help-from: Tim Kohl # Last-revision: check the file system datestamp or the http header # Note: This version of the regular LaTeX generator withholds newlines # Its output is not easy to read, but it is more efficient and # more reliable. ######################################################################## use SGMLS; # Use the SGMLS package. use SGMLS::Output; # Use stack-based output. # For spawning new element code # Element: foox sgml('', ""); sgml('', ""); # Element fooy sgml('', sub{ }); sgml('', sub{ }); $WhoAmI = "slidegart.pl"; # Global variables -- strings to think about # none here for now (several in the HTML generating code) # Global variables -- flags and numbers to think about (See the notes # about these in the HTML generating code) # Let's not depend on time zone being cross-platform # This is keyed on the last entry in the array version of localtime() @GTimeZone = ("EST", "EDT"); # Month names @GMonth = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); # Abbreviated month names @GMoY = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); # Abbreviated day-of-week names @GDoW = ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); @Alphabetic = qw(o A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA BB CC); @alphabetic = qw(O a b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc); @Roman = qw(0 I II III IV V VI VII VIII IX X XI XII XIII XIV XV XVI XVII XVIII XIX XX XXI XXII XXIII XXIV XXV XXVI XXVII XXVIII XXIX); @roman = qw(0 i ii iii iv v vi vii viii ix x xi xii xiii xiv xv xvi xvii xviii xix xx xxi xxii xxiii xxiv xxv xxvi xxvii xxviii xxix); $nobanner = 0; $nogratlinks = 0; $nobaseprint = 0; $secnumdepth = 3; # inert, except for name reservation, as this code is now $slabelprefix = "SU-"; $tocunitlength = 0; # E.g., in TOC show sec 4.2.3 as 2.3 (with indentation) $unknown_elements = 0; # # Document Handlers. # sgml('start', sub{ print STDERR $0, " *** ", $WhoAmI, "\n"; my $os = "% LaTeX\n"; output($os); $isxml = 0; }); sgml('end', sub{ output("\n"); if(($unknown_elements > 0) && (1)){ print STDERR "***** WARNING: ", $unknown_elements, " ", "unknown elements;\n"; if($isxml == 0){ print STDERR " Was the document filtered to XML first?\n"; }; }; }); # sgml('cdata',sub {output("*CDATA* " . $_[0] . "**");}); sgml('sdata',sub { die "Unknown SDATA: " . $_[0]; }); # # Replace each newline in the SGML with " %\n" rather than "\n" in # order to (1) avoid triggering a new paragraph (or quote or verse) # and (2) keep the LaTeX file more human-readable than it would be # if we simply put out " ". sgml('re',sub{ my $os = "\n"; if($isxml == 1){ $os = ""; }; output($os); }); # # Things to die for: # #sgml('pi',sub { die "Unknown processing instruction: " . $_[0]; }); sgml('pi', sub{ my $inst = $_[0]; my $os = ""; if($inst =~ /^xml/){ if($isxml == 0){ $isxml = 1; $os = $os . "% " . $_[1]->file . ": " . $inst . "\n"; } else{ $os = $os . "% " . $_[1]->file . ": " . $inst . "\n"; }; output($os); } else{ die "Unknown processing instruction: " . $inst; }; }); sgml('entity',sub { die "Unknown external entity: " . $_[0]->name; }); sgml('start_subdoc',sub { die "Unknown subdoc entity: " . $_[0]->name; }); # # sgml('end_subdoc',''); # sgml('conforming',''); # # Element Handlers. # # Element: article sgml('
', sub{ $anchopt = ""; $anchref = ""; $arrayrowseq = 0; $arrcols = ""; $arrpos = ""; @artauthor = (); $artbase = ""; $artdate = ""; $artsubtitle = ""; $arttitle = ""; $asstkey = ""; $asstser = ""; $asstname = ""; $asstid = ""; # Should these be made 2-dimensional for greater flexibility? @auth_addr = (); # @auth_email = (); @AuthEmail = (); $auth_ser = 0; $basefile = ""; $baseloc = ""; $baseurl = ""; $biblabel = ""; $bibkey = ""; # $binomdepth = 0; not recursive for now $binargid = 0; $binoml = ""; $binomu = ""; $bodymaketitle = 0; #If used, must occur before title, author, or date. $thiscitenote = ""; $thiscitekey = ""; $thiscitetext = ""; $compacttitle = 0; $copynotice = ""; $currtocdepth = 0; # for tableofcontents rendering @denm = (); $docclass_arg = ""; $docclass_opt = ""; $eqnamode = 0; $eqnarowseq = 0; $eqnkey = ""; $eqrkey = ""; $fracdepth = 0; $fracser = 0; @frid = (); @haveaddr = (); $haveanchopt = 0; $haveauthor = 0 ; $havebase = 0; $havedate = 0 ; $havedocclass = 0 ; @haveemail = (); $havetitle = 0; $holdlatextitle = 0; # do not write "\\title", ... to the output # when "", ... contain footnotes $inanch = 0; $inanchopt = 0; %labelinfo = (); @labelkeys=(); %labelseqs=(); %labeltypes=(); %labelsids=(); %labelsers=(); %labelserseqs=(); %labelsecunits=(); $lastlabelkey = ""; $lglbl = 0; # logical for successful opening of label info file as GLBL $lgcnt = 0; # logical for successful opening of contents data as GCNT $maketitle = 0; $markdraft = 0 ; $noanchorfootnote = 0; $nocustomlengths = 0; $notitle = 0; @numr = (); $oldlabelflag=0; $plainhdr = 0; # no bolding of headers if set (Hmmm... ?) @radicand=(); @radx=(); $sech_os = ""; # output line for current sectional unit $sepregexp = '\\\\'; # regexp for field separator in label aux file $sopt = ""; $sprefix = ""; $sunit = ""; $sunitflag = 0; @sqrtarg=(); $sqrtdepth = 0; @sqrtopt=(); $stemname=""; $surtitle=""; $tabdepth = 0; @tabhlen=(); @tabvlen=(); @tabarg = (); @tabopt = (); @tabid = (); $tabser = 0; @tdcount=(); @trcount = (); @trulecount = (); @termnote = (); @termnoteseq = 0; $tocdepth = ""; $tocentry = ""; # carrier for value of <tocentry> to <tocitem> handler $tocunit = ""; # carrier for value of <tocunit> to <tocitem> handler my $stem = $_[0]->attribute("stem")->value; if($stem ne ""){ $stemname = $stem; my $flbl = $stemname . ".xlb"; my $fcnt = $stemname . ".xcn"; $lglbl = open(GLBL, $flbl); $lgcnt = open(GCNT, $fcnt); if($lglbl == 0){ # test label file print STDERR "slidegart.pl WARNING:\n", " Failed to open label info file \"", $flbl, "\" for reading.\n"; } else{ # Good file -- let's read it. # Line format: key seq container section-id [ series series-seq ] my $inline = ""; my @tarray=(); my $tkey = ""; while($inline = <GLBL>){ chomp($inline); @tarray = (split(/$sepregexp/, $inline)); $tkey = shift @tarray; # @{labelinfo{$tkey}} = @tarray; @{$labelinfo{$tkey}} = @tarray; @labelkeys = (keys %labelinfo); }; my $nkeys = scalar @labelkeys; if($nkeys > 0){ #foreach $tkey (@labelkeys){ # $labelsids{$tkey} = @{$labelinfo{$tkey}}[2]; # $labelsers{$tkey} = @{$labelinfo{$tkey}}[3]; # $labelserseqs{$tkey} = @{$labelinfo{$tkey}}[4]; # # Debug output # foreach $tkey (@labelkeys){ # print STDERR "Label key \"$tkey\" is in series", # " \"$labelsers{$tkey}\", seq. $labelserseqs{$tkey}\n"; # }; my $test = scalar @tarray; if(($test == 4) || ($test == 6)){ foreach $tkey (@labelkeys){ $labelsids{$tkey} = @{$labelinfo{$tkey}}[2]; $labelsecunits{$tkey} = @{$labelinfo{$tkey}}[3]; $labelsers{$tkey} = @{$labelinfo{$tkey}}[4]; $labelserseqs{$tkey} = @{$labelinfo{$tkey}}[5]; }; } elsif(($test == 3) || ($test == 5)){ $oldlabelflag = 1; print STDERR "slidegart.pl: Old label aux file format\n"; foreach $tkey (@labelkeys){ $labelsids{$tkey} = @{$labelinfo{$tkey}}[2]; $labelsers{$tkey} = @{$labelinfo{$tkey}}[3]; $labelserseqs{$tkey} = @{$labelinfo{$tkey}}[4]; }; } else{ print STDERR "slidegart.pl: Label aux file not in correct format\n"; }; }; # # Debug output # foreach $tkey (@labelkeys){ # print STDERR "Label key \"$tkey\" is in series", # " \"$labelsers{$tkey}\", seq. $labelserseqs{$tkey}\n"; # }; }; # end of if test label file if($lgcnt == 0){ # test contents file print STDERR "slidegart.pl WARNING:\n", " Failed to open contents info file \"", $fcnt, "\" for reading.\n"; }; } # end of case where article has a stem else{ print STDERR "slidegart.pl WARNING: No stem attribute for root element."; }; }); sgml('</article>', sub{ if($lglbl != 0){ close(GLBL); }; if($lgcnt != 0){ close(GCNT); }; }); sgml('<dbgarticle>', ""); sgml('</dbgarticle>', sub{ print STDERR "Debugging AuthEmail:\n"; my $jaut = 1; my $jem = 1; if($auth_ser > 0){ while($jaut <= $auth_ser){ print STDERR " Author ", $jaut, "\n"; if($haveemail[$jaut] > 0){ $jem = 1; while($jem <= $haveemail[$jaut]){ print STDERR " Email, id ", $jem, ": ", $AuthEmail[$jaut][$jem], "\n"; $jem++; }; }; $jaut++; }; }; }); # Element: preamble sgml('<preamble>', sub{ push_output('string'); }); sgml('</preamble>', sub{ my $pos = pop_output; my $os = ""; my $jauth = 0; my $jaddr = 0; my $jemail = 0; my $as = ""; my $jem = 0; if ($havedocclass == 0){ $os = $os . "\\documentclass{slides}\n"; $os = $os . "\\usepackage{url}\n"; $os = $os . "\\usepackage{amsmath}\n"; $os = $os . "\\usepackage{amsfonts}\n"; }; # Pick up command definitions required by GELLMU $os = $os . "\\newcommand{\\hsf}{\\hspace*{\\fill}}\n"; $os = $os . "\\newcommand{\\tdbc}[1]{\\hsf\\textbf{\#1}\\hsf}\n"; $os = $os . "\\newenvironment{menulist}{\n"; $os = $os . "\\begin{list}{}{\n"; $os = $os . "\\setlength{\\topsep}{0bp}\n"; $os = $os . "\\setlength{\\labelwidth}{0bp}\n"; $os = $os . "\\setlength{\\leftmargin}{0.04\\linewidth}\n"; $os = $os . "\\setlength{\\itemindent}{0bp}\n"; $os = $os . "\\setlength{\\itemsep}{0bp}\n"; $os = $os . "\\setlength{\\parsep}{0bp}}\n"; $os = $os . "}{\\end{list}}\n"; $os = $os . "\\newenvironment{Menulist}{\n"; $os = $os . "\\begin{list}{}{\n"; $os = $os . "\\setlength{\\topsep}{0bp}\n"; $os = $os . "\\setlength{\\labelwidth}{0bp}\n"; $os = $os . "\\setlength{\\leftmargin}{0.04\\linewidth}\n"; $os = $os . "\\setlength{\\itemindent}{0bp}\n"; $os = $os . "\\setlength{\\itemsep}{3bp}\n"; $os = $os . "\\setlength{\\parsep}{3bp}}\n"; $os = $os . "}{\\end{list}}\n"; $os = $os . "\\newenvironment{toclist}{\\normalsize\n"; $os = $os . "\\begin{list}{}{\n"; $os = $os . "}}{\\end{list}}\n"; $os = $os . "\\newenvironment{Toclist}{\\large\n"; $os = $os . "\\begin{list}{}{\n"; $os = $os . "}}{\\end{list}}\n"; # Change the lengths below to be relative to \linewidth $os = $os . "\\newenvironment{citations}{\n"; $os = $os . "\\begin{list}{}{\n"; $os = $os . "\\setlength{\\topsep}{0bp}\n"; $os = $os . "\\setlength{\\labelwidth}{0bp}\n"; $os = $os . "\\setlength{\\leftmargin}{0.04\\linewidth}\n"; $os = $os . "\\setlength{\\labelsep}{0bp}\n"; $os = $os . "\\setlength{\\itemindent}{-0.2\\leftmargin}\n"; $os = $os . "\\setlength{\\itemsep}{3bp}\n"; $os = $os . "\\setlength{\\parsep}{0bp}}\n"; $os = $os . "}{\\end{list}}\n"; $os = $os . "\\setcounter{secnumdepth}{-2}\n"; if($auth_ser > 0){ $jauth = 1; # This code only generates the contents of LaTeX's \author while($jauth <= $auth_ser){ $as = "\\author{" . $artauthor[$jauth]; if($haveaddr[$jauth] > 0){ $as = $as . "\\\\{}" . $auth_addr[$jauth]; } my $jemail = $haveemail[$jauth]; if($jemail > 0){ if ($jemail > 1){ $as = $as . "\n\\\\{}Email addresses:\\\\{}\n"; $jem = 1; while($jem <= $jemail){ if($jem > 1){ $as = $as . "\\\\\\hsf\\\\{}\n"; }; $as = $as . "\\texttt{" . $AuthEmail[$jauth][$jem] . "}\n"; $jem++; }; } else{ $as = $as . "\n\\\\{}Email: "; $as = $as . "\\texttt{" . $AuthEmail[$jauth][$jemail] . "}\n"; }; }; $os = $os . $as . "}\n"; $jauth ++; }; }; output($os); }); # Element: documentclass # This is skeletal; it is not clear to what extent it will be supported. # For now we'll just grab any option (at most one) and argument # (exactly one) and pass them on, suppressing custom length settings. sgml('<documentclass>', sub{ $havedocclass = 1; push_output('string'); }); # Note that if there is a single argument, then it is in popped output. sgml('</documentclass>', sub{ my $pos = pop_output; my $os = "\\documentclass"; if($docclass_opt ne ""){ $os = $os . "[" . $docclass_opt . "]"; } if($docclass_arg ne ""){ $os = $os . "{" . $docclass_arg . "}\n"; } else{ $os = $os . "{" . $pos . "}\n"; } output($os); }); # Element: dclass sgml('<dclass>', sub{ push_output('string'); }); sgml('</dclass>', sub{ $docclass_arg = pop_output; }); # Element: dstyle sgml('<dstyle>', sub{ push_output('string'); }); sgml('</dstyle>', sub{ $docclass_opt = pop_output; }); # Element: bodymaketitle sgml('<bodymaketitle>', sub{ $bodymaketitle = 1; }); sgml('</bodymaketitle>', ""); # Element: maketitle sgml('<maketitle>', sub{ my $pan = $_[0]->parent->name; my $os = ""; if($pan eq "preamble"){ $maketitle = 1; } elsif(($bodymaketitle == 1) &&($pan eq "body")){ $os = $os . "\\maketitle{}\n"; if($markdraft == 1){ $os = $os . draft_label(); } output($os); }; }); sgml('</maketitle>', ""); # Element: title # # In processing to LaTeX we could just slip this through for # subsequent rendering with "\maketitle". This treatment leaves # open the possibility of custom titling outside of that. # It may be a bit overdone. Currently there are three ways: # (1) GELLMU normal = custom_title(), (2) GELLMU alt = compact_title, # and (3) LaTeX normal. This code presently is inadequate for (3), # especially in regard to "\author{ ... }", which cannot simply be # written to the output without missing addresses. # sgml('<title>', sub{ $havetitle = 1; push_output('string'); }); sgml('', sub{ $arttitle = pop_output; # a global string variable if(!($holdlatextitle)){ my $os = "\\title{" . $arttitle . "}\n"; output($os); }; }); # Element: subtitle sgml('', sub{ push_output('string'); }); sgml('', sub{ $artsubtitle = pop_output; # a global string variable }); # Element: author sgml('', sub{ $haveauthor = 1; $auth_ser++; $haveaddr[$auth_ser] = 0; $auth_addr[$auth_ser] = ""; $haveemail[$auth_ser] = 0; $auth_email[$auth_ser] = ""; push_output('string'); }); sgml('', sub{ my $pos = pop_output; $artauthor[$auth_ser] = $pos; }); # Element: address sgml('
', sub{ push_output('string'); }); sgml('
', sub{ my $pos = pop_output; $haveaddr[$auth_ser]++; if($haveaddr[$auth_ser] > 1){ $auth_addr[$auth_ser] = $auth_addr[$auth_ser] . "\n\\\\\\hsf\\\\{}\n"; }; $auth_addr[$auth_ser] = $auth_addr[$auth_ser] . $pos; }); # Element: email sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; $haveemail[$auth_ser]++; $AuthEmail[$auth_ser][$haveemail[$auth_ser]] = $pos; # if($auth_email[$auth_ser] ne ""){ # not the first email address (other than an 'eaddr' in 'address') # $auth_email[$auth_ser] = $auth_email[$auth_ser] . "\n\\\\\\hsf\\\\{}\n"; # }; # $auth_email[$auth_ser] = $auth_email[$auth_ser] . "\\verb|" .$pos . "|"; }); # Element: date sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; $havedate = 1; $artdate = $pos; if(!($holdlatextitle)){ $os = "\\date{" . $pos . "}\n"; output($os); }; }); # Element: copynotice sgml('', sub{ push_output('string'); }); sgml('', sub{ $copynotice = pop_output; }); # Element: draftlabel sgml('', sub{$markdraft = 1;}); sgml('', ""); # Element: nobanner sgml('', sub{$nobanner = 1;}); sgml('', ""); # Element: banner sgml('', sub{$nobanner = 0;}); sgml('', ""); # Element: nocustomlengths sgml('', sub{$nocustomlengths = 1;}); sgml('', ""); # Element: nogratlinks -- Block writing default links; there are none yet. sgml('', ""); sgml('', ""); # Element: gratlinks -- Create default links; there are none yet. sgml('', ""); sgml('', ""); # Element: nobaseprint -- Don't show location info in non network formats. sgml('', sub{ $nobaseprint = 1; }); sgml('', ""); # Element: compacttitle sgml('', sub{$compacttitle = 1;}); sgml('', ""); # Element: base sgml('', sub{ push_output('string'); # catch the base in verbatim mode for LaTeX since it will be set that way $verb_on = 1; }); sgml('', sub{ $verb_on = 0; $havebase = 1; $artbase = pop_output; $artbase =~ s/[hi]ref\s*=\s*\"//; $artbase =~ s/\"\s*$//; }); # Element: baseloc sgml('', sub{ push_output('string'); $verb_on = 1; }); sgml('', sub{ $verb_on = 0; $baseloc = pop_output; my $es = ""; my $event = $_[1]; $basefile = $event->file; $basefile =~ s/ *//g; $basefile =~ s|^.*/||; $basefile =~ s/\..*$//; # print {"STDERR"} "baseloc: ", $baseloc ,"\n"; # print {"STDERR"} "basefile: ", $basefile, "\n"; }); # Element: body sgml('', \&open_artbody); sgml('', \&open_artbody); sub open_artbody{ $new_sec = 0; $sec_level = 0; $sec_serial = 0; $subsec_serial = 0; $subsubsec_serial = 0; $para_on = 0; $gmath_on = 0; $imath_on=0; $dmath_on=0; $emath_on=0; $gmath_was_on = 0; $verb_on = 0; $verb_was_on = 0; $verb_pn = ""; $emathstar_on = 0; $sv_gmath_on = 0; my $os = "\\begin{document}\n"; if($havetitle == 0){ die "A title is required.\n"; }; if (($bodymaketitle == 0)&&($maketitle == 0)){ if($compacttitle == 0){ $os = $os . custom_title(); $os = $os . "\n\\medskip\n"; } else{ $os = $os . compact_title(); } } # $maketitle is set if "\maketitle" is found in the preamble; # if so, put "\maketitle" at the top of the body elsif($maketitle == 1){ $os = $os . "\\maketitle{}\n"; # 19990719 if($markdraft == 1){ $os = $os . draft_label(); }; }; # 19990719 # if (($bodymaketitle == 1)&&($markdraft == 1)){ # $os = $os . draft_label(); # } output($os); } sgml('', \&end_artbody); sgml('', \&end_artbody); sub end_artbody{ my $os = ""; my $tmp = ""; my $dvi = ""; my $html = ""; $os = $os . "\\end{document}\n"; output($os); } # Element: Section sgml('
', sub{ $new_sec = 1; $sec_serial++; $sec_level++; $sopt = ""; $sprefix = ""; $sunit = ""; $sunitflag = 0; $sech_os = ""; output("\\begin{slide}\n"); }); sgml('
', sub{ $sec_level--; output("\\end{slide}\n"); }); # Element: section -- content is section-title sgml('
', sub{ push_output('string'); }); sgml('
', sub{ my $pos = pop_output; my $os = "\\section{" . $pos . "}\n"; output($os); }); # Element: Subsection sgml('', sub{ $new_sec = 1; $subsec_serial++; $sec_level++; $sopt = ""; $sprefix = ""; $sunit = ""; $sunitflag = 0; $sech_os = ""; push_output('nul'); }); sgml('', sub{ pop_output; $sec_level--; }); # Element: subsection -- content is subsection-title sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\subsection{" . $pos . "}\n"; output($os); }); # Element: Subsubsection sgml('', sub{ $new_sec = 1; $subsubsec_serial++; $sec_level++; $sopt = ""; $sprefix = ""; $sunit = ""; $sunitflag = 0; $sech_os = ""; }); sgml('', sub{ $sec_level--; }); # Element: Paragraph sgml('', sub{ $new_sec = 1; $subsec_serial++; $sec_level++; $sopt = ""; $sprefix = ""; $sunit = ""; $sunitflag = 0; $sech_os = ""; }); sgml('', sub{ $sec_level--; }); # Element: Subparagraph sgml('', sub{ $new_sec = 1; $subsec_serial++; $sec_level++; $sopt = ""; $sprefix = ""; $sunit = ""; $sunitflag = 0; $sech_os = ""; }); sgml('', sub{ $sec_level--; }); # Element: subsubsection -- content is subsubsection-title sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\subsubsection{" . $pos . "}\n"; output($os); }); # This code will still work with some old documents when passed through # here directly from article/SGML. Under the new regime all formatting # through here is done from article/XML, and "ag0" is not part of # article/XML. # Element: ag0 -- auto-generated command argument sgml('', sub{ push_output('string'); # in every case my $pan = $_[0]->parent->name; my $os = ""; if($pan eq "Section"){ $sec_name = "section"; } elsif($pan eq "Subsection"){ $sec_name = "subsection"; } elsif($pan eq "Subsubsection"){ $sec_name = "subsubsection"; } elsif($pan eq "anch"){ ; } # The next conditional must match code for the end tag. elsif($pan =~ /^table/){ ; } elsif($pan =~ /^mtable/){ ; } elsif($pan eq "frac"){ $frid[$fracdepth]++; } elsif($pan eq "binom"){ $binargid++; } elsif($pan eq "sqrt"){ ; } elsif($pan eq "documentclass"){ ; } else{ output("{ELT " . $_[0]->name . " IN " . $pan); }; }); sgml('', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; my $os = ""; # There is no collected "output()" in this code segment. # new_sec is set for all section-level elements if(($pan eq "Section")||($pan eq "Subsection")||($pan eq "Subsubsection")){ $new_sec = 0; my $ts = $pos; #mandatory section title $sech_os = "\n\\" . $sec_name . "{" . $ts . "}\n"; output($sech_os); } elsif($pan eq "anch"){ output($pos); } # The next conditional must match code for the start tag. elsif($pan =~ /^table/){ # Was: elsif(($pan eq "table")||($pan eq "tablec")){ my $qos = $pos; $qos =~ s/\|//g; if($tabdepth <= 0){ die "Have table arg without positive table depth"; }; $tabhlen[$tabdepth]=length($qos); # Are these next lines correct? $tabarg[$tabdepth] = '{' . $pos . '}'; } elsif($pan =~ /^mtable/){ my $qos = $pos; $qos =~ s/\|//g; if($tabdepth <= 0){ die "Have table arg without positive table depth"; }; $tabhlen[$tabdepth]=length($qos); # Are these next lines correct? $tabarg[$tabdepth] = '{' . $pos . '}'; } elsif($pan eq "frac"){ if($frid[$fracdepth] == 1){ $numr[$fracdepth] = $pos; } elsif($frid[$fracdepth] == 2){ $denm[$fracdepth] = $pos; } else{ $os = "Fraction management error in codelets\n" . "fraction serial: " . $fracser . "\n" . " fraction depth: " . $fracdepth . "\n" . " arg. number: " . $frid[$fracdepth] . "\n" . " numerator: " . $numr[$fracdepth] . "\n" . " denominator: " . $denm[$fracdepth] . "\n"; die $os; } } elsif($pan eq "binom"){ if($binargid == 1){ $binomu = $pos; } elsif($binargid == 2){ $binoml = $pos; } else{ print STDERR "binom management error in codelets\n"; die; }; } elsif($pan eq "sqrt"){ $sqrtarg[$sqrtdepth] = $pos; } elsif($pan eq "documentclass"){ $docclass_arg = $pos; } else{ output('}'); }; }); # Element: sopt -- option for Section, Subsection, ... sgml('', sub{ push_output('string'); }); sgml('', sub{ $sopt = pop_output; }); # Element: shead -- header for Section, Subsection, ... , the big containers # When formatting from the XML version of article, the end of # is the point where all information about the Section header elements # is available. # sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; #mandatory section header (or "title") $new_sec = 0; my $sec_name = ""; my $sec_num = ""; my $par = $_[0]->parent; my $pan = $par->name; my $shead = $pos; if($shead ne ""){ $sech_os = "\n\\begin{center}\\Large\n\\textbf{"; $sech_os = $sech_os . $shead . "}\n\\end{center}\n"; output($sech_os); }; }); # This code will still work with some old documents when passed through # here directly from article/SGML. Under the new regime all formatting # through here is done from article/XML, and "op0" is not part of # article/XML. # Element: op0 -- auto-generated command option sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; my $os = ""; if($pan eq "anch"){ $anchopt = $pos; $haveanchopt = 1; } elsif($pan eq "sqrt"){ $sqrtopt[$sqrtdepth] = $pos; } elsif($pan eq "documentclass"){ $docclass_opt = $pos; } elsif($pan eq "table"){ $tabopt[$tabdepth] = '[' . $pos . ']'; } else{ $os = "{ELT " . $_[0]->name . " IN " . $pan . "***". $pos . "*}"; }; output($os); }); sgml('', sub{ if($inanch == 1){ $haveanchopt = 1; $inanchopt = 1; push_output('string'); }}); sgml('', sub{ if ($haveanchopt == 1){ $anchopt = pop_output; $inanchopt = 0; }; }); # Element: mtable -- table in math mode sgml('', sub{ on_table(); }); sgml('', sub{ my ($arg, $rs) = off_table($_[0], $_[1]); my $os = ""; $os = $os . "\\begin{array}" . $arg . "\n"; $os = $os . $rs; $os = $os . "\n\\end{array}"; output($os); }); sgml('', sub{ $tabser++; $tabdepth++; $tabid[$tabdepth] = $tabser; $tabhlen[$tabdepth] = 0; $tabvlen[$tabdepth] = 0; $tabarg[$tabdepth] = ""; push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $es = ""; # my $rs = diag_table($pos, $_[0], $_[1]); # print {STDERR} $rs; # Check to see if we have an argument if($tabhlen[$tabdepth] == 0){ $es = $es . "Error: cannot find table argument for element \""; $es = $es . $_[0]->name . "\"\n with (general) table serial number "; $es = $es . $tabid[$tabdepth] . " at table depth " . $tabdepth; die $es; }; my $os = "\\begin{array}" . $tabarg[$tabdepth] . "\n"; $os = $os . $pos; $os = $os. "\\end{array}\n"; output($os); $tabdepth--; }); # Element: tabarg sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $qos = $pos; $qos =~ s/\|//g; if($tabdepth <= 0){ die "Have table arg without positive table depth"; }; $tabhlen[$tabdepth]=length($qos); $tabarg[$tabdepth] = '{' . $pos . '}'; }); # Element: tabopt sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; $tabopt[$tabdepth] = '[' . $pos . ']'; }); # Element: table -- somewhat like the HTML table model with , . # For sanity in rendition to LaTeX "tabular" we need the "tabular" # column argument. sgml('', sub{ $tabser++; $tabdepth++; $trcount[$tabdepth] = 0; $trulecount[$tabdepth] = 0; $tabid[$tabdepth] = $tabser; $tabhlen[$tabdepth] = 0; $tabvlen[$tabdepth] = 0; $tabopt[$tabdepth] = ""; $tabarg[$tabdepth] = ""; push_output('string'); }); sgml('
', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; my $os = ""; # Check to see if we have an argument my $es = ""; if($tabhlen[$tabdepth] == 0){ $es = $es . "Error: cannot find table argument for element \""; $es = $es . $_[0]->name . "\"\n with (general) table serial number "; $es = $es . $tabid[$tabdepth] . " at table depth " . $tabdepth; die $es; }; if($pan eq "td"){ $os = $os . "\\hspace*{-\\tabcolsep}"; }; $os = $os . "\\begin{tabular}"; if($tabopt[$tabdepth] ne ""){ $os = $os . $tabopt[$tabdepth]; }; $os = $os . $tabarg[$tabdepth] . "\n"; $os = $os . $pos; if($trulecount[$tabdepth] > 0){ $os = $os . "\\\\ "; while($trulecount[$tabdepth] > 0){ $os = $os . "\\hline "; $trulecount[$tabdepth]--; }; }; $os = $os. "\n\\end{tabular}\n"; output($os); $tabdepth--; }); # Element: tableb -- somewhat like the early HTML table model with , . # But for sanity in rendition to LaTeX "tabular" we'll need to work in # the "tabular" column argument as an option. This rendition is "boxed" # and centered. (We don't have any blanket centering here, right?) sgml('', sub{ $tabser++; $tabdepth++; $trcount[$tabdepth] = 0; $trulecount[$tabdepth] = 0; $tabid[$tabdepth] = $tabser; $tabhlen[$tabdepth] = 0; $tabvlen[$tabdepth] = 0; $tabarg[$tabdepth] = ""; push_output('string'); }); sgml('', sub{ my $pos = pop_output; # Check to see if we have an argument my $es = ""; if($tabhlen[$tabdepth] == 0){ $es = $es . "Error: cannot find table argument for element \""; $es = $es . $_[0]->name . "\"\n with (general) table serial number "; $es = $es . $tabid[$tabdepth] . " at table depth " . $tabdepth; die $es; }; my $os = "\\begin{center}\n\\begin{tabular}" . $tabarg[$tabdepth] . "\\hline "; $os = $os . $pos; $os = $os. "\\\\ \\hline "; while($trulecount[$tabdepth] > 0){ $os = $os . "\\hline "; $trulecount[$tabdepth]--; }; $os = $os . "\n\\end{tabular}\n\\end{center}"; output($os); $tabdepth--; }); # Element: tablec -- somewhat like the HTML table model with , . # For sanity in rendition to LaTeX "tabular" we need the "tabular" # column argument. This version is centered but not boxed. sgml('', sub{ $tabser++; $tabdepth++; $trcount[$tabdepth] = 0; $trulecount[$tabdepth] = 0; $tabid[$tabdepth] = $tabser; $tabhlen[$tabdepth] = 0; $tabvlen[$tabdepth] = 0; $tabarg[$tabdepth] = ""; push_output('string'); }); sgml('', sub{ my $pos = pop_output; # Check to see if we have an argument my $es = ""; if($tabhlen[$tabdepth] == 0){ $es = $es . "Error: cannot find table argument for element \""; $es = $es . $_[0]->name . "\"\n with (general) table serial number "; $es = $es . $tabid[$tabdepth] . " at table depth " . $tabdepth; die $es; }; my $os = "\\begin{center}\n\\begin{tabular}" . $tabarg[$tabdepth] . "\n"; $os = $os . $pos; if($trulecount[$tabdepth] > 0){ $os = $os . "\\\\ "; while($trulecount[$tabdepth] > 0){ $os = $os . "\\hline "; $trulecount[$tabdepth]--; }; }; $os = $os. "\n\\end{tabular}\n\\end{center}"; output($os); $tabdepth--; }); # Element: emprow -- empty table row, mainly for use with "tablec" sgml('', sub{ $trcount[$tabdepth]++; my $os = ""; if($trcount[$tabdepth] > 1){ $os = "\n\\\\ "; }; while($trulecount[$tabdepth] > 0){ $os = $os . "\\hline "; $trulecount[$tabdepth]--; }; my $pan = $_[0]->parent->name; if($pan eq "tableb"){ $os = $os . "\\hline "; }; $os = $os . "\\ {}~\\hsf"; output($os); }); sgml('', ""); # Element: trule -- table-wide horiz. rule, mainly for use with "tablec" # but usable elsewhere # (Rules are presently built into "tr".) sgml('', sub{ $trulecount[$tabdepth]++; }); sgml('', ""); # Element: tr -- table row sgml('', sub{ $trcount[$tabdepth]++; $tdcount[$tabdepth]=0; $tabvlen[$tabdepth]++; my $os = ""; if($trcount[$tabdepth] > 1){ $os = "\n\\\\ "; }; while($trulecount[$tabdepth] > 0){ $os = $os . "\\hline "; $trulecount[$tabdepth]--; }; my $pan = $_[0]->parent->name; if($pan eq "tableb"){ $os = $os . "\\hline "; }; output($os); }); sgml('', ""); # Element: th -- table header cell sgml('', sub{ $trcount[$tabdepth]++; $tdcount[$tabdepth]++; push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os; # Watch out for a first cell that inserts "[ ... ]" following "\\" if($tdcount[$tabdepth] == 1){ $os = "{}"; }; $os = $os . "\\textbf{" . $pos . "}"; if($tdcount[$tabdepth] < $tabhlen[$tabdepth]){ $os = $os . " & "; } output($os); }); # Element: td -- table cell sgml('', sub{ $tdcount[$tabdepth]++; push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; # Watch out for a first cell that inserts "[ ... ]" following "\\" if($tdcount[$tabdepth] == 1){ $os = "{}"; }; $os = $os . $pos; if($tdcount[$tabdepth] < $tabhlen[$tabdepth]){ $os = $os . " & "; } output($os); }); # Element: tdbc -- used to bold and center within a table cell # (or whatever); it uses LaTeX newcommands "hsf" and # "tdbc", where "hsf" is \hspace*{\fill} (see above) sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; my $os = ""; if($pan eq "th"){ $os = "\\hsf{}" . $pos . "\\hsf{}"; } else{ $os = "\\tdbc{" . $pos . "}"; }; output($os); }); # Element: tablech -- no border, flush to left margin # But for sanity in rendition to LaTeX "tabular" we'll need to work in # the "tabular" column argument as an option. This table is not "boxed" # and may have inter-row space. sgml('', sub{ $tabser++; $tabdepth++; $trcount[$tabdepth] = 0; $trulecount[$tabdepth] = 0; $tabid[$tabdepth] = $tabser; $tabhlen[$tabdepth] = 0; $tabvlen[$tabdepth] = 0; $tabarg[$tabdepth] = ""; push_output('string'); }); sgml('', sub{ my $pos = pop_output; # Check to see if we have an argument my $es = ""; if($tabhlen[$tabdepth] == 0){ $es = $es . "Error: cannot find table argument for element \""; $es = $es . $_[0]->name . "\"\n with (general) table serial number "; $es = $es . $tabid[$tabdepth] . " at table depth " . $tabdepth; die $es; }; # We move left by \tabcolsep to be flush with the left margin. my $os = "\\hspace*{-\\parindent}\\hspace*{-\\tabcolsep}\\begin{tabular}" . $tabarg[$tabdepth] . "\n"; $os = $os . $pos; $os = $os. "\\end{tabular}"; output($os); $tabdepth--; }); # Element: trc -- table row for "tablec" and "tablech" sgml('', sub{ $tdcount[$tabdepth]=0; $tabvlen[$tabdepth]++; }); sgml('', "\\\\{}\n"); # Element: tdc -- table cell sgml('', sub{ $tdcount[$tabdepth]++; push_output('string'); }); sgml('', sub{ my $os = pop_output; if($tdcount[$tabdepth] < $tabhlen[$tabdepth]){ $os = $os . " & "; }; output($os); }); # Element: bigskip sgml('', "\\bigskip\n\n"); sgml('', ""); # Element: medskip sgml('', "\\medskip\n\n"); sgml('', ""); # Element: smallskip sgml('', "\\smallskip\n\n"); sgml('', ""); # Element: supsupsuphdr sgml('', "\\begin{flushleft}\\Huge\\bf\n"); sgml('', "\\end{flushleft}\n"); # Element: supsuphdr sgml('', "\\begin{flushleft}\\LARGE\\bf\n"); sgml('', "\\end{flushleft}\n"); # Element: suphdr sgml('', "\\begin{flushleft}\\Large\\bf\n"); sgml('', "\\end{flushleft}\n"); # Element: hdr sgml('', "\\begin{flushleft}\\large\\bf\n"); sgml('', "\\end{flushleft}\n"); # Element: subhdr sgml('', "\\begin{flushleft}\\normalsize\\bf\n"); sgml('', "\\end{flushleft}\n"); # Element: subsubhdr sgml('', "\\begin{flushleft}\\small\\bf\n"); sgml('', "\\end{flushleft}\n"); # Element: supsupsuphdrc sgml('', "\\begin{center}\\Huge\\bf\n"); sgml('', "\\end{center}\n"); # Element: supsuphdrc sgml('', "\\begin{center}\\LARGE\\bf\n"); sgml('', "\\end{center}\n"); # Element: suphdrc sgml('', "\\begin{center}\\Large\\bf\n"); sgml('', "\\end{center}\n"); # Element: hdrc sgml('', "\\begin{center}\\large\\bf\n"); sgml('', "\\end{center}\n"); # Element: subhdrc sgml('', "\\begin{center}\\normalsize\\bf\n"); sgml('', "\\end{center}\n"); # Element: subsubhdrc sgml('', "\\begin{center}\\small\\bf\n"); sgml('', "\\end{center}\n"); # Element: itemize sgml('', "\\begin{itemize}\n"); sgml('', "\\end{itemize}"); # Element: enumerate sgml('', "\\begin{enumerate}\n"); sgml('', "\\end{enumerate}"); # Element: item sgml('', sub{ my $os = ""; my $pan = $_[0]->parent->name; if($pan eq "parlist"){ $os = ""; } else{ $os = "\\item "; output($os); }; }); sgml('', sub{ my $os = ""; my $pan = $_[0]->parent->name; if($pan eq "parlist"){ $os = "\\texttt{ }"; }; $os = $os . "\n"; output($os); }); # Element: today sgml('', "\\today{} "); sgml('', ""); # Element: mbox -- as in LaTeX sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; my $os = "\\mbox{"; if(($pan eq "sup") || ($pan eq "sub") || ($pan eq "pow")){ $os = $os . "\\small "; } $os = $os . $pos . "}"; output($os); }); # Element: regch -- an mbox for a single non-math char sgml('', "\\mbox{"); sgml('', "}"); # Element: text sgml('', sub{ push_output('string'); }); sgml('', sub{ my $ts = pop_output; my $os = $ts; if($gmath_on == 1){ $os = "\\mbox{" . $ts . "}"; }; output($os); }); # Element: display -- non-math displayed paragraph. sgml('', "\\begin{center}\n"); sgml('', "\n\\end{center}"); # Element: quote -- not LaTeX's "quote"; instead a single instance thereof sgml('', "\\begin{quote}\n"); sgml('', "\n\\end{quote}"); # Element: quotation -- LaTeX-like quotation sgml('', "\\begin{quotation}"); sgml('', "\\end{quotation}"); # Element: verse -- LaTeX-like verse sgml('', "\\begin{verse}"); sgml('', "\\end{verse}"); # Element: math -- inline math delimited by "\( ... \)" # Automatically precede and follow by a half space. Ending punctuation # should be inside. sgml('', sub{ $imath_on = 1; &on_gmath ; output ("\\,\\("); }); sgml('', sub{ output ("\\)\\,"); &off_gmath ; $imath_on = 0; }); # Element: tmath -- inline math delimited by "$ ... $" instead of # by "\math{ ... } or by "\( ... \)" sgml('', sub{ $imath_on = 1; &on_gmath ; output ("\\("); }); sgml('', sub{ output ("\\)"); &off_gmath ; $imath_on = 0; }); # Element: displaymath -- displayed math sgml('', \&on_dmath); sgml('', \&off_dmath); # Element: sup -- behavior depends on whether $gmath_on is set. sgml('', sub{push_output('string');}); sgml('', sub{ my $s = pop_output ; if($gmath_on == 1){ output("^{" . $s . "}"); } else{ output("\$^{\\mbox{" . $s . "}}\$"); }; }); # Element: sub -- behavior depends on whether $gmath_on is set. sgml('', sub{push_output('string');}); sgml('', sub{ my $s = pop_output ; if($gmath_on == 1){ output("_{" . $s . "}"); } else{ output("\$_{\\mbox{" . $s . "}}\$"); }; }); # Element: frac -- fraction. For now only the LaTeX (two arg) model. # If the input is valid (surviving "nsgmls"), we have $gmath_on = 1. sgml('', sub{ $fracser++; $fracdepth++; $frid[$fracdepth]=0; # move to 1 for first arg, to 2 for second $numr[$fracdepth]=""; $denm[$fracdepth]=""; push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\frac{" . $numr[$fracdepth] . "}{" . $denm[$fracdepth] . "}"; output($os); $fracdepth--; }); # Element: sqrt -- model (op0,ag0) OR (%vline)* sgml('', sub{ push_output('string'); $sqrtdepth++; $sqrtopt[$sqrtdepth] = ""; $sqrtarg[$sqrtdepth] = ""; $radicand[$sqrtdepth] = ""; $radx[$sqrtdepth] = ""; }); sgml('', sub{ my $pos = pop_output; my $os = "\\sqrt"; if(($sqrtopt[$sqrtdepth] eq "") && ($radicand[$sqrtdepth] eq "")){ $os = $os . "{" . $pos . "}"; } elsif($radicand[$sqrtdepth] ne ""){ if($radx[$sqrtdepth] ne ""){ $os = $os . '[' . $radx[$sqrtdepth] . ']'; }; $os = $os . '{' . $radicand[$sqrtdepth] . '}'; } else{ $os = $os . '[' . $sqrtopt[$sqrtdepth] . ']{' . $sqrtarg[$sqrtdepth] . '}'; }; output($os); $sqrtdepth--; }); # With "gellmu.dtd", the commands "sum", "int", & "prod" take a single # argument (i.e., are simple containers) which may or may not have # "sub" or "sup" or both as *leading* content. # Element: sum -- specif.: ((sub)?&(sup)?,(%gmath)*) # *required* surrounding braces) that may or may not contain sub/sup. # If the input is valid, we have $gmath_on = 1. sgml('', "\\sum"); sgml('', ""); # Element: int -- specif.: ((sub)?&(sup)?,(%gmath)*) # If the input is valid, we have $gmath_on = 1. sgml('', "\\int"); sgml('', ""); # Element: prod -- specif.: ((sub)?&(sup)?,(%gmath)*) # If the input is valid, we have $gmath_on = 1. sgml('', "\\prod"); sgml('', ""); # Element: par sgml('', sub{ $para_on = 1; output("\\par{"); }); sgml('', sub{ $para_on = 0; output("\n}\n"); }); # Element: parb sgml('', sub{ my $pan = $_[0]->parent->name; my $os = ""; if(($pan eq "quote")||($pan eq "quotation")||($pan eq "verse")){ $os = "\n"; } else{ $para_on = 1; $os = "\\par{"; } output($os); }); sgml('', sub{ my $pan = $_[0]->parent->name; my $os = ""; if(($pan eq "quote")||($pan eq "quotation")||($pan eq "verse")){ $os = "\n"; } else{ $para_on = 0; $os = "\n}\n"; } output($os); }); # OBSOLETE Element: bpar -- used as shortref for PARB, the alter ego of PAR # sgml('', ""); # sgml('', ""); # Element: aos -- @-end-of-sentence mark if we NOT in math mode # Forbidden in a math mode; punt for robustness. sgml('', sub{ if($gmath_on == 1) { if($dmath_on == 1) {output("\\ . \\ ")} else {output("\\, . \\,")} } else{output("\\@. \\ ")} }); sgml('', ""); # Element: aoq -- @-end-of-question mark sgml('', sub{ if($gmath_on == 1) { if($dmath_on == 1) {output("\\ ? \\ ")} else {output("\\, ? \\,")} } else{output("\\@? \\ ")} }); sgml('', ""); # Element: aoc -- @-comma sgml('', "\\@, \\,"); sgml('', ""); # Element: eos -- end-of-sentence mark if we are not in math mode # -- in math mode it's probably a sloppy ldot or a # -- decimal point, who knows? sgml('', sub{ if($dmath_on == 1){ output("\\ \\ ."); } elsif($gmath_on == 1){ output("\\,."); } elsif($verb_on > 0){ output("."); } else{ output(". \\ "); }; }); sgml('', ""); # Element: eoq -- end-of-question mark sgml('', sub{ if(($gmath_on == 1)||($verb_on > 0)){output("?")}else{output("? \\ ");}; }); sgml('', ""); # Element: eoe -- end-of-exclamation mark sgml('', sub{ if(($gmath_on == 1)||($verb_on > 0)){output("!")}else{output("! \\ ");}; }); sgml('', ""); # Element: bsl -- abstract char "\" # For this we really need a better "\backslash". sgml('', sub{ my $os = "\\textbackslash{}"; my $par = $_[0]->parent; if($verb_on == 1){ $os = "\\"; } elsif($par->name =~ /^(quostr|qquostr|quochar|nln)$/){ $os = "}\\verb+\\+\\texttt{"; # LaTeX's \verb cannot be within a command argument or option if($par->within("footnote") ne ""){ $os = "\\textbackslash{}"; } elsif($par->within("shead") ne ""){ $os = "\\textbackslash{}"; } elsif($par->within("itemlabel") ne ""){ $os = "\\textbackslash{}"; } elsif($par->within("term") ne ""){ $os = "\\textbackslash{}"; }; # there may be more for this list } elsif($par->name =~ /^(path|urlanch)$/){ # which are set with \url $os = "\\"; } elsif ($gmath_on == 1){ $os = "\\backslash{}"; }; output($os); }); sgml('', ""); # Element: vbr -- abstract char "|" sgml('', sub{ my $os = "\\textbar{}"; my $par = $_[0]->parent; my $pan = $par->name; if($verb_on == 1){ $os = "|"; } elsif($pan =~ /^(quostr|qquostr|quochar|nln)$/){ $os = "\\string|"; # perhaps not necessary from 1998/12/01 } elsif($pan =~ /^(path|urlanch|tabarg)$/){ $os = "|"; } elsif ($gmath_on == 1){ $os = "\\vert{}"; }; output($os); }); sgml('', ""); # # Element: vbr # sgml('', "|"); # sgml('', ""); # Element: lbr -- abstract char "{" sgml('', sub{ my $es = "{"; my $par = $_[0]->parent; my $pan = $par->name; my $ros = "\\" . $es; my $os = $ros; if($verb_on > 0){ $os = $es; } elsif($pan =~ /^(quostr|qquostr|quochar|nln)$/){ $os = "}\\verb+{+\\texttt{"; # LaTeX's \verb cannot be within a command argument or option if($par->within("footnote") ne ""){ $os = $ros; } elsif($par->within("shead") ne ""){ $os = $ros; } elsif($par->within("itemlabel") ne ""){ $os = $ros; } elsif($par->within("term") ne ""){ $os = $ros; }; # there may be more for this list } elsif($pan =~ /^(path|urlanch)$/){ # We're currently setting these with \url, which does not handle # either '{' or '}' but takes everything else verbatim while # ignoring blank spaces. print STDERR "slidegart.pl WARNING: \"{\" in ", $pan, " -- cannot set using \\url -- ignored\n"; $os = " "; }; output($os); }); sgml('', ""); # Element: rbr -- abstract char "}" sgml('', sub{ my $es = "}"; my $par = $_[0]->parent; my $pan = $par->name; my $ros = "\\" . $es; my $os = $ros; if($verb_on > 0){ $os = $es; } elsif($pan =~ /^(quostr|qquostr|quochar|nln)$/){ $os = "}\\verb+}+\\texttt{"; # LaTeX's \verb cannot be within a command argument or option if($par->within("footnote") ne ""){ $os = $ros; } elsif($par->within("shead") ne ""){ $os = $ros; } elsif($par->within("itemlabel") ne ""){ $os = $ros; } elsif($par->within("term") ne ""){ $os = $ros; }; # there may be more for this list } elsif($pan =~ /^(path|urlanch)$/){ # We're currently setting these with \url, which does not handle # either '{' or '}' but takes everything else verbatim while # ignoring blank spaces. print STDERR "slidegart.pl WARNING: \"}\" in ", $pan, " -- cannot set using \\url -- ignored\n"; $os = " "; }; output($os); }); sgml('', ""); # Element: lsb -- abstract char "[" sgml('', "["); sgml('', ""); # Element: rsb -- abstract char "]" sgml('', "]"); sgml('', ""); # Element: exc -- abstract exclamation point sgml('', "!"); sgml('', ""); # Element: atc -- abstract "@" sgml('', "@"); sgml('', ""); # Element: hsh -- abstract hash, i.e., "#" sgml('', sub{ my $es = "#"; my $os = "\\" . $es; if(($verb_on > 0) || ($_[0]->parent->name =~ /^(path|urlanch)$/)){ $os = $es; }; output($os); }); sgml('', ""); # Element: dol -- abstract dollar sign (needs '\' both for Perl and LaTeX) sgml('', sub{ my $es = "\$"; my $os = "\\" . $es; if(($verb_on > 0) || ($_[0]->parent->name =~ /^(path|urlanch)$/)){ $os = $es; }; output($os); }); sgml('', ""); # Element: pct -- abstract percent sign # If one of these shows up in the SGML version of a GELLMU doc it was # not a comment. A "', sub{ my $es = "%"; my $os = "\\" . $es; if(($verb_on > 0) || ($_[0]->parent->name =~ /^(path|urlanch)$/)){ $os = $es; }; output($os); }); sgml('', ""); # Element: crt -- abstract char caret sgml('', sub{ my $es = "^"; my $pan = $_[0]->parent->name; my $os = "\\textasciicircum{}"; if(($verb_on > 0) || ($pan =~ /^(path|urlanch)$/)){ $os = $es; } elsif($pan =~ /^(quostr|qquostr|quochar|nln)$/){ $os = "\\string^"; } elsif($gmath_on == 1){ $os = "\\wedge"; }; output($os); }); sgml('', ""); # Element: amp -- abstract ampersand sgml('', sub{ my $es = "&"; my $os = "\\" . $es; if(($verb_on > 0) || ($_[0]->parent->name =~ /^(path|urlanch)$/)){ $os = $es; }; output($os); }); sgml('', ""); # Element: ast -- abstract asterisk sgml('', "*"); sgml('', ""); # Element: und -- abstract underscore sgml('', sub{ my $es = "_"; my $pan = $_[0]->parent->name; my $os = "\\" . $es; if(($verb_on > 0) || ($pan =~ /^(path|urlanch)$/)){ $os = $es; # } # elsif($pan =~ /^(quostr|qquostr|quochar|nln)$/){ # $os = "\\string_"; ## But why not just plain "\_" }; output($os); }); sgml('', ""); # Element: eqc -- abstract char "=" sgml('', "="); sgml('', ""); # Element: hyp -- abstract hyphen # In a math mode this could be either a subtraction (binary) or a # negation (unary). sgml('', "-"); # sgml('', sub{ # if($gmath_on == 1){output("\\, - \\,");} # else{output("-");} # }); sgml('', ""); # Element: plu -- abstract "+" # "+" is used with LaTeX "\verb+...+"; escape the "+" when in verb # by using Gellmu "\plu;". sgml('', sub{ my $os = ""; if($verb_on > 0){ $os = "+\\verb-+-\\verb+"; } elsif($gmath_on == 1){ $os = "\, + \,"; } else{ $os = "+"; } output($os); }); sgml('', ""); # Element: quo -- abstract version of the keyboard double quote '"' # This is normally not a character in a properly prepared LaTeX # file unless a representation of the keyboard char is wanted. sgml('', sub{ my $pan = $_[0]->parent->name; if ( ($inanchopt == 1) || ($pan eq "anchref") ){ output('"'); } elsif(($pan ne "verb") && ($pan ne "verbatim")){ output("\\texttt{\"}"); } else{ output('"'); } }); sgml('', ""); # Element: sol -- abstract "/" sgml('', "/"); sgml('', ""); # Element: lsq -- abstract left single quote sgml('', "`"); sgml('', ""); # Element: rsq -- abstract right single quote sgml('', "'"); sgml('', ""); # Element: ldq -- abstract left double quote sgml('', "``"); sgml('', ""); # Element: rdq -- abstract right double quote sgml('', "''"); sgml('', ""); # Element: lpr sgml('', "("); sgml('', ""); # Element: rpr sgml('', ")"); sgml('', ""); # Element: ltc -- outside of gmath, one probably wants this in either # verb, quostr, qquostr, or verbatim; we'll not force # this since some legacy LaTeX may use what just comes sgml('', sub{ my $pan = $_[0]->parent->name; my $os = "\\textless{}"; if($verb_on == 1){ $os = "<"; } elsif($gmath_on == 1){ $os = "<"; } elsif($pan =~ /^(quostr|qquostr|quochar|eaddr|email|nln)$/){ $os = "\\string<"; } elsif($pan =~ /^(path|urlanch)$/){ $os = "<"; }; output($os); }); # sgml('', "<"); sgml('', ""); # Element: gtc sgml('', sub{ my $pan = $_[0]->parent->name; my $os = "\\textgreater{}"; if($verb_on == 1){ $os = ">"; } elsif($gmath_on == 1){ $os = ">"; } elsif($pan =~ /^(quostr|qquostr|quochar|eaddr|email|nln)$/){ $os = "\\string>"; } elsif($pan =~ /^(path|urlanch)$/){ $os = ">"; }; output($os); }); # sgml('', ">"); sgml('', ""); # Element: cln sgml('', ":"); sgml('', ""); # Element: scl sgml('', ";"); sgml('', ""); # Element: per sgml('', "."); sgml('', ""); # Element: cma sgml('', ","); sgml('', ""); # Element: qum sgml('', "?"); sgml('', ""); # Element: nul -- place-holder for whole-line comments in the # original .glm; on the one hand, we want to preserve line number # alignment between the .glm and the .sgml for author sanity. # So if we do and if we allow "\n" to bleed through in PCDATA from # there, we need to ** mark the location of former comments for # target markups that think blank lines are significant ** . # # Do not use newlines here where PCDATA can appear at the top level. # (There's already a newline there, and we don't want to make a blank # line.) # sgml('', sub{ my $pan = $_[0]->parent->name; my $os = "%nul"; if(($pan eq "article")||($pan eq "preamble")||($pan eq "body")|| ($pan =~ /[Ss]ection/)){ $os = $os . "\n"; } output($os); }); sgml('', ""); # Element: cm0 -- place holder for end-of-line comments sgml('', sub{ my $pan = $_[0]->parent->name; my $os = "%cm0"; if(($pan eq "article")||($pan eq "preamble")||($pan eq "body")|| ($pan =~ /[Ss]ection/)){ $os = $os . "\n"; } output($os); }); sgml('', ""); # Element: cs0 -- place holder for end-of-line comments sgml('', sub{ my $pan = $_[0]->parent->name; my $os = " %cs0"; if(($pan eq "article")||($pan eq "preamble")||($pan eq "body")|| ($pan =~ /[Ss]ection/)){ $os = $os . "\n"; } output($os); }); sgml('', ""); # Element: cw0 -- place holder for end-of-line comments sgml('', sub{ my $pan = $_[0]->parent->name; my $os = " %cw0"; if(($pan eq "article")||($pan eq "preamble")||($pan eq "body")|| ($pan =~ /[Ss]ection/)){ $os = $os . "\n"; } output($os); }); sgml('', ""); # Element: ldots -- abstract "..." sgml('', "\\ldots{}"); sgml('', ""); # Element: nbs -- non-breaking space (LaTeX's "~") sgml('', "~"); sgml('', ""); # Element: hsf -- stretchy horizontal fill sgml('', "\\hsf "); # a macro defined above sgml('', ""); # Element: dotfill sgml('', "\\dotfill{}"); sgml('', ""); # Element: hrulefill sgml('', "\\hrulefill{}"); sgml('', ""); # Element: tld -- a tilde char as a string # There are subtleties. \textasciitilde does not work inside \url, but # "~" itself is OK there. \url is presently used for and # but not for . sgml('', sub{ my $es = "~"; my $pan = $_[0]->parent->name; my $os = "\\textasciitilde{}"; if(($verb_on > 0) || ($pan =~ /^(path|urlanch)$/)){ $os = $es; } elsif($pan =~ /^(quostr|qquostr|quochar|nln)$/){ $os = "\\string~"; } elsif ($gmath_on == 1){ $os = "\\sim{}"; }; output($os); }); sgml('', ""); # Element: spc -- styled regular blank space (maybe like LaTeX's "\ ") sgml('', sub{ my $os = "\\ "; my $pan = $_[0]->parent->name; if($verb_on > 0){ $os = " "; } elsif($pan =~ /^(path|urlanch)$/){ print STDERR "slidegart.pl WARNING: using %20 for blank in \\url\n"; $os = "\\%20"; }; output($os); }); sgml('', ""); # Element: hsp -- thinner regular blank space (maybe like LaTeX's "\,") sgml('', "\\,"); sgml('', ""); # Element: Hsp -- thinner regular blank space (maybe like LaTeX's "\,") # use where some positive space is absolutely required sgml('', "\\,"); sgml('', ""); # Element: abbr -- content is an abbreviation (maybe for smallcaps) sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output('string'); my $pan = $_[0]->parent->name; my $os = ""; if( ($pan eq "title") || ($pan eq "surtitle") || ($pan eq "subtitle") || ($pan eq "author") || ($pan eq "date") || ($pan =~ /[Ss].*ection/) || ($pan eq "term") || ($pan eq "shead")){ $os = $pos; } else{ $os = "\\textsc{" . $pos . "}"; }; output($os); }); # Element: softw -- content is a software name sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output('string'); my $pan = $_[0]->parent->name; my $os = ""; if( ($pan eq "title") || ($pan eq "surtitle") || ($pan eq "subtitle") || ($pan eq "author") || ($pan eq "date") || ($pan =~ /[Ss].*ection/) || ($pan eq "term") || ($pan eq "shead") ){ $os = $pos; } else{ $os = "\\textsl{" . $pos . "}"; }; output($os); }); # Element: latex sgml('', "\\LaTeX{}"); sgml('', ); # Element: tex sgml('', "\\TeX{}"); sgml('', ); # Element: texinfo sgml('', "\\textsl{Texinfo}"); sgml('', ); # Element: bold -- emboldened sgml('', "\\textbf{"); sgml('', "}"); # Element: emph -- lower case emphasized sgml('', "\\emph{"); sgml('', "}"); # Element: Emph -- Capitalized form of emph sgml('', "\\textsf{"); sgml('', "}"); # Element: EMPH -- upper case emphasized sgml('', "\\textbf{\\emph{"); sgml('', "}}"); # Element: emph* -- starred form of emph sgml('', "{\\em "); sgml('', "}"); # Element: invr -- abstract inverse video sgml('', "\\textsl{"); sgml('', "}"); # Element étale -- a French name sgml('<étale>', "\\textsl{"); sgml('', "}"); # Element: anch -- visible marked inline area -- cannot be nested sgml('', sub{ $inanch = 1; $anchref = ""; push_output('string'); }); sgml('', sub{ my $pan = $_[0]->parent->name; $inanch = 0; my $os = ""; my $pos=pop_output; my $hrs = ""; my $elt = $_[0]; my $alabel = ""; my $attsr = $elt->attributes; my %atts = %$attsr; if(exists $atts{"name"}){ if($elt->attribute(name)->value ne ""){ $alabel = $elt->attribute(name)->value; }; }; if(exists $atts{"href"}){ if($elt->attribute(href)->value ne ""){ $hrs = $hrs . ' href="' . $elt->attribute(href)->value . '" '; }; }; if($noanchorfootnote == 0){ if($haveanchopt == 1){ $hrs = $hrs . $anchopt; # reference information, e.g., href $haveanchopt = 0; } elsif($anchref ne ""){ # these days we should have: # $haveanchoropt == 0 # any ref info in $anchref $hrs = $hrs . $anchref; } else{ print STDERR "slidegart.pl: WARNING: \"anch\" has no", " reference.\n Looking at: \"", $pos, "\"\n"; }; }; # This next line could effect old docs: $hrs =~ s/^\s*//; # strip initial white space # And in the next two lines should I be using a marked RE? # (This code assumes only a single reference.) my $noFnote = 0; if($noanchorfootnote == 1){ $noFnote = 1; }; if($elt->attribute("noprinthref")->value ne ""){ $noFnote = 1; }; if($hrs =~ /^[Hi]ref\s*=/){ $noFnote = 1; } else{ # Clean $hrs up for use in footnote # Code here for $hrs was simply the next two lines: # $hrs =~ s/[fh]ref\s*=\s*\"//; # $hrs =~ s/\"\s*$//; # # Strip trailing white space prior to split on white space $trs = $hrs; $hrs = ""; $trs =~ s/\s*$//; # We have possibly (1) href=, (2) fref=, or (3) name= # my @har = (split(/\s/, $trs)); # No. This split does not work # if the value string has spaces in it. # foreach $subh (@har){ $subh = $trs; if($subh =~ /fref\s*=/){ # value is a straight footnote $subh =~ s/fref\s*=\s*\"//; $subh =~ s/\"\s*$//; } elsif($subh =~ /href\s*=/){ # value is web reference $subh =~ s/href\s*=\s*\"//; $subh =~ s/\"\s*$//; if($subh =~ /^\\\#/){ $subh =~ s/^\\\#//; $subh = "Reference to internal target with key: " . $subh; } else{ $subh = "URI: " . $subh; }; } elsif($subh =~ /name\s*=/){ # value is a label $subh =~ s/name\s*=\s*//; $subh = "Reference target for key: " . $subh; } if($hrs ne ""){ $subh = "\\\\{}" . $subh; }; $hrs = $hrs . $subh; # }; # End of foreach $subh (@har) }; my $act = $pos; # "visible" anchor content # HTML form: my $os = "" . $act . ""; # For print we have stripped the "href=" stuff out of $hrs if( ($noFnote == 1) || ($hrs eq "") ){ $os = $act; } elsif(($pan eq "term")||($pan eq "itemlabel")){ $termnoteseq++; $termnote[$termnoteseq] = "\\footnote{" . $hrs . "}"; $os = $act; } else{ $os = $act . "\\footnote{" . $hrs . "}"; }; output($os); }); # Element: footnote -- ordinary LaTeX-style footnote, regular content sgml('', sub{ my $elt = $_[0]; if($elt->within("preamble") ne ""){ $holdlatextitle = 1; }; push_output('string'); }); sgml('', sub{ my $pan = $_[0]->parent->name; my $pos = pop_output; if(($pan eq "term") || ($pan eq "itemlabel")){ $termnoteseq++; $termnote[$termnoteseq] = "\\footnote{" . $pos . "}"; } else{ my $os = "\\footnote{" . $pos . "}"; output($os); }; }); # Element: urlanch -- HTML-like anchor with visible = *absolute* URL sgml('', sub{ # $verb_on++; push_output('string'); }); sgml('', sub{ my $os = ""; my $pos = pop_output; # $verb_on--; if(length($pos) == 0){ $os = "[Location of empty URL-anchor]"; } else{ my $url = $pos; $url =~ s/^\s*//; $url =~ s/\s*$//; # $os = "\\verb|" . $url . "|"; # $os = "\\texttt{" . $url . "}"; # CAUTION: If the use of \url is reversed, then the code for # several of the non-printable ASCII chars needs to be changed. $os = "\\url{" . $url . "}"; }; output($os); }); # Element: urnanch -- Not supported here # Element: times -- explicit multiplicative operator sgml('', "\\times{}"); sgml('', ""); # Element: cdot -- explicit multiplicative operator sgml('', "\\cdot{}"); sgml('', ""); # Element: pm -- "either-plus-or-minus" binary operator (not associative) sgml('', "\\pm{}"); sgml('', ""); # Element: infty -- "infinity" symbol sgml('', "\\infty{}"); sgml('', ""); # Element: geq sgml('', "\\geq"); sgml('', ""); # Element: leq sgml('', "\\leq"); sgml('', ""); # Element: neq sgml('', "\\neq"); sgml('', ""); # # Default handlers (uncomment these if needed). Right now, these are set # up to gag on any unrecognised elements, sdata, processing-instructions, # or entities. # sgml('start_element', sub{ push_output('nul'); }); sgml('end_element',sub{ pop_output; my $nam = $_[0]->name; my $dos = "**ELT " . $nam . " DEL**"; my $os = $dos; if( ($nam eq "Gamma") || ($nam eq "Delta") || ($nam eq "Phi") || ($nam eq "Theta") || ($nam eq "Lambda") || ($nam eq "Pi") || ($nam eq "Sigma") || ($nam eq "Upsilon") || ($nam eq "Xi") || ($nam eq "Psi") || ($nam eq "Omega") || ($nam eq "alpha") || ($nam eq "beta") || ($nam eq "gamma") || ($nam eq "delta") || ($nam eq "epsilon") || ($nam eq "varepsilon") || ($nam eq "zeta") || ($nam eq "eta") || ($nam eq "theta") || ($nam eq "vartheta") || ($nam eq "iota") || ($nam eq "kappa") || ($nam eq "lambda") || ($nam eq "mu" || ($nam eq "nu") || ($nam eq "omicron") || ($nam eq "pi") || ($nam eq "varpi") || ($nam eq "rho") || ($nam eq "sigma") || ($nam eq "tau") || ($nam eq "upsilon") || ($nam eq "phi") || ($nam eq "varphi") || ($nam eq "chi") || ($nam eq "xi") || ($nam eq "psi") || ($nam eq "omega") ) ){ $os = "\\" . $nam . "{}"; } else{ $unknown_elements++; print {STDERR} "Unknown element: ", $_[0]->name, "\n"; }; output($os); }); sub on_gmath{ if($gmath_on == 1){ print {STDERR} "WARNING: Cannot enter math mode while in math mode.\n"; }; $gmath_on = 1; }; sub off_gmath{ if($gmath_on == 0){ print {STDERR} "WARNING: Cannot leave math mode if not in it.\n"; } $gmath_on = 0; }; sub on_imath{ $imath_on = 1; &on_gmath ; output ("\\("); }; sub off_imath{ output ("\\)"); &off_gmath ; $imath_on = 0; }; sub on_dmath{ $dmath_on = 1; &on_gmath ; output("\\["); }; sub off_dmath{ output("\\]"); &off_gmath ; $dmath_on = 0; }; # Separate out the "href =" part of an href and return the URL, # which *should* already be a quoted string, using \texttt sub parse_href{ # $ts =~ s/href += +// ; # $ts; 0; }; # Element: quochar sgml('', "\\texttt{`"); sgml('', "'}"); # Element: quostr sgml('', "\\texttt{"); sgml('', "}"); # Element: tée -- a French name sgml('', "\\texttt{"); sgml('', "}"); # Element: qquostr sgml('', "\\texttt{\""); sgml('', "\"}"); # Element: quophrase sgml('', '``'); sgml('', "''"); # Element: squophrase -- sgml('', '`'); sgml('', "'"); # Element: verbatim sgml('', sub{ $verb_on++; my $os = "\\begin{verbatim}\n"; output($os); }); # no newline after writing \end{verbatim} 19990707 sgml('', sub{ $verb_on--; my $os = "\n\\end{verbatim}"; output($os); }); # Element: verb # The use of GELLMU's \verb is deprecated. sgml('', sub{ $verb_on++; push_output('string'); }); sgml('', sub{ # my $mn = $_[0]->name; my $pan = $_[0]->parent->name; my $ts = pop_output; my $us = $ts; my $os = $us; if($verb_on == 1){ $us = "\\verb+" . $ts . "+"; $os = $us; if(($pan eq "quochar")||($pan eq "quostr")||($pan eq "qquostr")){ $os = "}" . $us . "\\texttt{"; }; }; output($os); # output($os . ""); $verb_on--; }); # Element: hrule sgml('', sub{ my $hsp = "\\hspace*{\\fill}"; my $ms = "\\medskip\n"; my $os = "\n\n" . $ms; $os = $os . $hsp . "\\rule[1bp]{0.8\\linewidth}{0.3bp}" . $hsp . "\n"; $os = $os . $ms; output($os); }); sgml('', ""); # Element: brk -- forced linebreak sgml('', sub{ my $pan = $_[0]->parent->name; my $tdn = 0; my $jj = 0; my $os = " \\\\{}"; # my $ds = "%% Parent: " . $pan . " tabdepth: " . $tabdepth; # $ds = $ds . "\n"; # output($ds); if(($tabdepth == 1) && (($pan eq "td") || ($pan eq "tdc"))){ # $ds = "%% tdcount: " . $tdcount[$tabdepth]; if($tdcount[$tabdepth] > 1){ $tdn = $tdcount[$tabdepth] - 1; }; # $ds = $ds . " tdn: " . $tdn . "\n"; # output($ds); for($jj = 0; $jj < $tdn; $jj++){$os = $os . "& ";}; }; output($os); }); sgml('', ""); # Element: brs -- LaTeX-like suggested line break, strength 3 sgml('', "\\linebreak[3]"); sgml('' , ""); # Element: rdash sgml('', "--"); sgml('', ""); # Element: pdash sgml('', "---"); sgml('', ""); # Element: i -- dotless `i' (and NOT "italic", as in HTML) sgml('', "\\i{}"); sgml('', ""); # Element: j -- dotless `j' sgml('', "\\j{}"); sgml('', ""); # Element: cedil sgml('', "\\c{"); sgml('', "}"); # Element: umlau sgml('', "\\\"{"); sgml('', "}"); # Element: acute sgml('', "\\'{"); sgml('', "}"); # Element: grave sgml('', "\\`{"); sgml('', "}"); # Element: ovhat sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\^{" . $pos . "}"; if($gmath_on == 1){ $os = "\\hat{" . $pos . "}"; }; output($os); }); sgml('', "\\^{"); sgml('', "}"); # Element: tilde sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\~{" . $pos . "}"; if($gmath_on == 1){ $os = "\\tilde{" . $pos . "}"; }; output($os); }); # Hmmm ... we should make a function set_math_sym # See the handling of 'end_element' # Element: oalpha sgml('', sub{ if($gmath_on == 1){ output("\\alpha "); } else{ output("\$\\,\\alpha\\,\$"); } }); sgml('', ""); # See the handling of 'end_element' # Element: oGamma sgml('', sub{ if($gmath_on == 1){ output("\\Gamma "); } else{ output("\$\\,\\Gamma\\,\$"); } }); sgml('', ""); # Element: bal sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; my $pre = "("; my $post = ")"; if($gmath_on == 1){ $pre = "\\left("; $post = "\\right)"; }; $os = $pre . $pos . $post; output($os); }); # Element: balbr sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; my $pre = "\\{"; my $post = "\\}"; if($gmath_on == 1){ $pre = "\\left\\{"; $post = "\\right\\}"; }; $os = $pre . $pos . $post; output($os); }); # Element: balsb sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; my $pre = "["; my $post = "]"; if($gmath_on == 1){ $pre = "\\left["; $post = "\\right]"; }; $os = $pre . $pos . $post; output($os); }); # Element: balab sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; my $pre = "<"; my $post = ">"; if($gmath_on == 1){ $pre = "\\left<"; $post = "\\right>"; }; $os = $pre . $pos . $post; output($os); }); # Element: balvbr sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; my $pre = "|"; my $post = "|"; if($gmath_on == 1){ $pre = "\\left|"; $post = "\\right|"; }; $os = $pre . $pos . $post; output($os); }); # Element: lbalbr sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; my $pre = "\\{"; my $post = "\\}"; if($gmath_on == 1){ $pre = "\\left\\{"; $post = "\\right."; }; $os = $pre . $pos . $post; output($os); }); # Element: func sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; if($gmath_on == 1){ $os = "\\" . $pos; } else{ $os = "\\emph{" . $pos . "}"; }; output($os); }); # Element: doctop sgml('', ""); sgml('', ""); # Element: notitle sgml('', sub{ $notitle = 1; }); sgml('', ""); # Element: surtitle -- motivated by NetScape's border title sgml('', sub{ push_output('string'); }); sgml('', sub{ $surtitle = pop_output; }); # Element: latexcommand -- for direct verbatim passage sgml('', sub{ $verb_on++; if($gmath_on == 1){ $gmath_was_on = 1; $gmath_on = 0; }; push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; $os = $pos . "\n"; $verb_on--; if($gmath_was_on == 1){ $gmath_on = 1; $gmath_was_on = 0; }; output($os); }); # Element: abstract sgml('', "\\begin{abstract}\n"); sgml('', "\\end{abstract}\n"); # Element: copyright sgml('', "\\copyright{}"); sgml('', ""); # Element: pounds sgml('', "\\pounds{}"); sgml('', ""); # Element: defnlist sgml('', "\\begin{description}\n"); sgml('', "\\end{description}"); # Element: citations sgml('', "\\begin{citations}\n"); sgml('', "\\end{citations}"); # Element: term sgml('', sub{ $termnoteseq = 0; push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; my $os = ""; if($pan eq "defnlist"){ $os = "\\item[{" . $pos . "}]"; $jj = 1; while($jj <= $termnoteseq){ $os = $os . $termnote[$jj]; $jj++; }; $os = $os . "\n"; } else{ $os = "\\item " . $pos. "\n"; } output($os); }); # Element: desc sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; my $os = ""; my $ln = length($pos); if($pan eq "defnlist"){ $os = "{" . $pos . "}\n"; output($os); } else{ if($ln > 0){ $os = "\\\\{} " . $pos . "\n"; output($os); }; } }); # Element: menu sgml('', "\\begin{menulist}\n"); sgml('', "\\end{menulist}"); # Element: Menu sgml('', "\\begin{Menulist}\n"); sgml('', "\\end{Menulist}"); # Element parlist sgml('', "\n\n"); sgml('', ""); # Element: label sgml('', sub{ my $pos = pop_output; my $lid = ""; my $os = ""; my $lseq = ""; my $pan = $_[0]->parent->name; if($pan eq "biblabel"){ return; } elsif($pan eq "eqnrow"){ $eqrkey = $pos; return; }; if($pos ne ""){ $lid = $pos; $lastlabelkey = $pos; } else{ $lseq = $_[0]->attribute("lseq")->value; if($lseq ne ""){ $lid = "label-" . $lseq; }; }; if($lid ne ""){ $os = "\\label{" . $lid . "}"; output($os); }; }); # Element: klabel -- Visible key label sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\label{" . $pos . "}[" . $pos ."]"; output($os); }); # Element: ref sgml('', sub{ push_output('string'); }); sgml('', sub{ my $key = pop_output; my $os = ""; $os = "\\ref{" . $key . "}"; # hit or miss reliance on LaTeX is default # Look in %labelinfo for a series # Perhaps we could think about a way to create a LaTeX aux file when # the XML is made so that here we could simply use the key if($labelsers{$key} ne ""){ $os = $labelserseqs{$key}; } elsif($labelsecunits{$key} ne ""){ $os = $labelsecunits{$key}; } elsif($labelsids{$key} ne ""){ $os = $labelsids{$key}; } # Looks as if the LaTeX default is entirely pre-empted else{ print STDERR "slidegart.pl -- ref key may not match label: \"$key\"\n"; }; output($os); }); # Element: pageref sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\pageref{" . $pos . "}"; output($os); }); sub custom_title{ my $os = ""; if($arttitle ne ""){ $os = $os . "\\begin{center}\\LARGE\\bf\n"; $os = $os . $arttitle . "\n"; $os = $os . "\\end{center}\n"; }; if($artsubtitle ne ""){ $os = $os . "\\begin{center}\\large\\bf\n"; $os = $os . $artsubtitle . "\n"; $os = $os . "\\end{center}\n"; }; if ($haveauthor == 1){ my $jaut = 1; my $jem = 0; while($jaut <= $auth_ser){ my $jemail = $haveemail[$jaut]; $os = $os . "\\begin{center}\\Large\\bf\n"; $os = $os . "\\textsl{" . $artauthor[$jaut] . "}\n"; $os = $os . "\\end{center}\n"; if (($haveaddr[$jaut] > 0)&&($auth_addr[$jaut] ne "")){ $os = $os . "\\begin{center}\\large\n"; $os = $os . $auth_addr[$jaut] . "\n"; $os = $os . "\\end{center}\n"; } if($jemail == 1){ $os = $os . "\\begin{center}\n"; $os = $os . "Email: \\verb|" . $AuthEmail[$jaut][$jemail] . "|\n"; $os = $os . "\\end{center}\n"; }; if($jemail > 1){ $os = $os . "\\begin{center}"; $jem = 1; while($jem <= $jemail){ $os = $os . "\n\\verb|" . $AuthEmail[$jaut][$jem] . "|\\\\{}"; $jem++; }; $os = $os. "\\end{center}\n"; }; # if (($haveemail[$jaut] > 0)&&($auth_email[$jaut] ne "")){ # $os = $os . "\\begin{center}\n"; # $os = $os . $auth_email[$jaut] . "\n"; # $os = $os . "\\end{center}\n"; # } $jaut++; } # end of while $jaut <= $auth_ser } if ($havedate == 1){ $os = $os . "\\begin{center}\n\\large\\bf\n"; $os = $os . $artdate . "\n"; $os = $os . "\\end{center}\n"; } if($copynotice ne ""){ $os = $os . "\\begin{center}\n\\normalsize\\bf\n"; $os = $os . $copynotice . "\n"; $os = $os . "\\end{center}\n"; }; if ($markdraft == 1){ $os = $os . draft_label(); } return $os; }; sub compact_title{ my $os = ""; $os = $os . "\\begin{center}\n"; $os = $os . "{\\LARGE\\bf " . $arttitle . "}\n"; if($artsubtitle ne ""){ $os = $os . "\\\\\\hsf\\\\{\\large\\bf " . $artsubtitle . "}\n"; }; if ($haveauthor == 1){ my $jaut = 1; while($jaut <= $auth_ser){ $os = $os . "\\\\\\hsf\\\\[\\partopsep]{\\Large\\bf \\textsl{" . $artauthor[$jaut] . "}}\n"; if (($haveaddr[$jaut] > 0)&&($auth_addr[$jaut] ne "")){ $os = $os . "\\\\\\hsf\\\\[\\partopsep]{\\large " . $auth_addr[$jaut] . "\n"; } my $jemail = $haveemail[$jaut]; if($jemail > 0){ $jem = 1; $os = $os . "\\hsf\\\\[\\partopsep]\n"; while($jem <= $jemail){ $os = $os . "\\verb|" . $AuthEmail[$jaut][$jem] . "|"; if($jem < $jemail){ $os = $os . "\\\\{}\n"; }; $jem++; } $os = $os . "}\n"; }; # if (($haveemail[$jaut] > 0)&&($auth_email[$jaut] ne "")){ # $os = $os . "\\\\[\\partopsep]" . $auth_email[$jaut] . "}\n"; # } $jaut++; }; # end of while $jaut <= $auth_ser }; if ($havedate == 1){ $os = $os . "\\\\\\hsf\\\\[\\partopsep]{\\large\\bf " . $artdate . "}\n"; }; if ($copynotice ne ""){ $os = $os . "\\\\\\hsf\\\\[\\partopsep]{\\normalsize\\bf " . $copynotice . "}\n"; }; if ($markdraft == 1){ $os = $os . "\\\\\\hsf\\\\[\\partopsep]{\\small\\bf D R A F T }\n"; } $os = $os . "\\end{center}\n"; $os = $os . "\\vspace*{-\\centerskip}\n"; return $os; }; sub custom_lengths{ my $os = ""; # I don't like to waste paper. # I normally don't indent paragraphs since it's pass\'e, but # doing so here may ferret out lousy paragraph setting. $os = $os . "\\setlength{\\parindent}{6bp}\n"; $os = $os . "\\setlength{\\topmargin}{0bp}\n"; $os = $os . "\\setlength{\\headheight}{0bp}\n"; $os = $os . "\\setlength{\\headsep}{0bp}\n"; $os = $os . "\\setlength{\\oddsidemargin}{23bp}\n"; $os = $os . "\\setlength{\\evensidemargin}{23bp}\n"; $os = $os . "\\setlength{\\textwidth}{422bp}\n"; $os = $os . "\\setlength{\\textheight}{612bp}\n"; $os = $os . "\\setlength{\\parskip}{6bp}\n"; $os = $os . "\\thispagestyle{empty}\n"; return $os; }; sub draft_label{ my $os = ""; if ($compacttitle == 0){ $os = "\\begin{center}\\small\\bf\n"; $os = $os . "D R A F T\n"; $os = $os . "\\end{center}\n"; $os = $os . "\\medskip\n"; return $os; } }; # Element: partial -- partial differentiation "d" symbol sgml('', "\\partial{}"); sgml('', ""); # Element: pmod -- as in "\pmod{m}" for "(mod m)" sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\pmod{" . $pos . "}"; output($os); }); # Element: bmod -- as in "a \mod m" for "a mod m" sgml('', "\\bmod{}"); sgml('', ""); # Element: equiv -- LaTeX "equiv" symbol sgml('', "\\equiv{}"); sgml('', ""); # Element: sim -- LaTeX "sim" symbol sgml('', "\\sim{}"); sgml('', ""); # Element: cong -- LaTeX "cong" symbol sgml('', "\\cong{}"); sgml('', ""); # Element: eaddr -- content is an email address sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; my $os = ""; if(($pan eq "address")||($pan eq "author")){ $os = "\\texttt{" . $pos . "}"; } else{ $os = "\\verb|" . $pos . "|"; }; output($os); }); # Element: cslaa -- LaTeX's \aa sgml('', "\\aa{}"); sgml('', ""); # Element: csll -- LaTeX's \l sgml('', "\\l{}"); sgml('', ""); # Element: nabla -- gradient symbol sgml('', "\\nabla{}"); sgml('', ""); # Element: ovbar -- over-bar accent sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\={" . $pos . "}"; if($gmath_on == 1){ $os = "\\bar{" . $pos . "}"; }; output($os); }); # Element: secnumdepth -- depth of the least significant sectional unit # that is to be numbered sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; $secnumdepth = $pos; # This next line needs to be moved if the default value of $secnumdepth # at the top of this file is to be other than LaTeX's default (3) # my $os = "\\setcounter{secnumdepth}{" . $secnumdepth . "}\n"; # output($os); }); # Element: circ -- LaTeX circ as with composition of functions sgml('', "\\circ{}"); sgml('', ""); # Element: rightarrow -- LaTeX rightarrow sgml('', "\\rightarrow{}"); sgml('', ""); # Element: longrightarrow -- LaTeX longrightarrow sgml('', "\\longrightarrow{}"); sgml('', ""); # Element: leftarrow -- LaTeX leftarrow sgml('', "\\leftarrow{}"); sgml('', ""); # Element: longleftarrow -- LaTeX longleftarrow sgml('', "\\longleftarrow{}"); sgml('', ""); # Element: noanchorfootnote sgml('', sub{ $noanchorfootnote = 1; }); sgml('', ""); # Element: wedge -- LaTeX wedge sgml('', "\\wedge{}"); sgml('', ""); # Element: otimes -- LaTeX otimes (tensor product math symbol) sgml('', "\\otimes{}"); sgml('', ""); # Element: in -- LaTeX in (math set membership symbol) sgml('', "\\in{}"); sgml('', ""); # Element: not -- LaTeX in (math set not-a-member-of symbol) sgml('', "\\not{}"); sgml('', ""); # Element: lg0 -- brace-delimited logical group sgml('', "{"); sgml('', "}"); # Element: norm -- math norm sgml('', "\\left|\\left|"); sgml('', "\\right|\\right|"); # Element: absval -- math absolute value sgml('', "\\left|"); sgml('', "\\right|"); # Element: vdots -- LaTeX-like vdots (in math) sgml('', "\\vdots{}"); sgml('', ""); # Element: mapsto -- LaTeX name sgml('', " \\mapsto{}"); sgml('', ""); # Element: longmapsto -- LaTeX name sgml('', " \\longmapsto{}"); sgml('', ""); # Element: angle -- LaTeX name sgml('', " \\angle{}"); sgml('', ""); # Element: perp -- LaTeX name sgml('', " \\perp{}"); sgml('', ""); # Element: ssec -- LaTeX name sgml('', "\\S{}"); sgml('', ""); # Element: feed sgml('', "\\pagebreak\n"); sgml('', ""); # Element: bref sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\ p. \\pageref{" . $pos . "}"; output($os); }); # Element: kref sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "[" . $pos . "]"; output($os); }); # Element: cap -- e.g., the symbol for intersection of sets sgml('', "\\cap{}"); sgml('', ""); # Element: cup -- e.g., the symbol for union of sets sgml('', "\\cup{}"); sgml('', ""); # Element: subseteq sgml('', "\\subseteq{}"); sgml('', ""); # Element: parallel sgml('', "\\parallel{}"); sgml('', ""); # Element: bullet sgml('', "\\bullet{}"); sgml('', ""); # Element: langle sgml('', "\\langle{}"); sgml('', ""); # Element: rangle sgml('', "\\rangle{}"); sgml('', ""); # Element: iseq -- item label for inline list sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = " " . $pos . " "; output($os); }); # Element: slnt -- "slanted" emphasis sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\textsl{" . $pos . "}"; output($os); }); # Element: kcite -- citation with key = visible label sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; # my $os = "\\cite[" . $pos . "]{" . $pos . "}"; my $os = "\\cite{" . $pos . "}"; output($os); }); ### sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; # my $os = "{" . $pos . "}"; $thiscitekey = $pos; }); sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; # my $os = "\[" . $pos . "\]"; $thiscitenote = $pos; }); ### # Element: citekey -- citation with key = visible label sgml('', sub{ push_output('string'); }); sgml('', sub{ $thiscitekey = pop_output; }); # Element: citenote sgml('', sub{ push_output('string'); }); sgml('', sub{ $thiscitenote = pop_output; }); # Element: citetext sgml('', sub{ push_output('string'); }); sgml('', sub{ $thiscitetext = pop_output; }); # Element: cite sgml('', sub{ $thiscitenote = ""; $thiscitekey = ""; $thiscitetext = ""; push_output('string'); }); sgml('', sub{ my $pos = pop_output; if($pos ne ""){ print STDERR "slidegart.pl WARNING: loose output in \n"; }; my $os = "\\cite"; if($thiscitenote ne ""){ $os = $os . "\[{" . $thiscitenote . "}\]"; }; $os = $os . "{" . $thiscitekey . "}"; output($os); }); # Element: ovvee -- citation with key = visible label sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\v{" . $pos . "}"; if($gmath_on == 1){ $os = "\\check{" . $pos . "}"; }; output($os); }); sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\v{" . $pos . "}"; output($os); }); # Element: thebibliography -- citation with key = visible label sgml('', "\\begin{thebibliography}{MM}\n"); sgml('', "\\end{thebibliography}\n"); # Element: bibentry sgml('', ""); sgml('', ""); # Element: bibhead sgml('', sub{ $biblabel = ""; $bibkey = ""; push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\bibitem"; if ($biblabel ne ""){ $os = $os . "\[{" . $biblabel . "}\]"; }; $os = $os . "{" . $bibkey . "}" . $pos; $os = $os . "\n"; output($os); }); # Element: biblabel sgml('', sub{ push_output('string'); }); sgml('', sub{ $biblabel = pop_output; }); # Element: bibkey sgml('', sub{ push_output('string'); }); sgml('', sub{ $bibkey = pop_output; }); # Element: bibbody sgml('', ""); sgml('', ""); # Element: vbibitem -- citation with key = visible label sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\bibitem[" . $pos . "]{" . $pos . "}\n"; output($os); }); # Element: hy0 -- hyphenation hint sgml('', "\\-"); sgml('', ""); # Element: binom sgml('', sub{ $binargid = 0; push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; if ($binargid != 2){ print STDERR "Code Error: binom does not have 2 arguments.\n"; exit; }; $os = " \\mbox{binom}($binomu, $binoml) "; output($os); }); # Element: equation sgml('', sub{ push_output('string'); $emath_on = 1; &on_gmath; $eqnkey = ""; output("\\begin{gather*}\n"); }); sgml('', sub{ &off_gmath; $emath_on = 0; my $pos = pop_output; my $os = $pos; $os = $os . "\n\\end{gather*}"; output($os); }); # Element: numr sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; $numr[$fracdepth] = $pos; }); # Element: denm sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; $denm[$fracdepth] = $pos; }); # Element: anchref sgml('', sub{ push_output('string'); }); sgml('', sub{ $anchref = pop_output; }); # Element: anchv sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; output($pos); }); # Element: lgg sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "{" . $pos . "}"; output($os); }); # Element: msub sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "_{" . $pos . "}"; output($os); }); # Element: msup sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "^{" . $pos . "}"; output($os); }); # Element: pow sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "^{" . $pos . "}"; output($os); }); # Element: sarg sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "_{" . $pos . "}"; output($os); }); # Element: plus sgml('', "+"); sgml('', ""); # Element: minus sgml('', "-"); sgml('', ""); # Element: quotient sgml('', "/"); sgml('', ""); # Element: equals sgml('', sub{ my $pan = $_[0]->parent->name; if( (($dmath_on == 1) || ($emath_on == 1)) && (inanchopt ==0) && ($pan ne "anchref") && ($pan ne "msub") && ($pan ne "msup")){ output("\\ = \\ "); } elsif(($imath_on == 1) && (inanchopt == 0) && ($pan ne "anchref") && ($pan ne "msub") && ($pan ne "msup")){ output("\\, = \\,"); } else{ output("="); }; }); sgml('', ""); # Element neg -- unary negation (math) sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "-{" . $pos . "}"; output($os); }); # Element: radicand sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; if ($sqrtdepth > 0){ $radicand[$sqrtdepth] = $pos; } else{ print STDERR "slidegart.pl: ERROR (radicand) sqrtdepth not positive in", $pan, "\n"; }; }); # Element: radx sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $pan = $_[0]->parent->name; if ($sqrtdepth > 0){ $radx[$sqrtdepth] = $pos; } else{ print STDERR "slidegart.pl: ERROR (radx) sqrtdepth not positive in", $pan, "\n"; }; }); # Element: path -- a filesystem pathname # sgml('', "\\texttt{"); sgml('', "\\url{"); sgml('', "}"); # Element: dummy -- replaceable part of code sgml('', "\\emph{\$\\langle\$"); sgml('', "\$\\rangle\$}"); # Element: csss -- LaTeX's \ss (lowercase German ss) sgml('', "\\ss{}"); sgml('', ""); # Element: cslae -- LaTeX's \ae (lower case ae ligature) sgml('', "\\ae{}"); sgml('', ""); # Element: csuae -- LaTeX's \AE (upper case ae ligature) sgml('', "\\AE{}"); sgml('', ""); # Element: legalnotice sgml('', "\\begin{center}\\large\\textbf{Permission}\\end{center}\n"); sgml('', "\n"); # Element: citetitle -- an external title citation sgml('', "\\emph{"); sgml('', "}"); # Element: boq -- beginning of question mark sgml('', ">"); sgml('', ""); # Element: Sym -- declared math symbol wrapper sgml('', ""); sgml('', ""); # Element: mathsym -- markup for declaring math symbol sgml('', sub{ push_output('nul'); }); sgml('', sub{ pop_output; }); # Element: TableOfContents sgml('', sub{ my $os = "\\section*{Table of Contents}\n\\begin{Toclist}\n"; output($os); $currtocdepth = 0; }); sgml('', sub{ my $os = ""; while($currtocdepth > 1){ $os = $os . "\\end{toclist}\n"; $currtocdepth--; } $os = $os . "\\end{Toclist}\n"; output($os); }); # Element: tocitem sgml('', sub{ my $elt = $_[0]; my $depth = $elt->attribute("depth")->value; my $diff = $currtocdepth - $depth; my $os = ""; if($depth <= 0){ print STDERR "slidegart.pl WARNING: Attribute \"depth\" of\n", " \"tocitem\" is not positive, element seq. $eltser \n"; return; }; if($depth == $currtocdepth){ # No change in menu level $os = "\\item\["; # Close old and open new item in same menu } elsif($diff < 0){ # Need to subdivide menu if($diff != -1){ print STDERR "slidegart.pl WARNING: Cannot descend more than one section", "\n level at a time -- elt. ", $_[0]->name, "seq. $eltser \n"; return; } else{ # Begin new menu -- no item to close $currtocdepth++; if($depth == 1){ # first item in ToC, Toclist already open $os = "\\item\["; } else{ # use toclist (leaving previous item open) $os = "\\begin{toclist}\\normalsize\n\\item\["; }; }; } else{ # $diff > 0 -- Need to go back up before opening current item while($diff > 0){ # Because there's a new item this cannot be the end # of the level 1 Toclist # Close last item and the toclist $os = $os . "\\end{toclist}\n"; $currtocdepth--; $diff--; }; # Open current item $os = $os . "\\item\["; }; output($os); push_output('string'); }); sgml('', sub{ my $pos = pop_output; # Maybe it's better not to use an item label my $os = "\]{" . $tocunit . "\\ \\ " . $tocentry . "}\n"; output($os); }); # Element: tocunitlength sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; $tocunitlength = $pos; }); # Element: tocunit sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my @tunitarray = split(/\./, $pos); my $len = scalar @tunitarray; my $tcu = $pos; if(($tocunitlength > 0) && ($len > $tocunitlength)){ while($len > $tocunitlength){ shift @tunitarray; $len--; }; $tcu = join(".", @tunitarray); }; $tcu = $tcu . ""; $tocunit = $tcu; }); # Element: tocentry sgml('', sub{ push_output('string'); }); sgml('', sub{ $tocentry = pop_output; }); # Element: tocdepth sgml('', sub{ push_output('string'); }); sgml('', sub{ $tocdepth = pop_output; }); # Element: sprefix sgml('', sub{ push_output('string'); }); sgml('', sub{ $sprefix = pop_output; }); # Element: sunit sgml('', sub{ $sunitflag = 1; push_output('string'); }); sgml('', sub{ $sunit = pop_output; }); # Element series sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; my $typeatt = $_[0]->attribute("type")->value; if(($pos =~ /[1-9][0-9]?/) && ($pos < 30)){ if($typeatt eq "A"){ $os = $Alphabetic[$pos]; } elsif($typeatt eq "a"){ $os = $alphabetic[$pos]; } elsif($typeatt eq "I"){ $os = $Roman[$pos]; } elsif($typeatt eq "i"){ $os = $roman[$pos]; } else{ $os = $pos; }; } else{ print STDERR "slidegart.pl: Cannot perform series conversion on \"", $pos, "\"\n"; $os = $pos; }; output($os); }); # Element logo sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\" . $pos . "{}"; output($os); }); # Element insas sgml('', ""); sgml('', ""); # Element booklist sgml('', "\\begin{citations}"); sgml('', "\\end{citations}"); # Element description sgml('', "\\begin{description}\n"); sgml('', "\\end{description}"); # Element ditem sgml('', "\\item"); sgml('', ""); # Element itemlabel sgml('', sub{ push_output('string'); $termnoteseq = 0; }); sgml('', sub{ my $pos = pop_output; my $par = $_[0]->parent; my $pan = $par->name; my $gpan = $par->parent->name; my $os = "[{" . $pos . "}]"; if($gpan eq "booklist"){ $os = "[{\\textsl{" . $pos . "}}]"; }; $jj = 1; while($jj <= $termnoteseq){ $os = $os . $termnote[$jj]; $jj++; }; if($gpan eq "booklist"){ $os = $os . "\n\\ "; } else{ $os = $os . "\n"; }; output($os); }); # Element itembody sgml('', " "); sgml('', ""); # Element addr sgml('', "\\begin{menulist}\n"); sgml('', "\\end{menulist}"); # Element aln sgml('', "\\item\\ "); sgml('', "\n"); # Element verblist sgml('', "\\begin{menulist}\n"); sgml('', "\\end{menulist}"); # Element nln sgml('', "\\item\\texttt{"); sgml('', "}\n"); # Element: acc0 -- for cloning accent code sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\X{" . $pos . "}"; if($gmath_on == 1){ $os = "\\Y{" . $pos . "}"; }; output($os); }); # Element: ovdot -- over-dot accent sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\.{" . $pos . "}"; if($gmath_on == 1){ $os = "\\dot{" . $pos . "}"; }; output($os); }); # Element: overline -- overline as in LaTeX sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\overline{" . $pos . "}"; output($os); }); # Element: underline -- underline as in LaTeX sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\underline{" . $pos . "}"; output($os); }); # Element: overbrace -- overbrace as in LaTeX sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\overbrace{" . $pos . "}"; output($os); }); # Element: underbrace -- underbrace as in LaTeX sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = "\\underbrace{" . $pos . "}"; output($os); }); # Element empty sgml('', " "); sgml('', ""); # Element assertion sgml('', "\\begin{trivlist}\n\\item "); sgml('', "\\end{trivlist}\n"); # Element assthead sgml('', sub{ push_output('string'); }); sgml('', sub{ my $pos=pop_output; my $os; if($asstname =~ /^\s*$/){ $os = ""; } elsif($asstid =~ /^\s*$/){ $os = "\\textbf{" . $asstname . ".}\\ "; } else{ $os = "\\textbf{" . $asstname . "~" . $asstid . ".}\\ "; }; output($os); }); # Element asstbody sgml('', "\\begin{em}\n"); sgml('', "\\end{em}\n"); # Element asstkey sgml('', sub{ push_output('string'); }); sgml('', sub{ $asstkey = pop_output; }); # Element asstser sgml('', sub{ push_output('string'); }); sgml('', sub{ $asstser = pop_output; }); # Element asstname sgml('', sub{ push_output('string'); }); sgml('', sub{ $asstname = pop_output; }); # Element asstid sgml('', sub{ push_output('string'); }); sgml('', sub{ $asstid = pop_output; }); # Element eqnline -- content of equation after eqnkey, eqnser sgml('', sub{ my $os = ""; my $nonum = 0; my $par = $_[0]->parent; if($par->attribute("nonum")->value eq "true"){ $nonum = 1; }; # This is the better way: if(($eqnkey ne "") && ($labelsers{$eqnkey} ne "")){ $os = $os . "\\tag{" . $labelserseqs{$eqnkey} . "} "; } # or the old way: elsif(($lastlabelkey ne "") && ($labelsers{$lastlabelkey}) && !($nonum)){ $os = $os . "\\tag{" . $labelserseqs{$lastlabelkey} . "} "; }; output($os); }); sgml('', ""); # Element eqnarray -- content of equation after eqnkey, eqnser sgml('', sub{ my $os = ""; $emath_on = 1; &on_gmath; $eqnkey = ""; $eqnamode = 0; my $mode = $_[0]->attribute("mode")->value; if($mode > 0){$eqnamode = $mode;}; if($eqnamode > 1){ $os = $os . "\\begin{gather*}\n"; } else{ $os = $os . "\\begin{align*}\n"; }; output($os); }); sgml('', sub{ my $os = ""; if($eqnamode > 1){ $os = $os . "\\end{gather*}"; } else{ $os = $os . "\\end{align*}"; }; $emath_on = 0; &off_gmath; output($os); }); # Element eqnkey -- content of equation after eqnkey, eqnser sgml('', sub{ push_output('string'); }); sgml('', sub{ $eqnkey = pop_output; }); # Element eqnser -- content of equation after eqnkey, eqnser sgml('', sub{ push_output('nul'); }); sgml('', sub{ pop_output; }); # Element eqnabody -- content of equation after eqnkey, eqnser sgml('', sub{ $eqnarowseq = 0; my $os = ""; if($eqnamode > 1){ if($eqnkey ne ""){ my $tag = 0; $tag = $labelserseqs{$eqnkey}; if($tag > 0){ $os = $os . "\\tag{" . $tag . "} "; } else{ print STDERR "slidegart.pl WARNING: No series value for\n", " eqnarray key ", $eqnkey, " eqseq=", $_[0]->parent->attribute("eqseq")->value, "\n"; }; } else{ print STDERR "slidegart.pl WARNING: No key for eqnarray\n", " with mode ", $eqnamode, " eqseq=", $_[0]->parent->attribute("eqseq")->value, "\n"; }; $os = $os . "\\begin{aligned}\n"; output($os); }; }); sgml('', sub{ if($eqnamode > 1){ output("\\end{aligned}"); }; }); # Element eqnrow -- content of equation after eqnkey, eqnser sgml('', sub{ $eqrkey = ""; $eqnarowseq++; my $os = ""; if($eqnarowseq > 1){ $os = $os . "\\\\ {}"; }; output($os); push_output('string'); }); sgml('', sub{ my $pos = pop_output; my $os = ""; my $tag = 0; if($eqrkey ne ""){ $tag = $labelserseqs{$eqrkey}; if($tag > 0){ $os = $os . "\\tag{" . $tag . "}\\label{" . $eqrkey . "} "; }; }; $os = $os . $pos; output($os); }); # Element eqnleft -- content of equation after eqnkey, eqnser sgml('', ""); sgml('', ""); # Element eqncenter -- content of equation after eqnkey, eqnser sgml('', " & "); sgml('', ""); # Element eqnright -- content of equation after eqnkey, eqnser sgml('', ""); sgml('', "\n"); # Element mathbb sgml('', "\\mathbb{"); sgml('', "}"); # Element mathcal sgml('', "\\mathcal{"); sgml('', "}"); # Element mathfrak sgml('', "\\mathfrak{"); sgml('', "}"); # Element apos sgml('', "'"); sgml('', ""); # Element array sgml('', sub{ $tabdepth++; output("\\begin{array}"); }); sgml('', sub{ output("\\end{array}"); $tabdepth--; }); # Element arrhead sgml('', sub{ $tabopt[$tabdepth] = ""; $tabarg[$tabdepth] = ""; push_output('string'); }); sgml('', sub{ pop_output; my $os = ""; if($tabopt[$tabdepth] ne ""){ $os = $os . "[" . $tabopt[$tabdepth] . "]"; }; $os = $os . "{" . $tabarg[$tabdepth] . "}"; $os = $os . "\n"; output($os); }); # Element arrpos sgml('', sub{ push_output('string'); }); sgml('', sub{ $tabopt[$tabdepth] = pop_output; }); # Element arrcols sgml('', sub{ push_output('string'); }); sgml('', sub{ $tabarg[$tabdepth] = pop_output; }); # Element arrbody sgml('', sub{ $trcount[$tabdepth] = 0; }); sgml('', ""); # Element arrayrow sgml('', sub{ $trcount[$tabdepth]++; if($trcount[$tabdepth] > 1){ output("\\\\{}\n"); }; }); sgml('', ""); # Element firstacell sgml('', ""); sgml('', ""); # Element arraycell sgml('', sub{ output("& "); }); sgml('', ""); # General table processing routines -- under construction sub on_table{ $tabser++; $tabdepth++; $trcount[$tabdepth] = 0; $trulecount[$tabdepth] = 0; $tabid[$tabdepth] = $tabser; $tabhlen[$tabdepth] = 0; $tabvlen[$tabdepth] = 0; $tabarg[$tabdepth] = ""; push_output('string'); }; sub off_table{ my ($elt, $evt) = @_; my $name = $elt->name; my $pos = pop_output; my $es = ""; my $rs = ""; if($tabhlen[$tabdepth] == 0){ $es = $es . "Error: cannot find table argument for element \""; $es = $es . $name . "\"\n with (general) table serial number "; $es = $es . $tabid[$tabdepth] . " at table depth " . $tabdepth; die $es; }; $arg = $tabarg[$tabdepth]; $rs = $rs . $pos; $tabdepth--; return ($arg, $rs); }; sub diag_table{ my ($pos, $elt, $evt) = @_; my $name = $elt->name; my $fn = $evt->file; my $es = ""; my $rs = ""; $rs = $rs . "REPORT on " . $name . " in file " . $name . "\n\n"; $rs = $rs . "\\begin{" . $name . "}" . $tabarg[$tabdepth] . "\n"; $rs = $rs . $pos; $rs = $rs. "\\end{" . $name . "}\n\n"; return $rs; }; 1;