diff -ruN latex2html-2018/config/config.pl l2h-2018-jp3.2b1.21/config/config.pl
--- latex2html-2018/config/config.pl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/config/config.pl	2019-08-27 19:43:48.826385000 +0900
@@ -741,10 +741,12 @@
 set arg=
 set prog=%0
 :one
-if "%1"=="" goto two
-set arg=%arg% %1
-shift
-goto one
+rem 11/08 2017 shige: 2-23)
+rem if "%1"=="" goto two
+rem set arg=%arg% %1
+rem shift
+rem goto one
+set arg=%*
 :two
 if exist %prog%.bat goto indot
 $newcfg{'PERL'} -x -S %prog% %arg%
@@ -828,6 +830,10 @@
   if($initex) {
     $newcfg{'INITEX'} = $initex;
   }
+  # shige: 1-2)
+  elsif ( $newcfg{'TEX'} ) {
+    $newcfg{'INITEX'} = "$newcfg{'TEX'} -ini";
+  }
 }
 
 $newcfg{'KPSEWHICH'} = '';
@@ -1184,10 +1190,15 @@
         my @right_paths = ();
         my $gs_lib = 0;
         my $gs_fonts = 0;
+        # 04/11 2017 shige: 2-24)
+	my $gs_stand_ps;
         Gslibpaths: foreach $path (@try_path) {
           foreach('',"$dd$gs_version","${dd}gs$gs_version") {
             my $testpath = $path . $_;
-            if(!$gs_lib && -d $testpath && -s "$testpath${dd}gs_init.ps") {
+	    # 04/11 2017 shige: 2-24)
+	    if ($testpath =~ /tlgs/) { $gs_stand_ps = "showpage.ps"; }
+	    else { $gs_stand_ps = "gs_init.ps"; }
+            if(!$gs_lib && -d $testpath && -s "$testpath${dd}$gs_stand_ps") {
               push(@right_paths,L2hos->path2os($testpath));
               $gs_lib = 1;
             }
@@ -1306,8 +1317,11 @@
 	($stat,$msg,$err) = &get_out_err("$pnmcrop -l $timg");
     } elsif ($major_vers > 8) {
 	my $sub_vers = '';
-	if ($vers =~ /9\.(\d+)/) {
-	    $sub_vers = $1;
+	#if ($vers =~ /9\.(\d+)/) {
+	#    $sub_vers = $1;
+	# 2019-04-23 shige: 2-8)
+	($sub_vers) = $vers =~ /^\d+\.(\d+)/;
+	if ($major_vers == 9) {
 	    unless ($sub_vers > 11) {
 		$newcfg{'PNMBLACK'} = ' -black ';
 		print
@@ -1317,6 +1331,10 @@
 #		$pnmcrop .= ' -sides ';
 		$newcfg{'PNMCROPOPT'} = ' -sides ';
 	    }
+	# 2019-04-23 shige: 2-8)
+	} elsif ($major_vers > 10 || $sub_vers >= 86) { 
+	    # Pnmcrop after 10.86.00 cannot recieve -sides
+	    $newcfg{'PNMCROPOPT'} = ''; 
 	} else { $newcfg{'PNMCROPOPT'} = ' -sides '; }
 	$pnmcrop .= ' -verbose ' if ($major_vers >= 10 || $sub_vers > 10);
 	print "\n$pnmcrop";
@@ -1366,10 +1384,22 @@
 # --------------------------------------------------------------------------
 
 $newcfg{'PPMQUANT'} = '';
+# shige: 2-8)
+$newcfg{'PPMQUANTOPT'} = '';
 
 if(1) {
   my $ppmquant = &find_prog(&get_name('PPMQUANT',1));
   if($ppmquant) {
+    # shige: 2-8)
+    my ($stat,$msg,$err) = ('','','');
+    ($stat,$msg,$err) = &get_out_err("$ppmquant -version");
+    my $vers = '';
+    $msg = $msg || $err;
+    if ($msg =~ /Version/) { 
+	$newcfg{'PPMQUANTOPT'} = ' -floyd';
+    } else {
+	$newcfg{'PPMQUANTOPT'} = ''; # script version
+    }
     $newcfg{'PPMQUANT'} = $ppmquant;
   }
 }
@@ -2245,7 +2275,9 @@
   Search: foreach $name (@names) {
     my $base = $name;
     $base =~ s:^.*[/$dd$dd]::; # strip path
-    &checking("for $name");
+    # 01/28 2011 shige: 2-17)
+    #&checking("for $name");
+    &checking("for $base");
     if($name =~ /\Q$dd/) { # contains dir delimiter?
       unless($name =~ /^$drive_rx\Q$dd/oi) { # absolute dir?
         $name = &simplify_path("$cwd$dd$name");
@@ -2304,6 +2336,10 @@
           return "$path$ext";
         }
       }
+      # 04/11 2017 shige: 2-25)
+      if (-s $path && !-d _ && is_perl_script($path)) {
+	  return "$newcfg{'PERL'} -w $path";
+      }
     }
   }
   else { # do the regular check
@@ -2312,6 +2348,17 @@
     }
   }
   ''; # failure
+}
+
+# 04/11 2017 shige: 2-25)
+sub is_perl_script {
+    my ($file) = @_;
+
+    return 0 unless(open(IN, "<$file"));
+    $_ = <IN>;
+    close(IN);
+    return 1 if /^\#\s*\!.*perl/;
+    return 0;
 }
 
 #------------------------------------------------------------------------------
diff -ruN latex2html-2018/configure l2h-2018-jp3.2b1.21/configure
--- latex2html-2018/configure	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/configure	2019-08-27 19:44:13.029524000 +0900
@@ -1236,7 +1236,8 @@
 fi
 
 # this is used to get the values from the config file
-eval `perl -w -e 'use cfgcache; foreach(keys %cfg) { print qq($_='"'"'$cfg{$_}'"'"'\n);}'`
+# 07/22 2018 shige: 2-37)
+#eval `perl -w -e 'use cfgcache; foreach(keys %cfg) { print qq($_='"'"'$cfg{$_}'"'"'\n);}'`
 
 
 
diff -ruN latex2html-2018/docs/manual.tex l2h-2018-jp3.2b1.21/docs/manual.tex
--- latex2html-2018/docs/manual.tex	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/docs/manual.tex	2019-07-09 18:30:03.000000000 +0900
@@ -4,6 +4,8 @@
 \usepackage[dvips]{graphicx,color}
 % \usepackage{times}
 
+% 08/20 2014 shige: for pdflatex: 2-22)
+\let\pdfoutput\undefined
 \usepackage{html,htmllist,makeidx,enumerate}
 %\usepackage{frames}
 
diff -ruN latex2html-2018/j2utf8.pl l2h-2018-jp3.2b1.21/j2utf8.pl
--- latex2html-2018/j2utf8.pl	1970-01-01 09:00:00.000000000 +0900
+++ l2h-2018-jp3.2b1.21/j2utf8.pl	2019-08-26 16:19:06.921305000 +0900
@@ -0,0 +1,21 @@
+#! /usr/local/bin/perl
+# $Id: j2utf8.pl,v 1.1 2019-08-26 16:10:21+09 shige Exp $
+# j2utf8.pl
+# Kanji translator from {EUC-JP/SJIS/JIS} to UTF-8 for init file
+# 
+use Encode;
+
+if ( $#ARGV >= 0 && $ARGV[0] =~ /^euc/i ) {
+    binmode STDIN, ":encoding(euc-jp)";
+} elsif ( $#ARGV >= 0 && $ARGV[0] =~ /sjis/i ) {
+    binmode STDIN, ":encoding(shiftjis)";
+} elsif ( $#ARGV >= 0 && $ARGV[0] =~ /^jis/i ) {
+    binmode STDIN, ":encoding(iso-2022-jp)";
+} else {
+    die "Not supported option is specified.";
+}
+binmode STDOUT, ":utf8";
+
+while ( <STDIN> ) {
+    print;
+} 
diff -ruN latex2html-2018/l2hconf.pin l2h-2018-jp3.2b1.21/l2hconf.pin
--- latex2html-2018/l2hconf.pin	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/l2hconf.pin	2019-07-09 18:38:39.000000000 +0900
@@ -366,6 +366,14 @@
 $ANTI_ALIAS_TEXT = 1;
 
 
+# 02/16 2018 shige: 3-4)
+# -dresolution
+# [n] = DPI value for the display images. Default value is 72 (cf. 
+#       -density option of pstoimg). The value 0 means the default.
+#
+$DRESOLUTION = 0;
+
+
 # -font_size
 # To set the point size of LaTeX-generated GIF files, uncomment the following
 # variable, and set it to its desired value (i.e, 10pt, 11pt, 12pt, etc.)
@@ -836,6 +844,8 @@
 $PNMROTATE = '@PNMROTATE@';
 $PNMSCALE = '@PNMSCALE@';
 $PNMCROP = '@PNMCROP@';
+# 09/09 2010 shige: 2-14)
+$PPMQUANT = '@PPMQUANT@';
 
 $GIFTOPNM = '@GIFTOPNM@';
 $JPEGTOPNM = '@JPEGTOPNM@';
diff -ruN latex2html-2018/latex2html.pin l2h-2018-jp3.2b1.21/latex2html.pin
--- latex2html-2018/latex2html.pin	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/latex2html.pin	2019-08-30 18:27:33.639127000 +0900
@@ -1,6 +1,8 @@
 #- -*- perl -*-
 #
 # $Id: latex2html.pin,v 1.71 2004/01/06 23:49:54 RRM Exp $
+# jLaTeX2HTML version 1.99+3.0 1999/9/15
+# jLaTeX2HTML version 3.2b1.21 2019-08-26 shige
 #
 # Comprises patches and revisions by various authors:
 #   See Changes, the log file of LaTeX2HTML.
@@ -9,6 +11,13 @@
 #
 # LaTeX2HTML by Nikos Drakos <nikos@cbl.leeds.ac.uk>
 
+# Japanese Patched:
+# jLaTeX2HTML by Kenshi Muto <kmuto@debian.org>
+#  jLaTeX2HTML copyright follows LaTeX2HTML copyright.
+
+# modified for latex2html-{2K.1beta,2002,2008,2015-2018} by shige
+# Shigeharu TAKENO <shige@iee.niit.ac.jp>
+
 # ****************************************************************
 # LaTeX To HTML Translation **************************************
 # ****************************************************************
@@ -56,7 +65,11 @@
 use Getopt::Long;
 use Fcntl;
 use AnyDBM_File;
-use Encode qw(decode_utf8 encode_utf8);			# for russian UTF-8 hack
+#use Encode qw(decode_utf8 encode_utf8);		# for russian UTF-8 hack
+# 03/13 2018 shige: 1-4)
+use Encode ();
+use utf8;
+use open IO => ":encoding(UTF-8)";
 
 # The following are global variables that also appear in some modules
 use vars qw($LATEX2HTMLDIR $LATEX2HTMLPLATDIR $SCRIPT
@@ -138,13 +151,22 @@
 #$TPATCHLEVEL = " release";
 #$RELDATE = "(March 30, 1999)";
 #$TEX2HTMLV_SHORT = $TVERSION . $TPATCHLEVEL;
+# shige: 1-6)
+$JREVISION = "Released Aug 26, 2019";
+$JVERSION = "JA patch-3.2beta1.21";
 
 $TEX2HTMLV_SHORT = $RELEASE;
+$JTEX2HTMLV_SHORT = "$RELEASE $JVERSION";
 $TEX2HTMLVERSION = "$TEX2HTMLV_SHORT ($REVISION)";
+$JTEX2HTMLVERSION = "$JTEX2HTMLV_SHORT ($JREVISION)";
 $TEX2HTMLADDRESS = "http://www.latex2html.org/";
+#$JTEX2HTMLADDRESS = "http://www.topstudio.co.jp/&#126;kmuto/software/latex2html/";
+$JTEX2HTMLADDRESS = "http://takeno.iee.niit.ac.jp/&#126;shige/TeX/latex2html/";
 $AUTHORADDRESS = "http://cbl.leeds.ac.uk/nikos/personal.html";
 #$AUTHORADDRESS2 = "http://www-math.mpce.mq.edu.au/%7Eross/";
 $AUTHORADDRESS2 = "http://www.maths.mq.edu.au/&#126;ross/";
+$JAUTHORADDRESS = "http://www.topstudio.co.jp/&#126;kmuto/";
+$JAUTHORADDRESS2 = "http://takeno.iee.niit.ac.jp/&#126;shige/";
 
 # Set $HOME to what the system considers the home directory
 $HOME = L2hos->home();
@@ -337,6 +359,12 @@
         'xbit!',                \$XBIT_HACK,
         'ssi!',                 \$ALLOW_SSI,
         'php!',                 \$ALLOW_PHP,
+        # 08/08 2017 shige: 3-4)
+        'dresolution=i',	\$DRESOLUTION,
+        # 2019-07-30 shige: 1-4)
+        'tenc=s',               \$TERMENCODE,
+        'ienc=s',               \$TEXENCODE,
+        'oenc=s',               \$HTMLENCODE,
         'test_mode!' # undocumented switch
        )) {
     &usage();
@@ -424,9 +452,14 @@
     $NO_MATH_PARSING = !$opt{math_parsing};
     $NO_SIMPLE_MATH = !$opt{math_parsing} unless(defined $opt{math});
 }
