diff -ruN latex2html-2024/config/config.pl l2h-2024-jp3.2b1.39/config/config.pl
--- latex2html-2024/config/config.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/config/config.pl	2025-03-11 11:06:05.316908000 +0900
@@ -695,6 +695,40 @@
   &result('yes');
 }
 
+# 2020-04-14 shige: 
+# -----
+# checking for Encode::Locale
+# -----
+&checking('for Encode::Locale');
+
+$newcfg{'Use_Encode_Locale'} = 0;
+$newcfg{'TerminalEncode'} = ''; 
+my $elpath;
+foreach $elpath (@INC) {
+    if ( -f "$elpath/Encode/Locale.pm" ) {
+	$newcfg{'Use_Encode_Locale'} = 1;
+	last;
+    }
+}
+if ( $newcfg{'Use_Encode_Locale'} ) {
+    &result('yes');
+} else {
+    &result('no');
+    $newcfg{'TerminalEncode'} = $opt{'TERMENCODE'} || $prefs{'TERMENCODE'} 
+    || '';
+    if ($newcfg{'TerminalEncode'} eq '') {
+	if (L2hos->plat eq 'win32') {
+	    $newcfg{'TerminalEncode'} = 'cp932';
+	    # $newcfg{'TerminalEncode'} = 'cp65001';
+	} else {
+	    # $newcfg{'TerminalEncode'} = 'eucJP';
+	    $newcfg{'TerminalEncode'} = 'UTF-8';
+	}
+    }
+    &checking('for default terminal locale setting');
+    &result($newcfg{'TerminalEncode'});
+}
+
 # --------------------------------------------------------------------------
 # Hashbang script starts
 # --------------------------------------------------------------------------
@@ -869,6 +903,10 @@
   if($initex) {
     $newcfg{'INITEX'} = $initex;
   }
+  # shige: 1-2)
+  elsif ( $newcfg{'TEX'} ) {
+    $newcfg{'INITEX'} = "$newcfg{'TEX'} -ini";
+  }
 }
 
 $newcfg{'KPSEWHICH'} = '';
@@ -1400,8 +1438,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
@@ -1411,6 +1452,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 '; }
 	$msg = 'there is nothing to crop'; $stat = '';
     } else {
@@ -1541,27 +1586,28 @@
     $newcfg{'PPMTOGIF'} = $ppmtogif;
 
     if ($opt{'have_pstoimg'} && $opt{'GIF'}) {
-    unless($msg =~ /ppm(to|2)gif/i) {
-      $opt{'GIF'} = 0;
-      result("error\n    Execution of $ppmtogif did not produce expected output\n");
-    }
-    else {
-      if($msg =~ /-transparent/i) {
-        &result('yes');
-        $newcfg{'gif_trans'} = 'netpbm';
+      unless($msg =~ /ppm(to|2)gif/i) {
+        $opt{'GIF'} = 0;
+        result("error\n    Execution of $ppmtogif did not produce expected output\n");
       }
       else {
-        &result('no');
+        if($msg =~ /-transparent/i) {
+          &result('yes');
+          $newcfg{'gif_trans'} = 'netpbm';
+        }
+        else {
+          &result('no');
+        }
+        &checking('if ppmtogif can make interlaced GIFs');
+        if($msg =~ /-interlace/i) {
+          &result('yes');
+          $newcfg{'gif_interlace'} = 'netpbm';
+        }
+        else {
+          &result('no');
+        }
       }
-      &checking('if ppmtogif can make interlaced GIFs');
-      if($msg =~ /-interlace/i) {
-        &result('yes');
-        $newcfg{'gif_interlace'} = 'netpbm';
-      }
-      else {
-        &result('no');
-      }
-    }}
+    }
   }
   else {
     $opt{'GIF'} = 0;
@@ -2383,6 +2429,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
@@ -2391,6 +2441,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-2024/configure l2h-2024-jp3.2b1.39/configure
--- latex2html-2024/configure	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/configure	2025-03-11 11:06:05.317281000 +0900
@@ -62,6 +62,8 @@
 ac_help="$ac_help
   --enable-texlive        build LaTeX2HTML for TeXlive cdrom"
 ac_help="$ac_help
+  --with-termencode=NAME  encode name on the terminal"
+ac_help="$ac_help
   --with-gs=PATH          path/name of the GhostScript executable"
 ac_help="$ac_help
   --with-dvips=PATH       path/name of the dvips executable"
@@ -838,6 +840,14 @@
 fi
 
 
+# Check whether --with-termencode or --without-termencode was given.
+if test "${with_termencode+set}" = set; then
+  withval="$with_termencode"
+  :
+else
+  with_termencode=${TERMENCODE:-}
+fi
+
 # Check whether --with-gs or --without-gs was given.
 if test "${with_gs+set}" = set; then
   withval="$with_gs"
@@ -1257,6 +1267,7 @@
   SHLIBDIR=$shlibdir \
   WRAPPER=$enable_wrapper \
   TEXLIVE=$enable_texlive \
+  TERMENCODE=$with_termencode \
   GS=$with_gs \
   DVIPS=$with_dvips \
   DVIPNG=$with_dvipng \
diff -ruN latex2html-2024/docs/manual.tex l2h-2024-jp3.2b1.39/docs/manual.tex
--- latex2html-2024/docs/manual.tex	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/docs/manual.tex	2025-03-11 11:06:05.317487000 +0900
@@ -4,6 +4,8 @@
 \usepackage{graphicx}
 %\usepackage{xcolor}
 
+% 08/20 2014 shige: for pdflatex: 2-22)
+\let\pdfoutput\undefined
 \usepackage{html,htmllist,makeidx,enumerate}
  \usepackage{longtable}
 %\usepackage{frames}
diff -ruN latex2html-2024/j2utf8.pl l2h-2024-jp3.2b1.39/j2utf8.pl
--- latex2html-2024/j2utf8.pl	1970-01-01 09:00:00.000000000 +0900
+++ l2h-2024-jp3.2b1.39/j2utf8.pl	2025-03-11 11:06:05.317632000 +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-2024/l2hconf.pin l2h-2024-jp3.2b1.39/l2hconf.pin
--- latex2html-2024/l2hconf.pin	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/l2hconf.pin	2025-03-11 11:06:05.317975000 +0900
@@ -377,6 +377,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.)
diff -ruN latex2html-2024/latex2html.pin l2h-2024-jp3.2b1.39/latex2html.pin
--- latex2html-2024/latex2html.pin	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/latex2html.pin	2025-03-11 11:18:29.569409000 +0900
@@ -7,6 +7,14 @@
 #
 # 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-2024} by shige
+# Shigeharu TAKENO <shige@iee.niit.ac.jp>
+# jLaTeX2HTML version 3.2b1.39 2025-03-11 shige
+
 # ****************************************************************
 # LaTeX To HTML Translation **************************************
 # ****************************************************************
@@ -55,7 +63,19 @@
 use Fcntl;
 use AnyDBM_File;
 use POSIX;						# for ceil()
-use Encode qw(decode_utf8 encode_utf8);			# for russian UTF-8 hack
+# 2020-04-28 shige: 1-4)
+#if @Use_Encode_Locale@
+# use Encode qw(decode_utf8 encode_utf8);		# for russian UTF-8 hack
+# 2019-12-24 shige: 1-4)
+use Encode::Locale qw(decode_argv $ENCODING_CONSOLE_OUT);
+$TERMENCODE = "$ENCODING_CONSOLE_OUT";
+#else
+$TERMENCODE = "@TerminalEncode@";
+#fi - Use_Encode_Locale
+# 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
@@ -96,6 +116,18 @@
 #fi
 
 use L2hos; # Operating system dependent routines
+# 2019-12-24 shige: 1-4)
+binmode STDERR, ":encoding($TERMENCODE)";
+binmode STDOUT, ":encoding($TERMENCODE)";
+# 2020-04-30 shige: 1-4)
+#if @Use_Encode_Locale@
+decode_argv();
+#else
+# for (@ARGV) {
+#    $_ = Encode::decode($TERMENCODE, $_);
+# }
+@ARGV = map { Encode::decode($TERMENCODE, $_); } @ARGV;
+#fi - Use_Encode_Locale
 
 # $^W = 1; # turn on warnings
 
@@ -141,6 +173,13 @@
 $TEX2HTMLV_SHORT = $RELEASE;
 $TEX2HTMLVERSION = "$TEX2HTMLV_SHORT ($REVISION)";
 $TEX2HTMLADDRESS = "http://www.latex2html.org/";
+# shige: 1-6)
+$JREVISION = "Released 2025-03-11";
+$JVERSION = "JA patch-3.2beta1.39";
+$JTEX2HTMLV_SHORT = "$RELEASE $JVERSION";
+$JTEX2HTMLVERSION = "$JTEX2HTMLV_SHORT ($JREVISION)";
+#$JTEX2HTMLADDRESS = "http://www.topstudio.co.jp/&#126;kmuto/software/latex2html/";
+$JTEX2HTMLADDRESS = "http://takeno.iee.niit.ac.jp/&#126;shige/TeX/latex2html/";
 
 # Set $HOME to what the system considers the home directory
 $HOME = L2hos->home();
@@ -281,6 +320,8 @@
         'dir=s',                \$FIXEDDIR,
         'mkdir',                \$MKDIR,
         'use_dvipng!',          \$USE_DVIPNG,