+# 08/08 2017 shige: 3-4)
+if ($DRESOLUTION && ($DRESOLUTION < 36 || $DRESOLUTION > 2000)) {
+    die "Error: dresolution value $DRESOLUTION are out of range [36,2000]\n";
+}
 &set_if_false($NO_ISOLATIN, $opt{latin});
 if ($INIT_FILE) {
-    if ($INIT_FILE !~ /^[.$dd]/) {	# should start with / or .
+    # 11/08 2017 shige: 2-26)
+    if ($INIT_FILE !~ /^[.$dd$dd]/) {	# should start with / or .
 	$INIT_FILE = ".$dd$INIT_FILE";	# so that value of @INC has no effect
     }
     if (-f $INIT_FILE && -r _) {
@@ -527,6 +560,49 @@
 # _TODO_ this should be determined by configure
 $DVIPS_SAFE = 1;
 
+# 2019-07-30 shige: 1-4)
+%encoding_names = (
+		   "jis",	"ISO-2022-JP",
+		   "euc",	"EUC-JP",
+		   "sjis",	"Shift_JIS",
+		   "utf8",	"UTF-8",
+		   );
+# -tenc: jis/euc/sjis/utf8
+if ($TERMENCODE) {
+    if ($encoding_names{$TERMENCODE}) {
+	$TERMENCODE = $encoding_names{$TERMENCODE};
+    } else {
+	die "Error: $TERMENCODE not invalid option to -tenc\n";
+    }
+    binmode STDERR, ":encoding($TERMENCODE)" 
+	|| die "Cannot set terminal encode to $TERMENCODE.\n";
+    binmode STDOUT, ":encoding($TERMENCODE)" 
+	|| die "Cannot set terminal encode to $TERMENCODE.\n";
+}
+# -ienc: jis/euc/sjis/utf8/noja
+if (! $TEXENCODE || $TEXENCODE =~ /noja/) {
+    $TEXENCODE = "";
+} else {
+    if ($encoding_names{$TEXENCODE}) {
+	$TEXENCODE = $encoding_names{$TEXENCODE};
+    } else {
+	die "Error: $TEXENCODE not invalid option to -ienc\n";
+    }
+    $LATEX = "$LATEX --kanji=$TEXENCODE";
+}
+# -oenc: jis/euc/sjis/utf8/noja
+if (! $HTMLENCODE || $HTMLENCODE =~ /noja/) {
+    $HTMLENCODE = "";
+} else {
+    if ($encoding_names{$HTMLENCODE}) {
+	$HTMLENCODE = $encoding_names{$HTMLENCODE};
+    } else {
+	die "Error: $HTMLENCODE not invalid option to -oenc\n";
+    }
+    $charset = $HTMLENCODE;
+    $HTMLENCODE = "" if $HTMLENCODE =~ /UTF-8/;
+}
+
 $CHARSET = $charset || 'iso-8859-1';
 
 $DVIPNG_DPI=200 unless $DVIPNG_DPI;
@@ -837,6 +913,8 @@
 		 . "-save_styles \"$DESTDIR$dd$TMP_${dd}styles\" "
 		 . ($TEXINPUTS ? "-texinputs \"$TEXINPUTS\" " : '' )
 		 . (($VERBOSITY >2) ? "-verbose " : '' )
+		 # 2019-07-30 shige: 1-4)
+		 . ($TEXENCODE ? "-texenc \"$TEXENCODE\" " : '' )
 		 . "-out \"$DESTDIR$dd$TMP_$dd$FILE\" "
 		 . "\"$texfilepath$dd$FILE.$EXT\"")
 	    && die " texexpand  failed: $!\n";
@@ -1406,8 +1484,11 @@
     &replace_html_special_chars;
     # Remove fake environment which should be invisible to LaTeX2HTML.
     s/\001//m;
-    s/[%]end\s*{latexonly}/\001/gom;
-    s/[%]begin\s*{latexonly}([^\001]*)\001/%/gos;
+    #s/[%]end\s*{latexonly}/\001/gom;
+    #s/[%]begin\s*{latexonly}([^\001]*)\001/%/gos;
+    # shige: 2-35)
+    s/[%]end\s*\{latexonly\}/\001/gom;
+    s/[%]begin\s*\{latexonly\}([^\001]*)\001/%/gos;
     s/\001//m;
 
     &preprocess_alltt if defined(&preprocess_alltt);
@@ -1418,9 +1499,13 @@
 #	    '<tex2html_'.($1?'':'end').'file>'.qq|#$2#|."\n"/em) {
 #	    $_ = "<tex2html_file>#$2#\n". $_ };
 	#RRM: ignore \n at end of included file, else \par may result
-	if (s/(\n{1,2})?%%% TEXEXPAND: \w+ FILE( MARKER)? (\S*).*\n?/
-	    ($2?$1:"\n").'<tex2html_'.($2?'':'end').'file>'.qq|#$3#|."\n"/em) {
-	    $_ = "<tex2html_file>#$3#\n". $_ };
+#	if (s/(\n{1,2})?%%% TEXEXPAND: \w+ FILE( MARKER)? (\S*).*\n?/
+#	    ($2?$1:"\n").'<tex2html_'.($2?'':'end').'file>'.qq|#$3#|."\n"/em) {
+#	    $_ = "<tex2html_file>#$3#\n". $_ };
+	# 03/09 2018 shige: 2-40)
+	if (s/(\n{1,2})?%%% TEXEXPAND: \w+ FILE( MARKER)? (\S*\\)?(\S*).*\n?/
+	    ($2?$1:"\n").'<tex2html_'.($2?'':'end').'file>'.qq|#$4#|."\n"/em) {
+	    $_ = "<tex2html_file>#$4#\n". $_ };
     } else {
 	s/%%% TEXEXPAND[^\n]*\n//gm;
     }
@@ -1431,13 +1516,21 @@
 	&write_mydb("verbatim", $global{'verbatim_counter'}, $3);
 	"$1$comment_mark".$global{'verbatim_counter'}."\n"/mge;
     # Remove the htmlonly-environment
-    s/\\begin\s*{htmlonly}\s*\n?//gom;
-    s/\\end\s*{htmlonly}\s*\n?//gom;
+    #s/\\begin\s*{htmlonly}\s*\n?//gom;
+    #s/\\end\s*{htmlonly}\s*\n?//gom;
+    # shige: 2-35)		
+    s/\\begin\s*\{htmlonly\}\s*\n?//gom;
+    s/\\end\s*\{htmlonly\}\s*\n?//gom;
     # Remove enviroments which should be invisible to LaTeX2HTML.
-    s/\n[^%\n]*\\end\s*{latexonly}\s*\n?/\001/gom;
-    s/((^|\n)[^%\n]*)\\begin\s*{latexonly}([^\001]*)\001/$1/gom;
-    s/\\end\s*{comment}\s*\n?/\001/gom;
-    s/\\begin\s*{comment}([^\001]*)\001//gom;
+    #s/\n[^%\n]*\\end\s*{latexonly}\s*\n?/\001/gom;
+    #s/((^|\n)[^%\n]*)\\begin\s*{latexonly}([^\001]*)\001/$1/gom;
+    #s/\\end\s*{comment}\s*\n?/\001/gom;
+    #s/\\begin\s*{comment}([^\001]*)\001//gom;
+    # shige: 2-35)		
+    s/\n[^%\n]*\\end\s*\{latexonly\}\s*\n?/\001/gom;
+    s/((^|\n)[^%\n]*)\\begin\s*\{latexonly\}([^\001]*)\001/$1/gom;
+    s/\\end\s*\{comment\}\s*\n?/\001/gom;
+    s/\\begin\s*\{comment\}([^\001]*)\001//gom;
 
     # this used to be earlier, but that can create problems with comments
     &wrap_other_environments if (%other_environments);
@@ -1589,7 +1682,9 @@
 	    } else {
 		$contents =~ s|\\\\ |\\\\|g;
 		$contents =~ s|\n| |g;
-		$verb{$id}=$contents;
+		# 04\/14 2017 shige: 1-4)
+		# $verb{$id}=$contents;
+		$verb{$id} = Encode::encode("utf8", $contents);
 		$verb_delim{$id}=$del;
 		join('',$vb_mark,$id,$verb_mark)
 	    }
@@ -1629,8 +1724,11 @@
 
     $KEEP_FILE_MARKERS = 1;
     if ($KEEP_FILE_MARKERS) {
-	s/%%% TEXEXPAND: \w+ FILE( MARKER) (\S*).*\n/
-	    '<tex2html_'.($1?'':'end').'file>'.qq|#.$2#\n|/gem;
+	# 03/09 2018 shige: 2-40)
+	#s/%%% TEXEXPAND: \w+ FILE( MARKER) (\S*).*\n/
+	#    '<tex2html_'.($1?'':'end').'file>'.qq|#.$2#\n|/gem;
+	s/%%% TEXEXPAND: \w+ FILE( MARKER) (\S*\\)?(\S*).*\n/
+	    '<tex2html_'.($1?'':'end').'file>'.qq|#.$3#\n|/gem;
     } else {
 	s/%%% TEXEXPAND[^\n]*\n//gm;
     }
@@ -1761,8 +1859,10 @@
     local(%string, @files, $pos);
     local ($count) =  1;
 