+        # 2020-04-03 shige: 3-6)
+        'use_dvipng_alter!',    \$USE_DVIPNG_ALTER,
         'dvipng_dpi=s',         \$DVIPNG_DPI,
         'use_pdftex!',          \$USE_PDFTEX,
         'use_luatex!',          \$USE_LUATEX,
@@ -338,6 +379,11 @@
         'xbit!',                \$XBIT_HACK,
         'ssi!',                 \$ALLOW_SSI,
         'php!',                 \$ALLOW_PHP,
+        # 08/08 2017 shige: 3-4)
+        'dresolution=i',	\$DRESOLUTION,
+        # 2019-07-30 shige: 1-4)
+        'ienc=s',               \$TEXENCODE,
+        'oenc=s',               \$HTMLENCODE,
         'test_mode!' # undocumented switch
        )) {
     &usage();
@@ -423,10 +469,12 @@
     $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$dd]/) {	# should start with / or .
-    # 2019-12-18 shige: 2-43)
     if ($INIT_FILE !~ /^\./ && !L2hos->is_absolute_path($INIT_FILE)) {
 	$INIT_FILE = ".$dd$INIT_FILE";	# so that value of @INC has no effect
     }
@@ -528,6 +576,38 @@
 # _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",
+		   );
+# -ienc: jis/euc/sjis/utf8/noja
+if (! $TEXENCODE || $TEXENCODE =~ /noja/) {
+    $TEXENCODE = "";
+} else {
+    $USE_PDFTEX = $USE_LUATEX = $USE_LUADVI = $USE_DVIPNG = 0;
+    $LATEX = "$LATEX --kanji=$TEXENCODE";
+    if ($encoding_names{$TEXENCODE}) {
+	$TEXENCODE = $encoding_names{$TEXENCODE};
+    } else {
+	die "Error: $TEXENCODE not invalid option to -ienc\n";
+    }
+}
+# -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 || 'utf-8';
 
 # This will be set to 1 by polyglossia.perl to mark its own presence
@@ -844,6 +924,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";
@@ -1106,7 +1188,8 @@
             unless($ignore);
         return undef;
     }
-    binmode CATFILE;
+#    binmode CATFILE;
+# 2022-10-21 shige 1-10)
     local($/) = undef; # slurp in whole file
     my $contents = <CATFILE>;
     close(CATFILE);
@@ -1369,7 +1452,8 @@
     $auto_styles =~ s/\|$//;
 
     if(open(STYLES, "<$TMP_${dd}styles")) {
-        binmode STYLES;
+#        binmode STYLES;
+# 2022-10-21 shige 1-10)
         while(<STYLES>) {
             if(s/^\s*(\S+)\s*(.*)$/$style = $1; $options = $2;/eo) {
                 &do_require_package($style);
@@ -1427,8 +1511,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);
@@ -1439,9 +1526,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;
     }
@@ -1452,13 +1543,21 @@
 	&write_mydb("verbatim", $global{'verbatim_counter'}, $2);
 	"$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);
@@ -1619,7 +1718,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)
 	    }
@@ -1661,8 +1762,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;
     }
@@ -1793,10 +1897,13 @@
     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";
     }