-    unless(open(SINPUT,"<$file")) {
-        die "\nError: Cannot read '$file': $!\n";
+    # unless(open(SINPUT,"<$file")) {
+    # 2019-07-30 shige: 1-4)
+    unless(open(SINPUT,"< :encoding(UTF-8)", "$file")) {
+	die "\nError: Cannot read '$file': $!\n";
     }
     local(@file_string);
     print STDOUT "$file" if ($VERBOSITY >1);
@@ -1867,7 +1967,10 @@
 sub slurp_input  {
     local($file) = @_;
     local(%string);
-    if(open(INPUT,"<$file")) {
+    # if(open(INPUT,"<$file")) {
+    # 2019-07-30 shige: 1-4)
+    if (($TEXENCODE && open(INPUT, "< :encoding($TEXENCODE)", "$file")) 
+	|| (! $TEXENCODE && open(INPUT,"<$file"))) {
         local(@file_string);
         while (<INPUT>) {
 	    push(@file_string, $_ );
@@ -1905,14 +2008,19 @@
     # MRO: removed deprecated $*, replaced by option /m
     $_[0] =~ s/(^|[^\\])\\\{/$1tex2html_escaped_opening_bracket/gom;
     $_[0] =~ s/(^|[^\\])\\\{/$1tex2html_escaped_opening_bracket/gom; # repeat this
-    $_[0] =~ s/(^|[^\\])\\}/$1tex2html_escaped_closing_bracket/gom;
-    $_[0] =~ s/(^|[^\\])\\}/$1tex2html_escaped_closing_bracket/gom; # repeat this
+#    $_[0] =~ s/(^|[^\\])\\}/$1tex2html_escaped_closing_bracket/gom;
+#    $_[0] =~ s/(^|[^\\])\\}/$1tex2html_escaped_closing_bracket/gom; # repeat this
+    # shige: 2-35)
+    $_[0] =~ s/(^|[^\\])\\\}/$1tex2html_escaped_closing_bracket/gom;
+    $_[0] =~ s/(^|[^\\])\\\}/$1tex2html_escaped_closing_bracket/gom; # repeat this
     my $id = $global{'max_id'};
     my $prev_id = $id;
     # mark all balanced braces
     # MRO: This should in fact mark all of them as the hierarchy is
     # processed inside-out.
-    1 while($_[0] =~ s/{([^{}]*)}/join("",$O,++$id,$C,$1,$O,$id,$C)/geo);
+    #1 while($_[0] =~ s/{([^{}]*)}/join("",$O,++$id,$C,$1,$O,$id,$C)/geo);
+    # shige: 2-35)
+    1 while($_[0] =~ s/\{([^{}]*)\}/join("",$O,++$id,$C,$1,$O,$id,$C)/geo);
     # What follows seems esoteric...
     my @processedB = ();
     # Take one opening brace at a time
@@ -1927,7 +2035,9 @@
         }
         $_[0] = join('',$before,"\{",$after) if($change);
         # MRO: mark one opening brace
-	if($_[0] =~ s/^([^{]*){/push(@processedB,$1);join('',$O,++$id,$C)/eos) {
+	# if($_[0] =~ s/^([^{]*){/push(@processedB,$1);join('',$O,++$id,$C)/eos) {
+	# shige: 2-35)
+	if($_[0] =~ s/^([^{]*)\{/push(@processedB,$1);join('',$O,++$id,$C)/eos) {
 	    $before=''; $after=$';
         }
         if ($after =~ /\}/) { 
@@ -2028,7 +2138,9 @@
 	if ($xafter =~ /noexpand/) { $before .= "\\$funct"; next; }
 
 	s/^[\s%]*(.)/$delim=$1;''/eo;
-	if ($delim =~ /{/ ) {
+	# if ($delim =~ /{/ ) {
+	# shige: 2-35)
+	if ($delim =~ /\{/ ) {
             # brackets not yet numbered...
 #	    $before .= $funct . $delim;
 	    push(@case_processed, $funct . $delim);
@@ -2325,8 +2437,12 @@
 	    }
 	    $CURRENT_FILE = &make_name($curr_sec, join('_',@curr_sec_id));
 	    
-	    open(OUTPUT, ">$CURRENT_FILE")
-		|| die "Cannot write '$CURRENT_FILE': $!\n";
+	    # open(OUTPUT, ">$CURRENT_FILE")
+	    # 2019-07-30 shige: 1-4)
+	    ($TEXENCODE && 
+	     open(OUTPUT, "> :encoding($TEXENCODE)", "$CURRENT_FILE"))
+		|| (!$TEXENCODE && open(OUTPUT, ">$CURRENT_FILE"))
+		    || die "Cannot write '$CURRENT_FILE': $!\n";
 	    if ($XBIT_HACK) { # use Apache's XBit hack
 		chmod 0744, $CURRENT_FILE;
 		&check_htaccess;
@@ -2474,8 +2590,8 @@
     $CURRENT_FILE = '';
     print OUTPUT;
     close OUTPUT;
-    
 
+
 #    # this may alter the section-keys
 #    &adjust_root_keys if $multiple_toc;
 
@@ -3507,7 +3623,9 @@
     }
     $fullcontents =  $contents; # save for later \label search.
     # MRO: replaced $* with /m
-    $contents =~ s/\n?$labels_rx(\%([^\n]+$|$EOL))?/\n/gm;
+    # 06/16 2004 shige: 2-10)
+    # $contents =~ s/\n?$labels_rx(\%([^\n]+$|$EOL))?/\n/gm;
+    $contents =~ s/\n?\s*$labels_rx(\%([^\n]+$|$EOL))?/\n/gm;
 
     local($tmp) = $contents;
     $tmp =~ s/^((\\par|\%)?\s*\n)+$//g;
@@ -3517,9 +3635,20 @@
     if ($tmp =~ /\$\\(display|text|(script)+)style\s*$comment_mark\d+\s*\$$/)
 	{ return ( &do_labels($fullcontents, "\&nbsp;") ) };
 
-    $contents = "\n% latex2html id marker $id\n$contents" if
-	(!$PREAMBLE &&($contents =~ /$order_sensitive_rx/)
-		&&(!($env =~ /makeimage/)));
+    # 10/27 2010 shige: 2-16)
+    #$contents = "\n% latex2html id marker $id\n$contents" if
+    #$contents = "\n% latex2html id marker $id $contents" if
+    #	(!$PREAMBLE &&($contents =~ /$order_sensitive_rx/)
+    #		&&(!($env =~ /makeimage/)));
+    # 07/30 2018 shige: 2-16)
+    if (!$PREAMBLE &&($contents =~ /$order_sensitive_rx/)
+      &&(!($env =~ /makeimage/))) {
+	if ($contents =~ /^[ \t]*\n/) {
+	    $contents = "\n% latex2html id marker $id $contents";
+	} else {
+	    $contents = "% latex2html id marker $id\n$contents";
+	}
+    }
 
     $env =~ s/displaymath/equation*/
 	if ($contents =~ /\\begin\{(x+|fl)*align/);
@@ -3602,8 +3731,13 @@
 	#RRM: this (old) code frequently crashes NDBM, so do it in 2 steps
 #	$img_params{$name} = join('#', &extract_parameters($contents));
 	local(@params) = &extract_parameters($contents);
-	$img_params{$name} = join('#',@params); undef $params;
-	print "\nIMAGE_PARAMS $name: ".$img_params{$name} if ($VERBOSITY > 3);
+	# 04/14 2017 shige: 1-4)
+	#$img_params{$name} = join('#',@params); undef $params;
+	#print "\nIMAGE_PARAMS $name: ".$img_params{$name} if ($VERBOSITY > 3);
+	$img_params{$name} = Encode::encode("utf8", join('#',@params));
+	undef $params;
+	print "\nIMAGE_PARAMS $name: "
+    	. Encode::decode("utf8", $img_params{$name}) if ($VERBOSITY > 3);
 
 	$contents =~ s/\\(index|label)\s*(($O|$OP)\d+($C|$CP)).*\2//sg;
 	print STDOUT "\nLATEX {$env}:\n$contents" if ($VERBOSITY > 3);
@@ -3804,8 +3938,12 @@
 sub make_image_file {
     do {
 	print "\nWriting image file ...\n";
-	open(ENV,">.$dd${PREFIX}images.tex")
-            || die "\nCannot write '${PREFIX}images.tex': $!\n";
+	# open(ENV, ">.$dd${PREFIX}images.tex")
+	# 2019-07-30 shige: 1-4)
+	($TEXENCODE &&
+	 open(ENV, "> :encoding($TEXENCODE)", ".$dd${PREFIX}images.tex"))
+	    || (!$TEXENCODE && open(ENV, ">.$dd${PREFIX}images.tex"))
+		|| die "\nCannot write '${PREFIX}images.tex': $!\n";
 	print ENV &make_latex($latex_body);
 	print ENV "\n";
 	close ENV;
@@ -3889,24 +4027,37 @@
 	if ($LATEX_DUMP) {
 	    # dump a pre-compiled format
 	    if (!(-f "${PREFIX}images.fmt")) {
-	        print "$INILATEX ./${PREFIX}images.tex\n" 
+	        #print "$INILATEX ./${PREFIX}images.tex\n" 
+		# 07/20 2017 shige: 2-26)
+	        print "$INILATEX .$dd${PREFIX}images.tex\n" 
 		    if (($DEBUG)||($VERBOSITY > 1));
+	        #print "dumping ${PREFIX}images.fmt\n"
+		#    unless ( L2hos->syswait("$INILATEX ./${PREFIX}images.tex"));
+		# shige: 2-26)
 	        print "dumping ${PREFIX}images.fmt\n"
-		    unless ( L2hos->syswait("$INILATEX ./${PREFIX}images.tex"));
+		    unless ( L2hos->syswait("$INILATEX .$dd${PREFIX}images.tex"));
 	    }
 	    local ($img_fmt) = (-f "${PREFIX}images.fmt");
 	    if ($img_fmt) {
                 # use the pre-compiled format
-	        print "$TEX \"&./${PREFIX}images\" ./${PREFIX}images.tex\n"
+	        #print "$TEX \"&./${PREFIX}images\" ./${PREFIX}images.tex\n"
+		#    if (($DEBUG)||($VERBOSITY > 1));
+	        #L2hos->syswait("$TEX \"&.$dd${PREFIX}images\" .$dd${PREFIX}images.tex");
+		# 07/20 2017 shige: 2-26)
+	        print "$TEX \"&.$dd${PREFIX}images\" .$dd${PREFIX}images.tex\n"
 		    if (($DEBUG)||($VERBOSITY > 1));
-	        L2hos->syswait("$TEX \"&./${PREFIX}images\" ./${PREFIX}images.tex");
+	        L2hos->syswait("$TEX \"&.$dd${PREFIX}images\" .$dd${PREFIX}images.tex");
 	    } elsif (-f "${PREFIX}images.dvi") {
 	        print "${PREFIX}images.fmt failed, proceeding anyway\n";
 	    } else {
 	        print "${PREFIX}images.fmt failed, trying without it\n";
-		print "$LATEX ./${PREFIX}images.tex\n"
+		#print "$LATEX ./${PREFIX}images.tex\n"
+		#    if (($DEBUG)||($VERBOSITY > 1));
+		#L2hos->syswait("$LATEX ./${PREFIX}images.tex");
+		# 07/20 2017 shige: 2-26)
+		print "$LATEX .$dd${PREFIX}images.tex\n"
 		    if (($DEBUG)||($VERBOSITY > 1));
-		L2hos->syswait("$LATEX ./${PREFIX}images.tex");
+		L2hos->syswait("$LATEX .$dd${PREFIX}images.tex");
 	    }
 	} else { &make_latex_images() }
 #	    local($latex_call) = "$LATEX .$dd${PREFIX}images.tex";
@@ -3914,8 +4065,13 @@
 #	    L2hos->syswait("$latex_call");
 ##	    print "$LATEX ./${PREFIX}images.tex\n" if (($DEBUG)||($VERBOSITY > 1));
 ##	    L2hos->syswait("$LATEX ./${PREFIX}images.tex");
+#	    # 07/20 2017 shige: 2-26)
+##	    print "$LATEX .$dd${PREFIX}images.tex\n" if (($DEBUG)||($VERBOSITY > 1));
+##	    L2hos->syswait("$LATEX .$dd${PREFIX}images.tex");
 ##        }
 	$LaTeXERROR = 0;
+	#&process_log_file(".$dd${PREFIX}images.log"); # Get image size info
+	# 07/20 2017 shige: 2-26)
 	&process_log_file("./${PREFIX}images.log"); # Get image size info
     }
     if ($NO_IMAGES) {
@@ -4112,7 +4268,9 @@
 	$img = "$basename.$IMAGE_TYPE";
 	($scale, $external, $thumbnail, $map, $psimage, $align, $usemap, 
 	    $flip, $aalias, $trans, $exscale, $alt, $exstr) =
-            split('#', $img_params{$name});
+            # 04/18 2017 shige: 1-4)
+            # split('#', $img_params{$name});
+            split('#', Encode::decode("utf8", $img_params{$name}));
 	$lwidth = ($align =~ s/nojustify/middle/) ? 0 : $LINE_WIDTH;
 	$alt = "ALT=\"$name\"" unless $alt;
 	$exscale = $EXTRA_IMAGE_SCALE unless($exscale);
@@ -4208,6 +4366,8 @@
 		. ($TMPDIR ? "-tmp $TMPDIR " : '' )
 		. (($DISCARD_PS && !$thumbnail && !$psimage)? "-discard " :'')
 		. (($INTERLACE) ? "-interlace " : '' )
+		# 08/08 2017 shige: 3-4)
+		. (($DRESOLUTION)? "-density $DRESOLUTION " : '' )
 		. (((($ANTI_ALIAS)||($aalias))&&($aalias !~ /no|text/))? "-antialias ":'')
 		. (($ANTI_ALIAS_TEXT||(($aalias =~/text/)&&($aalias !~/no/)))?
 			"-aaliastext ":'') 
@@ -4231,6 +4391,8 @@
 		    . ($TMPDIR ? "-tmp $TMPDIR " : '' )
 		    . (($DISCARD_PS && !$psimage) ? "-discard " : '' )
 		    . (($INTERLACE) ? "-interlace " : '' )
+		    # 08/08 2017 shige: 3-4)
+		    . (($DRESOLUTION)? "-density $DRESOLUTION " : '' )
 		    . ((($ANTI_ALIAS||($aalias))&&(!($aalias =~/no/)))? "-antialias " :'')
 		    . (($ANTI_ALIAS_TEXT||(($aalias =~/text/)&&($aalias !~/no/)))?
 			"-aaliastext ":'') 
@@ -4263,6 +4425,8 @@
 		. ($TMPDIR ? "-tmp $TMPDIR " : '' )
 		. (($DISCARD_PS)? "-discard " : '' )
 		. (($INTERLACE)? "-interlace " : '' )
+		# 08/08 2017 shige: 3-4)
+		. (($DRESOLUTION)? "-density $DRESOLUTION " : '' )
 		. ((($ANTI_ALIAS_TEXT||($aalias))&&($aalias !=~/no/))? 
 		    "-antialias -depth 1 " :'')
 		. (($custom_size)? "-geometry $custom_size " : '' )
@@ -4297,6 +4461,8 @@
 		. ($TMPDIR ? "-tmp $TMPDIR " : '' )
 		. (($DISCARD_PS) ? "-discard " : '' )
 		. (($INTERLACE) ? "-interlace " : '' )
+		# 08/08 2017 shige: 3-4)
+		. (($DRESOLUTION)? "-density $DRESOLUTION " : '' )
 		. ((($ANTI_ALIAS_TEXT||($aalias))&&(!($aalias =~ /no/)))?
 		    "-antialias -depth 1 " :'')
 		. ((($exscale)&&($exscale != 1)&&
@@ -4909,8 +5075,11 @@
 		} else {
 		    $cmd_trans =~ m|</.*$|;
 		    $pc_after = $` . $pc_after unless ($` =~ /^<>/);
+		    #push(@$open_tags_R, $cmd)
+		    #	if ($cmd =~ /$fontchange_rx|$fontweight_rx|$sizechange_rx/o);
+		    # 07/04 2017 shige: 2-21)
 		    push(@$open_tags_R, $cmd)
-			if ($cmd =~ /$fontchange_rx|$fontweight_rx|$sizechange_rx/o);
+			if ($cmd =~ /$sizechange_rx|$fontchange_rx|$fontweight_rx/o);
 		}
 	    } elsif ($mathentity) {
 #print "\nM-ENT:$mathentity :  ";
@@ -5861,7 +6030,9 @@
     $this_cmd = join(''
 	, "command{\\$cmd}"
 	, ($argn ? "[$argn]" :'') 
-	, (($opt =~ /^}$/) ? '' : "[$opt]" )
+	#, (($opt =~ /^}$/) ? '' : "[$opt]" )
+        # shige: 2-35)	     
+	, (($opt =~ /^\}$/) ? '' : "[$opt]" )
 	, "{", $body , "}" );
     $this_cmd = &revert_to_raw_tex($this_cmd);
     if ($renewed) {
@@ -5877,6 +6048,8 @@
 #		, "\n\\renewcommand{\\$cmd}"
 #		, ($argn ? "[$argn]" :'') 
 #		, (($opt =~ /^}$/) ? '' : "[$opt]" )
+                # shige: 2-35)	     
+#		, (($opt =~ /^\}$/) ? '' : "[$opt]" )
 #		, "{", $body , "}\n" );
 #	    $latex_body .= &revert_to_raw_tex($this_cmd);
 	    $latex_body .= "\n\\renew". $this_cmd."\n";
@@ -6825,7 +6998,9 @@
 	||(s/$next_pair_rx/$which = $2;''/eo));
     if ($hash) {
 	local($tmp) = "\%$hash";
-	if (eval "defined \%{$hash}") { $! = '';
+	# 01/27 2011 shige: 2-19)
+	# if (eval "defined \%{$hash}") { $! = '';
+	if (eval "\%{$hash}") { $! = '';
 	    $value = ${$hash}{'$which'};
 	} else { print "\nhash: \%$hash not defined" }
     } elsif ($which) {
@@ -6846,7 +7021,9 @@
 	||(s/$next_pair_rx/$value = $2;''/eo));
     if ($hash) {
 	local($tmp) = "\%$hash";
-	if (eval "defined \%{$hash}") { $! = '';
+	# 01/27 2011 shige: 2-19)
+	# if (eval "defined \%{$hash}") { $! = '';
+	if (eval "\%{$hash}") { $! = '';
 #	    eval "\$$hash{'$which'} = \"$value\";";
 	    ${$hash}{'$which'} = $value;
 	    print "\nHTMLset failed: $! " if ($!);
@@ -6876,7 +7053,9 @@
 	push(@preamble, $next_def ); 
     }
     else {
-	($name) = $next_def =~ /$marker\s*({[^}]+})/; # matches type{name}
+	#($name) = $next_def =~ /$marker\s*({[^}]+})/; # matches type{name}
+	# shige: 2-35)
+	($name) = $next_def =~ /$marker\s*(\{[^}]+\})/; # matches type{name}
 	$name = &escape_rx_chars($name);
 #	$preamble .= $next_def . "\n" unless ($preamble =~ /$marker\s*$name/);
 	push(@preamble, $name ); 
@@ -6931,7 +7110,9 @@
 	# \usepackage is invalid in LaTeX 2.09 and LaTeX-2e compatibility mode
 	$LATEX_COLOR = ''; $LOAD_LATEX_COLOR = '';
 	# ... so is \providecommand 
-	$preamble =~ s/\\documentstyle[^{]*{[^}]*}\n?/
+	#$preamble =~ s/\\documentstyle[^{]*{[^}]*}\n?/
+	# shige: 2-35)
+	$preamble =~ s/\\documentstyle[^{]*\{[^}]*\}\n?/
 		$&."\n\\let\\providecommand\\newcommand\n"/eo;
     }
 
@@ -7210,17 +7391,21 @@
     }
 
     join("\n", (($DOCTYPE)? $DTDcomment : '' )
-	,"<!--Converted with LaTeX2HTML $TEX2HTMLVERSION"
-	    . " -->\n<HTML>\n<HEAD>\n<TITLE>".$title."</TITLE>"
-	, &meta_information($title)
+        # shige: 1-6)
+	,"<!--Converted with jLaTeX2HTML $JTEX2HTMLVERSION"
+	    . " -->\n<HTML>\n<HEAD>\n"
 	,  ($CHARSET && $HTML_VERSION ge "2.1" ? 
 	      "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=$this_charset\">" 
 	      : "" )
 	, $LATEX2HTML_META
+        # shige: 2-13)
+	, &meta_information($title)
 	, ($BASE ? "<BASE HREF=\"$BASE\">" : "" )
 	, $STYLESHEET_CASCADE
 	, ($STYLESHEET ? "<LINK REL=\"STYLESHEET\" HREF=\"$STYLESHEET\">" : '' )
 	, $more_links_mark
+        # shige: 2-13)
+	, "<TITLE>".$title."</TITLE>\n"
 	, "</HEAD>" , ($before_body? $before_body : '')
 	, "<BODY $body>", '');
 }
@@ -7348,14 +7533,21 @@
 
 sub recover_image_code {
     local($key) = @_;
-    local($text) = $img_params{$key};
+    # local($text) = $img_params{$key};
+    # 04/18 2017 shige: 1-4)
+    local($text) = Encode::decode("utf8", $img_params{$key});
     if (!$text) {
 	if ($text = $id_map{$key}) {
 	    if ($orig_name_map{$text}) {
-		$text = $img_params{$orig_name_map{$text}}
+		# $text = $img_params{$orig_name_map{$text}}
+		# 04/18 2017 shige: 1-4)
+		$text = Encode::decode("utf8",
+				       $img_params{$orig_name_map{$text}})
 	    }
 	} elsif ($cached_env_img{$key}) {
-	    $text = $img_params{$cached_env_img{$key}};
+	    # $text = $img_params{$cached_env_img{$key}};
+	    # 04/18 2017 shige: 1-4)
+	    $text = Encode::decode("utf8", $img_params{$cached_env_img{$key}});
 	}
 	if ($text =~ /\#*ALT="([^"]+)"(>|#)/s) { $text = $1 }
     }
@@ -7378,11 +7570,15 @@
 sub encode {
     local($_) = @_;
     # Remove invocation-specific stuff
-    1 while(s/\\(begin|end)\s*(($O|$OP)\d+($C|$CP))?|{?tex2html_(wrap|nowrap|deferred|)(_\w+)?}?(\2)?//go);
+    #1 while(s/\\(begin|end)\s*(($O|$OP)\d+($C|$CP))?|{?tex2html_(wrap|nowrap|deferred|)(_\w+)?}?(\2)?//go);
+    # shige: 2-35)
+    1 while(s/\\(begin|end)\s*(($O|$OP)\d+($C|$CP))?|\{?tex2html_(wrap|nowrap|deferred|)(_\w+)?\}?(\2)?//go);
     $_ = &revert_to_raw_tex($_);
     s/\\protect//g;		# remove redundant \protect macros
     #$_ = pack("u*", $_);	# uuencode
     s/\\\$/dollar/g;		# replace funnies, may cause problems in a hash key
+    # 12/14 2004 shige: 2-1)
+    s/\\([ij])([^a-zA-Z_])/$1nodot$2/g;
     s/\//slash/g;		# replace funnies, may cause problems in a hash key
     s/\$|\/|\\//g;		# remove funnies, may cause problems in a hash key
     s/\s*|\n//g;		# Remove spaces  and newlines
@@ -7535,8 +7731,12 @@
 		if ($this_file =~ /\Q$dd\E([^$dd$dd]+)$/) { $this_file = $1 }
 	    }
 	    &slurp_input($this_file);
-	    open(OUTFILE, ">$this_file")
-                || die "\nError: Cannot write file '$this_file': $!\n";
+	    # open(OUTFILE, ">$this_file")
+	    # 2019-07-30 shige: 1-4)
+	    ($HTMLENCODE && 
+	     open(OUTFILE, "> :encoding($HTMLENCODE)", "$this_file"))
+		|| (!$HTMLENCODE && open(OUTFILE, ">$this_file")) 
+		    || die "\nError: Cannot write file '$this_file': $!\n";
 
 	    if (($INDEX) && ($SHORT_INDEX) && ($SEGMENT eq 1)) {
 		&make_index_segment($title,$file); }
@@ -7546,8 +7746,12 @@
 	    if (/$childlinks_on_mark\#(\d)\#/) { $child_star = $1 }
 	    $child_links = &add_child_links('',$file, $depth, $child_star,$key, @keys)
 		unless (/$childlinks_null_mark\#(\d)\#/);
-	    if (($child_links)&&(!/$childlinks_mark/)&&($MAX_SPLIT_DEPTH > 1)) {
-		if ($depth < $MAX_SPLIT_DEPTH -1) {
+	    # 07/13 2017 shige: 2-27)
+	    # if (($child_links)&&(!/$childlinks_mark/)&&($MAX_SPLIT_DEPTH > 1)) {
+	    #	if ($depth < $MAX_SPLIT_DEPTH -1) {
+	    if (($child_links)&&(!/$childlinks_mark/)) {
+		if ($MAX_SPLIT_DEPTH <= 1 || $depth < $MAX_SPLIT_DEPTH -1) {
+
 		    $_ = join('', $header, $_, &child_line(), $childlinks_mark, "\#0\#" );
 		} else {
 		    $_ = join('', $header, "\n$childlinks_mark\#0\#", &upper_child_line(), $_ );
@@ -8662,7 +8866,11 @@
 
 sub post_process_footnotes {
     &slurp_input($footfile);
-    open(OUT, ">$footfile") || die "Cannot write file '$footfile': $!\n";
+    #open(OUT, ">$footfile") || die "Cannot write file '$footfile': $!\n";
+    # 2019-07-30 shige: 1-4)
+    ($HTMLENCODE && open(OUT, "> :encoding($HTMLENCODE)", "$footfile"))
+	|| (! $HTMLENCODE && open(OUT, ">$footfile"))
+	    || die "Cannot write file '$footfile': $!\n";
     &replace_markers;
     &post_post_process if (defined &post_post_process);
     &adjust_encoding;
@@ -8743,7 +8951,9 @@
 sub replace_verb_marks {
     # Modifies $_
     s/(?:$verb_mark|$verbstar_mark)(\d+)$verb_mark/
-	$code = $verb{$1};
+	# $code = $verb{$1};
+	# 04\/18 2017 shige: 1-4)
+	$code = Encode::decode("utf8", $verb{$1});
 	$code = &replace_comments($code) if ($code =~ m:$comment_mark:);
 	"<code>$code<\/code>"/ego;
 }
@@ -9101,8 +9311,12 @@
 
 # MRO: Print standardized header
 sub banner {
+# shige: 1-6)
     print <<"EOF";
-This is LaTeX2HTML Version $TEX2HTMLVERSION
+This is jLaTeX2HTML Version $JTEX2HTMLVERSION
+by Kenshi Muto, Debian Project.
+
+Original LaTeX2HTML Version $TEX2HTMLVERSION
 by Nikos Drakos, Computer Based Learning Unit, University of Leeds.
 
 EOF
@@ -9648,15 +9862,25 @@
     s/(\\\w+)?$tex2html_wrap_rx([^\\\n])?/$tmp=$2;
         ((($tmp eq 'end')&&($1)&&!($5)&&($6))? "$1 $6":"$1$5$6")/egs;
     undef $tmp;
-    s/\s*\\newedcommand\s*{/"%\n\\providecommand{\\"/gem;
-    s/\\newedcommand\s*{/\\providecommand{\\/gom;
-#    s/(\n*)\\renewedcommand{/($1? "\n":'')."\\renewcommand{\\"/geo;
-    s/\s*\\providedcommand\s*{/"%\n\\providecommand{\\"/gem;
-#    s/\\providedcommand{/\\providecommand{\\/go;
+#    s/\s*\\newedcommand\s*{/"%\n\\providecommand{\\"/gem;
+#    s/\\newedcommand\s*{/\\providecommand{\\/gom;
+##    s/(\n*)\\renewedcommand{/($1? "\n":'')."\\renewcommand{\\"/geo;
+#    s/\s*\\providedcommand\s*{/"%\n\\providecommand{\\"/gem;
+##    s/\\providedcommand{/\\providecommand{\\/go;
+    # shige: 2-35)
+    s/\s*\\newedcommand\s*\{/"%\n\\providecommand{\\"/gem;
+    s/\\newedcommand\s*\{/\\providecommand{\\/gom;
+#    s/(\n*)\\renewedcommand\{/($1? "\n":'')."\\renewcommand{\\"/geo;
+    s/\s*\\providedcommand\s*\{/"%\n\\providecommand{\\"/gem;
+#    s/\\providedcommand\{/\\providecommand{\\/go;
     s/\\renewedenvironment\s*/\\renewenvironment/gom;
-    s/\\newedboolean\s*{/\\newboolean{/gom;
-    s/\\newedcounter\s*{/\\newcounter{/gom;
-    s/\\newedtheorem\s*{/\\newtheorem{/gom;
+#    s/\\newedboolean\s*{/\\newboolean{/gom;
+#    s/\\newedcounter\s*{/\\newcounter{/gom;
+#    s/\\newedtheorem\s*{/\\newtheorem{/gom;
+    # shige: 2-35)
+    s/\\newedboolean\s*\{/\\newboolean{/gom;
+    s/\\newedcounter\s*\{/\\newcounter{/gom;
+    s/\\newedtheorem\s*\{/\\newtheorem{/gom;
     s/\\xystar/\\xy\*/gom; # the * has a special meaning in Xy-pic
 
     #fix-up the star'd environment names
@@ -10043,7 +10267,10 @@
             unless ($exstr =~ /BORDER/i);
     } else { 
         # MRO: dubious (&extern_image_mark takes only one arg)
-        $extern_image_mark = &extern_image_mark($IMAGE_TYPE,$altst);
+        #$extern_image_mark = &extern_image_mark($IMAGE_TYPE,$altst);
+	# 07/20 2017 shige: 2-28)
+	my ($typename) = ($PS_IMAGES) ? "ps" : $IMAGE_TYPE;
+	$extern_image_mark = &extern_image_mark($typename, $altst);
     }
 
     my ($anch1,$anch2) = ('','');
@@ -10154,6 +10381,11 @@
             $img_w = int($width / $scale + .5);
             $img_h = int($height / $scale + .5);
 	}
+	# 08/08 2017 shige: 3-4)
+	if ($DRESOLUTION && $DRESOLUTION != 72) {
+	    $img_w = int($img_w*72 / $DRESOLUTION + .5);
+	    $img_h = int($img_h*72 / $DRESOLUTION + .5);
+	}
 	$size = qq{WIDTH="$img_w" HEIGHT="$img_h"};
 
 	# allow height/width to be stored in the stylesheet
@@ -10171,6 +10403,11 @@
 		# How high is an ex in the most likely browser font ?
 		    $width = $width/$scale; $height = $height/$scale;
 		}
+		# 08/08 2017 shige: 3-4)
+		if ($DRESOLUTION && $DRESOLUTION != 72) {
+		    $width = $width*72 / $DRESOLUTION;
+		    $height = $height*72 / $DRESOLUTION;
+		}
 		$width = int(100*$width + .5)/100;
 		$height = int(100*$height + .5)/100;
 		$img_style{$imgID} = qq(width:${width}em ; height:${height}ex );
@@ -11120,6 +11357,8 @@
 sub do_require_package {
     local($file)= @_;
     local($dir);
+    # 08/23 2016 shige: 2-29)
+    local($rfile) = $file;
     #RRM: make common ps/eps-packages use  epsfig.perl
     $file = 'epsfig' if ($file =~ /^(psfig|epsf)$/);
 
@@ -11130,12 +11369,16 @@
 	    print STDOUT "\nPackage: loading $texfilepath$dd${file}.perl";
 	    require("$texfilepath$dd${file}.perl");
 	    $styles_loaded{$file} = 1;
+	    # 08/23 2016 shige: 2-29)
+	    $styles_loaded{$rfile} = 1 if $rfile ne $file;
 	} else {
 	    foreach $dir (split(/$envkey/,$LATEX2HTMLSTYLES)) {
 		if ((-f "$dir$dd${file}.perl") && ! $styles_loaded{$file}){
 		    print STDOUT "\nPackage: loading $dir$dd${file}.perl";
 		    require("$dir$dd${file}.perl");
 	    	    $styles_loaded{$file} = 1;
+		    # 08/23 2016 shige: 2-29)
+		    $styles_loaded{$rfile} = 1 if $rfile ne $file;
 		    last;
 		}
 	    }
@@ -11184,6 +11427,8 @@
     &do_require_package($option) unless ($styles_loaded{$option});
     # next look for a subroutine named  do_$option
     $do_option = "do_$option";
+    # 11/01 2001 shige: 2-2)
+    $do_option =~ s/-/_/g;
     if (!($styles_loaded{$option}) && defined(&$do_option)) {
 	&$do_option();
 	$styles_loaded{$option} = 1;
@@ -11272,7 +11517,14 @@
 
 	# Search for [aAiI1] which is not between a pair of { }
 	# Other cases like "\theenumi" are not handled
-	@label_fields = $standard_label =~ /$enum_label_rx/;
+	# @label_fields = $standard_label =~ /$enum_label_rx/;
+	# 07/13 2018 shige: 2-36)
+	my $std_label = $standard_label;
+	$std_label =~ s/$any_next_pair_rx/\{$2\}/g;
+	@label_fields = $std_label =~ /$enum_label_rx/;
+	$label_fields[0] =~ s/[\{\}]//g;
+	$label_fields[$#label_fields] =~ s/[\{\}]//g;
+	$std_label =~ s/[\{\}]//g;
 	if (($standard_label =~ /^[aAiI1]$/)&&(not(/item\s*\[/))) {
 	    $enum_type = ' TYPE="'.$standard_label.'"';
 	    $standard_label = '';
@@ -11283,9 +11535,12 @@
 #	local($thislabel) = "\&$label_func";
 #	do { local($_) = $thislabel; &make_unique($_);
 #	     $enum{'theenum' . $rlevel} = $_; };
-	    $standard_label = 
+	    # $standard_label = 
+	    # 07/13 2018 shige: 2-36)
+	    $standard_label = ($#label_fields > 0) ?
 		"\"$label_fields[0]\" . eval(\$enum{\"theenum$rlevel\"})"
-		. ".\"$label_fields[$#label_fields]\"";
+		. ".\"$label_fields[$#label_fields]\"" :
+		$std_label;    
 	    $enum{'labelenum' . $rlevel} = $standard_label;
 	}
     }  elsif (s/^((.|\n)+?)\\item/$preitems=$1;"\\item"/es) {
@@ -11303,9 +11558,16 @@
 	    $label_part = '"'.$label_part.'"';
 	    $enum{$cmd} = $label_part;
         }
-	$standard_label = 
-	    "\"$label_fields[0]\" . eval(\$enum{\"theenum$rlevel\"})"
-	    . ".\"$label_fields[$#label_fields]\"" if ($cmd);
+	# $standard_label = 
+	#    "\"$label_fields[0]\" . eval(\$enum{\"theenum$rlevel\"})"
+	#    . ".\"$label_fields[$#label_fields]\"" if ($cmd);
+	# 07/13 2018 shige: 2-36)
+	if ($cmd) {
+	    $standard_label = ($#label_fields > 0) ? 
+		"\"$label_fields[0]\" . eval(\$enum{\"theenum$rlevel\"})"
+		. ".\"$label_fields[$#label_fields]\"" :
+		$std_label;
+	}
 	$_ = $pre_preitems . $preitems . $_ if ($pre_preitems||$preitems);
     } else {
 	@enum_default_type = ('A', '1', 'a', 'i', 'A') unless (@enum_default_type);
@@ -11354,7 +11616,9 @@
 		$item = "[$enum_label\]$item";
 		$enum_label =~ s/\.$//;
 	    }
-	    if ($standard_label) {
+	    # if ($standard_label) {
+	    # 07/13 2018 shige: 2-36)
+	    if ($standard_label && $standard_label !~ /eval\(/) {
 	        $item =~ s/(\\labelitem$rlevel|$standard_label)/$enum_label/g
 	    } else {
 	        $item =~ s/(\\labelitem$rlevel)/$enum_label/g
@@ -12412,12 +12676,16 @@
 	$closures .= $post unless ($pre =~ /^<>/);
 	print STDOUT "\n</$next>" if $VERBOSITY > 2;
 
-	if ($next =~ /$fontchange_rx/) {
+	# 07/04 2017 shige: 2-21)
+	if ($next =~ /$sizechange_rx/) {
+	    # discard it
+	} elsif ($next =~ /$fontchange_rx/) {
 	    $font = $next unless ($font);
 	} elsif ($next =~ /$fontweight_rx/) {
 	    $fontwt = $next unless ($fontwt);
-	} elsif ($next =~ /$sizechange_rx/) {
-	    # discard it
+	# 07/04 2017 shige: 2-21)
+	#} elsif ($next =~ /$sizechange_rx/) {
+	#    # discard it
 	} else {
 	    unshift (@tags, $next);
 	    print STDOUT "\n<<$next>" if $VERBOSITY > 2;
@@ -12480,7 +12748,9 @@
 	    $t_author = &translate_environments($_);
 	    $t_author =~ s/\s+/ /g;
 	    $t_author = &simplify(&translate_commands($t_author));
-	    ($t_author,$t_affil,$t_address) = split (/\s*<BR>s*/, $t_author);
+	    # ($t_author,$t_affil,$t_address) = split (/\s*<BR>s*/, $t_author);
+	    # 04/27 2010 shige: 2-20)
+	    ($t_author,$t_affil,$t_address) = split (/\s*<BR>s*/, $t_author, 3);
 	    push @authors, $t_author;
 	    push @affils, $t_affil;
 	    push @addresses, $t_address;
@@ -12489,7 +12759,9 @@
 	$_ = &translate_environments($next);
 	$next = &translate_commands($_);
 	($t_author) = &simplify($next);
-	($t_author,$t_affil,$t_address) = split (/\s*<BR>s*/, $t_author);
+	# ($t_author,$t_affil,$t_address) = split (/\s*<BR>s*/, $t_author);
+	# 04/27 2010 shige: 2-20)
+	($t_author,$t_affil,$t_address) = split (/\s*<BR>s*/, $t_author, 3);
 	push @authors, $t_author;
 	push @affils, $t_affil if $t_affil;
 	push @addresses, $t_address if $t_address;
@@ -12652,10 +12924,14 @@
     if ($t_date&&!($t_date=~/^\s*(($O|$OP)\d+($C|$CP))\s*\1\s*$/)) {
 	$t_title .= "\n<P$alignc><STRONG>$t_date</STRONG></P>";}
     if ($t_address&&!($t_address=~/^\s*(($O|$OP)\d+($C|$CP))\s*\1\s*$/)) {
-	$t_title .= "\n<P$alignl><SMALL>$t_address</SMALL></P>";
+	# $t_title .= "\n<P$alignl><SMALL>$t_address</SMALL></P>";
+	# 04/27 2010 shige: 2-20)
+	$t_title .= "\n<P$alignc><SMALL>$t_address</SMALL></P>";
     }  # else { $t_title .= "\n<P$alignl>"}
     if ($t_email&&!($t_email=~/^\s*(($O|$OP)\d+($C|$CP))\s*\1\s*$/)) {
-	$t_title .= "\n<P$alignl><SMALL>$t_email</SMALL></P>";
+	# $t_title .= "\n<P$alignl><SMALL>$t_email</SMALL></P>";
+	# 04/27 2010 shige: 2-20)
+	$t_title .= "\n<P$alignc><SMALL>$t_email</SMALL></P>";
     }  # else { $t_title .= "</P>" }
     join("\n", $s_author_info, $t_title, $e_author_info);
 }
@@ -13840,6 +14116,8 @@
 sub do_cmd_footnotename { $foot_title . $_[0] }
 sub do_cmd_childlinksname { '<STRONG>'.$child_name.'</STRONG>'. $_[0] }
 sub do_cmd_infopagename { $info_title . $_[0] }
+# shige: 2-9)
+sub do_cmd_prefacename { $pre_title . $_[0] }
 
 
 sub do_cmd_ref {
@@ -14163,7 +14441,9 @@
 sub default_textohtmlinfopage {
     local($_) = @_;
     local($argv) = $argv;
-    if (-f "../$argv") { $argv = &make_href ("../$argv", $argv, ); }
+    # if (-f "../$argv") { $argv = &make_href ("../$argv", $argv, ); }
+    # 07/20 2017 shige: 2-26)
+    if (-f "..$dd$argv") { $argv = &make_href ("..$dd$argv", $argv, ); }
     $_ = ($INFO && $INFO =~ /^\d+$/
       ? join('', $close_all
 	, "<STRONG>$t_title</STRONG><P>\nThis document was generated using the\n"
@@ -14390,8 +14670,11 @@
 
 sub do_body_newcounter {
     local($ctr) = @_;
+    #$latex_body .= &revert_to_raw_tex("\\newcounter{$ctr}\n")
+    #	unless ($preamble =~ /\\new(counter|theorem){$ctr}/);
+    # shige: 2-35)
     $latex_body .= &revert_to_raw_tex("\\newcounter{$ctr}\n")
-	unless ($preamble =~ /\\new(counter|theorem){$ctr}/);
+	unless ($preamble =~ /\\new(counter|theorem)\{$ctr\}/);
     $global{$ctr} = 0;
     &process_commands_wrap_deferred("the$ctr ");
     $_;
@@ -14819,18 +15102,26 @@
 sub do_cmd_LaTeX {
     local($_) = @_;
     if ($USING_STYLES) {
-	$env_style{'LaTeX'} = ' ' unless ($env_style{'LaTeX'});
-	$env_style{'logo-LaTeX'} = ' ' unless ($env_style{'logo-LaTeX'});
-	join('',"<SPAN CLASS=\"logo,LaTeX\">",$Laname, $TeXname,"</SPAN>",$_);
+	#$env_style{'LaTeX'} = ' ' unless ($env_style{'LaTeX'});
+	#$env_style{'logo-LaTeX'} = ' ' unless ($env_style{'logo-LaTeX'});
+	#join('',"<SPAN CLASS=\"logo,LaTeX\">",$Laname, $TeXname,"</SPAN>",$_);
+	# shige: 2-12)
+	$txt_style{'LaTeX'} = ' ' unless ($txt_style{'LaTeX'});
+	$txt_style{'logo-LaTeX'} = ' ' unless ($txt_style{'logo-LaTeX'});
+	join('',"<SPAN CLASS=\"logo-LaTeX LaTeX\">",$Laname, $TeXname,"</SPAN>",$_);
     } else { join('',$Laname, $TeXname, $_); }
 }
 
 sub do_cmd_LaTeXe {
     local($_) = @_;
     if ($USING_STYLES) {
-	$env_style{'LaTeX2e'} = ' ' unless ($env_style{'LaTeX2e'});
-	$env_style{'logo-LaTeX2e'} = ' ' unless ($env_style{'logo-LaTeX2e'});
-	join('',"<SPAN CLASS=\"logo,LaTeX2e\">"
+	#$env_style{'LaTeX2e'} = ' ' unless ($env_style{'LaTeX2e'});
+	#$env_style{'logo-LaTeX2e'} = ' ' unless ($env_style{'logo-LaTeX2e'});
+	#join('',"<SPAN CLASS=\"logo,LaTeX2e\">"
+	# shige: 2-12)
+	$txt_style{'LaTeX2e'} = ' ' unless ($txt_style{'LaTeX2e'});
+	$txt_style{'logo-LaTeX2e'} = ' ' unless ($txt_style{'logo-LaTeX2e'});
+	join('',"<SPAN CLASS=\"logo-LaTeX2e LaTeX2e\">"
 		,$Laname, $TeXname,'2<SUB>e</SUB>',"</SPAN>",$_);
     } else { join('',$Laname,$TeXname
 		,(($HTML_VERSION >= 3.0)? '2<SUB>e</SUB>':'2e'),$_);
@@ -14840,9 +15131,13 @@
 sub do_cmd_latextohtml {
     local($_) = @_;
     if ($USING_STYLES) {
-	$env_style{'LaTeX2HTML'} = ' ' unless ($env_style{'LaTeX2HTML'});
-	$env_style{'logo-LaTeX2HTML'} = ' ' unless ($env_style{'logo-LaTeX2HTML'});
-	join('',"<SPAN CLASS=\"logo,LaTeX2HTML\">"
+	#$env_style{'LaTeX2HTML'} = ' ' unless ($env_style{'LaTeX2HTML'});
+	#$env_style{'logo-LaTeX2HTML'} = ' ' unless ($env_style{'logo-LaTeX2HTML'});
+	#join('',"<SPAN CLASS=\"logo,LaTeX2HTML\">"
+	# shige: 2-12)
+	$txt_style{'LaTeX2HTML'} = ' ' unless ($txt_style{'LaTeX2HTML'});
+	$txt_style{'logo-LaTeX2HTML'} = ' ' unless ($txt_style{'logo-LaTeX2HTML'});
+	join('',"<SPAN CLASS=\"logo-LaTeX2HTML LaTeX2HTML\">"
 		,$Laname, $TeXname,"2<TT>HTML</TT>","</SPAN>",$_);
     } else { join('',$Laname,$TeXname,"2<TT>HTML</TT>",$_);}
 }
@@ -14850,7 +15145,9 @@
 sub do_cmd_TeX {
     local($_) = @_;
     if ($USING_STYLES) {
-	$env_style{'logo-TeX'} = ' ' unless ($env_style{'logo-TeX'});
+	#$env_style{'logo-TeX'} = ' ' unless ($env_style{'logo-TeX'});
+	# shige: 2-12)
+	$txt_style{'logo-TeX'} = ' ' unless ($txt_style{'logo-TeX'});
 	join('',"<SPAN CLASS=\"logo-TeX\">",$TeXname,"</SPAN>",$_);
     } else { join('',$TeXname, $_);}
 }
@@ -14858,7 +15155,9 @@
 sub do_cmd_MF {
     local($_) = @_;
     if ($USING_STYLES) {
-	$env_style{'logo-Metafont'} = ' ' unless ($env_style{'logo-Metafont'});
+	#$env_style{'logo-Metafont'} = ' ' unless ($env_style{'logo-Metafont'});
+	# shige: 2-12)
+	$txt_style{'logo-Metafont'} = ' ' unless ($txt_style{'logo-Metafont'});
 	join('',"<SPAN CLASS=\"logo-Metafont\">",$MFname,"</SPAN>",$_);
     } else { join('', $MFname, $_);}
 }
@@ -14866,7 +15165,9 @@
 sub do_cmd_Xy {
     local($_) = @_;
     if ($USING_STYLES) {
-	$env_style{'logo-Xy-pic'} = ' ' unless ($env_style{'logo-Xy-pic'});
+	#$env_style{'logo-Xy-pic'} = ' ' unless ($env_style{'logo-Xy-pic'});
+	# shige: 2-12)
+	$txt_style{'logo-Xy-pic'} = ' ' unless ($txt_style{'logo-Xy-pic'});
 	join('',"<SPAN CLASS=\"logo-Xy-pic\">",$Xyname,"</SPAN>",$_);
     } else { join('',$Xyname, $_);}
 }
@@ -14874,7 +15175,9 @@
 sub do_cmd_AmS {
     local($_) = @_;
     if ($USING_STYLES) {
-	$env_style{'logo-AMS'} = ' ' unless ($env_style{'logo-AMS'});
+	#$env_style{'logo-AMS'} = ' ' unless ($env_style{'logo-AMS'});
+	# shige: 2-12)
+	$txt_style{'logo-AMS'} = ' ' unless ($txt_style{'logo-AMS'});
 	join('',"<SPAN CLASS=\"logo-AMS\">",$AmSname,"</SPAN>",$_);
     } else { join('',$AmSname, $_);}
 }
@@ -14882,7 +15185,9 @@
 sub do_cmd_AmSTeX {
     local($_) = @_;
     if ($USING_STYLES) {
-	$env_style{'logo-AMS'} = ' ' unless ($env_style{'logo-AMS'});
+	#$env_style{'logo-AMS'} = ' ' unless ($env_style{'logo-AMS'});
+	# shige: 2-12)
+	$txt_style{'logo-AMS'} = ' ' unless ($txt_style{'logo-AMS'});
 	join('',"<SPAN CLASS=\"logo-AMS\">",$AmSname,"-$TeXname","</SPAN>",$_);
     } else { join('',$AmSname, "-", $TeXname, $_);}
 }
@@ -14901,17 +15206,25 @@
     $spmrx =~ s/\000/|/g;
     $spmrx = "(.)" unless $spmrx =~ s/(.+)/($1|.)/;
 
-    s/^[ \t]*(\d{1,3})[ \t]*/&#$1;/ &&
+    #s/^[ \t]*(\d{1,3})[ \t]*/&#$1;/ &&
+    # 09/13 2010 shige: 2-15)
+    s/^[ \t]*(\d+)[ \t]*/&#$1;/ &&
 	return($_);
 
-    s/^[ \t]*\'(\d{1,3})[ \t]*/"&#".oct($1).";"/e &&
+    #s/^[ \t]*\'(\d{1,3})[ \t]*/"&#".oct($1).";"/e &&
+    # 09/13 2010 shige: 2-15)
+    s/^[ \t]*\'([0-7]+)[ \t]*/"&#".oct($1).";"/e &&
 	return($_);
 
-    s/^[ \t]*$spmquot(\d{1,2})[ \t]*/"&#".hex($1).";"/e &&
+    #s/^[ \t]*$spmquot(\d{1,2})[ \t]*/"&#".hex($1).";"/e &&
+    # 09/13 2010 shige: 2-15)
+    s/^[ \t]*$spmquot([0-9a-fA-F]+)[ \t]*/"&#".hex($1).";"/e &&
 	return($_);
 
 # This is a kludge to work together with german.perl. Brrr.
-    s/^[ \t]*\'\'(\d{1,2})[ \t]*/"&#".hex($1).";"/e &&
+    #s/^[ \t]*\'\'(\d{1,2})[ \t]*/"&#".hex($1).";"/e &&
+    # 09/13 2010 shige: 2-15)
+    s/^[ \t]*\'\'([0-9a-fA-F]+)[ \t]*/"&#".hex($1).";"/e &&
 	return($_);
 # If l2h's special char marker represents more than one character,
 # it's already in the &#xxx; form. Else convert the single character
@@ -14993,7 +15306,10 @@
 	# Accent of this form: "\^{\i}rest" or not an accent on i nor j
 	($arg) =  &get_next_pair_or_char_pr;
     }
-    $arg =~ s/([^\s\\<])/$first_char = $1; ''/eo;
+    #$arg =~ s/([^\s\\<])/$first_char = $1; ''/eo;
+    # 12/13 2004 shige: 2-3)
+    if ($type eq "t" ) { $first_char = $arg; $arg = ""; }
+    else { $arg =~ s/([^\s\\<])/$first_char = $1; ''/eo; }
 #   print STDOUT "\nACCENT1 type:$type arg:|${arg}| first_char: |$first_char| $ij_cmd 
 #	, $ACCENT_IMAGES\n";
 
@@ -15050,8 +15366,16 @@
     # ...or the accent is wider than the letter, so pad it out a bit
     $afterkern = "\\kern.15em" if ($char =~ /i|l/); #||($type=~/v/));
 
-    &process_undefined_environment("tex2html_accent_inline"
-        , ++$global{'max_id'}, "${bstyle}\\${type}\{$char\\/\}$estyle$afterkern");
+    #&process_undefined_environment("tex2html_accent_inline"
+    #    , ++$global{'max_id'}, "${bstyle}\\${type}\{$char\\/\}$estyle$afterkern");
+    # 01/18 2002 shige: 2-4)
+    if ( $type =~ /^accent/ ) {
+	&process_undefined_environment("tex2html_accent_inline" 
+          , ++$global{'max_id'}, "${bstyle}\\${type}$char\\/$estyle$afterkern");
+    } else {
+	&process_undefined_environment("tex2html_accent_inline"
+          , ++$global{'max_id'}, "${bstyle}\\${type}\{$char\\/\}$estyle$afterkern");
+    }
 }
 
 # MEH: Actually tries to find a dotless i or j
@@ -15071,7 +15395,9 @@
 	&write_warnings("Accent number $number is unknown.\n");
 	return $_;
     }
-    &accent_safe_for_ij($type , 'accent$number' );
+    #&accent_safe_for_ij($type , 'accent$number' );
+    # 01/18 2002 shige: 2-4)
+    &accent_safe_for_ij($type , "accent$number" );
     $_;
 }
 
@@ -15383,7 +15709,9 @@
     # MRO: replaced $* with /m
     while ($text =~ /(\\[a-zA-Z]+|[&;]SPM\w+;|<[^>]+>)+/m ) {
 	$scbef = $`; $special = $&; $text = $';
-	while ( $scbef =~ /(&#\d+;|[a-z$sclower])+[a-z\W\d$sclower]*/m) {
+	# while ( $scbef =~ /(&#\d+;|[a-z$sclower])+[a-z\W\d$sclower]*/m) {
+	# 04/27 2010 shige: 2-20)
+	while ( $scbef =~ /(&#\d+;|[a-z$sclower])+[a-z\s\d$sclower]*/m) {
 	    $scstr .= $`; $scbef = $';
 	    $next = $&; 
 	    $next =~ s/&#(\d+);/&lowercase_entity($1)/egm;
@@ -15394,7 +15722,9 @@
 	$scstr .= $scbef . $special;
     }
     if ($text) {
-	while ( $text =~ /(&#\d+;|[a-z$sclower])+[a-z\W\d$sclower]*/m) {
+	# while ( $text =~ /(&#\d+;|[a-z$sclower])+[a-z\W\d$sclower]*/m) {
+	# 04/27 2010 shige: 2-20)
+	while ( $text =~ /(&#\d+;|[a-z$sclower])+[a-z\s\d$sclower]*/m) {
 	    $scstr .= $`; $text = $';
 	    $next = $&;
 	    $next =~ s/&#(\d+);/&lowercase_entity($1)/egm;
@@ -15641,7 +15971,9 @@
     $delim = '%:%';		# Delimits items of sectioning information
 				# stored in a string
 
-    $LATEX2HTML_META = '<META NAME="Generator" CONTENT="LaTeX2HTML v'.$TEX2HTMLV_SHORT.'">'
+    #$LATEX2HTML_META = '<META NAME="Generator" CONTENT="LaTeX2HTML v'.$TEX2HTMLV_SHORT.'">'
+    # shige: 1-6)
+    $LATEX2HTML_META = '<META NAME="Generator" CONTENT="jLaTeX2HTML v'.$JTEX2HTMLV_SHORT.'">'
 	. "\n<META HTTP-EQUIV=\"Content-Style-Type\" CONTENT=\"text/css\">"
 	      unless ($LATEX2HTML_META);
 
@@ -15654,6 +15986,8 @@
     $EQN_TAGS = "R" unless ($EQN_TAGS);
     $EQNO_START = "(";
     $EQNO_END   = ")";
+    # 09/09 2010 shige: 3-3)
+    $EQNO_WIDTH = "10";
 
     $AtBeginDocument_hook  = "\$AtBeginDocument_hook\=\'\'; "
 	unless $AtBeginDocument_hook;
@@ -15711,6 +16045,9 @@
     &banner();
     print "Revised and extended by:"
 	. "\n Marcus Hennecke, Ross Moore, Herb Swan and others\n";
+    # shige: 1-6)
+    print "Modified of Japanese version by:"
+	. "\n Shige TAKENO\n";
 
     # Collect HTML options and figure out HTML version
     $HTML_OPTIONS = '' unless ($HTML_OPTIONS);
@@ -15733,16 +16070,43 @@
     print ($HTML_OPTIONS ? "with $HTML_OPTIONS extensions\n\n\n" : "\n\n\n");
 
     # load the character defs for latin-1, but don't set the charset yet
-    &do_require_extension('latin1');
-    $charset = $CHARSET = $PREV_CHARSET = '';
+    #&do_require_extension('latin1');
+    #$charset = $CHARSET = $PREV_CHARSET = '';
+    # 08/24 2002, 01/26 2003, 12/09 2004, 03/25 2010 shige: 1-5)
+    {
+	local($save_charset) = '';
+	$save_charset=$CHARSET 
+	    if $CHARSET =~ /(iso[-_]2022[-_]jp|EUC[-_]JP|Shift[-_]JIS|UTF[-_]8)/;
+	&do_require_extension('latin1');
+	$charset = $CHARSET = $PREV_CHARSET = $save_charset;
+	undef $save_charset;
+    }
 
-    if ($HTML_VERSION =~ /(2.0|3.0|3.2|4.0|4.1)/) {
+    # if ($HTML_VERSION =~ /(2.0|3.0|3.2|4.0|4.1)/) {
+    # 03/26 2011 shige: 2-18)
+    if ($HTML_VERSION =~ /(2.[012]|3.[012]|4.[01])/) {
 	# Require the version specific file 
-	do { $_ = "$LATEX2HTMLVERSIONS${dd}html$1.pl";
-	     if (!(-f $_)) {  s/(\d).(\d.pl)$/$1_$2/ };
-	     if (!(-f $_)) {  s/(\d)_(\d.pl)$/$1-$2/ };
-	     require $_ || die "\n*** Could not load $_ ***\n";
-	     print "\nHTML version: loading $_\n";
+	#do { $_ = "$LATEX2HTMLVERSIONS${dd}html$1.pl";
+	#     if (!(-f $_)) {  s/(\d).(\d.pl)$/$1_$2/ };
+	#     if (!(-f $_)) {  s/(\d)_(\d.pl)$/$1-$2/ };
+	#     require $_ || die "\n*** Could not load $_ ***\n";
+	#     print "\nHTML version: loading $_\n";
+	#} unless ($HTML_VERSION =~ /2.0/);
+	# 03/26 2011 shige: 2-18)
+	local($dir,$found) = ('',0);
+	do {
+	    foreach $dir (split(/$envkey/,$LATEX2HTMLVERSIONS)) {
+		$_ = "${dir}${dd}html$1.pl";
+		if (!(-f $_)) {  s/(\d).(\d.pl)$/$1_$2/ };
+		if (!(-f $_)) {  s/(\d)_(\d.pl)$/$1-$2/ };
+		if (-f $_) { $found = 1; last; }
+	    }
+	    if ( $found ) {
+		require $_ || die "\n*** Could not load $_ ***\n";
+		print "\nHTML version: loading $_\n";
+	    } else {
+		die "\n*** Could not found html$1.pl in $LATEX2HTMLVERSIONS ***\n";
+	    }
 	} unless ($HTML_VERSION =~ /2.0/);
 	$DOCTYPE = "-//".(($HTML_VERSION eq "2.0")? "IETF" : "W3C")
 	    . "//DTD HTML $HTML_VERSION"
@@ -15769,12 +16133,26 @@
 	    . "  i18n  table  math  frame  latin1  unicode  etc.\n";
 
     # Require all necessary version specific files
-	foreach ( sort <$LATEX2HTMLVERSIONS${dd}html[1-9].[0-9].pl> ) {
-	    last if ( $_ gt "$LATEX2HTMLVERSIONS${dd}html$HTML_VERSION.pl" );
-	    do { print "\nloading $_" if ($DEBUG);
-		 require $_; } unless (
-		($NO_SIMPLE_MATH)&&($_ eq "$LATEX2HTMLVERSIONS${dd}html3.1.pl"));
-	};
+	#foreach ( sort <$LATEX2HTMLVERSIONS${dd}html[1-9].[0-9].pl> ) {
+	#    last if ( $_ gt "$LATEX2HTMLVERSIONS${dd}html$HTML_VERSION.pl" );
+	#    do { print "\nloading $_" if ($DEBUG);
+	#	 require $_; } unless (
+	#	($NO_SIMPLE_MATH)&&($_ eq "$LATEX2HTMLVERSIONS${dd}html3.1.pl"));
+	#};
+	# 03/26 2011 shige: 2-18)
+	local($dir,$found) = ('',0);
+	foreach $dir (split(/$envkey/,$LATEX2HTMLVERSIONS)) {
+	    foreach ( sort <${dir}${dd}html[1-9].[0-9].pl> ) {
+		if ( $_ gt "${dir}${dd}html$HTML_VERSION.pl" ) {
+		    $found = 1; last;
+		}
+	    }
+    	    last if $found;
+	}
+	if ( $found && (! $NO_SIMPLE_MATH || $_ ne "${dir}${dd}html3.1.pl" )) {
+	    print "\nloading $_" if ($DEBUG);
+	    require $_;
+	}
 	$STRICT_HTML = 0;
     }
 
@@ -15987,6 +16365,8 @@
 	 , 'spanish',	'spanish_translation'
 	 , 'swedish',	'swedish_translation'
 	 , 'turkish',	'turkish_translation'
+	 # shige: 1-5)
+	 , 'japanese',	'japanese_translation'
 	);
 
 # Reiner: 
@@ -16047,7 +16427,9 @@
 }
 sub Alph{
     local($num)=@_;
-    &falph(eval($enum{$num}));
+    # &falph(eval($enum{$num}));
+    # 07/13 2018 shige: 2-36)
+    &fAlph(eval($enum{$num}));
 }
 
 sub Roman{
@@ -16590,7 +16972,9 @@
     # used for labels in {enumerate} environments
     $standard_label_rx = 
 	"\\s*[[]\\s*((($any_next_pair_rx4)|([[][^]]*[]])|[^]])*)[]]";
-    $enum_label_rx = "^((({[^{}]*})|([^{}]))*)([aAiI1])(.*)";
+    # $enum_label_rx = "^((({[^{}]*})|([^{}]))*)([aAiI1])(.*)";
+    # 07/13 2018 shige: 2-36)
+    $enum_label_rx = "^(((\{[^{}]*\})|([^{}]))*)([aAiI1])(.*)";
     $enum_level = 0;	# level for enumerate (1-4, i-iv)
 
 
@@ -16863,7 +17247,9 @@
 
 sub make_order_sensitive_rx {
     local(@theorem_alts, $theorem_alts);
-    @theorem_alts = ($preamble =~ /\\newtheorem\s*{([^\s}]+)}/og);
+    #@theorem_alts = ($preamble =~ /\\newtheorem\s*{([^\s}]+)}/og);
+    # shige: 2-35)
+    @theorem_alts = ($preamble =~ /\\newtheorem\s*\{([^\s}]+)\}/og);
     $theorem_alts = join('|',@theorem_alts);
 #
 #  HWS: Added kludge to require counters to be more than 2 characters long
diff -ruN latex2html-2018/prefs.pm l2h-2018-jp3.2b1.21/prefs.pm
--- latex2html-2018/prefs.pm	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/prefs.pm	2019-07-09 18:30:03.000000000 +0900
@@ -180,14 +180,20 @@
 # but with reduced capabilities.
 
 # the TeX executable
-$prefs{'TEX'} = 'tex';
+# shige: 1-2)
+#$prefs{'TEX'} = 'tex';
+$prefs{'TEX'} = 'ptex,tex';
 
 # the LaTeX executable
 # needed for image generation
-$prefs{'LATEX'} = 'latex';
+# shige: 1-2)
+#$prefs{'LATEX'} = 'latex';
+$prefs{'LATEX'} = 'platex,latex';
 
 # the initex executable
-$prefs{'INITEX'} = 'initex';
+# shige: 1-2)
+#$prefs{'INITEX'} = 'initex';
+$prefs{'INITEX'} = 'iniptex,initex';
 
 # the kpsewhich (part of Web2C) executable. If it is found, we have
 # Web2C
@@ -210,14 +216,17 @@
 $prefs{'MKTEXLSR'} = 'mktexlsr,texhash,MakeTeXlsR';
 
 # The dvips executable and its features. dvips32 added for OS/2
-$prefs{'DVIPS'} = 'dvips,dvi2ps,dvips32';
+# shige: 1-2)
+$prefs{'DVIPS'} = 'pdvips,dvips,dvi2ps,dvips32';
 
 # Many options can be used with dvips to produce better quality images
 # or speed-up other aspects of image-generation.
 # $prefs{'DVIPSOPT'} = ' -E';  # create encapsulated (EPS) images
 # $prefs{'DVIPSOPT'} = ' -Ppdf'; # use Type 1 fonts, as for PDF
 # $prefs{'DVIPSOPT'} = ' -Pcmz -Pamz'; # use CM and AMS Type 1 fonts
-$prefs{'DVIPSOPT'} = ' -Ppdf';
+# 09/01 2005 shige: 2-30)
+#$prefs{'DVIPSOPT'} = ' -Ppdf';
+$prefs{'DVIPSOPT'} = ' -E';
 
 # set this to 1 if you want dvips to create special fonts for better
 # image generation. You need to set the following two items to correct
diff -ruN latex2html-2018/pstoimg.pin l2h-2018-jp3.2b1.21/pstoimg.pin
--- latex2html-2018/pstoimg.pin	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/pstoimg.pin	2019-08-27 19:45:15.578021000 +0900
@@ -324,6 +324,8 @@
 #fi
 #if @PPMQUANT@
 my $PPMQUANT = '@PPMQUANT@';
+# shige: 2-8)
+my $PPMQUANTOPT = '@PPMQUANTOPT@';
 #fi
 #-
 #if @PNMFLIP@
@@ -888,7 +890,8 @@
   if($opt{depth} == 1) { 
     $gs_aalias = '-dTextAlphaBits=4 ';
 #if @PPMQUANT@
-    $reduce_color = "$PPMQUANT -floyd 256";
+    # shige: 2-8)
+    $reduce_color = "$PPMQUANT $PPMQUANTOPT 256";
 #fi
     }
   else {
@@ -899,7 +902,8 @@
   $GSDEVICE = $GSALIASDEVICE;
     $gs_aalias = '-dTextAlphaBits=4 ';
 #if @PPMQUANT@
-    $reduce_color = "$PPMQUANT -floyd 256";
+    # shige: 2-8)
+    $reduce_color = "$PPMQUANT $PPMQUANTOPT 256";
 #fi
   }
 #fi
@@ -1507,6 +1511,9 @@
 #fi
 #if @gif_trans@ eq 'netpbm'
     if($TRANSPARENT) {
+      # 2019-03-05 shige: 2-39)
+      $trans_color = $TRANSPARENT_COLOR||'#d9d9d9'; # don't lookup rgb.txt
+      #$trans_color = $TRANSPARENT_COLOR||'gray85';
       $pnmtoimg .= ' -trans ' . L2hos->quote($trans_color);
     }
 #fi
diff -ruN latex2html-2018/styles/alltt.perl l2h-2018-jp3.2b1.21/styles/alltt.perl
--- latex2html-2018/styles/alltt.perl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/alltt.perl	2019-08-27 10:57:01.662456000 +0900
@@ -51,11 +51,15 @@
     local ($alltt_begin) = "<alltt_begin>";
     local ($alltt_end) = "<alltt_end>";
     local($saveRS) = $/; undef $/;
-    while (/\\begin\s*{($alltt_rx)}([ \t]*\n)?/m) {
+    #while (/\\begin\s*{($alltt_rx)}([ \t]*\n)?/m) {
+    # shige: 2-35)
+    while (/\\begin\s*\{($alltt_rx)\}([ \t]*\n)?/m) {
 	$alltt_env = $1;
 	$alltt = "";
 	($before, $after) = ($`, $');
-	if ($after =~ /\\end\s*{($alltt_rx)}/sm) {
+	#if ($after =~ /\\end\s*{($alltt_rx)}/sm) {
+	# shige: 2-35)
+	if ($after =~ /\\end\s*\{($alltt_rx)\}/sm) {
 	    ($alltt, $after) = ($`, $');
 	    local(@check) = split("\n",$before);
 	    local($lastline) = pop @check unless ($before =~ s/\n$//sm);
diff -ruN latex2html-2018/styles/ascmac.perl l2h-2018-jp3.2b1.21/styles/ascmac.perl
--- latex2html-2018/styles/ascmac.perl	1970-01-01 09:00:00.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/ascmac.perl	2019-08-30 19:10:12.381997000 +0900
@@ -0,0 +1,83 @@
+# ascmac.perl by Kouji KODAMA <kdm@kobe-kosen.ac.jp>
+# copied from:
+# ascmac.perl, version 3.0 1999/9/15
+#
+# ascmac.perl by Kenshi Muto <kmuto@debian.org>
+
+# shige 04/14 2017: for 3.x
+use utf8;
+
+# Implemented features:
+#   Commands: \yen, \keytop{}, \return, \Return
+#   Environments: screen, itembox, shadebox, boxnote
+
+### shadebox と boxnote はscreen のコピ−で手抜き. (kdm)
+
+# Not implemented for the followings:
+# \ascii, \Ascii, \ASCII, \mask,
+# \Maskbox{width}{height}{mask_char}{pos}{rule_wid}{body},
+# \maskbox{width}{height}{mask_char}{pos}{body}
+
+sub do_cmd_yen { local($_) = @_; "￥$_"; }
+sub do_cmd_keytop{
+	local($_)=@_;
+	s/$next_pair_pr_rx//o; local($key)=&translate_commands($2);
+	"[".$key."]".$_;
+}
+sub do_cmd_return {
+  local($_) = @_;
+  if ($HTML_VERSION < 4.0) {
+    "[Enter]$_";
+  } else {
+    "<SPAN STYLE=\"border-width: thin; border-style: solid\">Enter</SPAN>$_";
+  }
+}
+sub do_cmd_Return {
+  local($_) = @_;
+  if ($HTML_VERSION < 4.0) {
+    "[Enter]$_";
+  } else {
+    "<SPAN STYLE=\"border-width: thin; border-style: solid\">Enter</SPAN>$_";
+  }
+}
+sub do_env_screen {
+  if ($HTML_VERSION < 4.0) {
+    join('',"<TABLE BORDER=\"1\"><TR><TD>","@_","</TD></TR></TABLE>");
+  } else {
+    join('',"<DIV STYLE=\"border: inset blue; background-color: white\">",
+	"@_","</DIV>")
+  }
+}
+sub do_env_shadebox{
+  if ($HTML_VERSION < 4.0) {
+    join('',"<TABLE BORDER=\"1\"><TR><TD>","@_","</TD></TR></TABLE>");
+  } else {
+    join('',"<DIV STYLE=\"border: inset blue; background-color: white\">",
+	"@_","</DIV>")
+  }
+}
+sub do_env_boxnote{
+  if ($HTML_VERSION < 4.0) {
+    join('',"<TABLE BORDER=\"1\"><TR><TD>","@_","</TD></TR></TABLE>");
+  } else {
+    join('',"<DIV STYLE=\"border: inset blue; background-color: white\">",
+	"@_","</DIV>")
+  }
+}
+sub do_env_itembox {
+   local($_) = @_; local($title) = '';
+   $title = &missing_braces unless
+     ((s/$next_pair_rx/$title=$2;''/e) ||
+      (s/$next_pair_pr_rx/$title=$2;''/e));
+   $_ = &translate_environments($_);
+   if ($HTML_VERSION < 4.0) {
+     join('',"<TABLE BORDER=\"1\"><TR><TD>$title</TD></TR>",
+	"<TR><TD>$_\n</TD></TR></TABLE>\n");
+   } else {
+     join('',"<TABLE STYLE=\"border: sold; background-color: lime\">",
+	"<TR><TH STYLE=\"background-color: green\">$title</TH></TR>",
+	"<TR><TD>$_\n</TD></TR></TABLE>\n");
+   }
+ }
+
+1; # end
diff -ruN latex2html-2018/styles/frames.perl l2h-2018-jp3.2b1.21/styles/frames.perl
--- latex2html-2018/styles/frames.perl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/frames.perl	2019-08-27 12:01:20.329707000 +0900
@@ -706,7 +706,9 @@
     $_[0] =~ s/<(META NAME|LINK)[^>]*>\s*//g;
     $_[0] =~ s/$more_links_mark/$NO_ROBOTS\n$LATEX2HTML_META/g;
     local($savedRS)=$/; $/ = '';
-    $_[0] =~ s/\n\{2;}/\n/sg;
+    # $_[0] =~ s/\n\{2;}/\n/sg;
+    # 07/09 2019 shige: 2-35)
+    $_[0] =~ s/\n{2,}/\n/sg;
     $_[0] =~ s/\s$//s;
     $_[0] =~ s!\s*(\n</HEAD>\n)\s*!$1!s;
     $/ = $savedRS;
diff -ruN latex2html-2018/styles/getimagesize.perl l2h-2018-jp3.2b1.21/styles/getimagesize.perl
--- latex2html-2018/styles/getimagesize.perl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/getimagesize.perl	2019-07-09 18:30:03.000000000 +0900
@@ -44,6 +44,11 @@
             $img_w = int($width / $scale + .5);
             $img_h = int($height / $scale + .5);
 	}
+	# 08/08 2017 shige: 3-4)
+	if ($DRESOLUTION && $DRESOLUTION != 72) {
+	    $img_w = int($img_w*72 / $DRESOLUTION + .5);
+	    $img_h = int($img_h*72 / $DRESOLUTION + .5);
+	}
 	$size = qq{WIDTH="$img_w" HEIGHT="$img_h"};
 
 	# allow height/width to be stored in the stylesheet
@@ -60,6 +65,11 @@
 		if ($scale) {
 		# How high is an ex in the most likely browser font ?
 		    $width = $width/$scale; $height = $height/$scale;
+		}
+		# 08/08 2017 shige: 3-4)
+		if ($DRESOLUTION && $DRESOLUTION != 72) {
+		    $width = $width*72 / $DRESOLUTION;
+		    $height =$height*72 / $DRESOLUTION;
 		}
 		$width = int(100*$width + .5)/100;
 		$height = int(100*$height + .5)/100;
diff -ruN latex2html-2018/styles/graphics-support.perl l2h-2018-jp3.2b1.21/styles/graphics-support.perl
--- latex2html-2018/styles/graphics-support.perl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/graphics-support.perl	2019-08-27 11:04:43.060712000 +0900
@@ -172,21 +172,32 @@
 
     #RRM: may only work correctly for Unix    
     # $dd  holds the directory-delimiter, usually / 
-    $paths =~ s/\s*({|})\s*/$1/g;
-    local(@paths) = split (/}/, $paths);
+    #$paths =~ s/\s*({|})\s*/$1/g;
+    #local(@paths) = split (/}/, $paths);
+    # shige: 2-35)
+    $paths =~ s/\s*(\{|\})\s*/$1/g;
+    local(@paths) = split (/\}/, $paths);
     if ($DESTDIR eq $FILE) {
 	# given paths are relative to parent directory
-	map(s|^{([^/~\.\$\\][^}]*)|{..$dd$1|, @paths);
-	map(s/^{\.\Q$dd\E/{\.\.$dd/, @paths);
+	#map(s|^{([^/~\.\$\\][^}]*)|{..$dd$1|, @paths);
+	#map(s/^{\.\Q$dd\E/{\.\.$dd/, @paths);
+	# shige: 2-35)
+	map(s|^\{([^/~\.\$\\][^}]*)|{..$dd$1|, @paths);
+	map(s/^\{\.\Q$dd\E/{\.\.$dd/, @paths);
     } elsif ($DESTDIR eq '.') {
 	# paths are already relative to working directory
     } else { 
 	# specify full paths, by prepending source directory
-	map(s|^{([^/~\.\$\\][^}]*)|{$orig_cwd$dd$1|, @paths);
-	map(s/^{\.\Q$dd\E/{$orig_cwd$dd/, @paths);
+	#map(s|^{([^/~\.\$\\][^}]*)|{$orig_cwd$dd$1|, @paths);
+	#map(s/^{\.\Q$dd\E/{$orig_cwd$dd/, @paths);
+	# shige: 2-35)
+	map(s|^\{([^/~\.\$\\][^}]*)|{$orig_cwd$dd$1|, @paths);
+	map(s/^\{\.\Q$dd\E/{$orig_cwd$dd/, @paths);
     }
     $paths = join('}', @paths).'}';
-    map(s/^{//,@paths);		# Strip leading { and trailing $dd
+    #map(s/^{//,@paths);		# Strip leading { and trailing $dd
+    # shige: 2-35)
+    map(s/^\{//,@paths);		# Strip leading { and trailing $dd
     map(s/\Q$dd\E$//,@paths);
     $GRAPHICS_PATH = [@$GRAPHICS_PATH,@paths];
 
diff -ruN latex2html-2018/styles/html.perl l2h-2018-jp3.2b1.21/styles/html.perl
--- latex2html-2018/styles/html.perl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/html.perl	2019-08-27 11:05:04.222762000 +0900
@@ -704,7 +704,9 @@
 	||(s/$next_pair_rx/$value = $2;''/eo));
     if ($hash) {
 	local($tmp) = "\%$hash";
-	if (eval "defined \%{$hash}") { $! = '';
+	#if (eval "defined \%{$hash}") { $! = '';
+	# 01/27 2011 shige: 2-19)
+	if (eval "\%{$hash}") { $! = '';
 #	    eval "\$$hash{'$which'} = \"$value\";";
 	    ${$hash}{'$which'} = $value;
 	    print "\nHTMLset failed: $! " if ($!);
diff -ruN latex2html-2018/styles/japanese.perl l2h-2018-jp3.2b1.21/styles/japanese.perl
--- latex2html-2018/styles/japanese.perl	1970-01-01 09:00:00.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/japanese.perl	2019-08-30 19:10:12.378502000 +0900
@@ -0,0 +1,165 @@
+# japanese.perl, version 3.0 1999/9/15
+# japanese.pin,  l2h-2017-jp2.1b1.20 2019-04-23
+#
+# japanese.perl by Kenshi Muto <kmuto@debian.org>
+# modified by Shigeharu TAKENO <shige@iee.niit.ac.jp>
+# 
+use utf8;
+
+package japanese;
+
+print " [japanese]";
+
+sub main'japanese_translation { #'
+    @_[0];
+}
+
+package main;
+
+sub japanese_titles {
+    $toc_title = "目次";
+    $lof_title = "図目次";
+    $lot_title = "表目次";
+    $idx_title = "索引";
+    $bib_title = "参考文献";
+    #$ref_title = "参考文献";
+    #$bib_title = "関連図書";
+    $abs_title = "概要";
+    $app_title = "付録";
+    $pre_title = "序文";
+    $foot_title = "脚注";
+    $thm_title = "定理";
+    $fig_name  = "図";
+    $tab_name  = "表";
+    $prf_name = "証明";
+  #  Sectioning-level titles
+    $info_title = "この文書について..."; 
+  #  names in navigation panels
+    #$next_name = "次へ";
+    #$up_name = "上へ";
+    #$prev_name = "前へ";
+
+    @japanese_Month1 = ('', '1月', '2月', '3月', '4月', '5月',
+		       '6月', '7月', '8月', '9月', '10月',
+		       '11月', '12月');
+    @japanese_Month2 = ('', '睦月', '如月', '弥生', '卯月', '皐月',
+			'水無月', '文月', '葉月', '長月', '神無月',
+			'霜月', '師走');
+    @japanese_Month3 = ('', '孟春', '仲春', '季春', '孟夏', '仲夏',
+			'季夏', '孟秋', '仲秋', '季秋', '孟冬',
+			'仲冬', '季冬');
+    @Month = @japanese_Month1;
+    if ( defined $JAPANESEMONTHNAME ){
+	if ( $JAPANESEMONTHNAME == 1 ) { 
+	    @Month = @japanese_Month1;
+	} elsif ( $JAPANESEMONTHNAME == 2 ) {
+	    @Month = @japanese_Month2;
+	} elsif ( $JAPANESEMONTHNAME == 3 ) {
+	    @Month = @japanese_Month3;
+	}
+    }
+}
+
+sub japanese_infopage {
+    local($_) = @_;
+    local($argv) = $argv;
+    if (-f "../$argv") { $argv = &make_href ("../$argv", $argv, ); }
+    $_ = (($INFO == 1)
+      ? join('', "<STRONG>$t_title</STRONG><P>\nこの文書は"
+        , "<A HREF=\"$TEX2HTMLADDRESS\"><STRONG>LaTeX</STRONG>2<tt>HTML</tt></A>"
+        , " 翻訳プログラム Version $TEX2HTMLVERSION\n"
+        , "<P>Copyright &#169; 1993, 1994, 1995, 1996,\n"
+        , "<A HREF=\"$AUTHORADDRESS\">Nikos Drakos</A>, \n"
+        , "Computer Based Learning Unit, University of Leeds,\n"
+        , "<BR>Copyright &#169; 1997, 1998, 1999,\n"
+        , "<A HREF=\"$AUTHORADDRESS2\">Ross Moore</A>, \n"
+        , "Mathematics Department, Macquarie University, Sydney.\n"
+        , "<P>を<A HREF=\"$JTEX2HTMLADDRESS\">日本語化したもの</A>"
+        , " ($JTEX2HTMLVERSION 版)\n"
+        , "<P>Copyright &#169; 1998, 1999,\n"
+        , "<A HREF=\"$JAUTHORADDRESS\">Kenshi Muto</A>, \n"
+        , "Debian Project.\n"
+	, "<BR>Copyright &#169; 2001--2019,\n"
+	, "<A HREF=\"$JAUTHORADDRESS2\">Shige TAKENO</A>, \n"
+	, "Niigata Inst.Tech.\n"
+        , "<P>を用いて生成されました。\n"
+        , "<P>コマンド行は以下の通りでした。: <BR>\n "
+        , "<STRONG>latex2html</STRONG> <tt>$argv</tt>.\n"
+        , (($SHOW_INIT_FILE && ($INIT_FILE ne ''))?
+	   "\n<P>初期化ファイル: <TT>$INIT_FILE</TT>\n$init_file_mark\n" :'')
+# shige for latex2html-2017.2
+	, "<P>翻訳は"
+	, (($USESIGNEDINFOPAGE)? " $address_data[0] によって" : "")
+        , " $address_data[1] に実行されました。"
+	, $open_all, $_)
+   : join('', $close_all, $INFO,"\n", $open_all, $_));
+   &infopagehook if defined &infopagehook;
+   $_;
+}
+
+sub japanese_today {
+    local($today); 
+    if ( 1 ) { # オリジナルの get_date() を使うなら
+	local($m,$d,$y) = split(/\//,&get_date());
+	if ( $y < 1989 || $USEJAPANESESEIREKI ) { # 西暦
+	    $y = "$y年"; 
+	} elsif ( $y < 2019 || ($y == 2019 && $m < 5)) {
+	    $y -= 1988; 
+	    $y = "元" if $y == 1; 
+	    $y = "平成$y年"; 
+	} else {
+	    $y -= 2018;
+	    $y = "元" if $y == 1; 
+	    $y = "令和$y年"; 
+	}
+	$today = "$y$Month[$m]$d日";
+    } else { # 武藤さんの get_date() を使うなら
+	$today = &get_date();
+    }
+    join('',$today,$_[0]);
+}
+
+#sub get_date {
+#    local($format,$order) = @_;
+#    local(@lt) = localtime;
+#    local($d,$m,$y) = @lt[3,4,5];
+#    local($gengo) = "平成";
+#        $y += 1900;
+#	 if ($y < 2019 || ($y == 2019 && $m+1 < 5)) {
+#            $y -= 1988;
+#        } else {
+#	     $gengo = "令和"; $y -= 2018;
+#        }
+#        if ($y == 1) {
+#                $y = "元";
+#        } else {
+#                $y .= "";
+#        }
+#        sprintf("%s%s年%s%d日", $gengo, $y, @Month[$m+1], $d);
+#}
+#if (defined &address_data) {
+#  @address_data = &address_data('ISO');
+#  $ADDRESS = "$address_data[0]\n$address_data[1]";
+#}
+
+if ( defined &english_titles ) { &english_titles; }
+&japanese_titles;
+$default_language = 'japanese';
+$TITLES_LANGUAGE = 'japanese';
+# $ISO_LANGUAGE = 'JA';
+
+if ( $HTMLENCODE ) {
+    $charset = $CHARSET = "$HTMLENCODE";
+    $japanese_encoding = "$HTMLENCODE";
+} else {
+    $charset = $CHARSET = "UTF-8";
+    $japanese_encoding = "UTF-8";
+}
+
+if ( $USEBOTTOMLOCALDATE ) {
+    # @address_data = &address_data('ISO');
+    $address_data[1]=&japanese_today();
+    $ADDRESS = "$address_data[0]\n$address_data[1]";
+}
+
+1;
diff -ruN latex2html-2018/styles/more_amsmath.perl l2h-2018-jp3.2b1.21/styles/more_amsmath.perl
--- latex2html-2018/styles/more_amsmath.perl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/more_amsmath.perl	2019-08-27 11:05:55.774061000 +0900
@@ -93,6 +93,8 @@
 		, $EQNO_END);
 	}
     } else { $tag = ';SPMnbsp;;SPMnbsp;;SPMnbsp;' }
+    # 10/01 2004 shige: 2-5)
+    $scan =~ s/($comment_mark\d+) /$1\n/g;
     if ($labels) {
 	$labels =~ s/$anchor_mark/$tag/o;
 	($labels , $scan);
@@ -162,8 +164,11 @@
 $mspace = "\&nbsp;";
 $mdlim = $html_specials{'&'};
 
-$lseqno = "$eqno_class WIDTH=\"10\" ALIGN=\"LEFT\">\n";
-$rseqno = "$eqno_class WIDTH=\"10\" ALIGN=\"RIGHT\">\n";
+#$lseqno = "$eqno_class WIDTH=\"10\" ALIGN=\"LEFT\">\n";
+#$rseqno = "$eqno_class WIDTH=\"10\" ALIGN=\"RIGHT\">\n";
+# 09/09 2010 shige: 3-3)
+$lseqno = "$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\"LEFT\">\n";
+$rseqno = "$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\"RIGHT\">\n";
 
 
 # do these indirectly, so that they only over-ride the existing
diff -ruN latex2html-2018/styles/psfrag.perl l2h-2018-jp3.2b1.21/styles/psfrag.perl
--- latex2html-2018/styles/psfrag.perl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/psfrag.perl	2019-07-09 18:30:03.000000000 +0900
@@ -23,9 +23,10 @@
 epsfbox # {}
 _RAW_ARG_CMDS_
 
+# shige: 2-6)
 &process_commands_nowrap_in_tex (<<_RAW_ARG_CMDS_);
-psfragstar # {} # {}
-psfrag # {} # {}
+psfragstar # {} # [] # [] # [] # [] # {}
+psfrag # {} # [] # [] # [] # [] # {}
 _RAW_ARG_CMDS_
 
 
diff -ruN latex2html-2018/styles/romanian.perl l2h-2018-jp3.2b1.21/styles/romanian.perl
--- latex2html-2018/styles/romanian.perl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/romanian.perl	2019-08-27 11:06:36.826668000 +0900
@@ -75,7 +75,9 @@
 &romanian_titles;
 $default_language = 'romanian';
 $TITLES_LANGUAGE = 'romanian';
-$romanian_encoding = 'is-8859-16';
+#$romanian_encoding = 'is-8859-16';
+# 09/28 2015 shige: 2-31)
+$romanian_encoding = 'iso-8859-16';
 
 # $Log: romanian.perl,v $
 # Revision 1.1  1998/08/25 01:59:07  RRM
diff -ruN latex2html-2018/styles/texdefs.perl l2h-2018-jp3.2b1.21/styles/texdefs.perl
--- latex2html-2018/styles/texdefs.perl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/styles/texdefs.perl	2019-08-27 11:07:01.378703000 +0900
@@ -63,17 +63,25 @@
     $spmrx =~ s/\000/|/g;
     $spmrx = "(.)" unless $spmrx =~ s/(.+)/($1|.)/;
 
-    s/^[ \t]*(\d{1,3})[ \t]*/&#$1;/ &&
+    #s/^[ \t]*(\d{1,3})[ \t]*/&#$1;/ &&
+    # 09/13 2010 shige: 2-15)
+    s/^[ \t]*(\d+)[ \t]*/&#$1;/ &&
 	return($_);
 
-    s/^[ \t]*\'(\d{1,3})[ \t]*/"&#".oct($1).";"/e &&
+    #s/^[ \t]*\'(\d{1,3})[ \t]*/"&#".oct($1).";"/e &&
+    # 09/13 2010 shige: 2-15)
+    s/^[ \t]*\'([0-7]+)[ \t]*/"&#".oct($1).";"/e &&
 	return($_);
 
-    s/^[ \t]*$spmquot(\d{1,2})[ \t]*/"&#".hex($1).";"/e &&
+    #s/^[ \t]*$spmquot(\d{1,2})[ \t]*/"&#".hex($1).";"/e &&
+    # 09/13 2010 shige: 2-15)
+    s/^[ \t]*$spmquot([0-9a-fA-F]+)[ \t]*/"&#".hex($1).";"/e &&
 	return($_);
 
 # This is a kludge to work together with german.perl. Brrr.
-    s/^[ \t]*\'\'(\d{1,2})[ \t]*/"&#".hex($1).";"/e &&
+    #s/^[ \t]*\'\'(\d{1,2})[ \t]*/"&#".hex($1).";"/e &&
+    # 09/13 2010 shige: 2-15)
+    s/^[ \t]*\'\'([0-9a-fA-F]+)[ \t]*/"&#".hex($1).";"/e &&
 	return($_);
 
 # If l2h's special char marker represents more than one character,
diff -ruN latex2html-2018/texexpand.pin l2h-2018-jp3.2b1.21/texexpand.pin
--- latex2html-2018/texexpand.pin	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/texexpand.pin	2019-08-27 11:47:15.026979000 +0900
@@ -374,6 +374,9 @@
 #fi
 
 use L2hos;
+# 2019-07-30 shige: 1-4)
+use utf8;
+use Encode ();
 
 my $RELEASE = '@distver@';
 my $VERSION = '@release_date@';
@@ -409,9 +412,11 @@
 # Parse arguments
 use Getopt::Long;
 my %opt = ();
+# 2019-07-30 shige: 1-4)
 unless(GetOptions(\%opt, qw(-help -version -debug -verbose -w
      -do_include=s@ -dont_include=s@ -auto_exclude -unsegment
-     -save_styles=s -texinputs=s@ -output=s -out=s))) {
+     -save_styles=s -texinputs=s@ -output=s -out=s -texenc=s))) {
+     # -save_styles=s -texinputs=s@ -output=s -out=s))) {
   die "$prompt Error: Invalid option(s) specified.\n";
 }
 
@@ -439,6 +444,12 @@
     $TEXINPUTS = join($envkey, @{$opt{texinputs}});
 }
 
+# 2019-07-30 shige: 1-4)
+my $encname = 'utf-8';
+if($opt{texenc}) {
+    $encname = $opt{texenc};
+} 
+
 unless(@ARGV) {
   die "$prompt Error: No input file specified.\n";
 }
@@ -550,16 +561,27 @@
     $do_include_rx = join("|",@do_include);
 
     if($opt{save_styles}) {
-	open(STYLES,">$opt{save_styles}")
+	# open(STYLES,">$opt{save_styles}")
+	# 2019-07-30 shige: 1-4)
+	($opt{texenc} &&
+	 open(STYLES,"> :encoding(UTF-8)", "$opt{save_styles}"))
+	    || (!$opt{texenc} && open(STYLES,">$opt{save_styles}"))
             || die "$prompt Error: Cannot open style file '$opt{save_styles}': $!\n";
     }
     my $out_file = $opt{output}||$opt{out};
     if($out_file) {
-	open(OUT,">$out_file")
+	# open(OUT,">$out_file")
+	# 2019-07-30 shige: 1-4)
+	($opt{texenc} && 
+	 open(OUT,"> :encoding(UTF-8)", "$out_file"))
+	    || (!$opt{texenc} && open(OUT, ">$out_file"))
             || die "$prompt Error: Cannot open output file '$out_file': $!\n";
     }
     else {
-	open(OUT,">&STDOUT");
+	# open(OUT,">&STDOUT");
+	# 2019-07-30 shige: 1-4)
+	($opt{texenc} && open(OUT,"> :encoding(UTF-8)", "&STDOUT"))
+	    || (!$opt{texenc} && open(OUT, ">&STDOUT"));
     }
 
     &process_file($infile); # the workhorse...
@@ -677,7 +699,11 @@
     # Keep track of input/include level
     $includelevel++;
 
-    open(IN,"<$infile") || die "$prompt Cannot open $infile\n";
+    # open(IN,"<$infile") || die "$prompt Cannot open $infile\n";
+    # 2019-07-30 shige: 1-4)
+    ($opt{texenc} && open(IN, "< :encoding($encname)", "$infile"))
+	|| (!$opt{texenc} && open(IN, "<$infile"))
+	|| die "$prompt Cannot open $infile\n";
     print STDERR "$prompt %--- Processing $infile" if ($debug > 1);
 
     # if we don't include this file marker LaTeX2HTML won't split
diff -ruN latex2html-2018/versions/html3_1.pl l2h-2018-jp3.2b1.21/versions/html3_1.pl
--- latex2html-2018/versions/html3_1.pl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/versions/html3_1.pl	2019-08-27 11:49:06.689865000 +0900
@@ -158,7 +158,9 @@
     local($math_start,$math_end)= ($sbig,$ebig);
 
     local($eqno) = '&nbsp;'; # spacer, when no numbering
-    local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    #local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    # 09/09 2010 shige: 3-3)
+    local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
                          , (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		         , "\">\n");
     do { # include the equation number, using a <TABLE>
@@ -326,8 +328,11 @@
 	# Inside <MATH>, { and } have special meaning. Thus, need &lcub;
 	# and &rcub;
 #    s/{/&lcub;/g; s/}/&rcub;/g; # Where are these defined ?
-	s/{/&lbrace;/g;
-	s/}/&rbrace;/g;
+	#s/{/&lbrace;/g;
+	#s/}/&rbrace;/g;
+	# shige: 2-35)
+	s/\{/&lbrace;/g;
+	s/\}/&rbrace;/g;
 
 	# Remove the safety markers for math-entities
 	s/(\&\w+)#\w+;/$1;/g; 
@@ -929,7 +934,9 @@
 	$sarray .= "ALIGN=\"CENTER\" WIDTH=\"100%\">";
 	$env_id = '';
 
-	local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	#local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	# 09/09 2010 shige: 3-3)
+	local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
 		, (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		, "\">\n");
 	if ($EQN_TAGS =~ /L/) { # number on left
@@ -1579,7 +1586,9 @@
 		local($extra) = &get_supsub;
 # contents of $extra may require an image !!
 		# revert the brace-pairs
-		if ($extra =~ /{|}/) { 
+		#if ($extra =~ /{|}/) { 
+		# shige: 2-35)
+		if ($extra =~ /\{|\}/) { 
 		    &mark_string($extra);
 		    $extra =~ s/$O(\d+)$C/$OP$1$CP/g;
 		}
diff -ruN latex2html-2018/versions/html3_2.pl l2h-2018-jp3.2b1.21/versions/html3_2.pl
--- latex2html-2018/versions/html3_2.pl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/versions/html3_2.pl	2019-08-27 11:50:05.898198000 +0900
@@ -270,6 +270,8 @@
 $TD_attribs_rx_list = $TH_attribs_rx_list = ",COLSPAN,ROWSPAN,WIDTH,HEIGHT,";
 $TD__COLSPAN_rx = $TD__ROWSPAN_rx = $TD__WIDTH_rx = $TD__HEIGHT_rx = $num_type;
 $TH__COLSPAN_rx = $TH__ROWSPAN_rx = $TH__WIDTH_rx = $TH__HEIGHT_rx = $num_type;
+# 03/26 2011 shige: 3-2)
+$TDADDOPT = $THADDOPT = '';
 
 
 $TEXTAREA_attribs_rx_list = ",COLS,ROWS,NAME,";
@@ -607,7 +609,9 @@
 
     if ($color_env) {
 	local($color_test) = join(',',@$open_tags_R);
-	if ($color_test =~ /(color\{[^}]*})/g ) {
+	#if ($color_test =~ /(color\{[^}]*})/g ) {
+	# 02/19 2018 shige: 2-35)
+	if ($color_test =~ /(color\{[^}]*\})/g ) {
 	    $color_env = $1;
 	}
     }
@@ -860,6 +864,9 @@
 		$colspec =~ s/<TD/<$headcell/g;
 		$colspec =~ s/<\/TD/<\/$headcell/g;
 	    }
+	    # 03/26 2011 shige: 3-2)
+	    $colspec =~ s/<TD/<TD $TDADDOPT/g if $TDADDOPT;
+	    $colspec =~ s/<TH/<TH $THADDOPT/g if $THADDOPT;
 	    $return .= $colspec;
 	    undef $cell_done;
 	};
@@ -1046,7 +1053,9 @@
     local($math_start,$math_end)= ($sbig,$ebig);
 
     local($eqno);
-    local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    #local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    # 09/09 2010 shige: 3-3)
+    local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
                          , (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		         , "\">\n");
     do { # get the equation number
@@ -1106,7 +1115,7 @@
     if ($border||($attribs)) { 
 	join('',"<BR>\n<DIV$math_class>\n"
 	    , &make_table( $border, $attribs, '', '', '', $_ )
-	    , "\n<BR CLEAR=\"ALL\">");
+	    , "\n<BR CLEAR=\"ALL\">"); # </DIV> ? shige: 2-32)
     } elsif ($failed) {
 	$falign = (($EQN_TAGS =~ /L/)? 'LEFT' : 'RIGHT') if ($eqno);
 	local($fclass) = $math_class;
@@ -1193,7 +1202,9 @@
 	    , "</TD>\n<TD ALIGN=\"LEFT\" NOWRAP>"
 	    , "</TD></TR>", "\n</TABLE>", "</TD>\n<TD>" );
 	$sarray .= (($no_eqn_numbers) ? ">" :  " WIDTH=\"100%\">" );
-	local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	#local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	# 09/09 2010 shige: 3-3)
+	local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
 		, (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		, "\">\n");
 	if ($EQN_TAGS =~ /L/) { # number on left
diff -ruN latex2html-2018/versions/html4_0.pl l2h-2018-jp3.2b1.21/versions/html4_0.pl
--- latex2html-2018/versions/html4_0.pl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/versions/html4_0.pl	2019-08-27 11:50:54.825296000 +0900
@@ -590,6 +590,8 @@
 $TD__BGCOLOR_rx = $TH__BGCOLOR_rx = $color_type;
 $TD__ABBR_rx = $TH__ABBR_rx  = $TD__AXIS_rx = $TH__AXIS_rx = $cdata_type;
 $TD__AXES_rx = $TH__AXES_rx = $id_list_type;
+# 03/26 2011 shige: 3-2)
+$TDADDOPT = $THADDOPT = '';
 
 
 $TEXTAREA_attribs = ",DISABLED,READONLY,DIR,";
@@ -1208,6 +1210,9 @@
 		$colspec =~ s/<TD/<$headcell/g;
 		$colspec =~ s/<\/TD/<\/$headcell/g;
 	    }
+	    # 03/26 2011 shige: 3-2)
+	    $colspec =~ s/<TD/<TD $TDADDOPT/g if $TDADDOPT;
+	    $colspec =~ s/<TH/<TH $THADDOPT/g if $THADDOPT;
 	    $return .= $colspec;
 	    undef $cell_done;
 	};
@@ -1408,7 +1413,9 @@
     local($math_start,$math_end)= ($sbig,$ebig);
 
     local($eqno);
-    local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    #local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    # 09/09 2010 shige: 3-3)
+    local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
                          , (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		         , "\">\n");
     do { # get the equation number
@@ -1469,7 +1476,7 @@
     if ($border||($attribs)) { 
 	join('',"<BR>\n<DIV$math_class>\n"
 	    , &make_table( $border, $attribs, '', '', '', $_ )
-	    , "\n<BR CLEAR=\"ALL\">");
+	    , "\n<BR CLEAR=\"ALL\">"); # </DIV> ? shige: 2-32)
     } elsif ($failed) {
 	$falign = (($EQN_TAGS =~ /L/)? 'LEFT' : 'RIGHT') if ($eqno);
 	local($fclass) = $math_class;
@@ -1558,7 +1565,9 @@
 	    , "</TD></TR>", "\n</TABLE>", "</TD>\n<TD>" );
 	$env_id = '';
 	$sarray .= (($no_eqn_numbers) ? ">" :  " WIDTH=\"100%\">" );
-	local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	#local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	# 09/09 2010 shige: 3-3)
+	local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
 		, (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		, "\">\n");
 	if ($EQN_TAGS =~ /L/) { # number on left
@@ -1703,6 +1712,9 @@
 	join('' #,"<BR>\n<DIV$math_class>"
 	    , &make_table( $border, $attribs, '', '', '', $_ )
 	    , "\n</DIV><P></P><BR CLEAR=\"ALL\">");
+    # 02/16 2018 shige: 2-34)
+    } elsif ($no_eqn_numbers) {
+	$_;
     } else {
 	join('', $_ ,"<BR CLEAR=\"ALL\"><P></P>");
     }
diff -ruN latex2html-2018/versions/html4_01.pl l2h-2018-jp3.2b1.21/versions/html4_01.pl
--- latex2html-2018/versions/html4_01.pl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/versions/html4_01.pl	2019-08-27 11:51:35.631645000 +0900
@@ -611,6 +611,8 @@
 $TD__ABBR_rx = $TH__ABBR_rx  = $TD__AXIS_rx = $TH__AXIS_rx = $cdata_type;
 $TD__SCOPE_rx = $TH__SCOPE_rx = $scope_type;
 $TD__HEADERS_rx = $TH__HEADERS_rx = $id_list_type;
+# 03/26 2011 shige: 3-2)
+$TDADDOPT = $THADDOPT = '';
 
 
 $TEXTAREA_attribs = ",DISABLED,READONLY,DIR,";
@@ -976,7 +978,9 @@
 
     if ($color_env) {
 	local($color_test) = join(',',@$open_tags_R);
-	if ($color_test =~ /(color\{[^}]*})/g ) {
+	#if ($color_test =~ /(color\{[^}]*})/g ) {
+	# 02/19 2018 shige: 2-35)
+	if ($color_test =~ /(color\{[^}]*\})/g ) {
 	    $color_env = $1;
 	}
     }
@@ -1229,6 +1233,9 @@
 		$colspec =~ s/<TD/<$headcell/g;
 		$colspec =~ s/<\/TD/<\/$headcell/g;
 	    }
+	    # 03/26 2011 shige: 3-2)
+	    $colspec =~ s/<TD/<TD $TDADDOPT/g if $TDADDOPT;
+	    $colspec =~ s/<TH/<TH $THADDOPT/g if $THADDOPT;
 	    $return .= $colspec;
 	    undef $cell_done;
 	};
@@ -1429,7 +1436,9 @@
     local($math_start,$math_end)= ($sbig,$ebig);
 
     local($eqno);
-    local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    #local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    # 09/09 2010 shige: 3-3)
+    local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
                          , (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		         , "\">\n");
     do { # get the equation number
@@ -1490,7 +1499,7 @@
     if ($border||($attribs)) { 
 	join('',"<BR>\n<DIV$math_class>\n"
 	    , &make_table( $border, $attribs, '', '', '', $_ )
-	    , "\n<BR CLEAR=\"ALL\">");
+	    , "\n<BR CLEAR=\"ALL\">"); # </DIV> ? shige: 2-32)
     } elsif ($failed) {
 	$falign = (($EQN_TAGS =~ /L/)? 'LEFT' : 'RIGHT') if ($eqno);
 	local($fclass) = $math_class;
@@ -1579,7 +1588,9 @@
 	    , "</TD></TR>", "\n</TABLE>", "</TD>\n<TD>" );
 	$env_id = '';
 	$sarray .= (($no_eqn_numbers) ? ">" :  " WIDTH=\"100%\">" );
-	local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	#local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	# 09/09 2010 shige: 3-3)
+	local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
 		, (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		, "\">\n");
 	if ($EQN_TAGS =~ /L/) { # number on left
@@ -1724,6 +1735,9 @@
 	join('' #,"<BR>\n<DIV$math_class>"
 	    , &make_table( $border, $attribs, '', '', '', $_ )
 	    , "\n</DIV><P></P><BR CLEAR=\"ALL\">");
+    # 02/16 2018 shige: 2-34)
+    } elsif ($no_eqn_numbers) {
+	$_;
     } else {
 	join('', $_ ,"<BR CLEAR=\"ALL\"><P></P>");
     }
diff -ruN latex2html-2018/versions/math.pl l2h-2018-jp3.2b1.21/versions/math.pl
--- latex2html-2018/versions/math.pl	2018-02-02 01:52:36.000000000 +0900
+++ l2h-2018-jp3.2b1.21/versions/math.pl	2019-08-27 12:03:21.179116000 +0900
@@ -121,7 +121,9 @@
     local($saved) = $_;
 #   s/(^\s*(\$|\\\()\s*|\s*(\$|\\\))\s*$)//g; # remove the \$ signs or \(..\)
 #   s/^\\ensuremath(($O|$OP)\d+($C|$CP))(.*)\1/$4/; # remove an ensuremath wrapper
-    if (s/^$math_start_rx|$math_end_rx$//gs ) {}
+    #if (s/^$math_start_rx|$math_end_rx$//gs ) {}
+    # shige: 2-35)
+    if (s/^$math_start_rx|${math_end_rx}$//gs ) {}
     elsif (s/^\\ensuremath(($O|$OP)\d+($C|$CP))(.*)\1/$4/){} # remove an ensuremath wrapper
     else { $failed = 1 }
     s/\\(begin|end)(($O|$OP)\d+($C|$CP))tex2html_wrap\w*\2//g; # remove wrappers
@@ -171,7 +173,9 @@
     local($math_start,$math_end)= ($sbig,$ebig);
 
     local($eqno) = '&nbsp;'; # spacer, when no numbering
-    local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    #local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+    # 09/09 2010 shige: 3-3)
+    local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
                          , (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		         , "\">\n");
     do { # include the equation number, using a <TABLE>
@@ -370,9 +374,13 @@
     } else { 
 	# Inside <MATH>, { and } have special meaning. Thus, need &lcub;
 	# and &rcub;
-#    s/{/&lcub;/g; s/}/&rcub;/g; # Where are these defined ?
-	s/{/&lbrace;/g;
-	s/}/&rbrace;/g;
+##    s/{/&lcub;/g; s/}/&rcub;/g; # Where are these defined ?
+#	s/{/&lbrace;/g;
+#	s/}/&rbrace;/g;
+	# shige: 2-35)
+#    s/\{/&lcub;/g; s/}/&rcub;/g; # Where are these defined ?
+	s/\{/&lbrace;/g;
+	s/\}/&rbrace;/g;
 
 	# Remove the safety markers for math-entities
 	s/(\&\w+)#\w+;/$1;/g; 
@@ -985,7 +993,9 @@
 	$sarray .= "ALIGN=\"CENTER\" WIDTH=\"100%\">";
 	$env_id = '';
 
-	local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	#local($seqno) = join('',"\n<TD$eqno_class WIDTH=10 ALIGN=\""
+	# 09/09 2010 shige: 3-3)
+	local($seqno) = join('',"\n<TD$eqno_class WIDTH=\"$EQNO_WIDTH\" ALIGN=\""
 		, (($EQN_TAGS =~ /L/)? 'LEFT': 'RIGHT')
 		, "\">\n");
 	if ($EQN_TAGS =~ /L/) { # number on left
@@ -1430,6 +1440,8 @@
 	    while ($pre_test =~ s/(($O|$OP)\d+($C|$CP))(.*)\1/$4/) {};
 	    $use_all = 1 if ($pre_test=~s/($O|$OP)\d+($C|$CP)//);
 	    if (!$use_all) {
+		# 08/20 2014 shige: 2-33)
+		$pre_test = $pre_text;
 	        while ($pre_test =~ s/\\begin(($O|$OP)\d+($C|$CP))(.*)\\end\1/$4/){};
 		$use_all = 1 if ($pre_test=~s/\\(begin|end)($O|$OP)\d+($C|$CP)//);
 	    };
@@ -1657,7 +1669,9 @@
 		local($extra) = &get_supsub;
 # contents of $extra may require an image !!
 		# revert the brace-pairs
-		if ($extra =~ /{|}/) { 
+		#if ($extra =~ /{|}/) { 
+		# shige: 2-35)
+		if ($extra =~ /\{|\}/) { 
 		    &mark_string($extra);
 		    $extra =~ s/$O(\d+)$C/$OP$1$CP/g;
 		}