-    binmode SINPUT;
+#    binmode SINPUT;
+# 2022-10-21 shige 1-10)
     local(@file_string);
     print STDOUT "$file" if ($VERBOSITY >1);
     while (<SINPUT>) {
@@ -1881,7 +1988,8 @@
     &wrap_shorthand_environments;
     print STDOUT "\n *** End-of-partition ***" if ($VERBOSITY > 1);
     if(open(OUT, ">$TMP_$dd$PARTITION_PREFIX$count")) {
-        binmode OUT;
+#        binmode OUT;
+# 2022-10-21 shige 1-10)
         print OUT $_;
         close(OUT);
     } else {
@@ -1901,8 +2009,12 @@
 sub slurp_input  {
     local($file) = @_;
     local(%string);
-    if(open(INPUT,"<$file")) {
-        binmode INPUT;
+    # if(open(INPUT,"<$file")) {
+    # 2019-07-30 shige: 1-4)
+    if (($TEXENCODE && open(INPUT, "< :encoding($TEXENCODE)", "$file")) 
+	|| (! $TEXENCODE && open(INPUT,"<$file"))) {
+#	binmode INPUT; 
+# 2022-10-21 shige 1-10)
         local(@file_string);
         while (<INPUT>) {
 	    push(@file_string, $_ );
@@ -1940,14 +2052,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
@@ -2063,7 +2180,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);
@@ -2358,9 +2477,14 @@
 	    }
 	    $CURRENT_FILE = &make_name($curr_sec, join('_',@curr_sec_id));
 	    
-	    open(OUTPUT, ">$CURRENT_FILE")
+	    # 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";
-        binmode OUTPUT;
+#	    binmode OUTPUT;
+# 2022-10-21 shige 1-10)
 	    if ($XBIT_HACK) { # use Apache's XBit hack
 		chmod 0744, $CURRENT_FILE;
 		&check_htaccess;
@@ -2464,8 +2588,8 @@
 
 	# include $BODYTEXT in the section_info, when starting a new page
 	$section_info{join(' ',@curr_sec_id)} =
-	    "$current_depth$delim$CURRENT_FILE$delim$TITLE$delim"
-		. (($current_depth < $MAX_SPLIT_DEPTH)? $BODYTEXT: "");
+	   "$current_depth$delim$CURRENT_FILE$delim$TITLE$delim"
+	       . (($current_depth < $MAX_SPLIT_DEPTH)? $BODYTEXT: "");
 
 	# Get type of section (see also the split above)
 	$curr_sec = $sections[$i+1].$sections[$i+2];
@@ -3550,9 +3674,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/);
@@ -3639,8 +3774,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);
@@ -3780,7 +3920,10 @@
 #	inline math --- horizontal mode, captures height/depth + \mathsurround
 sub make_hbox {
     local($id,$contents) = @_;
-    if ($id =~ /indisplay/ or $USE_DVIPNG or $IMAGE_TYPE eq 'svg') {
+    # if ($id =~ /indisplay/ or $USE_DVIPNG or $IMAGE_TYPE eq 'svg') {
+    # 2020-04-03 shige: 3-6)
+    if ($id =~ /indisplay/ or $USE_DVIPNG or $IMAGE_TYPE eq 'svg'
+       or ($TEXENCODE && $USE_DVIPNG_ALTER)) {
 	"\\lthtmlinlinemathA{". $id ."}%\n". $contents ."%\n\\lthtmlindisplaymathZ\n";
     } else {
 	"\\lthtmlinlinemathA{". $id ."}%\n". $contents ."%\n\\lthtmlinlinemathZ\n";
@@ -3810,11 +3953,19 @@
 }
 
 sub preprocess_images {
+    # 2020-03-03 shige: 2-43)
+    local($myprefix) = "${PREFIX}";
+    if (!L2hos->is_absolute_path("${PREFIX}images.pre")) {
+	$myprefix = ".$dd${PREFIX}";
+    }
     do {
 	print "\nWriting image.pre file ...\n";
-	open(ENV,">.$dd${PREFIX}images.pre")
+	# open(ENV,">.$dd${PREFIX}images.pre")
+	# 2020-03-03 shige: 2-43)
+	open(ENV,">${myprefix}images.pre")
             || die "\nCannot write '${PREFIX}images.pre': $!\n";
-	binmode ENV;
+#	binmode ENV;
+# 2022-10-21 shige 1-10)
 	print ENV &make_latex($latex_body);
 	print ENV "\n";
 	close ENV;
@@ -3832,20 +3983,32 @@
 	    L2hos->syswait($this_cmd);
 	}
 	# save pre-processor commands in a file:  preproc
-	open(CMDS,">.$dd${PREFIX}preproc")
+	# open(CMDS,">.$dd${PREFIX}preproc")
+	# 2020-03-03 shige: 2-43)
+	open(CMDS,">${myprefix}preproc")
             || die "\nCannot write '${PREFIX}preproc': $!\n";
-	binmode CMDS;
+#	binmode CMDS;
+# 2022-10-21 shige 1-10)
 	print CMDS $preprocessor_cmds ;
 	close CMDS;
 
     } if ((%latex_body) && ($latex_body =~ /newpage/));
 }
 sub make_image_file {
+    # 2020-03-03 shige: 2-43)
+    local($myprefix) = "${PREFIX}";
+    if (!L2hos->is_absolute_path("${PREFIX}images.tex")) {
+	$myprefix = ".$dd${PREFIX}";
+    }
     do {
 	print "\nWriting image file ...\n";
-	open(ENV,">.$dd${PREFIX}images.tex")
+	# open(ENV,">.$dd${PREFIX}images.tex")
+	($TEXENCODE &&
+	 open(ENV, "> :encoding($TEXENCODE)", "${myprefix}images.tex"))
+	    || (!$TEXENCODE && open(ENV, ">${myprefix}images.tex"))
             || die "\nCannot write '${PREFIX}images.tex': $!\n";
-    binmode ENV;
+#	binmode ENV;
+# 2022-10-21 shige 1-10)
 	print ENV &make_latex($latex_body);
 	print ENV "\n";
 	close ENV;
@@ -3858,18 +4021,31 @@
     &close_dbm_database if $DJGPP;
     local($dd) = $dd; $dd = '/' if ($dd eq "\\");
     local($latex_call);
+    # 2020-03-03 shige: 2-43)
+    local($myprefix) = "${PREFIX}";
+    if (!L2hos->is_absolute_path("${PREFIX}images.tex")) {
+	$myprefix = ".$dd${PREFIX}";
+    }
     if ($USE_PDFTEX) {
       print "\nTranslating images to PDF using pdflatex ...\n";
-      $latex_call = "$PDFLATEX .$dd${PREFIX}images.tex";
+      # $latex_call = "$PDFLATEX .$dd${PREFIX}images.tex";
+      # 2020-03-03 shige: 2-43)
+      $latex_call = "$PDFLATEX ${myprefix}images.tex";
     } elsif ($USE_LUATEX) {
       print "\nTranslating images to PDF using lualatex ...\n";
-      $latex_call = "$LUALATEX .$dd${PREFIX}images.tex";
+      # $latex_call = "$LUALATEX .$dd${PREFIX}images.tex";
+      # 2020-03-03 shige: 2-43)
+      $latex_call = "$LUALATEX ${myprefix}images.tex";
     } elsif ($USE_LUADVI) {
       print "\nTranslating images to DVI using dvilualatex ...\n";
-      $latex_call = "$DVILUALATEX .$dd${PREFIX}images.tex";
+      # $latex_call = "$DVILUALATEX .$dd${PREFIX}images.tex";
+      # 2020-03-03 shige: 2-43)
+      $latex_call = "$DVILUALATEX ${myprefix}images.tex";
     } else {
       print "\nTranslating images to DVI using latex ...\n";
-      $latex_call = "$LATEX .$dd${PREFIX}images.tex";
+      # $latex_call = "$LATEX .$dd${PREFIX}images.tex";
+      # 2020-03-03 shige: 2-43)
+      $latex_call = "$LATEX ${myprefix}images.tex";
     }
     print "$latex_call\n" if (($DEBUG)||($VERBOSITY > 1));
     L2hos->syswait($latex_call);
@@ -3878,13 +4054,22 @@
 
 sub make_off_line_images {
     local($name, $page_num);
-    if (!$NOLATEX && -f ".${dd}${PREFIX}images.tex") {
+    # 2020-03-03 shige: 2-43)
+    local($myprefix) = "${PREFIX}";
+    if (!L2hos->is_absolute_path("${PREFIX}images.tex")) {
+	$myprefix = ".$dd${PREFIX}";
+    }
+    # if (!$NOLATEX && -f ".${dd}${PREFIX}images.tex") {
+    # 2020-03-03 shige: 2-43)
+    if (!$NOLATEX && -f "${myprefix}images.tex") {
 	&make_tmp_dir;	# sets  $TMPDIR  and  $DESTDIR
 	$IMAGE_PREFIX =~ s/^_//o if ($TMPDIR);
 
 	&make_latex_images();
 
-	&process_log_file(".$dd${PREFIX}images.log"); # Get eqn size info
+	# &process_log_file(".$dd${PREFIX}images.log"); # Get eqn size info
+	# 2020-03-03 shige: 2-43)
+	&process_log_file("${myprefix}images.log"); # Get eqn size info
 	unless ($LaTeXERROR) {
 	    &call_dvips();
 	    # add suffix .ps to the file-names for each image
@@ -3915,8 +4100,12 @@
 # by command line options
 sub call_dvips {
     # local($dvips_call);
-    # 2019-12-27 shige: 2-44)
-    local($dvips_call, $dvips_call2);
+    # 2020-03-03 shige: 2-43)
+    local($dvips_call, $dvips_call2, $myprefix);
+    $myprefix = "${PREFIX}";
+    if (!L2hos->is_absolute_path("${PREFIX}images.tex")) {
+	$myprefix = ".$dd${PREFIX}";
+    }
     if ($USE_PDFTEX || $USE_LUATEX) {
 	# svg images are produced directly from images.pdf,
 	# don't need to do anything here
@@ -3929,13 +4118,18 @@
 		    'png16m' :		# better use png16m and quantize later
 		    'png16m';		# 24 bit color for png
 		print "\nTransforming PDF images using gs/$device ...\n";
-		$dvips_call .= "-sDEVICE=$device -r$DVIPNG_DPI -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$TMPDIR$dd$IMAGE_PREFIX%d.png .${dd}${PREFIX}images.pdf";
+		# $dvips_call .= "-sDEVICE=$device -r$DVIPNG_DPI -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$TMPDIR$dd$IMAGE_PREFIX%d.png .${dd}${PREFIX}images.pdf";
+		# 2020-03-03 shige: 2-43)
+		$dvips_call .= "-sDEVICE=$device -r$DVIPNG_DPI -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$TMPDIR$dd$IMAGE_PREFIX%d.png ${myprefix}images.pdf";
 	    } else {
 		# did not usepackage{preview}, need to crop
 		print "\nTransforming PDF images to postscript using gs/ps2write ...\n";
-		$dvips_call2 = $dvips_call . "-sDEVICE=ps2write -sOutputFile=$TMPDIR$dd$IMAGE_PREFIX%.3d.ps .${dd}${PREFIX}images-crop.pdf";
+		# $dvips_call2 = $dvips_call . "-sDEVICE=ps2write -sOutputFile=$TMPDIR$dd$IMAGE_PREFIX%.3d.ps .${dd}${PREFIX}images-crop.pdf";
+		# 2020-03-03 shige: 2-43)
+		$dvips_call2 = $dvips_call . "-sDEVICE=ps2write -sOutputFile=$TMPDIR$dd$IMAGE_PREFIX%.3d.ps ${myprefix}images-crop.pdf";
 		$dvips_call = "$PDFCROP --hires " . ($DEBUG ? '--debug ' : '')
-		    . ".${dd}${PREFIX}images.pdf";
+		#     . ".${dd}${PREFIX}images.pdf";
+		     . "${myprefix}images.pdf";
 	    }
 	}
     } else {
@@ -3943,16 +4137,25 @@
 	if ($IMAGE_TYPE ne 'svg') {
 	    if ($USE_DVIPNG) {
 		print "\nGenerating images using dvipng ...\n";
-		$dvips_call = "$DVIPNG -D $DVIPNG_DPI -o$TMPDIR$dd$IMAGE_PREFIX%d.png -T tight .${dd}${PREFIX}images.dvi";
+		# $dvips_call = "$DVIPNG -D $DVIPNG_DPI -o$TMPDIR$dd$IMAGE_PREFIX%d.png -T tight .${dd}${PREFIX}images.dvi";
+		# 2020-03-03 shige: 2-43)
+		$dvips_call = "$DVIPNG -D $DVIPNG_DPI -o$TMPDIR$dd$IMAGE_PREFIX%d.png -T tight ${myprefix}images.dvi";
+	    } elsif ($TEXENCODE && $USE_DVIPNG_ALTER) { 
+		# 2020-04-03 shige: 3-6)
+		$dvips_call2 = "$GS -q -dNOPAUSE -dNO_PAUSE -dBATCH -dSAFER ";
+		$dvips_call2 .= "-sDEVICE=png16m -r$DVIPNG_DPI -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sOutputFile=$TMPDIR$dd$IMAGE_PREFIX%d.png ${myprefix}images.ps";
+		$dvips_call = "$DVIPS ${myprefix}images.dvi";
 	    } else {
 		print "\nGenerating postscript images using dvips ...\n";
-		$dvips_call = "$DVIPS -S1 -i $DVIPSOPT -o$TMPDIR$dd${IMAGE_PREFIX} .${dd}${PREFIX}images.dvi";
+		# $dvips_call = "$DVIPS -S1 -i $DVIPSOPT -o$TMPDIR$dd${IMAGE_PREFIX} .${dd}${PREFIX}images.dvi";
+		# 2020-03-03 shige: 2-43)
+		$dvips_call = "$DVIPS -S1 -i $DVIPSOPT -o$TMPDIR$dd${IMAGE_PREFIX} ${myprefix}images.dvi";
 	    }
 	} else {
 	    # $dvips_call = "$DVIPS .${dd}${PREFIX}images.dvi && $PS2PDF .${dd}${PREFIX}images.ps";
-	    # 2019-10-29, 2019-12-27 shige: 2-41)
-	    $dvips_call = "$DVIPS .${dd}${PREFIX}images.dvi";
-	    $dvips_call2 = "$PS2PDF .${dd}${PREFIX}images.ps";
+	    # 2019-10-29, 2019-12-27 shige: 2-41), 2020-03-03 shige: 2-43)
+	    $dvips_call = "$DVIPS ${myprefix}images.dvi";
+	    $dvips_call2 = "$PS2PDF ${myprefix}images.ps";
 	    print $dvips_call, "\n";
 	}
     }
@@ -3982,6 +4185,11 @@
 	  %page_map, $img);
     # 2020-03-03 shige:
     local $imgsize;
+    # 2020-03-03 shige: 2-43)
+    local($myprefix) = "${PREFIX}";
+    if (!L2hos->is_absolute_path("${PREFIX}images.tex")) {
+	$myprefix = ".$dd${PREFIX}";
+    }
     # It is necessary to run LaTeX this early because we need the log file
     # which contains information used to determine equation alignment
     if ( $latex_body =~ /newpage/) {
@@ -3990,17 +4198,23 @@
 	    local ($plain_latex) = !($USE_PDFTEX || $USE_LUATEX || $USE_LUADVI);
 	    # dump a pre-compiled format
 	    if (!(-f "${PREFIX}images.fmt") && $plain_latex) {
+		# 2020-03-03 shige: 2-43)
 	        print "$INILATEX .$dd${PREFIX}images.tex\n" 
 		    if (($DEBUG)||($VERBOSITY > 1));
 	        print "dumping ${PREFIX}images.fmt\n"
-		    unless ( L2hos->syswait("$INILATEX .$dd${PREFIX}images.tex"));
+		   # unless ( L2hos->syswait("$INILATEX .$dd${PREFIX}images.tex"));
+		   # 2020-03-03 shige: 2-43)
+		    unless ( L2hos->syswait("$INILATEX ${myprefix}images.tex"));
+
 	    }
 	    local ($img_fmt) = (-f "${PREFIX}images.fmt");
 	    if ($img_fmt && $plain_latex) {
                 # use the pre-compiled format
 	        print "$TEX \"&.$dd${PREFIX}images\" .$dd${PREFIX}images.tex\n"
 		    if (($DEBUG)||($VERBOSITY > 1));
-	        L2hos->syswait("$TEX \"&.$dd${PREFIX}images\" .$dd${PREFIX}images.tex");
+	        # L2hos->syswait("$TEX \"&.$dd${PREFIX}images\" .$dd${PREFIX}images.tex");
+		# 2020-03-03 shige: 2-43)
+	        L2hos->syswait("$TEX \"&${myprefix}images\" ${myprefix}images.tex");
 	    } elsif (-f "${PREFIX}images.dvi" && $plain_latex) {
 	        print "${PREFIX}images.fmt failed, proceeding anyway\n";
 	    } else {
@@ -4013,22 +4227,30 @@
 		  print "\nTranslating images to PDF using pdflatex ...\n";
 		  print "$PDFLATEX .$dd${PREFIX}images.tex\n"
 		    if (($DEBUG)||($VERBOSITY > 1));
-		  L2hos->syswait("$PDFLATEX .$dd${PREFIX}images.tex");
+		  # L2hos->syswait("$PDFLATEX .$dd${PREFIX}images.tex");
+		  # 2020-03-03 shige: 2-43)
+		  L2hos->syswait("$PDFLATEX ${myprefix}images.tex");
 		} elsif ($USE_LUATEX) {
 		  print "\nTranslating images to PDF using lualatex ...\n";
 		  print "$LUALATEX .$dd${PREFIX}images.tex\n"
 		    if (($DEBUG)||($VERBOSITY > 1));
-		  L2hos->syswait("$LUALATEX .$dd${PREFIX}images.tex");
+		  # L2hos->syswait("$LUALATEX .$dd${PREFIX}images.tex");
+		  # 2020-03-03 shige: 2-43)
+		  L2hos->syswait("$LUALATEX ${myprefix}images.tex");
 		} elsif ($USE_LUADVI) {
 		  print "\nTranslating images to DVI using dvilualatex ...\n";
 		  print "$DVILUALATEX .$dd${PREFIX}images.tex\n"
 		    if (($DEBUG)||($VERBOSITY > 1));
-		  L2hos->syswait("$DVILUALATEX .$dd${PREFIX}images.tex");
+		  # L2hos->syswait("$DVILUALATEX .$dd${PREFIX}images.tex");
+		  # 2020-03-03 shige: 2-43)
+		  L2hos->syswait("$DVILUALATEX ${myprefix}images.tex");
 		} else {
 		  print "\nTranslating images to DVI using latex ...\n";
 		  print "$LATEX .$dd${PREFIX}images.tex\n"
 		    if (($DEBUG)||($VERBOSITY > 1));
-		  L2hos->syswait("$LATEX .$dd${PREFIX}images.tex");
+		  # L2hos->syswait("$LATEX .$dd${PREFIX}images.tex");
+		  # 2020-03-03 shige: 2-43)
+		  L2hos->syswait("$LATEX ${myprefix}images.tex");
 		}
 	    }
 	} else { &make_latex_images() }
@@ -4064,7 +4286,9 @@
     }
     do {print "\n\n*** LaTeXERROR"; return()} if ($LaTeXERROR);
     return() if ($LaTeXERROR); # empty .dvi file
-    L2hos->Unlink(".$dd${PREFIX}images.dvi") unless $DEBUG;
+    # L2hos->Unlink(".$dd${PREFIX}images.dvi") unless $DEBUG;
+    # 2020-03-03 shige: 2-43)
+    L2hos->Unlink("${myprefix}images.dvi") unless $DEBUG;
 
     print "\n *** updating image cache\n" if ($VERBOSITY > 1);
     while ( ($uucontents, $_) = each %cached_env_img) {
@@ -4236,10 +4460,24 @@
     $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);
+
+    # 2021-02-10 shige: 2-49)
+    if ($name =~ /figure|table/ && $FIGURE_SCALE_FACTOR) {
+	$exscale = 1 unless($exscale);
+	$exscale *= $FIGURE_SCALE_FACTOR;
+    } elsif ($MATH_SCALE_FACTOR) {
+	$exscale = 1 unless($exscale);
+	$exscale *= $MATH_SCALE_FACTOR;
+	if ($name =~ /equation|eqnarray|display/ && $DISP_SCALE_FACTOR) {
+	    $exscale *= $DISP_SCALE_FACTOR;
+	}
+    }
     
     # without -noshrink and -nocenter, pdftocairo scales image slightly
     # due to internally rounding page size to nearest integer number of pt
@@ -4253,6 +4491,8 @@
 	  $eheight{$name} = $3 / $pt_per_ex{$name};	# image height in ex
 	  $edepth{$name} = $ptdepth{$name} / $pt_per_ex{$name};
 	  # extra .5pt in depth is border from latex "preview" package
+	  # 2021-02-10 shige:
+	  if ($exscale > 0) { $eheight{$name} *= $exscale; }
 	}
 	if ($name =~ /$inline_env_rx/) {
 	  # remove image size so that image can scale with font size
@@ -4306,7 +4546,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);
@@ -4317,6 +4559,9 @@
 		$thumbnail = "${PREFIX}T$img";
 	    }
     } elsif ($cropmarkheight{$name}) {
+    # 2020-04-03 shige: 3-6)
+    # } elsif ($cropmarkheight{$name} 
+    #      || ($TEXENCODE && $USE_DVIPNG_ALTER)) {
         my $p="$TMPDIR$dd$IMAGE_PREFIX$new_num";
         die $! unless -f "$p.png";
         &close_dbm_database if $DJGPP;
@@ -4325,8 +4570,15 @@
         print "imgpixeloverex=$imgpixeloverex\n" if ($VERBOSITY > 2);
         if ( $name =~ /figure|table/ and $FIGURE_SCALE_FACTOR) 
             {$imgpixeloverex*= $FIGURE_SCALE_FACTOR;}
-        if ($name =~ /equation|eqnarray|display/){
-            $imgpixeloverex *= $DISP_SCALE_FACTOR if $DISP_SCALE_FACTOR}
+        # if ($name =~ /equation|eqnarray|display/){
+	#    $imgpixeloverex *= $DISP_SCALE_FACTOR if $DISP_SCALE_FACTOR}
+	# 2021-02-10 shige:
+	elsif ($MATH_SCALE_FACTOR) {
+            $imgpixeloverex*= $MATH_SCALE_FACTOR;
+	    if ($name =~ /equation|eqnarray|display/ && $DISP_SCALE_FACTOR) {
+		$imgpixeloverex *= $DISP_SCALE_FACTOR;
+	    }
+	}
         my $millimeter=int(.04*$DVIPNG_DPI); 
         if ($TRANSPARENT_FIGURES) {
 	    my $TRANSPARENT_COLOR=
@@ -4422,6 +4674,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 ":'') 
@@ -4445,6 +4699,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 ":'') 
@@ -4479,6 +4735,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 " : '' )
@@ -4516,6 +4774,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 == int($exscale))&&($exscale != 1)&&
@@ -4665,11 +4925,18 @@
 # MRO: test for existance
 sub copy_file {
     local($file, $ext) = @_;
+    # 2020-03-03 shige: 2-43)
+    local($myprefix) = "${PREFIX}";
+    if (!L2hos->is_absolute_path("${PREFIX}images.tex")) {
+	$myprefix = ".$dd${PREFIX}";
+    }
     $file =  &fulltexpath("$FILE.$ext");
     if(-r $file) {
         print "\nNote: Copying '$file' for image generation\n"
             if($VERBOSITY > 2);
-        L2hos->Copy($file, ".$dd${PREFIX}images.$ext");
+        # L2hos->Copy($file, ".$dd${PREFIX}images.$ext");
+	# 2020-03-03 shige: 2-43)
+        L2hos->Copy($file, "${myprefix}images.$ext");
     }
 }
 
@@ -5180,8 +5447,11 @@
 		    # Regular (not block) tags are pushed from tail
 		    $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 :  ";
@@ -6139,7 +6409,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) {
@@ -6155,6 +6427,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";
@@ -6588,7 +6862,7 @@
 	    "$current_depth$delim$CURRENT_FILE$delim$title"
 		if ($current_depth <= $MAX_SPLIT_DEPTH + $MAX_LINK_DEPTH);
 	$section_info{join(' ',@curr_sec_id)} = \
-	    "$current_depth$delim$CURRENT_FILE$delim$title$delim";
+	   "$current_depth$delim$CURRENT_FILE$delim$title$delim";
 	$title = join('',"<A ID=\"SECTION$section_tag\"><B>"
 		      , $title , "</B></A>" );
     } else {
@@ -7103,7 +7377,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) {
@@ -7124,7 +7400,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 ($!);
@@ -7154,7 +7432,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 ); 
@@ -7209,7 +7489,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;
     }
 
@@ -7279,7 +7561,10 @@
     " \\parindent=0pt\\abovedisplayskip=0pt\\belowdisplayskip=0pt}%\n" .
     " \\def\\phantompar{\\csname par\\endcsname}\\normalsize}%\n" .
     "\\def\\lthtmltypeout#1{{\\let\\protect\\string \\immediate\\write\\lthtmlwrite{#1}}}%\n" .
-    (($USE_DVIPNG || $IMAGE_TYPE eq 'svg') ? <<'</dvipng>' :
+#    (($USE_DVIPNG || $IMAGE_TYPE eq 'svg') ? <<'</dvipng>' :
+# 2020-04-03 shige: 3-6)
+    (($USE_DVIPNG || $IMAGE_TYPE eq 'svg'
+	|| ($TEXENCODE && $USE_DVIPNG_ALTER)) ? <<'</dvipng>' :
 \usepackage[tightpage,active]{preview}
 \PreviewBorder=0.5bp
 \newbox\lthtmlPageBox
@@ -7507,19 +7792,27 @@
     }
 
     join("\n", (($DOCTYPE)? $DTDcomment : '' )
-	,"<!--Converted with LaTeX2HTML $TEX2HTMLVERSION"
-	    . " -->\n<HTML lang=\"". ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage)
-	 . "\">\n<HEAD>\n<TITLE>".$title."</TITLE>"
-	, &meta_information($title)
+	#,"<!--Converted with LaTeX2HTML $TEX2HTMLVERSION"
+	#    . " -->\n<HTML lang=\"". ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage)
+	# . "\">\n<HEAD>\n<TITLE>".$title."</TITLE>"
+	#, &meta_information($title)
+	# shige: 1-6)
+	,"<!--Converted with jLaTeX2HTML $JTEX2HTMLVERSION"
+	. " -->\n<HTML lang=\"". ($ISO_LANGUAGE ? $ISO_LANGUAGE : $isolanguage)
+	. "\">\n<HEAD>\n"
 	,  ($CHARSET && $HTML_VERSION ge "2.1" ? 
 	      "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=$this_charset\">" 
 	    : "" )
         , "<META NAME=\"viewport\" CONTENT=\"width=device-width, initial-scale=1.0\">"
 	, $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>", '');
 }
@@ -7537,10 +7830,12 @@
         print "\nError: Cannot write '$FILE.css': $!\n";
         return;
     }
-    binmode STYLESHEET;
+#    binmode STYLESHEET;
+# 2022-10-21 shige 1-10)
     if ( -f $EXTERNAL_STYLESHEET ) {
         if(open(EXT_STYLES, "<$EXTERNAL_STYLESHEET")) {
-            binmode EXT_STYLES;
+#            binmode EXT_STYLES;
+# 2022-10-21 shige 1-10)
             while (<EXT_STYLES>) { print STYLESHEET $_; }
             close(EXT_STYLES);
         } else {
@@ -7681,14 +7976,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 }
     }
@@ -7712,11 +8014,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
@@ -7871,9 +8177,14 @@
 		if ($this_file =~ /\Q$dd\E([^$dd$dd]+)$/) { $this_file = $1 }
 	    }
 	    &slurp_input($this_file);
-	    open(OUTFILE, ">$this_file")
+	    # 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";
-	    binmode OUTFILE;
+#	    binmode OUTFILE;
+# 2022-10-21 shige 1-10)
 	    if (($INDEX) && ($SHORT_INDEX) && ($SEGMENT eq 1)) {
 		&make_index_segment($title,$file); }
 
@@ -7882,8 +8193,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(), $_ );
@@ -8238,7 +8553,8 @@
 	return();
     }
     if(open(INIT, "<$init_file")) {
-        binmode INIT;
+#        binmode INIT;
+# 2022-10-21 shige 1-10)
         foreach $info_line (<INIT>) {
 	    $info_line =~ s/[<>"&]/'&'.$html_special_entities{$&}.';'/eg;
 	    $init_contents .= $info_line;
@@ -9000,8 +9316,13 @@
 
 sub post_process_footnotes {
     &slurp_input($footfile);
-    open(OUT, ">$footfile") || die "Cannot write file '$footfile': $!\n";
-    binmode OUT;
+    #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";
+#    binmode OUT;
+# 2022-10-21 shige 1-10)
     &replace_markers;
     &post_post_process if (defined &post_post_process);
     &adjust_encoding;
@@ -9019,11 +9340,15 @@
 	);
     &replace_markers unless ($filename eq $footfile); 
 
-    unless(open(FILE,">$filename")) {
+    #unless(open(FILE,">$filename")) {
+    # 2021-03-17 shige: (2-50)
+    unless(($HTMLENCODE && open(FILE, "> :encoding($HTMLENCODE)", "$filename"))
+    	   || (! $HTMLENCODE && open(FILE, ">$filename"))) {
         print "\nError: Cannot write '$filename': $!\n";
         return;
     }
-    binmode FILE;
+#    binmode FILE;
+# 2022-10-21 shige 1-10)
     print FILE $_;
     close(FILE);
 }
@@ -9088,7 +9413,9 @@
 sub replace_verb_marks {
     # Modifies $_
     s/($verb_mark|$verbstar_mark|$verblst_mark)(\d+)$verb_mark/
-	$code = $verb{$2};
+	# $code = $verb{$2};
+	# 04\/18 2017 shige: 1-4)
+	$code = Encode::decode("utf8", $verb{$2});
 	$code = &replace_comments($code) if ($code =~ m:$comment_mark:);
 	if ($1 eq $verblst_mark)
 	{$code=&process_lstinline($verb_lstopt{$2},$code);}
@@ -9507,8 +9834,9 @@
 
 # MRO: Print standardized header
 sub banner {
+# shige: 1-6)
     print <<"EOF";
-This is LaTeX2HTML Version $TEX2HTMLVERSION
+This is jLaTeX2HTML Version $JTEX2HTMLVERSION (based LaTeX2HTML Version $TEX2HTMLVERSION)
 EOF
 }
 
@@ -9528,7 +9856,8 @@
     my $script = $SCRIPT || $0;
     open(PIPE, "$perldoc -t $script |")
         || die "Fatal: can't open pipe: $!";
-    binmode PIPE;
+#    binmode PIPE;
+# 2022-10-21 shige 1-10)
     while (<PIPE>) {
         if (/^\s*$/) {
             next;
@@ -10068,15 +10397,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
@@ -10573,6 +10912,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
@@ -10590,6 +10934,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 );
@@ -10655,7 +11004,8 @@
         print "\nError: Cannot write '$urlimg': $!\n";
         return;
     }
-    binmode IMAGE_MAP;
+#    binmode IMAGE_MAP;
+# 2022-10-21 shige 1-10)
     ### HWS  Pass server map unchanged from user
     print IMAGE_MAP "<HTML>\n<BODY>\n<A HREF=\"$map\">\n";
     print IMAGE_MAP "<IMG\n SRC=\"$url\" ISMAP $ausemp $altst> </A>";
@@ -10673,8 +11023,9 @@
     ($to_prefix, $suffix) = split(/\./, $to);
     if ($EXTN =~ /$suffix$/) {
 	if (open(FROM, "<$from") && open(HTMP, ">HTML_tmp")) {
-        binmode FROM;
-        binmode HTMP;
+#        binmode FROM;
+#        binmode HTMP;
+# 2022-10-21 shige 1-10)
 	    while (<FROM>) {
 		s/$from_prefix\.$IMAGE_TYPE/$to_prefix.$IMAGE_TYPE/g;
 		print HTMP;
@@ -10699,7 +11050,8 @@
 	&replace_markers;
 	&add_dir_to_href if ($DESTDIR);
 	if(open(CAPTIONS, ">${PREFIX}$type.pl")) {
-        binmode CAPTIONS;
+#        binmode CAPTIONS;
+# 2022-10-21 shige 1-10)
 	    print CAPTIONS $_;
 	    close (CAPTIONS);
         } else {
@@ -10746,6 +11098,8 @@
 	    print FILE "# LaTeX2HTML $TEX2HTMLVERSION\n";
 	    print FILE "# Associate $type original text with physical files.\n\n";
         }
+	# 2020-03-02 shige: 2-45)
+	print FILE "use utf8;\n";
         for $uutxt (sort keys %array) {
             $file = $array{$uutxt};
 	    $uutxt =~ s|/|\\/|g;
@@ -11544,6 +11898,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)$/);
 
@@ -11554,12 +11910,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;
 		}
 	    }
@@ -11611,6 +11971,8 @@
     &do_require_package($option) unless ($styles_loaded{$optionfull});
     # 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{$optionfull}) && defined(&$do_option)) {
 	# value is sent as an argument to the routine
 	# <package>_<option> defined in <package>.perl
@@ -12925,12 +13287,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;
@@ -14390,6 +14756,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 {
@@ -15000,8 +15368,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 ");
     $_;
@@ -15429,18 +15800,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'),$_);
@@ -15450,9 +15829,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>",$_);}
 }
@@ -15460,7 +15843,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, $_);}
 }
@@ -15468,7 +15853,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, $_);}
 }
@@ -15476,7 +15863,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, $_);}
 }
@@ -15484,7 +15873,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, $_);}
 }
@@ -15492,7 +15883,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, $_);}
 }
@@ -15511,17 +15904,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
@@ -15603,7 +16004,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";
 
@@ -15660,8 +16064,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
@@ -15681,7 +16093,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" );
     $_;
 }
 
@@ -15985,7 +16399,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;
@@ -15996,7 +16412,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;
@@ -16243,7 +16661,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.'">'
 	      unless ($LATEX2HTML_META);
 
     $TeXname = (($HTML_VERSION ge "3.0")? "T<SMALL>E</SMALL>X" : "TeX");
@@ -16255,6 +16675,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;
@@ -16334,15 +16756,40 @@
     print ($HTML_OPTIONS ? "with $HTML_OPTIONS extensions\n\n\n" : "\n\n\n");
 
     # unicode by default
-    &do_require_extension('unicode');
+    #&do_require_extension('unicode');
+    # 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('unicode');
+	$charset = $CHARSET = $PREV_CHARSET = $save_charset;
+	undef $save_charset;
+    }
 
-    if ($HTML_VERSION =~ /(2.0|3.0|3.2|4.0|4.1|5.0)/) {
+    # if ($HTML_VERSION =~ /(2.0|3.0|3.2|4.0|4.1|5.0)/) {
+    # 03/26 2011 shige: 2-18)
+    if ($HTML_VERSION =~ /(2.[012]|3.[012]|4.[01]|5.0)/) {
 	# 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/);
+	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/);
 	if (!defined $DOCTYPE) {
 	    $DOCTYPE = "-//".(($HTML_VERSION eq "2.0")? "IETF" : "W3C")
@@ -16370,12 +16817,26 @@
 	    . "  i18n  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;
     }
 
@@ -16589,6 +17050,8 @@
 	 , 'spanish',	'spanish_translation'
 	 , 'swedish',	'swedish_translation'
 	 , 'turkish',	'turkish_translation'
+	 # shige: 1-5)
+	 , 'japanese',	'japanese_translation'
 	);
 
 # Reiner: 
@@ -16640,7 +17103,9 @@
 }
 sub alph{
     local($num)=@_;
-    &falph(eval($enum{$num}));
+    # &falph(eval($enum{$num}));
+    # 07/13 2018 shige: 2-36)
+    &fAlph(eval($enum{$num}));
 }
 sub fAlph{
     local($num)=@_;
@@ -17137,7 +17602,8 @@
     if (-f $access_file) {
 	print STDOUT " ... found";
 	open(HTACCESS, "<$access_file");
-    binmode HTACCESS;
+#    binmode HTACCESS;
+# 2022-10-21 shige 1-10)
 	while (<HTACCESS>) {
 	    if (/^\s*XBitHack\s*on\s*$/) {
 		print STDOUT " with XBitHack on";
@@ -17505,7 +17971,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
@@ -17682,6 +18150,7 @@
 S<[ B<->(B<no>)B<add_ref_name> ]>
 S<[ B<->(B<no>)B<cut_ref_num> ]>
 S<[ B<->(B<no>)B<use_dvipng> ]>
+S<[ B<->(B<no>)B<use_dvipng_alter> ]>
 S<[ B<->(B<no>)B<use_pdftex> ]>
 S<[ B<->(B<no>)B<use_luatex> ]>
 S<[ B<->(B<no>)B<use_luadvi> ]>
@@ -17699,6 +18168,9 @@
 S<[ B<-external_file> I<external_aux_file> ]>
 S<[ B<->(B<no>)B<short_index> ]>
 S<[ B<->(B<no>)B<unsegment> ]>
+S<[ B<-dresolution> I<num>]>
+S<[ B<-ienc> I<encodename> ]>
+S<[ B<-oenc> I<encodename> ]>
 S<[ B<->(B<no>)B<debug> ]>
 S<[ B<-tmp> I<path> ]>
 S<[ B<->(B<no>)B<ldump> ]>
@@ -18104,6 +18576,23 @@
 
 Use this to translate a segmented document as if it were not
 segmented.
+
+= item B<-dresolution> I<num>
+
+MISSING_DESCRIPTION
+This allows you to use high-resolution images. It is done by generating
+large images and spacifying small width. Some browsers may not display
+them correctly. Default resolution is 72. Note that it may use large
+disk size to specify large resolution value.
+
+# 2019-10-13 shige: 1-4)
+= item B<-ienc> I<encodename>
+
+= item B<-oenc> I<encodename>
+
+These are only for Japanese. I<encodename> is jis, euc, sjis, utf8, or
+noja. B<-ienc> is the encoding of LaTeX source files, and B<-oenc> is
+of HTML output files. Default encode is noja (no Japanese).
 
 =item B<->(B<no>)B<debug>
 
diff -ruN latex2html-2024/prefs.pm l2h-2024-jp3.2b1.39/prefs.pm
--- latex2html-2024/prefs.pm	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/prefs.pm	2025-03-11 11:06:05.321901000 +0900
@@ -172,6 +172,10 @@
 # set this to no if you do not want any image generation by LaTeX2HTML
 $prefs{'IMAGES'} = 'yes';
 
+# 2020-04-28 shige: 1-4)
+#$prefs{'TERMENCODE'} = 'UTF-8';
+$prefs{'TERMENCODE'} = '';
+
 # TeX and friends
 #
 # LaTeX and other executables of the TeX typesetting suite are needed to
@@ -180,17 +184,23 @@
 # but with reduced capabilities.
 
 # the TeX executable
-$prefs{'TEX'} = 'tex';
+#$prefs{'TEX'} = 'tex';
+# shige: 1-2)
+$prefs{'TEX'} = 'ptex,tex';
 
 # the variants for LaTeX executable
 # needed for image generation
-$prefs{'LATEX'} = 'latex';
+#$prefs{'LATEX'} = 'latex';
+# shige: 1-2)
+$prefs{'LATEX'} = 'platex,latex';
 $prefs{'PDFLATEX'} = 'pdflatex';
 $prefs{'LUALATEX'} = 'lualatex';
 $prefs{'DVILUALATEX'} = 'dvilualatex';
 
 # the initex executable
-$prefs{'INITEX'} = 'initex';
+#$prefs{'INITEX'} = 'initex';
+# shige: 1-2)
+$prefs{'INITEX'} = 'iniptex,initex';
 
 # the kpsewhich (part of Web2C) executable. If it is found, we have
 # Web2C
@@ -213,14 +223,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-2024/styles/alltt.perl l2h-2024-jp3.2b1.39/styles/alltt.perl
--- latex2html-2024/styles/alltt.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/alltt.perl	2025-03-11 11:06:05.322105000 +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-2024/styles/amsmath.perl l2h-2024-jp3.2b1.39/styles/amsmath.perl
--- latex2html-2024/styles/amsmath.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/amsmath.perl	2025-03-11 11:06:05.322338000 +0900
@@ -673,7 +673,9 @@
 if (($NO_SIMPLE_MATH)&&(defined &make_math)) { 
     &do_require_package('more_amsmath');
 } elsif ($HTML_VERSION > 3.1) {
-    require "$LATEX2HTMLVERSIONS${dd}math.pl";
+    # require "$LATEX2HTMLVERSIONS${dd}math.pl";
+    # 2020-02-03 shige: 2-48)
+    &do_require_extension('math');
     $NO_MATH_PARSING = $NO_SIMPLE_MATH = 1;
     &do_require_package('more_amsmath');
 }
diff -ruN latex2html-2024/styles/amstex.perl l2h-2024-jp3.2b1.39/styles/amstex.perl
--- latex2html-2024/styles/amstex.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/amstex.perl	2025-03-11 11:06:05.322564000 +0900
@@ -619,7 +619,9 @@
 if (($NO_SIMPLE_MATH)&&(defined &make_math)) { 
     &do_require_package('more_amsmath');
 } elsif ($HTML_VERSION > 3.1) {
-    require "$LATEX2HTMLVERSIONS${dd}math.pl";
+    # require "$LATEX2HTMLVERSIONS${dd}math.pl";
+    # 2020-02-03 shige: 2-48)
+    &do_require_extension('math');
     $NO_MATH_PARSING = $NO_SIMPLE_MATH = 1;
     &do_require_package('more_amsmath');
 }
diff -ruN latex2html-2024/styles/ascmac.perl l2h-2024-jp3.2b1.39/styles/ascmac.perl
--- latex2html-2024/styles/ascmac.perl	1970-01-01 09:00:00.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/ascmac.perl	2025-03-11 11:32:54.375894000 +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-2024/styles/color.perl l2h-2024-jp3.2b1.39/styles/color.perl
--- latex2html-2024/styles/color.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/color.perl	2025-03-11 11:06:05.322942000 +0900
@@ -153,7 +153,8 @@
 	if (-f $file) {
             if (open(COLORFILE,"<$file")) {
 		print STDOUT "\n(reading colors from $file" if $DEBUG;
-		binmode COLORFILE;
+#		binmode COLORFILE;
+# 2022-10-21 shige 1-10)
 		while (<COLORFILE>) {
 	s/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\w+(\s\w+)*)\s*/
 	    ($r,$g,$b,$name)=($1,$2,$3,$4);
@@ -184,7 +185,8 @@
 	if (-f $file) {
 	    if (open(COLORFILE,"<$file")) {
 		print STDOUT "\n(reading colors from $file";
-		binmode COLORFILE;
+#		binmode COLORFILE;
+# 2022-10-21 shige 1-10)
 		@colors = (<COLORFILE>);
 		foreach (@colors) {
 		    next if (/^\s*$/);
diff -ruN latex2html-2024/styles/frames.perl l2h-2024-jp3.2b1.39/styles/frames.perl
--- latex2html-2024/styles/frames.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/frames.perl	2025-03-11 11:06:05.323255000 +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;
@@ -1126,7 +1128,8 @@
 	);
     &text_cleanup;
     open(FILE,">$filename") || print "Cannot open $filename $!\n";
-	binmode FILE;
+#	binmode FILE;
+# 2022-10-21 shige 1-10)
     print FILE $_;
     close(FILE);
 }
diff -ruN latex2html-2024/styles/getimagesize.perl l2h-2024-jp3.2b1.39/styles/getimagesize.perl
--- latex2html-2024/styles/getimagesize.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/getimagesize.perl	2025-03-11 11:06:05.323418000 +0900
@@ -46,6 +46,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
@@ -62,6 +67,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-2024/styles/graphics-support.perl l2h-2024-jp3.2b1.39/styles/graphics-support.perl
--- latex2html-2024/styles/graphics-support.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/graphics-support.perl	2025-03-11 11:06:05.323671000 +0900
@@ -173,20 +173,30 @@
     #RRM: may only work correctly for Unix    
     # $dd  holds the directory-delimiter, usually / 
     $paths =~ s/\s*(\{|\})\s*/$1/g;
-    local(@paths) = split (/}/, $paths);
+    #local(@paths) = split (/}/, $paths);
+    # shige: 2-35)
+    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];
 
@@ -534,7 +544,8 @@
   my($file)=@_;
   my(@bb,$f);
   if(($f=find_file($file,$GRAPHICS_PATH,['.eps','.ps','.bb'])) && open(PS,$f)){
-	binmode PS;
+#	binmode PS;
+# 2022-10-21 shige 1-10)
     while(<PS>){
       if(/^%%BoundingBox:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s*$/){
 	@bb=($1,$2,$3,$4); last; }}
diff -ruN latex2html-2024/styles/html.perl l2h-2024-jp3.2b1.39/styles/html.perl
--- latex2html-2024/styles/html.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/html.perl	2025-03-11 11:06:05.323921000 +0900
@@ -305,7 +305,8 @@
 	if ($pretag) {
 	# code due to Alan Williams <alanw@cs.man.ac.uk>
 	    open(LABELS, "<$labelfile");
-		binmode LABELS;
+#		binmode LABELS;
+# 2022-10-21 shige 1-10)
     print "\nLoading external labels from $labelfile, with prefix $pretag"
 	if ($VERBOSITY > 1);
 	    local($translated_stream, $instream);
@@ -413,7 +414,8 @@
 	if ($pretag) {
 	# code due to Alan Williams <alanw@cs.man.ac.uk>
 	    open(LABELS, "<$labelfile");
-		binmode LABELS;
+#		binmode LABELS;
+# 2022-10-21 shige 1-10)
     print "\nLoading external labels from $labelfile, with prefix $pretag"
 	if ($VERBOSITY > 1);
 	    local($translated_stream, $instream);
@@ -506,7 +508,9 @@
 	||(s/$next_pair_rx/$prefix = $2; ''/eo));
 ##    s/$next_pair_pr_rx/$prefix = $2; ''/eo;
     $file = "${prefix}$type.pl";
-    if ($file !~ /^\Q$dd\E/) {
+    # if ($file !~ /^\Q$dd\E/) {
+    # 2020-02-19 shige: 2-43)
+    if (!L2os->is_absolute_path($file)) {
 	$file = ".$dd$file";
     }
     unless (-f $file) {
@@ -750,7 +754,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-2024/styles/inputenc.perl l2h-2024-jp3.2b1.39/styles/inputenc.perl
--- latex2html-2024/styles/inputenc.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/inputenc.perl	2025-03-11 11:06:05.324080000 +0900
@@ -38,13 +38,26 @@
 sub load_language_support {
     local($enc) = @_;
     return if ($styles_loaded{$enc});
-    my $file = "$LATEX2HTMLVERSIONS${dd}$enc.pl";
+    # my $file = "$LATEX2HTMLVERSIONS${dd}$enc.pl";
+    # 2020-02-03 shige: 2-48)
+    local($dir,$file);
 
-    if ( require($file) ) {
-        print STDERR "\nLoading $file";
-    } else {
-        print STDERR "\n*** could not load support for $enc encoding ***\n"; 0;
+    # if ( require($file) ) {
+    #    print STDERR "\nLoading $file";
+    # } else {
+    #     print STDERR "\n*** could not load support for $enc encoding ***\n"; 0;
+    # }
+    # 2020-02-03 shige: 2-48)
+    foreach $dir (split(/$envkey/,$LATEX2HTMLVERSIONS)) {
+	$file = "$dir$dd${enc}.pl";
+	if (-f "$file") {
+	    require("$file");
+	    print STDERR "\nLoading $file";
+	    return 1;
+	}
     }
+    print STDERR "\n*** could not load support for $enc encoding ***\n"; 
+    0;
 }
 
 sub no_language_support {
diff -ruN latex2html-2024/styles/japanese.perl l2h-2024-jp3.2b1.39/styles/japanese.perl
--- latex2html-2024/styles/japanese.perl	1970-01-01 09:00:00.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/japanese.perl	2025-03-11 11:32:54.373242000 +0900
@@ -0,0 +1,171 @@
+# japanese.perl, version 3.0 1999/9/15
+# japanese.pin,  l2h-2023-jp3.2b1.38 2023-09-05
+#
+# 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\">LaTeX2HTML</A>"
+        , " 翻訳プログラム Version $TEX2HTMLVERSION\n"
+        , "<P>を<A HREF=\"$JTEX2HTMLADDRESS\">日本語化したもの</A>"
+        , " ($JTEX2HTMLVERSION 版)\n"
+        , "<P>を用いて生成されました。\n"
+        , "<P>コマンド行は以下の通りでした。: <BR>\n "
+        , "<kbd>latex2html $argv</kbd>\n"
+        , (($SHOW_INIT_FILE && ($INIT_FILE ne ''))?
+	   "\n<P>初期化ファイル: <kbd>$INIT_FILE</kbd>\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]";
+}
+
+## for accent
+#%EUC_JP_character_map
+#= %ISO_2022_JP_character_map
+#= %Shift_JIS_character_map
+##= (%iso_10646_character_map,
+#= (%iso_8859_1_character_map,
+#);
+
+#%EUC_JP_character_map_inv
+#= %ISO_2022_JP_character_map_inv
+#= %Shift_JIS_character_map_inv
+##= (%iso_10646_character_map_inv,
+#= (%iso_8859_1_character_map_inv,
+#);
+
+# if available above setting, the following setting may be need:
+# $USE_ENTITY_NAMES = 1;
+
+1;
diff -ruN latex2html-2024/styles/luainputenc.perl l2h-2024-jp3.2b1.39/styles/luainputenc.perl
--- latex2html-2024/styles/luainputenc.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/luainputenc.perl	2025-03-11 11:06:05.324436000 +0900
@@ -39,18 +39,36 @@
 sub load_language_support {
     local($enc) = @_;
     return if ($styles_loaded{$enc});
-    my $file = "$LATEX2HTMLVERSIONS${dd}$enc.pl";
+    # my $file = "$LATEX2HTMLVERSIONS${dd}$enc.pl";
+    # 2020-02-03 shige: 2-48)
+    local($dir,$file);
 
-    if ( require($file) ) {
-        print STDERR "\nLoading $file";
-	if ($charset =~ /^utf\-\d$/) {
-	    $PREV_CHARSET = $CHARSET;
-	    $CHARSET = "iso-10646";
-	    &make_unicode_map;
-	};1;
-    } else {
-        print STDERR "\n*** could not load support for $enc encoding ***\n"; 0;
+    # if ( require($file) ) {
+    #    print STDERR "\nLoading $file";
+    #	if ($charset =~ /^utf\-\d$/) {
+    #	    $PREV_CHARSET = $CHARSET;
+    #	    $CHARSET = "iso-10646";
+    #	    &make_unicode_map;
+    # 	};1;
+    # } else {
+    #     print STDERR "\n*** could not load support for $enc encoding ***\n"; 0;
+    # }
+    # 2020-02-03 shige: 2-48)
+    foreach $dir (split(/$envkey/,$LATEX2HTMLVERSIONS)) {
+	$file = "$dir$dd${enc}.pl";
+	if (-f "$file") {
+	    require("$file");
+	    print STDERR "\nLoading $file";
+	    if ($charset =~ /^utf\-\d$/) {
+		$PREV_CHARSET = $CHARSET;
+		$CHARSET = "iso-10646";
+		&make_unicode_map;
+	    };
+	    return 1;
+	}
     }
+    print STDERR "\n*** could not load support for $enc encoding ***\n"; 
+    0;
 }
 
 sub no_language_support {
diff -ruN latex2html-2024/styles/romanian.perl l2h-2024-jp3.2b1.39/styles/romanian.perl
--- latex2html-2024/styles/romanian.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/romanian.perl	2025-03-11 11:06:05.324587000 +0900
@@ -73,7 +73,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-2024/styles/texdefs.perl l2h-2024-jp3.2b1.39/styles/texdefs.perl
--- latex2html-2024/styles/texdefs.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/texdefs.perl	2025-03-11 11:06:05.324750000 +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-2024/styles/webtex.perl l2h-2024-jp3.2b1.39/styles/webtex.perl
--- latex2html-2024/styles/webtex.perl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/styles/webtex.perl	2025-03-11 11:06:05.324945000 +0900
@@ -227,7 +227,8 @@
 	    &webeq_failed($out_tag); $out_tag = '';
 	} else {
 	    open(TAG, "<$out_tag");
-		binmode TAG;
+#		binmode TAG;
+# 2022-10-21 shige 1-10)
 	    $app_tag = join('',<TAG>);
 	    close(TAG);
 	    # replace webeq fall-back image by LaTeX2HTML's own, or none at all
diff -ruN latex2html-2024/texexpand.pin l2h-2024-jp3.2b1.39/texexpand.pin
--- latex2html-2024/texexpand.pin	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/texexpand.pin	2025-03-11 11:06:05.325560000 +0900
@@ -377,6 +377,9 @@
 #fi
 
 use L2hos;
+# 2019-07-30 shige: 1-4)
+use utf8;
+use Encode ();
 
 my $RELEASE = '@distver@';
 my $VERSION = '@release_date@';
@@ -412,9 +415,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";
 }
 
@@ -442,6 +447,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";
 }
@@ -553,19 +564,32 @@
     $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";
-        binmode STYLES;
+#        binmode STYLES;
+# 2022-10-21 shige 1-10)
     }
     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"));
     }
-    binmode OUT;
+#    binmode OUT;
+# 2022-10-21 shige 1-10)
 
     &process_file($infile); # the workhorse...
 
@@ -683,8 +707,13 @@
     # Keep track of input/include level
     $includelevel++;
 
-    open(IN,"<$infile") || die "$prompt Cannot open $infile\n";
-    binmode IN;
+    # 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";
+#    binmode IN;
+# 2022-10-21 shige 1-10)
     print STDERR "$prompt %--- Processing $infile" if ($debug > 1);
 
     # if we don't include this file marker LaTeX2HTML won't split
diff -ruN latex2html-2024/versions/frame.pl l2h-2024-jp3.2b1.39/versions/frame.pl
--- latex2html-2024/versions/frame.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/frame.pl	2025-03-11 11:06:05.326075000 +0900
@@ -1202,7 +1202,8 @@
 	);
     &text_cleanup;
     open(FILE,">$filename") || print "Cannot open $filename $!\n";
-	binmode FILE;
+#	binmode FILE;
+# 2022-10-21 shige 1-10)
     print FILE $_;
     close(FILE);
 }
diff -ruN latex2html-2024/versions/html3_1.pl l2h-2024-jp3.2b1.39/versions/html3_1.pl
--- latex2html-2024/versions/html3_1.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/html3_1.pl	2025-03-11 11:06:05.326534000 +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-2024/versions/html3_2.pl l2h-2024-jp3.2b1.39/versions/html3_2.pl
--- latex2html-2024/versions/html3_2.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/html3_2.pl	2025-03-11 11:06:05.326908000 +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,";
@@ -864,6 +866,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;
 	};
@@ -873,6 +878,8 @@
     $open_tags_R = [ @save_open_tags_tabular ];
     $TABLE_TITLE_TEXT = '';
     $TABLE_TAIL_TEXT = '';
+    # 2021-02-03 shige: 3-2)
+    $TDADDOPT = $THADDOPT = '';
     $return =~ s/$OP\d+$CP//g;
     $return =~ s/<(T[DH])( [^>]+)?>\s*($content_mark)?(<\/\1>)/<$1$2>;SPMnbsp;$4/g;
     $return . "\n</TABLE>";
@@ -1013,7 +1020,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
@@ -1073,7 +1082,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;
@@ -1160,7 +1169,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-2024/versions/html4_0.pl l2h-2024-jp3.2b1.39/versions/html4_0.pl
--- latex2html-2024/versions/html4_0.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/html4_0.pl	2025-03-11 11:06:05.327298000 +0900
@@ -591,6 +591,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,";
@@ -1214,6 +1216,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;
 	};
@@ -1223,6 +1228,8 @@
     $open_tags_R = [ @save_open_tags_tabular ];
     $TABLE_TITLE_TEXT = '';
     $TABLE_TAIL_TEXT = '';
+    # 2021-02-03 shige: 3-2)
+    $TDADDOPT = $THADDOPT = '';
     $return =~ s/$OP\d+$CP//g;
     $return =~ s/<(T[DH])( [^>]+)?>\s*($content_mark)?(<\/\1>)/<$1$2>;SPMnbsp;$4/g;
     $return . "\n</TABLE>";
@@ -1377,7 +1384,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
@@ -1438,7 +1447,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;
@@ -1527,7 +1536,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
@@ -1672,6 +1683,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-2024/versions/html4_01.pl l2h-2024-jp3.2b1.39/versions/html4_01.pl
--- latex2html-2024/versions/html4_01.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/html4_01.pl	2025-03-11 11:06:05.327704000 +0900
@@ -612,6 +612,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,";
@@ -1234,6 +1236,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;
 	};
@@ -1243,6 +1248,8 @@
     $open_tags_R = [ @save_open_tags_tabular ];
     $TABLE_TITLE_TEXT = '';
     $TABLE_TAIL_TEXT = '';
+    # 2021-02-03 shige: 3-2)
+    $TDADDOPT = $THADDOPT = '';
     $return =~ s/$OP\d+$CP//g;
     $return =~ s/<(T[DH])( [^>]+)?>\s*($content_mark)?(<\/\1>)/<$1$2>;SPMnbsp;$4/g;
     $return . "\n</TABLE>";
@@ -1397,7 +1404,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
@@ -1458,7 +1467,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;
@@ -1547,7 +1556,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
@@ -1692,6 +1703,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-2024/versions/html4_1.pl l2h-2024-jp3.2b1.39/versions/html4_1.pl
--- latex2html-2024/versions/html4_1.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/html4_1.pl	2025-03-11 11:06:05.327847000 +0900
@@ -3,6 +3,8 @@
 ### File: html4_1.pl
 ### Language definitions for HTML 4.1
 
-require("$LATEX2HTMLVERSIONS${dd}html4_01.pl");
+#require("$LATEX2HTMLVERSIONS${dd}html4_01.pl");
+# 2020-02-03 shige: 2-48)
+&do_require_extension('html4_01');
 
 1;
diff -ruN latex2html-2024/versions/html5_0.pl l2h-2024-jp3.2b1.39/versions/html5_0.pl
--- latex2html-2024/versions/html5_0.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/html5_0.pl	2025-03-11 11:06:05.328213000 +0900
@@ -580,6 +580,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,";
@@ -1198,6 +1200,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;
 	};
@@ -1207,6 +1212,8 @@
     $open_tags_R = [ @save_open_tags_tabular ];
     $TABLE_TITLE_TEXT = '';
     $TABLE_TAIL_TEXT = '';
+    # 2021-02-03 shige: 3-2)
+    $TDADDOPT = $THADDOPT = '';
     $return =~ s/$OP\d+$CP//g;
     $return =~ s/<(T[DH])( [^>]+)?>\s*($content_mark)?(<\/\1>)/<$1$2>;SPMnbsp;$4/g;
     $return . "\n</TABLE>";
diff -ruN latex2html-2024/versions/math.pl l2h-2024-jp3.2b1.39/versions/math.pl
--- latex2html-2024/versions/math.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/math.pl	2025-03-11 11:06:05.328701000 +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;
 		}
diff -ruN latex2html-2024/versions/techexpl.pl l2h-2024-jp3.2b1.39/versions/techexpl.pl
--- latex2html-2024/versions/techexpl.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/techexpl.pl	2025-03-11 11:06:05.328915000 +0900
@@ -212,7 +212,8 @@
 sub TE_check_file_contents {
     local ($ifile) = @_;
     open(TEINC, "<$ifile");
-	binmode TEINC;
+#	binmode TEINC;
+# 2022-10-21 shige 1-10)
     my($macrosOK,$macrosNUM,$numlines,$invalid) = (0,0,0,0);
     my $TE_special_macros_rx = join('|',@TE_special_macros);
     my $TE_defined_accents_rx = join('|',@TE_defined_accents);
diff -ruN latex2html-2024/versions/unicode.pl l2h-2024-jp3.2b1.39/versions/unicode.pl
--- latex2html-2024/versions/unicode.pl	2024-01-02 00:13:03.000000000 +0900
+++ l2h-2024-jp3.2b1.39/versions/unicode.pl	2025-03-11 11:06:05.329179000 +0900
@@ -37,7 +37,9 @@
 # save previous settings before loading  latin1.pl 
 $PREV_CHARSET = $CHARSET if ($CHARSET);
 $PREV_charset = $charset if ($charset);
-require("$LATEX2HTMLVERSIONS${dd}latin1.pl");
+# require("$LATEX2HTMLVERSIONS${dd}latin1.pl");
+# 2020-02-03 shige: 2-48)
+&do_require_extension('latin1');
 $CHARSET = $PREV_CHARSET if ($PREV_CHARSET);
 
 %unicode_table = ();
@@ -418,7 +420,7 @@
 	'qubuts', '&#1467;',
 	'dagesh', '&#1468;',
 	'meteg', '&#1469;',
-	'maqaf', '&#1470',
+	'maqaf', '&#1470;',
 	'rafe', '&#1471;',
 	'paseq', '&#1472;',
 	'sofpasuq', '&#1475;',
