#!/usr/bin/perl -w
#=======================================================================
# Copyright (C) 2000-2005 Daniele Giacomini daniele@swlibero.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=======================================================================
# alml OPTION... SGML_SOURCE
#
# Front-end for the Alml system.
#=======================================================================
#
# UTF-8
#
use utf8;
binmode (STDOUT, ":utf8");
binmode (STDERR, ":utf8");
binmode (STDIN,  ":utf8");
#
# If you don't use gettex, comment out the next four lines and
# uncomment the gettext function.
#
use POSIX;
use Locale::gettext;
setlocale (LC_MESSAGES, "");
textdomain ("alml");
#
#sub gettext
#{
#    return $_[0];
#}
#
###
### Program version.
###
($VERSION) = "2005.01.01";
###
### Configuration files.
###
($CATALOG)                      = "/usr/share/sgml/alml/alml.cat";
($HTML_CATALOG)                 = "/usr/share/sgml/alml/html/html.cat";
($HTMLISO_CATALOG)              = "/usr/share/sgml/alml/html/15445.cat";
($HTML401_CATALOG)              = "/usr/share/sgml/alml/html/html401.cat";
($HTML320_CATALOG)              = "/usr/share/sgml/alml/html/html320.cat";
($XML_CATALOG)                  = "/usr/share/sgml/alml/xml/xml.cat";
###
### Translation functions.
###
## These functions are used to translate some definitions into different
## languages.
##
## gettext() cannot be used, because language is controlled by a
## command inside the source SGML text and is not related to
## the locale configuration.
sub tome_def
{
    #
    # This definition might be modified inside the SGML source:
    #
    if ($DOCUMENT_TOME_DEFINITION ne "")
      {
        return ($DOCUMENT_TOME_DEFINITION);
      }
    else
      {  
        if ($CURRENT_LANGUAGE eq "it")
          {
            return ("volume");
          }
        else
          {
            return ("tome");
          }
      }  
}
#
sub part_def
{
    #
    # This definition might be modified inside the SGML source:
    #
    if ($DOCUMENT_PART_DEFINITION ne "")
      {
        return ($DOCUMENT_PART_DEFINITION);
      }
    else
      {  
        if ($CURRENT_LANGUAGE eq "it")
          {
            return ("parte");
          }
        else
          {
            return ("part");
          }
      }  
}
#
sub intro_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "introduzione";
      }
    else
      {
        return "introduction";
      }
}
#
sub chapter_def
{
    #
    # This definition might be modified inside the SGML source:
    #
    if ($DOCUMENT_CHAPTER_DEFINITION ne "")
      {
        return ($DOCUMENT_CHAPTER_DEFINITION);
      }
    else
      {  
        if ($CURRENT_LANGUAGE eq "it")
          {
            return ("capitolo");
          }
        else
          {
            return ("chapter");
          }
      }  
}

sub presentation_slide_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "diapositiva";
      }
    else
      {
        return "slide";
      }
}
#
sub summary_sheet_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "scheda riassuntiva";
      }
    else
      {
        return "summary sheet";
      }
}
#
sub appendix_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "appendice";
      }
    else
      {
        return "appendix";
      }
}
#
sub appendixes_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "appendici";
      }
    else
      {
        return "appendixes";
      }
}
#
sub section_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "sezione";
      }
    else
      {
        return "section";
    }
}

sub subsection_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "sottosezione";
      }
    else
      {
        return "subsection";
      }
}

sub subsubsection_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "sotto-sottosezione";
      }
    else
      {
        return "sub-subsection";
      }
}

sub contents_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "indice generale";
      }
    else
      {
        return "contents";
      }
}

sub index_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "indice analitico";
      }
    else
      {
        return "index";
      }
}

sub page_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "pagina";
      }
    else
      {
        return "page";
      }
}

sub short_page_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "pag.";
      }
    else
      {
        return "p.";
      }
}

sub command_continue_on_the_next_line_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "segue";
      }
    else
      {
        return "continue";
      }
}

sub next_page_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "successivo";
      }
    else
      {
        return "next";
      }
}

sub previous_page_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "precedente";
      }
    else
      {
        return "previous";
      }
}

sub top_page_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "inizio";
      }
    else
      {
        return "top";
      }
}


sub last_page_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return "fine";
      }
    else
      {
        return "last";
      }
}

sub may_link_to_human_readable_name_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return ("Dovrebbe essere possibile fare riferimento a questa "
                . "pagina anche con il nome ");
      }
    else
      {
        return ("It should be possible to link to this page also "
                . "with the name ");
      }
}

sub picture_def
{
    if ($CURRENT_LANGUAGE eq "it")
      {
        return ("immagine");
      }
    else
      {
        return ("picture");
      }
}
###
### Global variables that should not be modifyed by hand.
###
#
# Program executable without path.
#
($PROGRAM_EXECUTABLE)           = $0;
($PROGRAM_EXECUTABLE)           =~ m{([^/]*)$};
($PROGRAM_EXECUTABLE)           = $1;
#
# List of other temporary files that must be deleted at the end of
# elaboration.
#
($TEMP_FILES_LIST)              = "";
#
# Temporary file name prefix.
#
($TEMP_FILE_NAME_PREFIX)        = "";
#
# Static data.
#
($V_INFO)                       = 3;
($V_NORMAL)                     = 2;
($V_WARNING)                    = 1;
($V_ERROR)                      = 0;
($V_SUPER)                      = 0;
#
# Verbosity.
#
($VERBOSE)                      = 0;
#
# File names and file streams.
#
($SOURCE_FILE_NAME)             = "";
($ROOT_FILE_NAME)               = "";
($CURRENT_FILE_NAME)            = "";
($CURRENT_OUTPUT_STREAM)        = "";
#
# Counters.
#
($INPUT_STREAM_LINE_COUNTER)    = 0;
#
# Definitions.
#
($DOCUMENT_CHAPTER_DEFINITION)  = "";
($DOCUMENT_PART_DEFINITION)     = "";
($DOCUMENT_TOME_DEFINITION)     = "";
#
# Document language.
#
($CURRENT_LANGUAGE)             = "";
#
# Head informations.
#
($DOCUMENT_DESCRIPTION) = "";                   # it can be empty.
($DOCUMENT_KEYWORDS) = "";                      # it can be empty.
($DOCUMENT_LANGUAGE) = "";                      # it can be empty.
($TOME_LANGUAGE) = "";                          # it can be empty.
($PART_LANGUAGE) = "";                          # it can be empty.
($CHAPTER_LANGUAGE) = "";                       # it can be empty.
($DIV_LANGUAGE) = "";                           # it can be empty.
($SPAN_LANGUAGE) = "";                          # it can be empty.
($DOCUMENT_SPACING) = "";                       # it can be empty.
($PRINTED_FONT_SIZE_TITLE) = "";                # initially, must be empty.
($PRINTED_FONT_HEIGHT_TITLE) = "";              # initially, must be empty.
($PRINTED_FONT_SIZE_TOMEHEADING) = "";          # initially, must be empty.
($PRINTED_FONT_HEIGHT_TOMEHEADING) = "";        # initially, must be empty.
($PRINTED_FONT_SIZE_H0) = "";                   # initially, must be empty.
($PRINTED_FONT_HEIGHT_H0) = "";                 # initially, must be empty.
($PRINTED_FONT_SIZE_H1) = "";                   # initially, must be empty.
($PRINTED_FONT_HEIGHT_H1) = "";                 # initially, must be empty.
($PRINTED_FONT_SIZE_H2) = "";                   # initially, must be empty.
($PRINTED_FONT_HEIGHT_H2) = "";                 # initially, must be empty.
($PRINTED_FONT_SIZE_H3) = "";                   # initially, must be empty.
($PRINTED_FONT_HEIGHT_H3) = "";                 # initially, must be empty.
($PRINTED_FONT_SIZE_H4) = "";                   # initially, must be empty.
($PRINTED_FONT_HEIGHT_H4) = "";                 # initially, must be empty.
($PRINTED_FONT_SIZE_NORMAL)   = "10pt";
($PRINTED_FONT_HEIGHT_NORMAL) = "12pt";
($PRINTED_FONT_SIZE_TABLE) = "";                # initially, must be empty.
($PRINTED_FONT_HEIGHT_TABLE) = "";              # initially, must be empty.
($PRINTED_FONT_SIZE_EXAMPLE) = "";              # initially, must be empty.
($PRINTED_FONT_HEIGHT_EXAMPLE) = "";            # initially, must be empty.
($PRINTED_TOP_MARGIN)         = "2.5cm";
($PRINTED_BOTTOM_MARGIN)      = "3.0cm";
($PRINTED_INTERNAL_MARGIN)    = "3.5cm";
($PRINTED_BODY_WIDTH)         = "15cm";
#
# Borders reduce horizontal space.
#
(@IS_IT_A_FRAME) = ();
#
# Copy and paste.
#
# $COPY_LIST[x][0]        copy name
# $COPY_LIST[x][1]        string of copy
#
(@COPY_LIST) = ();
($COPY_NAME) = "";
#
# Can be a standard ISO 15445?
#
($STANDARD_ISO_15445) = 1;
###
### Global functions.
###
#
# Define a space string.
# &spaces (N) --> "  "
#
sub spaces
{
    my ($n)                     = $_[0];
    my ($spaces)                = "";

    while ($n > 0)
      {
        $spaces = $spaces . " ";
        $n--;
      }

    return ("$spaces");

} # &spaces

# Define a backspace string.
# &backspace (N) --> "\b\b..."

sub backspaces
{
    my ($n)                     = $_[0];
    my ($backspaces)            = "";

    while ($n > 0)
      {
        $backspaces = $backspaces . "\b";
        $n--;
      }

    return ("$backspaces");

} # &backspaces

# Waiting message.

sub wait_message
{
    my ($message)               = $_[0];

    chomp ($message);

    #! # Clean the screen line
    #!
    #! print STDOUT (&spaces (79));
    #! print STDOUT ("\r");

    # Prepare and print a message of exactly 80 characters,
    # filled with spaces.

    $message = $message . &spaces (76);
    $message = substr ($message, 0, 75);
    print STDOUT ($message);

    # Move the cursor back to the first position.
    # Bust be one less; I don't know why.

    #! print STDOUT (&backspaces (75));
    print STDOUT ("\r");

    # Finished.

    return;
}
#
# Intercept a system command output.
# &system_diag_output ()
#
sub system_diag_output
{
    my ($label)                 = $_[0];
    my ($command)               = $_[1];
    my ($verbosity)             = $_[2];
    my ($verbose_on)            = 0;
    my ($line)                  = "";
    #
    # Verbosity is a number from 0 (higher) and 2 (lower).
    #
    if ($VERBOSE >= $verbosity)
      {
        $verbose_on = 1;
      }
    #
    # Append to the diagnostic file.
    #
    open (DIAG, ">> $ROOT_FILE_NAME.diag");
    #
    # Open the command for input.
    #
    open (COMMAND, "$command 2>&1 |");
    #
    if ($verbose_on)
      {
        print STDOUT ("$label: $command\n");
      }
    else
      {
        &wait_message ("$label: $command");
      }
    #
    # Print it on the DIAG file.
    #
    print DIAG ("$label: $command\n");
    #
    # Report the result of the command.
    #
    while ($line = <COMMAND>)
      {
        chomp ($line);

        if ($verbose_on)
          {
            print STDOUT ("$label: $line\n");
          }
        else
          {
            print DIAG ("$label: $line\n");
            &wait_message ("$label: $line");
          }
      }
    #
    # Close the command file.
    #
    close (COMMAND);
    #
    # Close the file.
    #
    close (DIAG);
}


# Show the right syntax for the use of this program.
#
# &help_syntax ()

sub help_syntax
{
    printf STDOUT (gettext ("\
Usage: %s OPTIONS... SGML_SOURCE\
       %s --help\
       %s --version\
\
Front-end for the Alml system.\
\
Options:\
--help        display this help and exit.\
--version     display version information and exit.\
--paper=PAPER_NAME\
              the paper size name (\"a4\", \"a5x4\" and \"letter\").\
--paper-orientation=[portrait|landscape]\
              paper orientation.\
--draft       draft typesetting if available.\
--clean       remove stale files associated with the source name.\
--verbose     show more messages.\
--input-encoding=INPUT_ENCODING\
              SGML source file input encoding. It is allowed to use\
              only \"latin1\" or \"utf8\" keywords (default is \"utf8\").\
--sgml-include=PARAMETER_ENTITY\
              assign \"INCLUDE\" to an SGML parameter entity.\
--page-numbering={plain|default|tome}\
              define the page numbering way: plain request for\
                a plain numbering from 1 to n-th absolute page;\
                default distinguish the numbering;\
                tome restart numbering at each tome.\
--sgml-syntax, --sgml-check\
              check SGML syntax and report errors.\
--sgml-check-hard\
              check SGML syntax on every detail, for Alml DTD\
                developing purpose (not for common user).\
--sp          SP output for debugging purpose.\
--tex, --latex\
              LaTeX output for debugging purpose.\
--dvi         generate a DVI output.\
--ps, --postscript\
              generate a PostScript output.\
--pdf         generate a PDF output.\
--html        generate standard HTML output.\
--html-text   generate single HTML output for text browsers.\
--html-check, --htmliso-check\
              check HTML ISO 15445 syntax and report errors.\
--html401-check\
              check HTML 4.01 syntax and report errors.\
--html320-check\
              check HTML 3.2 syntax and report errors.\
--xml-check\
              check XML syntax and report errors (the argument\
            is an XML file with known DTD).\
\
Arguments:\
SGML_SOURCE   the SGML input file.\
\
Report bugs to <daniele\@swlibero.org>\
"),
        $PROGRAM_EXECUTABLE, $PROGRAM_EXECUTABLE, $PROGRAM_EXECUTABLE);
}

# Show version information.
#
# &version_info ()

sub version_info
{
    printf STDOUT (gettext ("\
%s %s\
\
Copyright (C) 2000-2005 Daniele giacomini <daniele\@swlibero.org>\
This is free software; see the source for copying conditions.\
There is NO warranty; not even for MERCHANTABILITY or FITNESS\
FOR A PARTICULAR PURPOSE.\
"),
    $PROGRAM_EXECUTABLE,
    $VERSION);
}

# Max.

sub max
{
    my ($x) = $_[0];
    my ($y) = $_[1];

    if (! defined ($x))
      {
        $x = 0;
      }
    if (! defined ($y))
      {
        $y = 0;
      }
    if ($x > $y)
      {
        return $x;
      }
    else
     {
        return $y;
     }
}
#
# Convert an EPS file into a PNG, but 10 times bigger,
# without loosing quality.
#
# Please note that the picture start at the coordinate
# 0,0 for postscript. So, this function does not
# work with EPS with lower left coordinate different
# than 0,0.
#
# &eps_to_10_times_png (<file_in_eps>, <file_out_png>)
#
sub eps_to_10_times_png
{
    my ($input_file)   = $_[0];
    my ($output_file)  = $_[1];
    my ($line)         = "";
    my ($bounding_box) = "";
    my ($min_x)        = "";
    my ($min_y)        = "";
    my ($max_x)        = "";
    my ($max_y)        = "";
    #
    # Open the result from the command
    # gs -sDEVICE=bbox ...
    #
    open (BOUNDING_BOX, "gs -q -dSAFER -dBATCH -dNOPAUSE -sDEVICE=bbox $input_file -c quit 2>&1 |");
    #
    # Scan the result.
    #
    while ($line = <BOUNDING_BOX>)
      {
        if ($line =~ m/^\%\%BoundingBox: +([0-9]+) +([0-9]+) +([0-9]+) +([0-9]+)/)
          {
            $min_x = $1;
            $min_y = $2;
            $max_x = $3;
            $max_y = $4;
            last;
          }
      }
    #
    #
    #
    close (BOUNDING_BOX);
    #
    # Fix a bounding box approximation problem, adding a point.
    #
    $max_x = ($max_x + 1);
    $max_y = ($max_y + 1);
    #
    # Convert the file to a PNG, but 10 times big
    # (see option "-g${max_x}0x${max_y}0" and
    # resolution "-r720x720").
    #
    system ("gs -q -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -g${max_x}0x${max_y}0 -r720x720 -sOutputFile=$output_file -- $input_file -c quit");
}
#
# Scan a PostScript file and substitute the page definition.
#
# &ps_new_bounding_box ( <file>, "%%BoundingBox 0 0 n m" )
#
sub ps_new_bounding_box
{
    my ($file_name) = $_[0];
    my ($new_bounding_box) = $_[1];
    my ($original_file_name) = $file_name . "~";
    my ($previous_line) = "";

    system ("mv -f $file_name $original_file_name 2> /dev/null");
    open (ORIGINAL, "< $original_file_name");
    open (NEW, "> $file_name");

    while ($line = <ORIGINAL>)
      {
        if ($line =~ m/^\%\%BoundingBox:\s/
            || $line =~ m/^\%\%DocumentPaperSizes:\s/)
          {
            $previous_line = $line;
            chomp ($previous_line);
            $line = "$new_bounding_box\n";
            &diag_output (sprintf (gettext ("%s:%s: $previous_line --> $line"),
                                   $PROGRAM_EXECUTABLE, $file_name), $V_NORMAL);
          }
        print NEW ($line);
      }
    #
    close (NEW);
    close (ORIGINAL);
}
#
# Define a temporary file.
#
# &temporary_file (PREFIX) --> NAME
#
sub temporary_file
{
    my ($file_prefix)           = $_[0];
    my ($temp_dir)              = "";
    my ($random_number)         = 0;
    my ($random_file_name)      = "";
    #
    # Check file prefix.
    #
    if ( $file_prefix ne "" )
      {
        $file_prefix = $file_prefix . "_";
      }
    #
    # Check for temp dir.
    #
    if (defined ($ENV{TEMPDIR})
        && -d $ENV{TEMPDIR}
        && -r $ENV{TEMPDIR}
        && -w $ENV{TEMPDIR}
        && -x $ENV{TEMPDIR})
      {
        #
        # This directory is good.
        #
        $temp_dir = $ENV{TEMPDIR};
      }
    elsif (-d "/tmp" && -r "/tmp" && -w "/tmp" && -x "/tmp")
      {
        #
        # This other directory is good.
        #
        $temp_dir = "/tmp";
      }
    elsif (-r "." && -w "." && -x ".")
      {
        #
        # Current directory is good.
        #
        $temp_dir = ".";
      }
    else
      {
        #
        # We cannot use any temporary file!
        #
        printf STDERR (gettext ("%s: cannot create any temporary file!\n"),
                       $PROGRAM_EXECUTABLE);
        exit 1;
      }
    #
    # If we are here, we have a valid temporary directory.
    # We try to find a good name for the file.
    #
    while (1)
      {
        #
        # Define the random number (six digits).
        #
        $random_number = int ((rand) * 1000000);
        #
        # Define the random file name: TF...tmp.
        #
        $random_file_name = "$temp_dir/$file_prefix" . "TF${random_number}tmp";
        #
        # Check if it is new.
        #
        if (-e $random_file_name)
          {
            #
            # The file exists already.
            #
            next;
          }
        else
          {
            if (open (TEMP_FILE, ">:utf8", "$random_file_name"))
              {
                #
                # It works.
                #
                close (TEMP_FILE);
                #
                last;
              }
            else
              {
                #
                # Don't know what to do.
                #
                printf STDERR
                  (gettext ("%s: cannot create the temporary file %s\n"),
                   $PROGRAM_EXECUTABLE, $random_file_name);
                #
                next;
              }
            #
            # This point cannot be reached.
            #
            printf STDERR
              (gettext ("%s: function %s unknown error 1\n"),
               $PROGRAM_EXECUTABLE, "&temporary_file($file_prefix)");
          }
        #
        # This point cannot be reached.
        #
        printf STDERR
          (gettext ("%s: function %s unknown error 2\n"),
           $PROGRAM_EXECUTABLE, "&temporary_file($file_prefix)");
      }         
    #
    # Return the file name.
    #
    return ("$random_file_name");
    #
} # &temporary_file
#
# Define a temporary directory according with function &temporary_file().
#
# &temporary_dir ()
#
sub temporary_dir
{
    my ($temp_dir) = "";

    # Check for temp dir.
    if (defined($ENV{TEMPDIR})
        && -d $ENV{TEMPDIR}
        && -r $ENV{TEMPDIR}
        && -w $ENV{TEMPDIR}
        && -x $ENV{TEMPDIR})
      {
        # This directory is good.
        $temp_dir = $ENV{TEMPDIR};
      }
    elsif (-d "/tmp" && -r "/tmp" && -w "/tmp" && -x "/tmp")
      {
        # This other directory is good.
        $temp_dir = "/tmp";
      }
    elsif (-r "." && -w "." && -x ".")
      {
        # Current directory is good.
        $temp_dir = ".";
      }
    else
      {
        # We cannot use any temporary file!
        printf STDERR (gettext ("%s: cannot create any temporary file!\n"),
                       $PROGRAM_EXECUTABLE);
        exit 1;
      }

    # Return the file name.
    return ("$temp_dir");

} # &temporary_dir

# Determinate the file name without extension.
#
# &root_name (FILE_NAME, EXTENSION)

sub root_name
{
    my ($file_name) = $_[0];
    my ($extension_name) = $_[1];
    my ($root_name) = "";
    
    $file_name =~ m/^(.*)$extension_name$/;

    $root_name = $1;
    if ($root_name eq "")
      {
        
        # The extension is not the same.

        $root_name = $file_name;
      }
    return ("$root_name");
} # &root_name
#
# Translate a positive integer into an alphabet sequence:
# from A to CZ.
#
# &integer_to_alphabet (INTEGER)
#
sub integer_to_alphabet
{
    my ($n) = $_[0];
    #
    # Generate an alphabet digit.
    # 1 -> A, 2 -> B,... 26 -> Z
    #
    # &aphabet_digit (1-26)
    #
    sub alphabet_digit
    {
        my ($digit) = $_[0];
	#
        if ($digit == 0)
          {
            return ("");
          }
        elsif ($digit == 1){
            return ("A");
          }
        elsif ($digit == 2)
          {
            return ("B");
          }
        elsif ($digit == 3)
          {
            return ("C");
          }
        elsif ($digit == 4)
          {
            return ("D");
          }
        elsif ($digit == 5)
          {
            return ("E");
          }
        elsif ($digit == 6)
          {
            return ("F");
          }
        elsif ($digit == 7)
          {
            return ("G");
          }
        elsif ($digit == 8)
          {
            return ("H");
          }
        elsif ($digit == 9)
          {
            return ("I");
          }
        elsif ($digit == 10)
          {
            return ("J");
          }
        elsif ($digit == 11)
          {
            return ("K");
          }
        elsif ($digit == 12)
          {
            return ("L");
          }
        elsif ($digit == 13)
          {
            return ("M");
          }
        elsif ($digit == 14)
          {
            return ("N");
          }
        elsif ($digit == 15)
          {
            return ("O");
          }
        elsif ($digit == 16)
          {
            return ("P");
          }
        elsif ($digit == 17)
          {
            return ("Q");
          }
        elsif ($digit == 18)
          {
            return ("R");
          }
        elsif ($digit == 19)
          {
            return ("S");
          }
        elsif ($digit == 20)
          {
            return ("T");
          }
        elsif ($digit == 21)
          {
            return ("U");
          }
        elsif ($digit == 22)
          {
            return ("V");
          }
        elsif ($digit == 23)
          {
            return ("W");
          }
        elsif ($digit == 24)
          {
            return ("X");
          }
        elsif ($digit == 25)
          {
            return ("Y");
          }
        elsif ($digit == 26)
          {
            return ("Z");
          }
    }
    #
    # Analyse the number.
    #
    if ($n <= 0)
      {
	#
        # We cannot translate zero or negative numbers.
        #
        $return = "##<A##";
      }
    elsif ($n <= 26)
      {
        #
        # We have only one letter.
        #
        $return = &alphabet_digit($n);
      }
    elsif ($n <= 52)
      {
	#
        # We have two letters: Ax.
	#
        $n = $n - 26;
        $return = "A" . &alphabet_digit($n);
      }
    elsif ($n <= 78)
      {
	#
        # We have two letters: Bx.
	#
        $n = $n - 52;
        $return = "B" . &alphabet_digit($n);
	#
      }
    elsif ($n <= 104)
      {
	#
        # We have two letters: Cx.
	#
        $n = $n - 78;
        $return = "C" . &alphabet_digit($n);
      }
    else
      {
	#
        # The number is too big.
	#
        $return = "##>CZ##";
      }
} # &integer_to_alphabet
#
# Translate a positive integer into a roman string.
#
# &integer_to_roman (INTEGER)
#
sub integer_to_roman
{
    my ( $n ) = $_[0];
    my ( $digit_1 ) = 0;
    my ( $digit_2 ) = 0;
    my ( $digit_3 ) = 0;
    my ( $digit_4 ) = 0;

    
    # First digit into roman: 1-9
    

    sub digit_1_to_roman
    {
        my ( $digit ) = $_[0];

        if ($digit == 0)
          {
            return ("");
          }
        elsif ($digit == 1)
          {
            return ("I");
          }
        elsif ($digit == 2)
          {
            return ("II");
          }
        elsif ($digit == 3)
          {
            return ("III");
          }
        elsif ($digit == 4)
          {
            return ("IV");
          }
        elsif ($digit == 5)
          {
            return ("V");
          }
        elsif ($digit == 6)
          {
            return ("VI");
          }
        elsif ($digit == 7)
          {
            return ("VII");
          }
        elsif ($digit == 8)
          {
            return ("VIII");
          }
        elsif ($digit == 9)
          {
            return ("IX");
          }
    }

    
    # Second digit into roman: 10-90
    

    sub digit_2_to_roman
    {
        my ($digit) = $_[0];

        if ($digit == 0)
          {
            return ("");
          }
        elsif ($digit == 1)
          {
            return ("X");
          }
        elsif ($digit == 2)
          {
            return ("XX");
          }
        elsif ($digit == 3)
          {
            return ("XXX");
          }
        elsif ($digit == 4)
          {
            return ("XL");
          }
        elsif ($digit == 5)
          {
            return ("L");
          }
        elsif ($digit == 6)
          {
            return ("LX");
          }
        elsif ($digit == 7)
          {
            return ("LXX");
          }
        elsif ($digit == 8)
          {
            return ("LXXX");
          }
        elsif ($digit == 9)
          {
            return ("XC");
          }
    }

    
    # Third digit into roman: 100-900
    

    sub digit_3_to_roman
    {
        my ($digit) = $_[0];

        if ($digit == 0)
          {
            return ("");
          }
        elsif ($digit == 1)
          {
            return ("C");
          }
        elsif ($digit == 2)
          {
            return ("CC");
          }
        elsif ($digit == 3)
          {
            return ("CCC");
          }
        elsif ($digit == 4)
          {
            return ("CD");
          }
        elsif ($digit == 5)
          {
            return ("D");
          }
        elsif ($digit == 6)
          {
            return ("DC");
          }
        elsif ($digit == 7)
          {
            return ("DCC");
          }
        elsif ($digit == 8)
          {
            return ("DCCC");
          }
        elsif ($digit == 9)
          {
            return ("CM");
          }
    }

    
    # Fourth digit into roman: 1000-9000
    

    sub digit_4_to_roman
    {
        my ($digit) = $_[0];

        if ($digit == 0)
          {
            return ("");
          }
        elsif ($digit == 1)
          {
            return ("M");
          }
        elsif ($digit == 2)
          {
            return ("MM");
          }
        elsif ($digit == 3)
          {
            return ("MMM");
          }
        elsif ($digit == 4)
          {
            return ("MMMM");
          }
        elsif ($digit == 5)
          {
            return ("MMMMM");
          }
        elsif ($digit == 6)
          {
            return ("MMMMMM");
          }
        elsif ($digit == 7)
          {
            return ("MMMMMMM");
          }
        elsif ($digit == 8)
          {
            return ("MMMMMMMM");
          }
        elsif ($digit == 9)
          {
            return ("MMMMMMMMM");
          }
    }

    
    # Start the work.
    

    $digit_4 = int( $n / 1000 );
    $n = ($n - $digit_4*1000);
    $digit_3 = int( $n / 100 );
    $n = ($n - $digit_3*100);
    $digit_2 = int( $n / 10 );
    $n = ($n - $digit_2*10);
    $digit_1 = $n;

    return (&digit_4_to_roman($digit_4)
            . &digit_3_to_roman($digit_3)
            . &digit_2_to_roman($digit_2)
            . &digit_1_to_roman($digit_1));
} # &integer_to_roman

# Return page width and height from page name.
#
# &paper_size (PAGE_NAME, ORIENTATION)
#   --> (PAGE_WIDTH, PAGE_HEIGHT)

sub paper_size
{
    my ($page_name) = lc ($_[0]);
    my ($orientation) = $_[1];
    my ($x) = 0;
    my ($y) = 0;
    my ($swap) = 0;

    if ($page_name eq "a4")
      {
        $x = "210mm";
        $y = "297mm";
      }
    elsif ($page_name eq "a5x4")
      {
        $x = "210mm";
        $y = "594mm";
      }
    elsif ($page_name eq "letter")
      {
        $x = "8.5in";
        $y = "11in";
      }
    else
      {
        
        # Unimplemented page size; use defaults.

        printf STDERR (gettext ("%s: do not know %s paper size!\n"),
                       $PROGRAM_EXECUTABLE,
                       $page_name);

        $x = "210mm";
        $y = "297mm";

      }

    if ($orientation eq "portrait")
      {
        
        # OK
        
        ;
      }
    elsif ($orientation eq "landscape")
      {
        # swap
        $swap = $x;
        $x = $y;
        $y = $swap;
      }

    return ($x, $y);

} # &paper_size


# Jump a %block; element that starts on its own line, and that
# terminates on a line by itself.
# This %block; element is meant in the way that it cannot contain
# itself recusively.
#
# Currently, this function is not used.


sub jump_block
{
    my ($input_stream)   = $_[0];
    my ($output_stream)  = $_[1];
    my ($line)           = $_[2];
    my ($termination_re) = $_[3];

    
    # Try to jump the block.
    

    while ($line !~ m/$termination_re/i)
      {

        
        # Print the line and read the next.
        

        print $output_stream "$line";
        $line = <$input_stream>;
      }

    
    # Print the last line.
    

    print $output_stream "$line";
}    


# Create a temporary texmf.cfg file with adequate values for big
# documents.
#
# Currently, this function is not used.
#
# &adapt_texmf_configuration (ORIGINAL_TEXMF_CONFIG_DIR) --> config_dir


sub adapt_texmf_configuration
{
    my ($original_texmf_config_dir) = $_[0];
    my ($line) = "";
    my ($new_texmf_config_dir) = &temporary_file ($TEMP_FILE_NAME_PREFIX);
    chomp ($new_texmf_config_dir);

    
    # Create temporary directory
    

    system ("rm -f $new_texmf_config_dir ; mkdir -p $new_texmf_config_dir");

    
    # Save last temporary file names into the list.
    

    $TEMP_FILES_LIST
      = "$TEMP_FILES_LIST" . " $new_texmf_config_dir";
    #
    # Modify the configurazione
    #
    open (ORIGINAL_TEXMF_CONFIG, "< $original_texmf_config_dir/texmf.cnf");
    open (NEW_TEXMF_CONFIG, "> $new_texmf_config_dir/texmf.cnf");
    while ($line = <ORIGINAL_TEXMF_CONFIG>)
      {
        if ($line =~ m/\s*font_mem_size\s*=\s*[^ ]*\s*$/i)
          {

            
            # Change the line
            

            $line = "font_mem_size = 800000\n";
          }
        elsif ($line =~ m/\s*main_memory\s*=\s*[^ ]*\s*$/i)
          {

            
            # Change the line
            

            $line = "main_memory = 500000\n";
          }
        print NEW_TEXMF_CONFIG ("$line");
      }

    close (NEW_TEXMF_CONFIG);
    close (ORIGINAL_TEXMF_CONFIG);

    return ("$new_texmf_config_dir");
} # &adapt_texmf_configuration

# Diagnostic output; it depends on the following global variables:
#   $VERBOSE
#   $ROOT_FILE_NAME

sub diag_output
{
    my ($string)                = $_[0];
    my ($verbosity)             = $_[1];
    my ($verbose_on)            = 0;
    
    # verbosity is a number from 0 (minimun) and 2 (maximun).

    if ($VERBOSE >= $verbosity)
      {
        $verbose_on = 1;
      }
    #
    # Append to the diagnostic file.
    #
    open (DIAG, ">> $ROOT_FILE_NAME.diag");
    #
    if ($verbose_on)
      {
        print STDOUT ("$string");
      }
    else
      {
        &wait_message ($string);
      }
    
    # In any case, print it on the DIAG file

    print DIAG ($string);
    
    # Close the file.

    close (DIAG);

}
#
# External anchor check
# &external_anchor_check (ID) --> TRUE|FALSE
#
sub external_anchor_check
{
    my ($id)            = $_[0];
                
    if ($id !~ m/^[a-zA-Z0-9_-]+$/)
      {
        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: external anchor \"%s\" is not valid. Please use only: a-z, A-Z, 0-9, \"_\" and \"-\".\n"),
                               $PROGRAM_EXECUTABLE,
                               $SOURCE_FILE_NAME,
                               $CURRENT_FILE_NAME,
                               $INPUT_STREAM_LINE_COUNTER,
                               $id), $V_ERROR);
        return (0);
      }
    elsif ($id =~ m/^[alml]+$/)
      {
        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: external anchors cannot start with the string \"alml\": \"%s\".\n"),
                               $PROGRAM_EXECUTABLE,
                               $SOURCE_FILE_NAME,
                               $CURRENT_FILE_NAME,
                               $INPUT_STREAM_LINE_COUNTER,
                               $id), $V_ERROR);
        return (0);
      }
    elsif (length ($id) > 20)
      {
        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: external anchors may not work it longer then 20 characters: \"%s\".\n"),
                               $PROGRAM_EXECUTABLE,
                               $SOURCE_FILE_NAME,
                               $CURRENT_FILE_NAME,
                               $INPUT_STREAM_LINE_COUNTER,
                               $id), $V_ERROR);
        return (0);
      }

    return (1);

}
#
# Add to the copy list.
#
sub add_copy_list
{
    my ($name) = $_[0];
    my ($string) = $_[1];
    #
    my ($n) = 0;
    #
    # Scan the @COPY_LIST to find the same entry.
    #
    # $COPY_LIST[x][0]        copy name
    # $COPY_LIST[x][1]        string
    #
    for ($n = 0;
         $n <= $#COPY_LIST;
         $n++)
      {
        if ($COPY_LIST[$n][0] eq $name)
          {
            #
            # There is already the same entry.
            # Add the string.
            #
            $COPY_LIST[$n][1] = $COPY_LIST[$n][1] . "$string";
            #
            last;
          }
      }
    #
    # If the entry wasn't found, add it.
    #
    if ($n > $#COPY_LIST)
      {
        $#COPY_LIST++;
        $COPY_LIST[$n][0] = $name;
        $COPY_LIST[$n][1] = $string;
      }
}
#
# Get a copy.
#
sub get_copy_list
{
    my ($name) = $_[0];
    #
    my ($n) = 0;
    #
    # Scan the @COPY_LIST array to find the same entry.
    #
    # $COPY_LIST[x][0]        copy name
    # $COPY_LIST[x][1]        string
    #
    for ($n = 0;
         $n <= $#COPY_LIST;
         $n++)
      {
        if ($COPY_LIST[$n][0] eq $name)
          {
            #
            # Name found.
            #
            return ($COPY_LIST[$n][1]);
            #
            last;
          }
      }
    #
    # If the entry wasn't found, return an empty string.
    #
    return ("");
}
#
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
# page_ref_replace (ROOT_FILE_NAME, STAGE)
#
# Replace page reference inside a TeX file genereated from Alml.
#
sub page_ref_replace
{
    #! local ($root_file_name) = $_[0];
    my ($stage)          = $_[1];
    #
    # Page references taken from the .pageref file
    # $tex_page_ref_list[x][0]        label
    # $tex_page_ref_list[x][1]        page
    #
    local (@tex_page_ref_list) = ();
    #
    # Scan an .pageref file and fill the tex page reference list.
    #
    # &tex_page_ref_list_fill (FILE)
    #
    sub tex_page_ref_list_fill
    {
        my ($file_name) = $_[0];
        my ($label) = "";
        my ($page) = "";
    
        # Reset the array.
    
        @tex_page_ref_list = ();

        open (PAGEREF, "< $file_name");

        while ($line = <PAGEREF>)
          {
            if ($line =~ m/^\\almlazlabel\{([^{}]+)\}\{([^{}]+)\}/)
              {
                $label = $1;
                $page = $2;

                # Page references taken from the .pageref file
                # $tex_page_ref_list[x][0]        label
                # $tex_page_ref_list[x][1]        page

                $#tex_page_ref_list++;
                $tex_page_ref_list[$#tex_page_ref_list] = ();
                $tex_page_ref_list[$#tex_page_ref_list][0] = $label;
                $tex_page_ref_list[$#tex_page_ref_list][1] = $page;

                &wait_message ("$PROGRAM_EXECUTABLE:$SOURCE_FILE_NAME: loading page reference $label at page $page");
              }
          }

        close (PAGEREF);
    }

    # Scan a .tex file and replace a dummy \pageref command.
    #
    # &tex_page_ref_list_replace (FILE_IN, FILE_OUT, N_SCAN)

    sub tex_page_ref_list_replace
    {
        my ($file_in) = $_[0];
        my ($file_out) = $_[1];
        my ($scan_order) = $_[2];
        my ($next_scan_order) = $scan_order + 1;
        my ($line) = "";
        my ($n) = "";
        my ($pre) = "";
        my ($page) = "";
        my ($label) = "";
        my ($post) = "";
    
        open (FILE_IN, "< $file_in");
        open (FILE_OUT, "> $file_out");
    
        while ($line = <FILE_IN>)
          {
            while ($line =~ m/^(.*)\\almlczpageref\{$scan_order\}\{([^{}]*)\}\{([^{}]+)\}(.*)$/)
              {
                
                # \almlczpageref{0}{000}{pippo}
    
                $pre = $1;          
                $page = $2;         
                $label = $3;                
                $post = $4;         
                
                # Page references taken from the .pageref file
                # $tex_page_ref_list[x][0]        label
                # $tex_page_ref_list[x][1]        page
    
                $n = &find_tex_page_ref_list ($label, 0, $#tex_page_ref_list);
    
                if ($tex_page_ref_list[$n][0] eq $label)
                  {
                     $line = $pre
                            . "\\almlczpageref\{"
                            . "$next_scan_order"
                            . "\}\{"
                            . $tex_page_ref_list[$n][1]
                            . "\}\{"
                            . "$label"
                            . "\}"
                            . "$post\n";
    
                    &wait_message ("\\almlczpageref\{"
                                   . "$next_scan_order"
                                   . "\}\{"
                                   . $tex_page_ref_list[$n][1]
                                   . "\}\{"
                                   . "$label"
                                   . "\}");
                  }
                else
                  {
                    &diag_output (sprintf (gettext ("%s:%s:ERROR: label \"%s\" not found\n"),
                                           $PROGRAM_EXECUTABLE, "$ROOT_FILE_NAME.tex", "$label"), $V_ERROR);
                  
                    # Cannot keep the same wrong string, otherwise,
                    # at the next loop, it will be found again!
                    # So, the scan order is incremented anyway. Sorry.
    
                    $line = $pre
                            . "\\almlczpageref\{"
                            . "$next_scan_order"
                            . "\}\{"
                            . "$page"
                            . "\}\{"
                            . "$label"
                            . "\}"
                            . "$post\n";
                  }
              }
    
            print FILE_OUT ($line);
          }
    
        if ($VERBOSE >= $V_ERROR)
          {
            
            # Close with a new line on the screen.
    
            print STDOUT ("\n");
          }
    
        close (FILE_IN);
        close (FILE_OUT);
    }
    
    # Find an element inside tex_page_ref_list.
    #
    # &find_tex_page_ref_list (LABEL) --> array pointer
    
    sub find_tex_page_ref_list
    {
        my ($label) = $_[0];    # label to search
        my ($a) = $_[1];
        my ($z) = $_[2];
        my ($m);
        
        # Page references taken from the *.pageref file
        # $tex_page_ref_list[x][0]        label
        # $tex_page_ref_list[x][1]        page
    
        $m = $a;
        while ($label ne $tex_page_ref_list[$m][0])
          {
            $m++;
            if ($m > $z)
              {
                
                # Non restano elementi da controllare: l'elemento cercato
                # non c'.
    
                return -1;
              }
          }
        
        # L'elemento  stato trovato.
    
        return $m;
    }
    
    # Find an element inside tex_page_ref_list (sorted previously)
    #
    # The sorting and scanning with binary access is no more used
    # because too slow (it is really too much slow). It is better
    # to simply scan the array sequentially!
    #
    # &find_tex_page_ref_list_binary_search (LABEL) --> array pointer
    
    sub find_tex_page_ref_list_binary_search
    {
        my ($label) = $_[0];    # label to search
        my ($a) = $_[1];
        my ($z) = $_[2];
        my ($m);
        
        # Page references taken from the *.pageref file
        # $tex_page_ref_list[x][0]        label
        # $tex_page_ref_list[x][1]        page
        
        # Determina l'elemento centrale.
    
        $m = int (($a + $z) / 2);
    
        if ($m < $a)
          {
            
            # Non restano elementi da controllare: l'elemento cercato non c'.
    
            return -1;
          }
        elsif ($label lt $tex_page_ref_list[$m][0])
          {
            
            # Si ripete la ricerca nella parte inferiore.
    
            return &find_tex_page_ref_list ($label, $a, $m-1);
          }
        elsif ($label gt $tex_page_ref_list[$m][0])
          {
            
            # Si ripete la ricerca nella parte superiore.
    
            return &find_tex_page_ref_list ($label, $m+1, $z);
          }
        else
          {
            
            # $m rappresenta l'indice dell'elemento cercato.
    
            return $m;
          }
    }

    # Start of &page_ref_replace
    
    &diag_output (sprintf (gettext ("%s:%s: page references re-elaboration\n"),
                           $PROGRAM_EXECUTABLE,
                           "$ROOT_FILE_NAME.pageref"), $V_SUPER);
    
    &diag_output (sprintf (gettext ("%s:%s: reading data\n"),
                           $PROGRAM_EXECUTABLE,
                           "$ROOT_FILE_NAME.pageref"), $V_NORMAL);
    
    &tex_page_ref_list_fill ("$ROOT_FILE_NAME.pageref");
    
    system ("mv -f $ROOT_FILE_NAME.tex $ROOT_FILE_NAME.tex~");
    &diag_output (sprintf (gettext ("%s: replacing %s with new page references\n"),
                           $PROGRAM_EXECUTABLE,
                           "$ROOT_FILE_NAME.tex"), $V_NORMAL);
    
    &tex_page_ref_list_replace ("$ROOT_FILE_NAME.tex~",
                                "$ROOT_FILE_NAME.tex", $stage);
    system ("mv -f $ROOT_FILE_NAME.pageref $ROOT_FILE_NAME.pageref~ 2> /dev/null");
    system ("mv -f $ROOT_FILE_NAME.log $ROOT_FILE_NAME.log~ 2> /dev/null");

    # Free up memory

    @tex_page_ref_list = ();
    undef (@tex_page_ref_list);

} #&page_ref_replace
#    
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
# Convert a string into SP SDATA entities. That is, for example,
# "-" is converted into "\|[hyphen]\|".
#
# Some characters cannot be converted because it is difficult to
# distinguish them from escape sequence generated by SP output:
# "|", "[" and "]".
#
# &sp_text_to_sdata (TEXT)
#
sub sp_text_to_sdata
{
    my ($line) = $_[0];
    
    # First of all, SDATA like "[xxx   ]" should have no space
    # inside, like "[xxx]", because the space is then transformed.
    #
    # Entity names can have letters, lower and upper case, numbers
    # and points, like this: /[a-zA-Z0-9.]+/

    $line =~ s/\\\|\[([a-zA-Z0-9.]+) +\]\\\|/\\\|\[$1\]\\\|/g;
    
    # The space needs to be identified

    $line =~ s/\x{0020}/\\\|\[simplespace\]\\\|/g;

    # US-ASCII special characters for any typesetting system.
    $line =~ s/\x{0021}/\\\|\[excl\]\\\|/g;    # ISOnum : EXCLAMATION MARK
    $line =~ s/\x{0022}/\\\|\[quot\]\\\|/g;    # ISOnum : QUOTATION MARK
    $line =~ s/\x{0023}/\\\|\[num\]\\\|/g;     # ISOnum : NUMBER SIGN
    $line =~ s/\x{0024}/\\\|\[dollar\]\\\|/g;  # ISOnum : dollar sign
    $line =~ s/\x{0025}/\\\|\[percnt\]\\\|/g;  # ISOnum : percent sign
    $line =~ s/\x{0026}/\\\|\[amp\]\\\|/g;     # ISOnum : ampersand
    $line =~ s/\x{0027}/\\\|\[apos\]\\\|/g;    # ISOnum : apostrophe
    $line =~ s/\x{0028}/\\\|\[lpar\]\\\|/g;    # ISOnum : left parenthesis
    $line =~ s/\x{0029}/\\\|\[rpar\]\\\|/g;    # ISOnum : right parenthesis
    $line =~ s/\x{002A}/\\\|\[ast\]\\\|/g;     # ISOnum : asterisk
    $line =~ s/\x{002B}/\\\|\[plus\]\\\|/g;    # ISOnum : plus sign
    $line =~ s/\x{002C}/\\\|\[comma\]\\\|/g;   # ISOnum : comma
    $line =~ s/\x{002D}/\\\|\[hyphen\]\\\|/g;  # ISOnum : hyphen
    $line =~ s/\x{002E}/\\\|\[period\]\\\|/g;  # ISOnum : full stop, period
    $line =~ s/\x{002F}/\\\|\[sol\]\\\|/g;     # ISOnum : solidus
    # numbers from 0 to 9 are not translated
    $line =~ s/\x{003A}/\\\|\[colon\]\\\|/g;   # ISOnum : colon
    $line =~ s/\x{003B}/\\\|\[semi\]\\\|/g;    # ISOnum : semicolon
    $line =~ s/\x{003C}/\\\|\[lt\]\\\|/g;      # ISOnum : less-than sign
    $line =~ s/\x{003D}/\\\|\[equals\]\\\|/g;  # ISOnum : equals sign
    $line =~ s/\x{003E}/\\\|\[gt\]\\\|/g;      # ISOnum : greater-than sign
    $line =~ s/\x{003F}/\\\|\[quest\]\\\|/g;   # ISOnum : question mark
    $line =~ s/\x{0040}/\\\|\[commat\]\\\|/g;  # ISOnum : commercial at
    # letters from A to Z are not translated
    #$line =~ s/\x{005B}/\\\|\[lsqb\]\\\|/g;    # ISOnum : left square bracket
    $line =~ s/\x{005C}\x{005C}/\\\|\[bsol\]\\\|/g;    # ISOnum : reverse solidus - this is special!
    #$line =~ s/\x{005D}/\\\|\[rsqb\]\\\|/g;    # ISOnum : right square bracket
    $line =~ s/\x{005E}/\\\|\[circ\]\\\|/g;    # ISOnum : circumflex accent
    $line =~ s/\x{005F}/\\\|\[lowbar\]\\\|/g;  # ISOnum : low line
    $line =~ s/\x{0060}/\\\|\[lsquo\]\\\|/g;   # ISOnum : single quotation mark, left
    # letters from a to z are not translated
    $line =~ s/\x{007B}/\\\|\[lcub\]\\\|/g;    # ISOnum : left curly bracket
    #$line =~ s/\x{007C}/\\\|\[verbar\]\\\|/g;  # ISOnum : vertical bar
    $line =~ s/\x{007D}/\\\|\[rcub\]\\\|/g;    # ISOnum : right curly bracket
    $line =~ s/\x{007E}/\\\|\[tilde\]\\\|/g;   # ISOdia : tilde

    # Extra
    $line =~ s/\x{2212}/\\\|\[minus\]\\\|/g;   # ISOtech : minus

    return ($line);
}

# Avoid having Unicode charcarter that will generate errors with
# LaTeX
#
# This function MUST be the same inside alml-sp2sp and alml-sp2be!
#
# &sp_latex_to_sp_latex_unicode_clean (TEXT)

sub sp_latex_to_sp_latex_unicode_clean
{
    my ($line) = $_[0];
    my ($line_new) = "";
    my ($offset) = 0;
    my ($max) = 0;
    my ($char) = "";
    my ($unknown) = "{\\almlxxsymbolunprintable}";

    $max = length ($line);
    while (1)
      {
        if ($offset >= $max)
          {
            last;
          }
        else
          {
            $char = substr ($line, $offset, 1);

            if    (  ($char ge "\x{0180}" && $char le "\x{0191}")
                  || ($char ge "\x{0193}" && $char le "\x{01F4}")
                  || ($char ge "\x{01F6}" && $char le "\x{024F}"))
              {
                
                # Unused Latin extended-B

                $line_new = $line_new . $unknown;

              }
            elsif ($char ge "\x{0250}" && $char le "\x{02AF}")
              {
            
                # Unused IPA extentions

                $line_new = $line_new . $unknown;

              }
            elsif (  ($char ge "\x{0464}" && $char le "\x{0471}")
                  || ($char ge "\x{0476}" && $char le "\x{04C0}")
                  || ($char ge "\x{04C3}" && $char le "\x{04CE}")
                  || ($char ge "\x{04D4}" && $char le "\x{04D5}")
                  || ($char ge "\x{04D8}" && $char le "\x{04DB}")
                  || ($char ge "\x{04E0}" && $char le "\x{04FF}"))
              {
                
                # Unused Cyrillic

                $line_new = $line_new . $unknown;

              }
            elsif ($char ge "\x{0500}" && $char le "\x{050F}")
              {
                
                # Unused Supplementary Cyrillic

                $line_new = $line_new . $unknown;

              }
            elsif ($char ge "\x{0510}" && $char le "\x{19FF}")
              {
                
                # Unused

                $line_new = $line_new . $unknown;

              }
            elsif (  ($char ge "\x{2000}" && $char le "\x{200F}")
                  || ($char ge "\x{2011}" && $char le "\x{2011}")
                  || ($char ge "\x{2028}" && $char le "\x{202F}")
                  || ($char ge "\x{205F}" && $char le "\x{206F}"))
              {
                
                # Unused inside general punctuation.

                $line_new = $line_new . $unknown;

              }
            elsif (  ($char ge "\x{2102}" && $char le "\x{2102}")
                  || ($char ge "\x{2107}" && $char le "\x{2107}")
                  || ($char ge "\x{210D}" && $char le "\x{210D}")
                  || ($char ge "\x{2115}" && $char le "\x{2115}")
                  || ($char ge "\x{2119}" && $char le "\x{211A}")
                  || ($char ge "\x{211D}" && $char le "\x{211D}")
                  || ($char ge "\x{2124}" && $char le "\x{2124}")
                  || ($char ge "\x{213D}" && $char le "\x{213F}"))
              {
                
                # Unused inside letterlike symbols

                $line_new = $line_new . $unknown;

              }
            elsif (  ($char ge "\x{2190}" && $char le "\x{20FF}"))
              {
                
                # Unused

                $line_new = $line_new . $unknown;

              }
            elsif (  ($char ge "\x{246A}" && $char le "\x{2473}")
                  || ($char ge "\x{24B6}" && $char le "\x{24EA}"))
              {
                
                # Unused enclosed alphanumerics

                $line_new = $line_new . $unknown;

              }
            elsif (  ($char ge "\x{2500}" && $char le "\x{257F}")
                  || ($char ge "\x{2581}" && $char le "\x{2583}")
                  || ($char ge "\x{2585}" && $char le "\x{2587}")
                  || ($char ge "\x{2589}" && $char le "\x{2590}")
                  || ($char ge "\x{25CC}" && $char le "\x{25CC}"))
              {
                
                # Unused Geometric shapes

                $line_new = $line_new . $unknown;

              }
            elsif ($char ge "\x{2B00}" && $char le "\x{2FFF}")
              {
                
                # Unused Unknown

                $line_new = $line_new . $unknown;

              }
            elsif ($char ge "\x{FB13}" && $char le "\x{FE4F}")
              {
                
                # Unused

                $line_new = $line_new . $unknown;

              }
            elsif ($char ge "\x{FE70}")
              {
                
                # Unused

                $line_new = $line_new . $unknown;

              }
            else
              {
                $line_new = $line_new . $char;

              }
           }
         $offset++;
      }
    $line_new = $line_new . "\n";

    return ($line_new);
}
#
# Convert an SP SDATA string into LaTeX back-end code.
# That is, for example, "\|[circ  ]\|" is converted into "\\^{}".
#
# &sp_sdata_text_to_sp_latex (TEXT)
#
sub sp_sdata_text_to_sp_latex
{
    my ($line) = $_[0];
    my ($line_new) = "";
    my ($offset) = 0;
    my ($max) = 0;
    my ($char) = "";
    my ($unknown) = "{\\almlxxsymbolunprintable}";
    #
    # Please note that the space is handled because there are
    # commands eating spaces...
    #
    #!!!!
    #
    # In the near future, the space such as "{} " might be
    # changed into "\ ", that is more correct.
    # The DTD is arranged to delete duplicate spaces, replacing
    # also tabs into single space.
    #
    $line =~ s/\\\|\[simplespace\]\\\|/{} /g;    # &simplespace; does not exist.
    #
    # <!ENTITY % ISOpub PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN">
    #
    $line =~ s/\\\|\[emsp\]\\\|/\x{2003}/g;     # EM SPACE # 2003
    $line =~ s/\\\|\[ensp\]\\\|/\x{2002}/g;     # EN SPACE # 2002
    $line =~ s/\\\|\[emsp3\]\\\|/\x{2004}/g;    # THREE-PER-EM SPACE # 2004
    $line =~ s/\\\|\[emsp4\]\\\|/\x{2005}/g;    # FOUR-PER-EM SPACE # 2005
    $line =~ s/\\\|\[numsp\]\\\|/\x{2007}/g;    # FIGURE SPACE # 2007
    $line =~ s/\\\|\[puncsp\]\\\|/\x{2008}/g;   # PUNCTUATION SPACE # 2008
    $line =~ s/\\\|\[thinsp\]\\\|/\x{2009}/g;   # THIN SPACE # 2009
    $line =~ s/\\\|\[hairsp\]\\\|/\x{200A}/g;   # HAIR SPACE # 200A
    $line =~ s/\\\|\[mdash\]\\\|/\x{2014}/g;    # EM DASH # 2014
    $line =~ s/\\\|\[ndash\]\\\|/\x{2013}/g;    # EN DASH # 2013
    $line =~ s/\\\|\[dash\]\\\|/\x{2010}/g;     # HYPHEN # 2010
    $line =~ s/\\\|\[blank\]\\\|/\x{2423}/g;    # OPEN BOX # 2423
    $line =~ s/\\\|\[hellip\]\\\|/\x{2026}/g;   # HORIZONTAL ELLIPSIS # 2026
    $line =~ s/\\\|\[nldr\]\\\|/\x{2025}/g;     # TWO DOT LEADER # 2025
    $line =~ s/\\\|\[frac13\]\\\|/\x{2153}/g;   # VULGAR FRACTION ONE THIRD # 2153
    $line =~ s/\\\|\[frac23\]\\\|/\x{2154}/g;   # VULGAR FRACTION TWO THIRDS # 2154
    $line =~ s/\\\|\[frac15\]\\\|/\x{2155}/g;   # VULGAR FRACTION ONE FIFTH # 2155
    $line =~ s/\\\|\[frac25\]\\\|/\x{2156}/g;   # VULGAR FRACTION TWO FIFTHS # 2156
    $line =~ s/\\\|\[frac35\]\\\|/\x{2157}/g;   # VULGAR FRACTION THREE FIFTHS # 2157
    $line =~ s/\\\|\[frac45\]\\\|/\x{2158}/g;   # VULGAR FRACTION FOUR FIFTHS # 2158
    $line =~ s/\\\|\[frac16\]\\\|/\x{2159}/g;   # VULGAR FRACTION ONE SIXTH # 2159
    $line =~ s/\\\|\[frac56\]\\\|/\x{215A}/g;   # VULGAR FRACTION FIVE SIXTHS # 215A
    $line =~ s/\\\|\[incare\]\\\|/\x{2105}/g;   # CARE OF # 2105
    $line =~ s/\\\|\[block\]\\\|/\x{2588}/g;    # FULL BLOCK # 2588
    $line =~ s/\\\|\[uhblk\]\\\|/\x{2580}/g;    # UPPER HALF BLOCK # 2580
    $line =~ s/\\\|\[lhblk\]\\\|/\x{2584}/g;    # LOWER HALF BLOCK # 2584
    $line =~ s/\\\|\[blk14\]\\\|/\x{2591}/g;    # LIGHT SHADE # 2591
    $line =~ s/\\\|\[blk12\]\\\|/\x{2592}/g;    # MEDIUM SHADE # 2592
    $line =~ s/\\\|\[blk34\]\\\|/\x{2593}/g;    # DARK SHADE # 2593
    $line =~ s/\\\|\[marker\]\\\|/\x{25AE}/g;   # BLACK VERTICAL RECTANGLE # 25AE
    $line =~ s/\\\|\[cir\]\\\|/\x{25CB}/g;      # WHITE CIRCLE # 25CB
    $line =~ s/\\\|\[squ\]\\\|/\x{25A1}/g;      # WHITE SQUARE # 25A1
    $line =~ s/\\\|\[rect\]\\\|/\x{25AD}/g;     # WHITE RECTANGLE # 25AD
    $line =~ s/\\\|\[utri\]\\\|/\x{25B5}/g;     # WHITE UP-POINTING TRIANGLE # 25B5
    $line =~ s/\\\|\[dtri\]\\\|/\x{25BF}/g;     # WHITE DOWN-POINTING TRIANGLE # 25BF
    $line =~ s/\\\|\[star\]\\\|/\x{22C6}/g;     # STAR OPERATOR # 22C6
    $line =~ s/\\\|\[bull\]\\\|/\x{2022}/g;     # BULLET # 2022
    $line =~ s/\\\|\[squf\]\\\|/\x{25AA}/g;     #  # 25AA
    $line =~ s/\\\|\[utrif\]\\\|/\x{25B4}/g;    # BLACK UP-POINTING TRIANGLE # 25B4
    $line =~ s/\\\|\[dtrif\]\\\|/\x{25BE}/g;    # BLACK DOWN-POINTING TRIANGLE # 25BE
    $line =~ s/\\\|\[ltrif\]\\\|/\x{25C2}/g;    # BLACK LEFT-POINTING TRIANGLE # 25C2
    $line =~ s/\\\|\[rtrif\]\\\|/\x{25B8}/g;    # BLACK RIGHT-POINTING TRIANGLE # 25B8
    $line =~ s/\\\|\[clubs\]\\\|/\x{2663}/g;    # BLACK CLUB SUIT # 2663
    $line =~ s/\\\|\[diams\]\\\|/\x{2666}/g;    # BLACK DIAMOND SUIT # 2666
    $line =~ s/\\\|\[hearts\]\\\|/\x{2665}/g;   # BLACK HEART SUIT # 2665
    $line =~ s/\\\|\[spades\]\\\|/\x{2660}/g;   # BLACK SPADE SUIT # 2660
    $line =~ s/\\\|\[malt\]\\\|/\x{2720}/g;     # MALTESE CROSS # 2720
    $line =~ s/\\\|\[dagger\]\\\|/\x{2020}/g;   # DAGGER # 2020
    $line =~ s/\\\|\[Dagger\]\\\|/\x{2021}/g;   # DOUBLE DAGGER # 2021
    $line =~ s/\\\|\[check\]\\\|/\x{2713}/g;    # CHECK MARK # 2713
    $line =~ s/\\\|\[cross\]\\\|/\x{2717}/g;    # BALLOT X # 2717
    $line =~ s/\\\|\[ballot\]\\\|/\x{2717}/g;   # BALLOT X # 2717
    $line =~ s/\\\|\[sharp\]\\\|/\x{266F}/g;    # MUSIC SHARP SIGN # 266F
    $line =~ s/\\\|\[flat\]\\\|/\x{266D}/g;     # MUSIC FLAT SIGN # 266D
    $line =~ s/\\\|\[male\]\\\|/\x{2642}/g;     # MALE SIGN # 2642
    $line =~ s/\\\|\[female\]\\\|/\x{2640}/g;   #  # 2640
    $line =~ s/\\\|\[phone\]\\\|/\x{260E}/g;    # TELEPHONE SIGN # 260E
    $line =~ s/\\\|\[telrec\]\\\|/\x{2315}/g;   # TELEPHONE RECORDER # 2315
    $line =~ s/\\\|\[copysr\]\\\|/\x{2117}/g;   # SOUND RECORDING COPYRIGHT # 2117
    $line =~ s/\\\|\[caret\]\\\|/\x{2041}/g;    # CARET # 2041
    $line =~ s/\\\|\[lsquor\]\\\|/\x{201A}/g;   # SINGLE LOW-9 QUOTATION MARK # 201A
    $line =~ s/\\\|\[ldquor\]\\\|/\x{201E}/g;   # DOUBLE LOW-9 QUOTATION MARK # 201E
    $line =~ s/\\\|\[fflig\]\\\|/\x{FB00}/g;    #  # FB00
    $line =~ s/\\\|\[filig\]\\\|/\x{FB01}/g;    #  # FB01
    $line =~ s/\\\|\[fjlig\]\\\|/\{fj\}/g;      # small fj ligature
    $line =~ s/\\\|\[ffilig\]\\\|/\x{FB03}/g;   #  # FB03
    $line =~ s/\\\|\[ffllig\]\\\|/\x{FB04}/g;   #  # FB04
    $line =~ s/\\\|\[fllig\]\\\|/\x{FB02}/g;    #  # FB02
    $line =~ s/\\\|\[mldr\]\\\|/\x{2026}/g;     # HORIZONTAL ELLIPSIS # 2026
    $line =~ s/\\\|\[rdquor\]\\\|/\x{201C}/g;   #  # 201C
    $line =~ s/\\\|\[rsquor\]\\\|/\x{2018}/g;   #  # 2018
    $line =~ s/\\\|\[vellip\]\\\|/\x{22EE}/g;   #  # 22EE
    $line =~ s/\\\|\[hybull\]\\\|/\x{2043}/g;   # HYPHEN BULLET # 2043
    $line =~ s/\\\|\[loz\]\\\|/\x{25CA}/g;      # LOZENGE # 25CA
    $line =~ s/\\\|\[lozf\]\\\|/\x{2726}/g;     #  # 2726
    $line =~ s/\\\|\[ltri\]\\\|/\x{25C3}/g;     # WHITE LEFT-POINTING TRIANGLE # 25C3
    $line =~ s/\\\|\[rtri\]\\\|/\x{25B9}/g;     # WHITE RIGHT-POINTING TRIANGLE # 25B9
    $line =~ s/\\\|\[starf\]\\\|/\x{2605}/g;    # BLACK STAR # 2605
    $line =~ s/\\\|\[natur\]\\\|/\x{266E}/g;    # MUSIC NATURAL SIGN # 266E
    $line =~ s/\\\|\[rx\]\\\|/\x{211E}/g;       # PRESCRIPTION TAKE # 211E
    $line =~ s/\\\|\[sext\]\\\|/\x{2736}/g;     # SIX POINTED BLACK STAR # 2736
    $line =~ s/\\\|\[target\]\\\|/\x{2316}/g;   # POSITION INDICATOR # 2316
    $line =~ s/\\\|\[dlcrop\]\\\|/\x{230D}/g;   # BOTTOM LEFT CROP # 230D
    $line =~ s/\\\|\[drcrop\]\\\|/\x{230C}/g;   # BOTTOM RIGHT CROP # 230C
    $line =~ s/\\\|\[ulcrop\]\\\|/\x{230F}/g;   # TOP LEFT CROP # 230F
    $line =~ s/\\\|\[urcrop\]\\\|/\x{230E}/g;   # TOP RIGHT CROP # 230E
    #
    # <!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN">
    #
    $line =~ s/\\\|\[half\]\\\|/\x{00BD}/g;     # VULGAR FRACTION ONE HALF # 00BD
    $line =~ s/\\\|\[frac12\]\\\|/\x{00BD}/g;   # VULGAR FRACTION ONE HALF # 00BD
    $line =~ s/\\\|\[frac14\]\\\|/\x{00BC}/g;   # VULGAR FRACTION ONE QUARTER # 00BC
    $line =~ s/\\\|\[frac34\]\\\|/\x{00BE}/g;   # VULGAR FRACTION THREE QUARTERS # 00BE
    $line =~ s/\\\|\[frac18\]\\\|/\x{215B}/g;   #  # 215B
    $line =~ s/\\\|\[frac38\]\\\|/\x{215C}/g;   #  # 215C
    $line =~ s/\\\|\[frac58\]\\\|/\x{215D}/g;   #  # 215D
    $line =~ s/\\\|\[frac78\]\\\|/\x{215E}/g;   #  # 215E
    $line =~ s/\\\|\[sup1\]\\\|/\x{00B9}/g;     # SUPERSCRIPT ONE # 00B9
    $line =~ s/\\\|\[sup2\]\\\|/\x{00B2}/g;     # SUPERSCRIPT TWO # 00B2
    $line =~ s/\\\|\[sup3\]\\\|/\x{00B3}/g;     # SUPERSCRIPT THREE # 00B3
    $line =~ s/\\\|\[plus\]\\\|/\x{002B}/g;     # PLUS SIGN # 002B
    $line =~ s/\\\|\[plusmn\]\\\|/\x{00B1}/g;   # PLUS-MINUS SIGN # 00B1
    $line =~ s/\\\|\[lt\]\\\|/\{\<\}/g;         # LESS-THAN SIGN # 003C
    $line =~ s/\\\|\[equals\]\\\|/=/g;          # EQUALS SIGN # 003D
    $line =~ s/\\\|\[gt\]\\\|/\{\>\}/g;         # GREATER-THAN SIGN # 003E
    $line =~ s/\\\|\[divide\]\\\|/\x{00F7}/g;   # DIVISION SIGN # 00F7
    $line =~ s/\\\|\[times\]\\\|/\x{00D7}/g;    # MULTIPLICATION SIGN # 00D7
    $line =~ s/\\\|\[curren\]\\\|/\x{00A4}/g;   # CURRENCY SIGN # 00A4
    $line =~ s/\\\|\[pound\]\\\|/\x{00A3}/g;    # POUND SIGN # 00A3
    $line =~ s/\\\|\[dollar\]\\\|/\\textdollar /g;    # DOLLAR SIGN # 0024
    $line =~ s/\\\|\[cent\]\\\|/\x{00A2}/g;     # CENT SIGN # 00A2
    $line =~ s/\\\|\[yen\]\\\|/\x{00A5}/g;      # YEN SIGN # 00A5
    $line =~ s/\\\|\[num\]\\\|/\\\#/g;          # NUMBER SIGN # 0023
    $line =~ s/\\\|\[percnt\]\\\|/\{\\%\}/g;    # PERCENT SIGN # 0025
    $line =~ s/\\\|\[amp\]\\\|/\\\&/g;          # AMPERSAND # 0026
    $line =~ s/\\\|\[ast\]\\\|/\*/g;            # ASTERISK # 002A
    $line =~ s/\\\|\[commat\]\\\|/\\symbol\{64\}/g;     # COMMERCIAL AT # 0040
    $line =~ s/\\\|\[lsqb\]\\\|/\{\x{005B}\}/g; # LEFT SQUARE BRACKET # 005B
    $line =~ s/\\\|\[bsol\]\\\|/\\textbackslash /g;    # REVERSE SOLIDUS # 005C
    $line =~ s/\\\|\[rsqb\]\\\|/\{\x{005D}\}/g; # RIGHT SQUARE BRACKET # 005D
    $line =~ s/\\\|\[lcub\]\\\|/\\textbraceleft /g;    # LEFT CURLY BRACKET # 007B
    $line =~ s/\\\|\[horbar\]\\\|/\x{2015}/g;   # HORIZONTAL BAR # 2015
    $line =~ s/\\\|\[verbar\]\\\|/\\textbar /g; # VERTICAL LINE # 007C
    $line =~ s/\\\|\[rcub\]\\\|/\\textbraceright /g;    # RIGHT CURLY BRACKET # 007D
    $line =~ s/\\\|\[micro\]\\\|/\x{00B5}/g;    # MICRO SIGN # 00B5
    $line =~ s/\\\|\[ohm\]\\\|/\x{2126}/g;      # OHM SIGN # 2126
    $line =~ s/\\\|\[deg\]\\\|/\x{00B0}/g;      # DEGREE SIGN # 00B0
    $line =~ s/\\\|\[ordm\]\\\|/\x{00BA}/g;     # MASCULINE ORDINAL INDICATOR # 00BA
    $line =~ s/\\\|\[ordf\]\\\|/\x{00AA}/g;     # FEMININE ORDINAL INDICATOR # 00AA
    $line =~ s/\\\|\[sect\]\\\|/\x{00A7}/g;     # SECTION SIGN # 00A7
    $line =~ s/\\\|\[para\]\\\|/\x{00B6}/g;     # PILCROW SIGN # 00B6
    $line =~ s/\\\|\[middot\]\\\|/\x{00B7}/g;   # MIDDLE DOT # 00B7
    $line =~ s/\\\|\[larr\]\\\|/\x{2190}/g;     # LEFTWARDS ARROW # 2190
    $line =~ s/\\\|\[rarr\]\\\|/\x{2192}/g;     # RIGHTWARDS ARROW # 2192
    $line =~ s/\\\|\[uarr\]\\\|/\x{2191}/g;     # UPWARDS ARROW # 2191
    $line =~ s/\\\|\[darr\]\\\|/\x{2193}/g;     # DOWNWARDS ARROW # 2193
    $line =~ s/\\\|\[copy\]\\\|/\x{00A9}/g;     # COPYRIGHT SIGN # 00A9
    $line =~ s/\\\|\[reg\]\\\|/\x{00AE}/g;      # REG TRADE MARK SIGN # 00AE
    $line =~ s/\\\|\[trade\]\\\|/\x{2122}/g;    # TRADE MARK SIGN # 2122
    $line =~ s/\\\|\[brvbar\]\\\|/\x{00A6}/g;   # BROKEN BAR # 00A6
    $line =~ s/\\\|\[not\]\\\|/\x{00AC}/g;      # NOT SIGN # 00AC
    $line =~ s/\\\|\[sung\]\\\|/\x{2669}/g;     #  # 2669
    $line =~ s/\\\|\[excl\]\\\|/\x{0021}/g;     # EXCLAMATION MARK # 0021
    $line =~ s/\\\|\[iexcl\]\\\|/\x{00A1}/g;    # INVERTED EXCLAMATION MARK # 00A1
    $line =~ s/\\\|\[quot\]\\\|/\\symbol\{34\}/g;    # QUOTATION MARK # 0022
    $line =~ s/\\\|\[apos\]\\\|/\{\'\}/g;       # APOSTROPHE # 0027
    $line =~ s/\\\|\[lpar\]\\\|/\x{0028}/g;     # LEFT PARENTHESIS # 0028
    $line =~ s/\\\|\[rpar\]\\\|/\x{0029}/g;     # RIGHT PARENTHESIS # 0029
    $line =~ s/\\\|\[comma\]\\\|/\{\x{002C}\}/g;    # COMMA # 002C
    $line =~ s/\\\|\[lowbar\]\\\|/\\textunderscore /g;    # LOW LINE # 005F
    $line =~ s/\\\|\[hyphen\]\\\|/\{\x{002D}\}/g;    # HYPHEN-MINUS # 002D
    $line =~ s/\\\|\[period\]\\\|/\x{002E}/g;   # FULL STOP # 002E
    $line =~ s/\\\|\[sol\]\\\|/\x{002F}/g;      # SOLIDUS # 002F
    $line =~ s/\\\|\[colon\]\\\|/\x{003A}/g;    # COLON # 003A
    $line =~ s/\\\|\[semi\]\\\|/\x{003B}/g;     # SEMICOLON # 003B
    $line =~ s/\\\|\[quest\]\\\|/\x{003F}/g;    # QUESTION MARK # 003F
    $line =~ s/\\\|\[iquest\]\\\|/\x{00BF}/g;   # INVERTED QUESTION MARK # 00BF
    $line =~ s/\\\|\[laquo\]\\\|/\x{00AB}/g;    # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK # 00AB
    $line =~ s/\\\|\[raquo\]\\\|/\x{00BB}/g;    # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK # 00BB
    $line =~ s/\\\|\[lsquo\]\\\|/\\textquoteleft /g;    #  # 2018
    $line =~ s/\\\|\[rsquo\]\\\|/\x{2019}/g;    # RIGHT SINGLE QUOTATION MARK # 2019
    $line =~ s/\\\|\[ldquo\]\\\|/\x{201C}/g;    #  # 201C
    $line =~ s/\\\|\[rdquo\]\\\|/\x{201D}/g;    # RIGHT DOUBLE QUOTATION MARK # 201D
    $line =~ s/\\\|\[nbsp\]\\\|/\x{00A0}/g;     # NO-BREAK SPACE # 00A0
    $line =~ s/\\\|\[shy\]\\\|/\x{00AD}/g;      # SOFT HYPHEN # 00AD
    #
    # <!ENTITY % ISObox PUBLIC "ISO 8879:1986//ENTITIES Box and Line Drawing//EN">
    #
    $line =~ s/\\\|\[boxh\]\\\|/\x{2500}/g;     # BOX DRAWINGS LIGHT HORIZONTAL # 2500
    $line =~ s/\\\|\[boxv\]\\\|/\x{2502}/g;     # BOX DRAWINGS LIGHT VERTICAL # 2502
    $line =~ s/\\\|\[boxur\]\\\|/\x{2514}/g;    # BOX DRAWINGS LIGHT UP AND RIGHT # 2514
    $line =~ s/\\\|\[boxul\]\\\|/\x{2518}/g;    # BOX DRAWINGS LIGHT UP AND LEFT # 2518
    $line =~ s/\\\|\[boxdl\]\\\|/\x{2510}/g;    # BOX DRAWINGS LIGHT DOWN AND LEFT # 2510
    $line =~ s/\\\|\[boxdr\]\\\|/\x{250C}/g;    # BOX DRAWINGS LIGHT DOWN AND RIGHT # 250C
    $line =~ s/\\\|\[boxvr\]\\\|/\x{251C}/g;    # BOX DRAWINGS LIGHT VERTICAL AND RIGHT # 251C
    $line =~ s/\\\|\[boxhu\]\\\|/\x{2534}/g;    # BOX DRAWINGS LIGHT UP AND HORIZONTAL # 2534
    $line =~ s/\\\|\[boxvl\]\\\|/\x{2524}/g;    # BOX DRAWINGS LIGHT VERTICAL AND LEFT # 2524
    $line =~ s/\\\|\[boxhd\]\\\|/\x{252C}/g;    # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL # 252C
    $line =~ s/\\\|\[boxvh\]\\\|/\x{253C}/g;    # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL # 253C
    $line =~ s/\\\|\[boxvR\]\\\|/\x{255E}/g;    # BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE # 255E
    $line =~ s/\\\|\[boxhU\]\\\|/\x{2567}/g;    # BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE # 2567
    $line =~ s/\\\|\[boxvL\]\\\|/\x{2561}/g;    # BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE # 2561
    $line =~ s/\\\|\[boxhD\]\\\|/\x{2564}/g;    # BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE # 2564
    $line =~ s/\\\|\[boxvH\]\\\|/\x{256A}/g;    # BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE # 256A
    $line =~ s/\\\|\[boxH\]\\\|/\x{2550}/g;     # BOX DRAWINGS DOUBLE HORIZONTAL # 2550
    $line =~ s/\\\|\[boxV\]\\\|/\x{2551}/g;     # BOX DRAWINGS DOUBLE VERTICAL # 2551
    $line =~ s/\\\|\[boxUR\]\\\|/\x{2558}/g;    # BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE # 2558
    $line =~ s/\\\|\[boxUL\]\\\|/\x{255B}/g;    # BOX DRAWINGS UP SINGLE AND LEFT DOUBLE # 255B
    $line =~ s/\\\|\[boxDL\]\\\|/\x{2555}/g;    # BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE # 2555
    $line =~ s/\\\|\[boxDR\]\\\|/\x{2552}/g;    # BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE # 2552
    $line =~ s/\\\|\[boxVR\]\\\|/\x{255F}/g;    # BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE # 255F
    $line =~ s/\\\|\[boxHU\]\\\|/\x{2568}/g;    # BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE # 2568
    $line =~ s/\\\|\[boxVL\]\\\|/\x{2562}/g;    # BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE # 2562
    $line =~ s/\\\|\[boxHD\]\\\|/\x{2565}/g;    # BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE # 2565
    $line =~ s/\\\|\[boxVH\]\\\|/\x{256B}/g;    # BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE # 256B
    $line =~ s/\\\|\[boxVr\]\\\|/\x{2560}/g;    # BOX DRAWINGS DOUBLE VERTICAL AND RIGHT # 2560
    $line =~ s/\\\|\[boxHu\]\\\|/\x{2569}/g;    # BOX DRAWINGS DOUBLE UP AND HORIZONTAL # 2569
    $line =~ s/\\\|\[boxVl\]\\\|/\x{2563}/g;    # BOX DRAWINGS DOUBLE VERTICAL AND LEFT # 2563
    $line =~ s/\\\|\[boxHd\]\\\|/\x{2566}/g;    # BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL # 2566
    $line =~ s/\\\|\[boxVh\]\\\|/\x{256C}/g;    # BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL # 256C
    $line =~ s/\\\|\[boxuR\]\\\|/\x{2559}/g;    # BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE # 2559
    $line =~ s/\\\|\[boxUl\]\\\|/\x{255C}/g;    # BOX DRAWINGS UP DOUBLE AND LEFT SINGLE # 255C
    $line =~ s/\\\|\[boxdL\]\\\|/\x{2556}/g;    # BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE # 2556
    $line =~ s/\\\|\[boxDr\]\\\|/\x{2553}/g;    # BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE # 2553
    $line =~ s/\\\|\[boxUr\]\\\|/\x{255A}/g;    # BOX DRAWINGS DOUBLE UP AND RIGHT # 255A
    $line =~ s/\\\|\[boxuL\]\\\|/\x{255D}/g;    # BOX DRAWINGS DOUBLE UP AND LEFT # 255D
    $line =~ s/\\\|\[boxDl\]\\\|/\x{2557}/g;    # BOX DRAWINGS DOUBLE DOWN AND LEFT # 2557
    $line =~ s/\\\|\[boxdR\]\\\|/\x{2554}/g;    # BOX DRAWINGS DOUBLE DOWN AND RIGHT # 2554
    #
    # <!ENTITY % ISOtech PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN">
    #
    $line =~ s/\\\|\[aleph\]\\\|/\x{2135}/g;    # ALEF SYMBOL # 2135
    $line =~ s/\\\|\[and\]\\\|/\x{2227}/g;      #  # 2227
    $line =~ s/\\\|\[ang90\]\\\|/\x{221F}/g;    # RIGHT ANGLE # 221F
    $line =~ s/\\\|\[angsph\]\\\|/\x{2222}/g;   #  # 2222
    $line =~ s/\\\|\[ap\]\\\|/\x{2248}/g;       #  # 2248
    $line =~ s/\\\|\[becaus\]\\\|/\x{2235}/g;   # BECAUSE # 2235
    $line =~ s/\\\|\[bottom\]\\\|/\x{22A5}/g;   #  # 22A5
    $line =~ s/\\\|\[cap\]\\\|/\x{2229}/g;      #  # 2229
    $line =~ s/\\\|\[cong\]\\\|/\x{2245}/g;     #  # 2245
    $line =~ s/\\\|\[conint\]\\\|/\x{222E}/g;   #  # 222E
    $line =~ s/\\\|\[cup\]\\\|/\x{222A}/g;      #  # 222A
    $line =~ s/\\\|\[equiv\]\\\|/\x{2261}/g;    #  # 2261
    $line =~ s/\\\|\[exist\]\\\|/\x{2203}/g;    #  # 2203
    $line =~ s/\\\|\[forall\]\\\|/\x{2200}/g;   #  # 2200
    $line =~ s/\\\|\[fnof\]\\\|/\x{0192}/g;     # LATIN SMALL LETTER F WITH HOOK # 0192
    $line =~ s/\\\|\[ge\]\\\|/\x{2265}/g;       # GREATER-THAN OR EQUAL TO # 2265
    $line =~ s/\\\|\[iff\]\\\|/\x{21D4}/g;      # LEFT RIGHT DOUBLE ARROW # 21D4
    $line =~ s/\\\|\[infin\]\\\|/\x{221E}/g;    #  # 221E
    $line =~ s/\\\|\[int\]\\\|/\x{222B}/g;      #  # 222B
    $line =~ s/\\\|\[isin\]\\\|/\x{220A}/g;     #  # 220A
    $line =~ s/\\\|\[lang\]\\\|/\x{3008}/g;     #  # 3008
    $line =~ s/\\\|\[lArr\]\\\|/\x{21D0}/g;     # LEFTWARDS ARROW # 21D0
    $line =~ s/\\\|\[le\]\\\|/\x{2264}/g;       #  # 2264
    $line =~ s/\\\|\[minus\]\\\|/\\textminus /g;    # MINUS SIGN # 2212
    $line =~ s/\\\|\[mnplus\]\\\|/\x{2213}/g;   #  # 2213
    $line =~ s/\\\|\[nabla\]\\\|/\x{2207}/g;    # NABLA # 2207
    $line =~ s/\\\|\[ne\]\\\|/\x{2260}/g;       #  # 2260
    $line =~ s/\\\|\[ni\]\\\|/\x{220D}/g;       #  # 220D
    $line =~ s/\\\|\[or\]\\\|/\x{2228}/g;       #  # 2228
    $line =~ s/\\\|\[par\]\\\|/\x{2225}/g;      # PARALLEL TO # 2225
    $line =~ s/\\\|\[part\]\\\|/\x{2202}/g;     #  # 2202
    $line =~ s/\\\|\[permil\]\\\|/\x{2030}/g;   # PER MILLE SIGN # 2030
    $line =~ s/\\\|\[perp\]\\\|/\x{22A5}/g;     #  # 22A5
    $line =~ s/\\\|\[prime\]\\\|/\x{2032}/g;    # PRIME # 2032
    $line =~ s/\\\|\[Prime\]\\\|/\x{2033}/g;    # DOUBLE PRIME # 2033
    $line =~ s/\\\|\[prop\]\\\|/\x{221D}/g;     #  # 221D
    $line =~ s/\\\|\[radic\]\\\|/\x{221A}/g;    #  # 221A
    $line =~ s/\\\|\[rang\]\\\|/\x{3009}/g;     #  # 3009
    $line =~ s/\\\|\[rArr\]\\\|/\x{21D2}/g;     # RIGHTWARDS ARROW # 21D2
    $line =~ s/\\\|\[sim\]\\\|/\x{223C}/g;      #  # 223C
    $line =~ s/\\\|\[sime\]\\\|/\x{2243}/g;     #  # 2243
    $line =~ s/\\\|\[square\]\\\|/\x{25A1}/g;   # WHITE SQUARE # 25A1
    $line =~ s/\\\|\[sub\]\\\|/\x{2282}/g;      #  # 2282
    $line =~ s/\\\|\[sube\]\\\|/\x{2286}/g;     #  # 2286
    $line =~ s/\\\|\[sup\]\\\|/\x{2283}/g;      #  # 2283
    $line =~ s/\\\|\[supe\]\\\|/\x{2287}/g;     #  # 2287
    $line =~ s/\\\|\[there4\]\\\|/\x{2234}/g;   #  # 2234
    $line =~ s/\\\|\[Verbar\]\\\|/\x{2016}/g;   # DOUBLE VERTICAL LINE # 2016
    $line =~ s/\\\|\[angst\]\\\|/\x{212B}/g;    # ANGSTROM SIGN # 212B
    $line =~ s/\\\|\[bernou\]\\\|/\x{212C}/g;   # SCRIPT CAPITAL B # 212C
    $line =~ s/\\\|\[compfn\]\\\|/\x{2218}/g;   # RING OPERATOR # 2218
    $line =~ s/\\\|\[Dot\]\\\|/\x{00A8}/g;      #  # 00A8
    $line =~ s/\\\|\[DotDot\]\\\|/\x{20DC}/g;   # COMBINING FOUR DOTS ABOVE # 20DC
    $line =~ s/\\\|\[hamilt\]\\\|/\x{210B}/g;   # SCRIPT CAPITAL H # 210B
    $line =~ s/\\\|\[lagran\]\\\|/\x{2112}/g;   # SCRIPT CAPITAL L # 2112
    $line =~ s/\\\|\[lowast\]\\\|/\x{2217}/g;   # ASTERISK OPERATOR # 2217
    $line =~ s/\\\|\[notin\]\\\|/\x{2209}/g;    #  # 2209
    $line =~ s/\\\|\[order\]\\\|/\x{2134}/g;    # SCRIPT SMALL O # 2134
    $line =~ s/\\\|\[phmmat\]\\\|/\x{2133}/g;   # SCRIPT CAPITAL M # 2133
    $line =~ s/\\\|\[tdot\]\\\|/\x{20DB}/g;     # COMBINING THREE DOTS ABOVE # 20DB
    $line =~ s/\\\|\[tprime\]\\\|/\x{2034}/g;   # TRIPLE PRIME # 2034
    $line =~ s/\\\|\[wedgeq\]\\\|/\x{2259}/g;   # ESTIMATES # 2259
    #
    # <!ENTITY % ISOgrk3 PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN">
    #
    $line =~ s/\\\|\[alpha\]\\\|/\\ensuremath\{\\alpha\}/g;    # U+03B1 ### greek small letter alpha
    $line =~ s/\\\|\[beta\]\\\|/\\ensuremath\{\\beta\}/g;    # U+03B2 ### greek small letter beta
    $line =~ s/\\\|\[gamma\]\\\|/\\ensuremath\{\\gamma\}/g;    # U+03B3 ### greek small letter gamma
    $line =~ s/\\\|\[Gamma\]\\\|/\\ensuremath\{\\Gamma\}/g;    # U+0393 ### greek capital letter gamma
    $line =~ s/\\\|\[gammad\]\\\|/\\ensuremath\{\\digamma\}/g;    # U+03DC ### /digamma
    $line =~ s/\\\|\[delta\]\\\|/\\ensuremath\{\\delta\}/g;    # U+03B4 ### greek small letter delta
    $line =~ s/\\\|\[Delta\]\\\|/\\ensuremath\{\\Delta\}/g;    # U+0394 ### greek capital letter delta
    $line =~ s/\\\|\[epsi\]\\\|/\\ensuremath\{\\epsilon\}/g;    # iso-8879-grk3 ## U+03B5 ### greek small letter epsilon
    $line =~ s/\\\|\[epsiv\]\\\|/\\ensuremath\{\\varepsilon\}/g;    # U+0000 ### /varepsilon  </latex> </char>
    $line =~ s/\\\|\[epsi\]\\\|/\\ensuremath\{\\epsilon\}/g;    # U+220A ### /straightepsilon, small epsilon, Greek
    $line =~ s/\\\|\[zeta\]\\\|/\\ensuremath\{\\zeta\}/g;    # U+03B6 ### greek small letter zeta
    $line =~ s/\\\|\[eta\]\\\|/\\ensuremath\{\\eta\}/g;    # U+03B7 ### greek small letter eta
    $line =~ s/\\\|\[thetas\]\\\|/\\ensuremath\{\\theta\}/g;    # U+03B8 ### greek small letter theta
    $line =~ s/\\\|\[Theta\]\\\|/\\ensuremath\{\\Theta\}/g;    # U+0398 ### greek capital letter theta
    $line =~ s/\\\|\[thetav\]\\\|/\\ensuremath\{\\vartheta\}/g;    # U+03D1 ### greek small letter theta symbol
    $line =~ s/\\\|\[iota\]\\\|/\\ensuremath\{\\iota\}/g;    # U+03B9 ### greek small letter iota
    $line =~ s/\\\|\[kappa\]\\\|/\\ensuremath\{\\kappa\}/g;    # U+03BA ### greek small letter kappa
    $line =~ s/\\\|\[kappav\]\\\|/\\ensuremath\{\\varkappa\}/g;    # U+03F0 ### /varkappa
    $line =~ s/\\\|\[lambda\]\\\|/\\ensuremath\{\\lambda\}/g;    # U+03BB ### greek small letter lambda
    $line =~ s/\\\|\[Lambda\]\\\|/\\ensuremath\{\\Lambda\}/g;    # U+039B ### greek capital letter lambda
    $line =~ s/\\\|\[mu\]\\\|/\\ensuremath\{\\mu\}/g;    # U+03BC ### greek small letter mu
    $line =~ s/\\\|\[nu\]\\\|/\\almlxxsymbolnu /g;    # U+03BD ### greek small letter nu
    $line =~ s/\\\|\[xi\]\\\|/\\ensuremath\{\\xi\}/g;    # U+03BE ### greek small letter xi
    $line =~ s/\\\|\[Xi\]\\\|/\\ensuremath\{\\Xi\}/g;    # U+039E ### greek capital letter xi
    $line =~ s/\\\|\[pi\]\\\|/\\ensuremath\{\\pi\}/g;    # U+03C0 ### greek small letter pi
    $line =~ s/\\\|\[piv\]\\\|/\\ensuremath\{\\varpi\}/g;    # U+03D6 ### greek pi symbol
    $line =~ s/\\\|\[Pi\]\\\|/\\ensuremath\{\\Pi\}/g;    # U+03A0 ### greek capital letter pi
    $line =~ s/\\\|\[rho\]\\\|/\\ensuremath\{\\rho\}/g;    # U+03C1 ### greek small letter rho
    $line =~ s/\\\|\[rhov\]\\\|/\\ensuremath\{\\varrho\}/g;    # U+03F1 ### /varrho
    $line =~ s/\\\|\[sigma\]\\\|/\\ensuremath\{\\sigma\}/g;    # U+03C3 ### greek small letter sigma
    $line =~ s/\\\|\[Sigma\]\\\|/\\ensuremath\{\\Sigma\}/g;    # U+03A3 ### greek capital letter sigma
    $line =~ s/\\\|\[sigmav\]\\\|/\\ensuremath\{\\varsigma\}/g;    # U+03C2 ### greek small letter final sigma
    $line =~ s/\\\|\[tau\]\\\|/\\ensuremath\{\\tau\}/g;    # U+03C4 ### greek small letter tau
    $line =~ s/\\\|\[upsi\]\\\|/\\ensuremath\{\\upsilon\}/g;    # U+03C5 ### greek small letter upsilon
    $line =~ s/\\\|\[Upsi\]\\\|/\\ensuremath\{\\Upsilon\}/g;    # U+03D2 ### greek upsilon with hook symbol
    $line =~ s/\\\|\[phis\]\\\|/\\ensuremath\{\\phi\}/g;    # U+03C6 ### greek small letter phi
    $line =~ s/\\\|\[Phi\]\\\|/\\ensuremath\{\\Phi\}/g;    # U+03A6 ### greek capital letter phi
    $line =~ s/\\\|\[phiv\]\\\|/\\ensuremath\{\\varphi\}/g;    # U+03D5 ### /varphi - curly or open phi
    $line =~ s/\\\|\[chi\]\\\|/\\ensuremath\{\\chi\}/g;    # U+03C7 ### greek small letter chi
    $line =~ s/\\\|\[psi\]\\\|/\\ensuremath\{\\psi\}/g;    # U+03C8 ### greek small letter psi
    $line =~ s/\\\|\[Psi\]\\\|/\\ensuremath\{\\Psi\}/g;    # U+03A8 ### greek capital letter psi
    $line =~ s/\\\|\[omega\]\\\|/\\ensuremath\{\\omega\}/g;    # U+03C9 ### greek small letter omega
    $line =~ s/\\\|\[Omega\]\\\|/\\ensuremath\{\\Omega\}/g;    # U+03A9 ### greek capital letter omega
    
    # <!ENTITY % ISOgrk4 PUBLIC "ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN">
    $line =~ s/\\\|\[b\.alpha\]\\\|/\\ensuremath\{\\alpha\}/g;    # U+03B1 ### small alpha, Greek
    $line =~ s/\\\|\[b\.beta\]\\\|/\\ensuremath\{\\beta\}/g;    # U+03B2 ### small beta, Greek
    $line =~ s/\\\|\[b\.gamma\]\\\|/\\ensuremath\{\\gamma\}/g;    # U+03B3 ### small gamma, Greek
    $line =~ s/\\\|\[b\.Gamma\]\\\|/\\ensuremath\{\\Gamma\}/g;    # U+0393 ### capital Gamma, Greek
    $line =~ s/\\\|\[b\.gammad\]\\\|/\\ensuremath\{\\digamma\}/g;    # U+03DC ### digamma
    $line =~ s/\\\|\[b\.delta\]\\\|/\\ensuremath\{\\delta\}/g;    # U+03B4 ### small delta, Greek
    $line =~ s/\\\|\[b\.Delta\]\\\|/\\ensuremath\{\\Delta\}/g;    # U+0394 ### capital Delta, Greek
    $line =~ s/\\\|\[b\.epsi\]\\\|/\\ensuremath\{\\epsilon\}/g;    # U+03B5 ### =small epsilon, Greek
    $line =~ s/\\\|\[b\.epsiv\]\\\|/\\ensuremath\{\\varepsilon\}/g;    # U+03B5 ### variant epsilon
    $line =~ s/\\\|\[b\.epsis\]\\\|/\\ensuremath\{\\epsilon\}/g;    # U+03B5 ### small epsilon, Greek
    $line =~ s/\\\|\[b\.zeta\]\\\|/\\ensuremath\{\\zeta\}/g;    # U+03B6 ### small zeta, Greek
    $line =~ s/\\\|\[b\.eta\]\\\|/\\ensuremath\{\\eta\}/g;    # U+03B7 ### small eta, Greek
    $line =~ s/\\\|\[b\.thetas\]\\\|/\\ensuremath\{\\theta\}/g;    # U+03B8 ### straight theta, small theta, Greek
    $line =~ s/\\\|\[b\.Theta\]\\\|/\\ensuremath\{\\Theta\}/g;    # U+0398 ### capital Theta, Greek
    $line =~ s/\\\|\[b\.thetav\]\\\|/\\ensuremath\{\\vartheta\}/g;    # U+03D1 ### variant theta - curly or open theta
    $line =~ s/\\\|\[b\.iota\]\\\|/\\ensuremath\{\\iota\}/g;    # U+03B9 ### small iota, Greek
    $line =~ s/\\\|\[b\.kappa\]\\\|/\\ensuremath\{\\kappa\}/g;    # U+03BA ### small kappa, Greek
    $line =~ s/\\\|\[b\.kappav\]\\\|/\\ensuremath\{\\varkappa\}/g;    # U+03F0 ### variant kappa
    $line =~ s/\\\|\[b\.lambda\]\\\|/\\ensuremath\{\\lambda\}/g;    # U+03BB ### small lambda, Greek
    $line =~ s/\\\|\[b\.Lambda\]\\\|/\\ensuremath\{\\Lambda\}/g;    # U+039B ### capital Lambda, Greek
    $line =~ s/\\\|\[b\.mu\]\\\|/\\ensuremath\{\\mu\}/g;    # U+03BC ### small mu, Greek
    $line =~ s/\\\|\[b\.nu\]\\\|/\\almlxxsymbolnu /g;    # U+03BD ### small nu, Greek
    $line =~ s/\\\|\[b\.xi\]\\\|/\\ensuremath\{\\xi\}/g;    # U+03BE ### small xi, Greek
    $line =~ s/\\\|\[b\.Xi\]\\\|/\\ensuremath\{\\Xi\}/g;    # U+039E ### capital Xi, Greek
    $line =~ s/\\\|\[b\.pi\]\\\|/\\ensuremath\{\\pi\}/g;    # U+03C0 ### small pi, Greek
    $line =~ s/\\\|\[b\.Pi\]\\\|/\\ensuremath\{\\Pi\}/g;    # U+03A0 ### capital Pi, Greek
    $line =~ s/\\\|\[b\.piv\]\\\|/\\ensuremath\{\\varpi\}/g;    # U+03D6 ### variant pi
    $line =~ s/\\\|\[b\.rho\]\\\|/\\ensuremath\{\\rho\}/g;    # U+03C1 ### small rho, Greek
    $line =~ s/\\\|\[b\.rhov\]\\\|/\\ensuremath\{\\varrho\}/g;    # U+03F1 ### variant rho
    $line =~ s/\\\|\[b\.sigma\]\\\|/\\ensuremath\{\\sigma\}/g;    # U+03C3 ### small sigma, Greek
    $line =~ s/\\\|\[b\.Sigma\]\\\|/\\ensuremath\{\\Sigma\}/g;    # U+03A3 ### capital Sigma, Greek
    $line =~ s/\\\|\[b\.sigmav\]\\\|/\\ensuremath\{\\varsigma\}/g;    # U+03C2 ### variant sigma
    $line =~ s/\\\|\[b\.tau\]\\\|/\\ensuremath\{\\tau\}/g;    # U+03C4 ### small tau, Greek
    $line =~ s/\\\|\[b\.upsi\]\\\|/\\ensuremath\{\\upsilon\}/g;    # U+03C5 ### small upsilon, Greek
    $line =~ s/\\\|\[b\.Upsi\]\\\|/\\ensuremath\{\\Upsilon\}/g;    # U+03D2 ### capital Upsilon, Greek
    $line =~ s/\\\|\[b\.phis\]\\\|/\\ensuremath\{\\phi\}/g;    # U+03C6 ### straight phi, small phi, Greek
    $line =~ s/\\\|\[b\.Phi\]\\\|/\\ensuremath\{\\Phi\}/g;    # U+03A6 ### capital Phi, Greek
    $line =~ s/\\\|\[b\.phiv\]\\\|/\\ensuremath\{\\varphi\}/g;    # U+03D5 ### variant phi - curly or open phi
    $line =~ s/\\\|\[b\.chi\]\\\|/\\ensuremath\{\\chi\}/g;    # U+03C7 ### small chi, Greek
    $line =~ s/\\\|\[b\.psi\]\\\|/\\ensuremath\{\\psi\}/g;    # U+03C8 ### small psi, Greek
    $line =~ s/\\\|\[b\.Psi\]\\\|/\\ensuremath\{\\Psi\}/g;    # U+03A8 ### capital Psi, Greek
    $line =~ s/\\\|\[b\.omega\]\\\|/\\ensuremath\{\\omega\}/g;    # U+03C9 ### small omega, Greek
    $line =~ s/\\\|\[b\.Omega\]\\\|/\\ensuremath\{\\Omega\}/g;    # U+03A9 ### capital Omega, Greek

    # <!ENTITY % ISOamso PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN">
    $line =~ s/\\\|\[ang\]\\\|/\x{2220}/g;    # ANGLE # 2220
    $line =~ s/\\\|\[angmsd\]\\\|/\x{2221}/g;    # MEASURED ANGLE # 2221
    $line =~ s/\\\|\[beth\]\\\|/\x{2136}/g;    # BET SYMBOL # 2136
    $line =~ s/\\\|\[bprime\]\\\|/\x{2035}/g;    # REVERSED PRIME # 2035
    $line =~ s/\\\|\[comp\]\\\|/\x{2201}/g;    # COMPLEMENT # 2201
    $line =~ s/\\\|\[daleth\]\\\|/\x{2138}/g;    # DALET SYMBOL # 2138
    $line =~ s/\\\|\[ell\]\\\|/\x{2113}/g;    # SCRIPT SMALL L # 2113
    $line =~ s/\\\|\[empty\]\\\|/\x{2205}/g;    #  # 2205
    $line =~ s/\\\|\[gimel\]\\\|/\x{2137}/g;    # GIMEL SYMBOL # 2137
    $line =~ s/\\\|\[image\]\\\|/\x{2111}/g;    # BLACK-LETTER CAPITAL I # 2111
    $line =~ s/\\\|\[inodot\]\\\|/\x{0131}/g;    # LATIN SMALL LETTER DOTLESS I # 0131
    $line =~ s/\\\|\[jnodot\]\\\|/\\ensuremath\{\\jmath\}/g;    # /jmath - small j, no dot
    $line =~ s/\\\|\[nexist\]\\\|/\x{2204}/g;    # THERE DOES NOT EXIST # 2204
    $line =~ s/\\\|\[oS\]\\\|/\x{24C8}/g;    # CIRCLED LATIN CAPITAL LETTER S # 24C8
    $line =~ s/\\\|\[planck\]\\\|/\x{210F}/g;    # PLANCK CONSTANT OVER TWO PI # 210F
    $line =~ s/\\\|\[real\]\\\|/\x{211C}/g;    # BLACK-LETTER CAPITAL R # 211C
    $line =~ s/\\\|\[sbsol\]\\\|/\x{FE68}/g;    # SMALL REVERSE SOLIDUS # FE68
    $line =~ s/\\\|\[vprime\]\\\|/\x{2032}/g;    # PRIME # 2032
    $line =~ s/\\\|\[weierp\]\\\|/\x{2118}/g;    # SCRIPT CAPITAL P # 2118

    # <!ENTITY % ISOamsb PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN">
    $line =~ s/\\\|\[amalg\]\\\|/\x{2210}/g;    # N-ARY COPRODUCT # 2210
    $line =~ s/\\\|\[Barwed\]\\\|/\x{2306}/g;    # PERSPECTIVE # 2306
    $line =~ s/\\\|\[barwed\]\\\|/\x{22BC}/g;    # NAND # 22BC
    $line =~ s/\\\|\[Cap\]\\\|/\x{22D2}/g;    # DOUBLE INTERSECTION # 22D2
    $line =~ s/\\\|\[Cup\]\\\|/\x{22D3}/g;    # DOUBLE UNION # 22D3
    $line =~ s/\\\|\[cuvee\]\\\|/\x{22CE}/g;    # CURLY LOGICAL OR # 22CE
    $line =~ s/\\\|\[cuwed\]\\\|/\x{22CF}/g;    # CURLY LOGICAL AND # 22CF
    $line =~ s/\\\|\[diam\]\\\|/\x{22C4}/g;    # DIAMOND OPERATOR # 22C4
    $line =~ s/\\\|\[divonx\]\\\|/\x{22C7}/g;    # DIVISION TIMES # 22C7
    $line =~ s/\\\|\[intcal\]\\\|/\x{22BA}/g;    # INTERCALATE # 22BA
    $line =~ s/\\\|\[lthree\]\\\|/\x{22CB}/g;    # LEFT SEMIDIRECT PRODUCT # 22CB
    $line =~ s/\\\|\[ltimes\]\\\|/\x{22C9}/g;    # LEFT NORMAL FACTOR SEMIDIRECT PRODUCT # 22C9
    $line =~ s/\\\|\[minusb\]\\\|/\x{229F}/g;    # SQUARED MINUS # 229F
    $line =~ s/\\\|\[oast\]\\\|/\x{229B}/g;    # CIRCLED ASTERISK OPERATOR # 229B
    $line =~ s/\\\|\[ocir\]\\\|/\x{229A}/g;    # CIRCLED RING OPERATOR # 229A
    $line =~ s/\\\|\[odash\]\\\|/\x{229D}/g;    # CIRCLED DASH # 229D
    $line =~ s/\\\|\[odot\]\\\|/\x{2299}/g;    # CIRCLED DOT OPERATOR # 2299
    $line =~ s/\\\|\[ominus\]\\\|/\x{2296}/g;    # CIRCLED MINUS # 2296
    $line =~ s/\\\|\[oplus\]\\\|/\x{2295}/g;    # CIRCLED PLUS # 2295
    $line =~ s/\\\|\[osol\]\\\|/\x{2298}/g;    # CIRCLED DIVISION SLASH # 2298
    $line =~ s/\\\|\[otimes\]\\\|/\x{2297}/g;    # CIRCLED TIMES # 2297
    $line =~ s/\\\|\[plusb\]\\\|/\x{229E}/g;    # SQUARED PLUS # 229E
    $line =~ s/\\\|\[plusdo\]\\\|/\x{2214}/g;    # DOT PLUS # 2214
    $line =~ s/\\\|\[rthree\]\\\|/\x{22CC}/g;    # RIGHT SEMIDIRECT PRODUCT # 22CC
    $line =~ s/\\\|\[rtimes\]\\\|/\x{22CA}/g;    # RIGHT NORMAL FACTOR SEMIDIRECT PRODUCT # 22CA
    $line =~ s/\\\|\[sdot\]\\\|/\x{22C5}/g;    # DOT OPERATOR # 22C5
    $line =~ s/\\\|\[sdotb\]\\\|/\x{22A1}/g;    # SQUARED DOT OPERATOR # 22A1
    $line =~ s/\\\|\[setmn\]\\\|/\x{2216}/g;    # SET MINUS # 2216
    $line =~ s/\\\|\[sqcap\]\\\|/\x{2293}/g;    # SQUARE CAP # 2293
    $line =~ s/\\\|\[sqcup\]\\\|/\x{2294}/g;    # SQUARE CUP # 2294
    $line =~ s/\\\|\[ssetmn\]\\\|/\x{2216}/g;    # SET MINUS # 2216
    $line =~ s/\\\|\[sstarf\]\\\|/\x{22C6}/g;    # STAR OPERATOR # 22C6
    $line =~ s/\\\|\[timesb\]\\\|/\x{22A0}/g;    # SQUARED TIMES # 22A0
    $line =~ s/\\\|\[top\]\\\|/\x{22A4}/g;    # DOWN TACK # 22A4
    $line =~ s/\\\|\[uplus\]\\\|/\x{228E}/g;    # MULTISET UNION # 228E
    $line =~ s/\\\|\[wreath\]\\\|/\x{2240}/g;    # WREATH PRODUCT # 2240
    $line =~ s/\\\|\[xcirc\]\\\|/\x{25CB}/g;    # WHITE CIRCLE # 25CB
    $line =~ s/\\\|\[xdtri\]\\\|/\x{25BD}/g;    # WHITE DOWN-POINTING TRIANGLE # 25BD
    $line =~ s/\\\|\[xutri\]\\\|/\x{25B3}/g;    # WHITE UP-POINTING TRIANGLE # 25B3
    $line =~ s/\\\|\[coprod\]\\\|/\x{2210}/g;    # N-ARY COPRODUCT # 2210
    $line =~ s/\\\|\[prod\]\\\|/\x{220F}/g;    # N-ARY PRODUCT # 220F
    $line =~ s/\\\|\[sum\]\\\|/\x{2211}/g;    # N-ARY SUMMATION # 2211

    # <!ENTITY % ISOamsr PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN">
    $line =~ s/\\\|\[ape\]\\\|/\x{224A}/g;    #  # 224A
    $line =~ s/\\\|\[asymp\]\\\|/\x{224D}/g;    # EQUIVALENT TO # 224D
    $line =~ s/\\\|\[bcong\]\\\|/\x{224C}/g;    # ALL EQUAL TO # 224C
    $line =~ s/\\\|\[bepsi\]\\\|/\x{220D}/g;    # SMALL CONTAINS AS MEMBER # 220D
    $line =~ s/\\\|\[bowtie\]\\\|/\x{22C8}/g;    #  # 22C8
    $line =~ s/\\\|\[bsim\]\\\|/\x{223D}/g;    #  # 223D
    $line =~ s/\\\|\[bsime\]\\\|/\x{22CD}/g;    #  # 22CD
    $line =~ s/\\\|\[bump\]\\\|/\x{224E}/g;    #  # 224E
    $line =~ s/\\\|\[bumpe\]\\\|/\x{224F}/g;    #  # 224F
    $line =~ s/\\\|\[cire\]\\\|/\x{2257}/g;    #  # 2257
    $line =~ s/\\\|\[colone\]\\\|/\x{2254}/g;    #  # 2254
    $line =~ s/\\\|\[cuepr\]\\\|/\x{22DE}/g;    #  # 22DE
    $line =~ s/\\\|\[cuesc\]\\\|/\x{22DF}/g;    #  # 22DF
    $line =~ s/\\\|\[cupre\]\\\|/\x{227C}/g;    #  # 227C
    $line =~ s/\\\|\[dashv\]\\\|/\x{22A3}/g;    #  # 22A3
    $line =~ s/\\\|\[ecir\]\\\|/\x{2256}/g;    #  # 2256
    $line =~ s/\\\|\[ecolon\]\\\|/\x{2255}/g;    #  # 2255
    $line =~ s/\\\|\[eDot\]\\\|/\x{2251}/g;    #  # 2251
    $line =~ s/\\\|\[esdot\]\\\|/\x{2250}/g;    #  # 2250
    $line =~ s/\\\|\[efDot\]\\\|/\x{2252}/g;    #  # 2252
    $line =~ s/\\\|\[egs\]\\\|/\x{22DD}/g;    #  # 22DD
    $line =~ s/\\\|\[els\]\\\|/\x{22DC}/g;    #  # 22DC
    $line =~ s/\\\|\[erDot\]\\\|/\x{2253}/g;    #  # 2253
    $line =~ s/\\\|\[fork\]\\\|/\x{22D4}/g;    #  # 22D4
    $line =~ s/\\\|\[frown\]\\\|/\x{2322}/g;    #  # 2322
    $line =~ s/\\\|\[gap\]\\\|/\x{2273}/g;    # GREATER-THAN OR EQUIVALENT TO # 2273
    $line =~ s/\\\|\[gsdot\]\\\|/\x{22D7}/g;    #  # 22D7
    $line =~ s/\\\|\[gE\]\\\|/\x{2267}/g;    #  # 2267
    $line =~ s/\\\|\[gel\]\\\|/\x{22DB}/g;    #  # 22DB
    $line =~ s/\\\|\[gEl\]\\\|/\x{22DB}/g;    #  # 22DB
    $line =~ s/\\\|\[ges\]\\\|/\x{2265}/g;    # GREATER-THAN OR EQUAL TO # 2265
    $line =~ s/\\\|\[Gg\]\\\|/\x{22D9}/g;    # VERY MUCH GREATER-THAN # 22D9
    $line =~ s/\\\|\[gl\]\\\|/\x{2277}/g;    #  # 2277
    $line =~ s/\\\|\[gsim\]\\\|/\x{2273}/g;    # GREATER-THAN OR EQUIVALENT TO # 2273
    $line =~ s/\\\|\[Gt\]\\\|/\x{226B}/g;    # MUCH GREATER-THAN # 226B
    $line =~ s/\\\|\[lap\]\\\|/\x{2272}/g;    # LESS-THAN OR EQUIVALENT TO # 2272
    $line =~ s/\\\|\[ldot\]\\\|/\x{22D6}/g;    #  # 22D6
    $line =~ s/\\\|\[lE\]\\\|/\x{2266}/g;    #  # 2266
    $line =~ s/\\\|\[lEg\]\\\|/\x{22DA}/g;    #  # 22DA
    $line =~ s/\\\|\[leg\]\\\|/\x{22DA}/g;    #  # 22DA
    $line =~ s/\\\|\[les\]\\\|/\x{2264}/g;    # LESS-THAN OR EQUAL TO # 2264
    $line =~ s/\\\|\[lg\]\\\|/\x{2276}/g;    # LESS-THAN OR GREATER-THAN # 2276
    $line =~ s/\\\|\[Ll\]\\\|/\x{22D8}/g;    #  # 22D8
    $line =~ s/\\\|\[lsim\]\\\|/\x{2272}/g;    # LESS-THAN OR EQUIVALENT TO # 2272
    $line =~ s/\\\|\[Lt\]\\\|/\x{226A}/g;    # MUCH LESS-THAN # 226A
    $line =~ s/\\\|\[ltrie\]\\\|/\x{22B4}/g;    #  # 22B4
    $line =~ s/\\\|\[mid\]\\\|/\x{2223}/g;    #  # 2223
    $line =~ s/\\\|\[models\]\\\|/\x{22A7}/g;    # MODELS # 22A7
    $line =~ s/\\\|\[pr\]\\\|/\x{227A}/g;    #  # 227A
    $line =~ s/\\\|\[prap\]\\\|/\x{227E}/g;    #  # 227E
    $line =~ s/\\\|\[pre\]\\\|/\x{227C}/g;    #  # 227C
    $line =~ s/\\\|\[prsim\]\\\|/\x{227E}/g;    #  # 227E
    $line =~ s/\\\|\[rtrie\]\\\|/\x{22B5}/g;    #  # 22B5
    $line =~ s/\\\|\[samalg\]\\\|/\x{2210}/g;    #  # 2210
    $line =~ s/\\\|\[sc\]\\\|/\x{227B}/g;    #  # 227B
    $line =~ s/\\\|\[scap\]\\\|/\x{227F}/g;    #  # 227F
    $line =~ s/\\\|\[sccue\]\\\|/\x{227D}/g;    #  # 227D
    $line =~ s/\\\|\[sce\]\\\|/\x{227D}/g;    #  # 227D
    $line =~ s/\\\|\[scsim\]\\\|/\x{227F}/g;    #  # 227F
    $line =~ s/\\\|\[sfrown\]\\\|/\x{2322}/g;    # FROWN # 2322
    $line =~ s/\\\|\[smid\]\\\|/\x{E301}/g;    #  # E301
    $line =~ s/\\\|\[smile\]\\\|/\x{2323}/g;    #  # 2323
    $line =~ s/\\\|\[spar\]\\\|/\x{2225}/g;    # PARALLEL TO # 2225
    $line =~ s/\\\|\[sqsub\]\\\|/\x{228F}/g;    #  # 228F
    $line =~ s/\\\|\[sqsube\]\\\|/\x{2291}/g;    #  # 2291
    $line =~ s/\\\|\[sqsup\]\\\|/\x{2290}/g;    #  # 2290
    $line =~ s/\\\|\[sqsupe\]\\\|/\x{2292}/g;    #  # 2292
    $line =~ s/\\\|\[ssmile\]\\\|/\x{2323}/g;    # SMILE # 2323
    $line =~ s/\\\|\[Sub\]\\\|/\x{22D0}/g;    #  # 22D0
    $line =~ s/\\\|\[subE\]\\\|/\x{2286}/g;    #  # 2286
    $line =~ s/\\\|\[Sup\]\\\|/\x{22D1}/g;    #  # 22D1
    $line =~ s/\\\|\[supE\]\\\|/\x{2287}/g;    #  # 2287
    $line =~ s/\\\|\[thkap\]\\\|/\x{2248}/g;    # ALMOST EQUAL TO # 2248
    $line =~ s/\\\|\[thksim\]\\\|/\x{223C}/g;    # TILDE OPERATOR # 223C
    $line =~ s/\\\|\[trie\]\\\|/\x{225C}/g;    #  # 225C
    $line =~ s/\\\|\[twixt\]\\\|/\x{226C}/g;    # BETWEEN # 226C
    $line =~ s/\\\|\[vdash\]\\\|/\x{22A2}/g;    #  # 22A2
    $line =~ s/\\\|\[Vdash\]\\\|/\x{22A9}/g;    #  # 22A9
    $line =~ s/\\\|\[vDash\]\\\|/\x{22A8}/g;    #  # 22A8
    $line =~ s/\\\|\[veebar\]\\\|/\x{22BB}/g;    #  # 22BB
    $line =~ s/\\\|\[vltri\]\\\|/\x{22B2}/g;    #  # 22B2
    $line =~ s/\\\|\[vprop\]\\\|/\x{221D}/g;    #  # 221D
    $line =~ s/\\\|\[vrtri\]\\\|/\x{22B3}/g;    #  # 22B3
    $line =~ s/\\\|\[Vvdash\]\\\|/\x{22AA}/g;    #  # 22AA

    # <!ENTITY % ISOamsn PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN">
    $line =~ s/\\\|\[gnap\]\\\|/\x{E411}/g;    #  # E411
    $line =~ s/\\\|\[gne\]\\\|/\x{2269}/g;    #  # 2269
    $line =~ s/\\\|\[gnE\]\\\|/\x{2269}/g;    #  # 2269
    $line =~ s/\\\|\[gnsim\]\\\|/\x{22E7}/g;    # GREATER-THAN BUT NOT EQUIVALENT TO # 22E7
    $line =~ s/\\\|\[gvnE\]\\\|/\x{2269}/g;    # GREATER-THAN BUT NOT EQUAL TO # 2269
    $line =~ s/\\\|\[lnap\]\\\|/\x{E2A2}/g;    #  # E2A2
    $line =~ s/\\\|\[lnE\]\\\|/\x{2268}/g;    #  # 2268
    $line =~ s/\\\|\[lne\]\\\|/\x{2268}/g;    #  # 2268
    $line =~ s/\\\|\[lnsim\]\\\|/\x{22E6}/g;    #  # 22E6
    $line =~ s/\\\|\[lvnE\]\\\|/\x{2268}/g;    # LESS-THAN BUT NOT EQUAL TO # 2268
    $line =~ s/\\\|\[nap\]\\\|/\x{2249}/g;    # NOT ALMOST EQUAL TO # 2249
    $line =~ s/\\\|\[ncong\]\\\|/\x{2247}/g;    # NEITHER APPROXIMATELY NOR ACTUALLY EQUAL TO # 2247
    $line =~ s/\\\|\[nequiv\]\\\|/\x{2262}/g;    # NOT IDENTICAL TO # 2262
    $line =~ s/\\\|\[ngE\]\\\|/\x{2271}/g;    #  # 2271
    $line =~ s/\\\|\[nge\]\\\|/\x{2271}/g;    # NEITHER GREATER-THAN NOR EQUAL TO # 2271
    $line =~ s/\\\|\[nges\]\\\|/\x{2271}/g;    #  # 2271
    $line =~ s/\\\|\[ngt\]\\\|/\x{226F}/g;    # NOT GREATER-THAN # 226F
    $line =~ s/\\\|\[nle\]\\\|/\x{2270}/g;    # NEITHER LESS-THAN NOR EQUAL TO # 2270
    $line =~ s/\\\|\[nlE\]\\\|/\x{2270}/g;    #  # 2270
    $line =~ s/\\\|\[nles\]\\\|/\x{2270}/g;    #  # 2270
    $line =~ s/\\\|\[nlt\]\\\|/\x{226E}/g;    # NOT LESS-THAN # 226E
    $line =~ s/\\\|\[nltri\]\\\|/\x{22EA}/g;    # NOT NORMAL SUBGROUP OF # 22EA
    $line =~ s/\\\|\[nltrie\]\\\|/\x{22EC}/g;    # NOT NORMAL SUBGROUP OF OR EQUAL TO # 22EC
    $line =~ s/\\\|\[nmid\]\\\|/\x{2224}/g;    # DOES NOT DIVIDE # 2224
    $line =~ s/\\\|\[npar\]\\\|/\x{2226}/g;    # NOT PARALLEL TO # 2226
    $line =~ s/\\\|\[npr\]\\\|/\x{2280}/g;    # DOES NOT PRECEDE # 2280
    $line =~ s/\\\|\[npre\]\\\|/\x{22E0}/g;    # DOES NOT PRECEDE OR EQUAL # 22E0
    $line =~ s/\\\|\[nrtri\]\\\|/\x{22EB}/g;    # DOES NOT CONTAIN AS NORMAL SUBGROUP # 22EB
    $line =~ s/\\\|\[nrtrie\]\\\|/\x{22ED}/g;    # DOES NOT CONTAIN AS NORMAL SUBGROUP OR EQUAL # 22ED
    $line =~ s/\\\|\[nsc\]\\\|/\x{2281}/g;    # DOES NOT SUCCEED # 2281
    $line =~ s/\\\|\[nsce\]\\\|/\x{22E1}/g;    # DOES NOT SUCCEED OR EQUAL # 22E1
    $line =~ s/\\\|\[nsim\]\\\|/\x{2241}/g;    #  # 2241
    $line =~ s/\\\|\[nsime\]\\\|/\x{2244}/g;    #  # 2244
    $line =~ s/\\\|\[nsmid\]\\\|/\x{E2AA}/g;    #  # E2AA
    $line =~ s/\\\|\[nspar\]\\\|/\x{2226}/g;    # NOT PARALLEL TO # 2226
    $line =~ s/\\\|\[nsub\]\\\|/\x{2284}/g;    # NOT A SUBSET OF # 2284
    $line =~ s/\\\|\[nsube\]\\\|/\x{2288}/g;    #  # 2288
    $line =~ s/\\\|\[nsubE\]\\\|/\x{2288}/g;    #  # 2288
    $line =~ s/\\\|\[nsup\]\\\|/\x{2285}/g;    # NOT A SUPERSET OF # 2285
    $line =~ s/\\\|\[nsupE\]\\\|/\x{2289}/g;    #  # 2289
    $line =~ s/\\\|\[nsupe\]\\\|/\x{2289}/g;    #  # 2289
    $line =~ s/\\\|\[nvdash\]\\\|/\x{22AC}/g;    # DOES NOT PROVE # 22AC
    $line =~ s/\\\|\[nvDash\]\\\|/\x{22AD}/g;    # NOT TRUE # 22AD
    $line =~ s/\\\|\[nVDash\]\\\|/\x{22AF}/g;    # NEGATED DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE # 22AF
    $line =~ s/\\\|\[nVdash\]\\\|/\x{22AE}/g;    # DOES NOT FORCE # 22AE
    $line =~ s/\\\|\[prnap\]\\\|/\x{22E8}/g;    #  # 22E8
    $line =~ s/\\\|\[prnE\]\\\|/\x{E2B3}/g;    #  # E2B3
    $line =~ s/\\\|\[prnsim\]\\\|/\x{22E8}/g;    #  # 22E8
    $line =~ s/\\\|\[scnap\]\\\|/\x{22E9}/g;    #  # 22E9
    $line =~ s/\\\|\[scnE\]\\\|/\x{E2B5}/g;    #  # E2B5
    $line =~ s/\\\|\[scnsim\]\\\|/\x{22E9}/g;    #  # 22E9
    $line =~ s/\\\|\[subne\]\\\|/\x{228A}/g;    #  # 228A
    $line =~ s/\\\|\[subnE\]\\\|/\x{228A}/g;    # SUBSET OF WITH NOT EQUAL TO # 228A
    $line =~ s/\\\|\[supne\]\\\|/\x{228B}/g;    #  # 228B
    $line =~ s/\\\|\[supnE\]\\\|/\x{228B}/g;    #  # 228B
    $line =~ s/\\\|\[vsubnE\]\\\|/\x{E2B8}/g;    #  # E2B8
    $line =~ s/\\\|\[vsubne\]\\\|/\x{228A}/g;    # SUBSET OF WITH NOT EQUAL TO # 228A
    $line =~ s/\\\|\[vsupne\]\\\|/\x{228B}/g;    # SUPERSET OF WITH NOT EQUAL TO # 228B
    $line =~ s/\\\|\[vsupnE\]\\\|/\x{228B}/g;    # SUPERSET OF WITH NOT EQUAL TO # 228B

    # <!ENTITY % ISOamsa PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN">
    $line =~ s/\\\|\[cularr\]\\\|/\x{21B6}/g;    # ANTICLOCKWISE TOP SEMICIRCLE ARROW # 21B6
    $line =~ s/\\\|\[curarr\]\\\|/\x{21B7}/g;    # CLOCKWISE TOP SEMICIRCLE ARROW # 21B7
    $line =~ s/\\\|\[dArr\]\\\|/\x{21D3}/g;    # DOWNWARDS DOUBLE ARROW # 21D3
    $line =~ s/\\\|\[darr2\]\\\|/\x{21CA}/g;    # DOWNWARDS PAIRED ARROWS # 21CA
    $line =~ s/\\\|\[dharl\]\\\|/\x{21C3}/g;    # DOWNWARDS HARPOON WITH BARB LEFTWARDS # 21C3
    $line =~ s/\\\|\[dharr\]\\\|/\x{21C2}/g;    # DOWNWARDS HARPOON WITH BARB RIGHTWARDS # 21C2
    $line =~ s/\\\|\[lAarr\]\\\|/\x{21DA}/g;    # LEFTWARDS TRIPLE ARROW # 21DA
    $line =~ s/\\\|\[Larr\]\\\|/\x{219E}/g;    # LEFTWARDS TWO HEADED ARROW # 219E
    $line =~ s/\\\|\[larr2\]\\\|/\x{21C7}/g;    # LEFTWARDS PAIRED ARROWS # 21C7
    $line =~ s/\\\|\[larrhk\]\\\|/\x{21A9}/g;    # LEFTWARDS ARROW WITH HOOK # 21A9
    $line =~ s/\\\|\[larrlp\]\\\|/\x{21AB}/g;    # LEFTWARDS ARROW WITH LOOP # 21AB
    $line =~ s/\\\|\[larrtl\]\\\|/\x{21A2}/g;    # LEFTWARDS ARROW WITH TAIL # 21A2
    $line =~ s/\\\|\[lhard\]\\\|/\x{21BD}/g;    # LEFTWARDS HARPOON WITH BARB DOWNWARDS # 21BD
    $line =~ s/\\\|\[lharu\]\\\|/\x{21BC}/g;    # LEFTWARDS HARPOON WITH BARB UPWARDS # 21BC
    $line =~ s/\\\|\[hArr\]\\\|/\x{21D4}/g;    #  # 21D4
    $line =~ s/\\\|\[harr\]\\\|/\x{2194}/g;    # LEFT RIGHT ARROW # 2194
    $line =~ s/\\\|\[lrarr2\]\\\|/\x{21C6}/g;    # LEFTWARDS ARROW OVER RIGHTWARDS ARROW # 21C6
    $line =~ s/\\\|\[rlarr2\]\\\|/\x{21C4}/g;    # RIGHTWARDS ARROW OVER LEFTWARDS ARROW # 21C4
    $line =~ s/\\\|\[harrw\]\\\|/\x{21AD}/g;    # LEFT RIGHT WAVE ARROW # 21AD
    $line =~ s/\\\|\[rlhar2\]\\\|/\x{21CC}/g;    # RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON # 21CC
    $line =~ s/\\\|\[lrhar2\]\\\|/\x{21CB}/g;    # LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON # 21CB
    $line =~ s/\\\|\[lsh\]\\\|/\x{21B0}/g;    # UPWARDS ARROW WITH TIP LEFTWARDS # 21B0
    $line =~ s/\\\|\[map\]\\\|/\x{21A6}/g;    # RIGHTWARDS ARROW FROM BAR # 21A6
    $line =~ s/\\\|\[mumap\]\\\|/\x{22B8}/g;    # MULTIMAP # 22B8
    $line =~ s/\\\|\[nearr\]\\\|/\x{2197}/g;    # NORTH EAST ARROW # 2197
    $line =~ s/\\\|\[nlArr\]\\\|/\x{21CD}/g;    # LEFTWARDS DOUBLE ARROW WITH STROKE # 21CD
    $line =~ s/\\\|\[nlarr\]\\\|/\x{219A}/g;    # LEFTWARDS ARROW WITH STROKE # 219A
    $line =~ s/\\\|\[nhArr\]\\\|/\x{21CE}/g;    # LEFT RIGHT DOUBLE ARROW WITH STROKE # 21CE
    $line =~ s/\\\|\[nharr\]\\\|/\x{21AE}/g;    # LEFT RIGHT ARROW WITH STROKE # 21AE
    $line =~ s/\\\|\[nrarr\]\\\|/\x{219B}/g;    # RIGHTWARDS ARROW WITH STROKE # 219B
    $line =~ s/\\\|\[nrArr\]\\\|/\x{21CF}/g;    # RIGHTWARDS DOUBLE ARROW WITH STROKE # 21CF
    $line =~ s/\\\|\[nwarr\]\\\|/\x{2196}/g;    # NORTH WEST ARROW # 2196
    $line =~ s/\\\|\[olarr\]\\\|/\x{21BA}/g;    # ANTICLOCKWISE OPEN CIRCLE ARROW # 21BA
    $line =~ s/\\\|\[orarr\]\\\|/\x{21BB}/g;    # CLOCKWISE OPEN CIRCLE ARROW # 21BB
    $line =~ s/\\\|\[rAarr\]\\\|/\x{21DB}/g;    # RIGHTWARDS TRIPLE ARROW # 21DB
    $line =~ s/\\\|\[Rarr\]\\\|/\x{21A0}/g;    # RIGHTWARDS TWO HEADED ARROW # 21A0
    $line =~ s/\\\|\[rarr2\]\\\|/\x{21C9}/g;    # RIGHTWARDS PAIRED ARROWS # 21C9
    $line =~ s/\\\|\[rarrhk\]\\\|/\x{21AA}/g;    # RIGHTWARDS ARROW WITH HOOK # 21AA
    $line =~ s/\\\|\[rarrlp\]\\\|/\x{21AC}/g;    # RIGHTWARDS ARROW WITH LOOP # 21AC
    $line =~ s/\\\|\[rarrtl\]\\\|/\x{21A3}/g;    # RIGHTWARDS ARROW WITH TAIL # 21A3
    $line =~ s/\\\|\[rarrw\]\\\|/\x{219D}/g;    # RIGHTWARDS SQUIGGLE ARROW # 219D
    $line =~ s/\\\|\[rhard\]\\\|/\x{21C1}/g;    # RIGHTWARDS HARPOON WITH BARB DOWNWARDS # 21C1
    $line =~ s/\\\|\[rharu\]\\\|/\x{21C0}/g;    # RIGHTWARDS HARPOON WITH BARB UPWARDS # 21C0
    $line =~ s/\\\|\[rsh\]\\\|/\x{21B1}/g;    # UPWARDS ARROW WITH TIP RIGHTWARDS # 21B1
    $line =~ s/\\\|\[drarr\]\\\|/\x{2198}/g;    # SOUTH EAST ARROW # 2198
    $line =~ s/\\\|\[dlarr\]\\\|/\x{2199}/g;    # SOUTH WEST ARROW # 2199
    $line =~ s/\\\|\[uArr\]\\\|/\x{21D1}/g;    # UPWARDS DOUBLE ARROW # 21D1
    $line =~ s/\\\|\[uarr2\]\\\|/\x{21C8}/g;    # UPWARDS PAIRED ARROWS # 21C8
    $line =~ s/\\\|\[vArr\]\\\|/\x{21D5}/g;    # UP DOWN DOUBLE ARROW # 21D5
    $line =~ s/\\\|\[varr\]\\\|/\x{2195}/g;    # UP DOWN ARROW # 2195
    $line =~ s/\\\|\[uharl\]\\\|/\x{21BF}/g;    # UPWARDS HARPOON WITH BARB LEFTWARDS # 21BF
    $line =~ s/\\\|\[uharr\]\\\|/\x{21BE}/g;    # UPWARDS HARPOON WITH BARB RIGHTWARDS # 21BE
    $line =~ s/\\\|\[xlArr\]\\\|/\x{21D0}/g;    # LEFTWARDS DOUBLE ARROW # 21D0
    $line =~ s/\\\|\[xhArr\]\\\|/\x{2194}/g;    # LEFT RIGHT ARROW # 2194
    $line =~ s/\\\|\[xharr\]\\\|/\x{2194}/g;    # LEFT RIGHT ARROW # 2194
    $line =~ s/\\\|\[xrArr\]\\\|/\x{21D2}/g;    # RIGHTWARDS DOUBLE ARROW # 21D2

    # <!ENTITY % ISOamsc PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN">
    $line =~ s/\\\|\[rceil\]\\\|/\x{2309}/g;    # RIGHT CEILING # 2309
    $line =~ s/\\\|\[rfloor\]\\\|/\x{230B}/g;    # RIGHT FLOOR # 230B
    $line =~ s/\\\|\[rpargt\]\\\|/\x{E291}/g;    #  # E291
    $line =~ s/\\\|\[urcorn\]\\\|/\x{231D}/g;    # TOP RIGHT CORNER # 231D
    $line =~ s/\\\|\[drcorn\]\\\|/\x{231F}/g;    # BOTTOM RIGHT CORNER # 231F
    $line =~ s/\\\|\[lceil\]\\\|/\x{2308}/g;    # LEFT CEILING # 2308
    $line =~ s/\\\|\[lfloor\]\\\|/\x{230A}/g;    # LEFT FLOOR # 230A
    $line =~ s/\\\|\[lpargt\]\\\|/\\ensuremath\{\\rlap\{\$\>\$\}\,(\}/g;    # /leftparengtr O: left parenthesis, gt
    $line =~ s/\\\|\[ulcorn\]\\\|/\x{231C}/g;    # TOP LEFT CORNER # 231C
    $line =~ s/\\\|\[dlcorn\]\\\|/\x{231E}/g;    # BOTTOM LEFT CORNER # 231E

    # <!ENTITY % ISOlat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN">
    $line =~ s/\\\|\[aacute\]\\\|/\x{00E1}/g;    # LATIN SMALL LETTER A WITH ACUTE # 00E1
    $line =~ s/\\\|\[Aacute\]\\\|/\x{00C1}/g;    # LATIN CAPITAL LETTER A WITH ACUTE # 00C1
    $line =~ s/\\\|\[acirc\]\\\|/\x{00E2}/g;    # LATIN SMALL LETTER A WITH CIRCUMFLEX # 00E2
    $line =~ s/\\\|\[Acirc\]\\\|/\x{00C2}/g;    # LATIN CAPITAL LETTER A WITH CIRCUMFLEX # 00C2
    $line =~ s/\\\|\[agrave\]\\\|/\x{00E0}/g;    # LATIN SMALL LETTER A WITH GRAVE # 00E0
    $line =~ s/\\\|\[Agrave\]\\\|/\x{00C0}/g;    # LATIN CAPITAL LETTER A WITH GRAVE # 00C0
    $line =~ s/\\\|\[aring\]\\\|/\x{00E5}/g;    # LATIN SMALL LETTER A WITH RING ABOVE # 00E5
    $line =~ s/\\\|\[Aring\]\\\|/\x{00C5}/g;    # LATIN CAPITAL LETTER A WITH RING ABOVE # 00C5
    $line =~ s/\\\|\[atilde\]\\\|/\x{00E3}/g;    # LATIN SMALL LETTER A WITH TILDE # 00E3
    $line =~ s/\\\|\[Atilde\]\\\|/\x{00C3}/g;    # LATIN CAPITAL LETTER A WITH TILDE # 00C3
    $line =~ s/\\\|\[auml\]\\\|/\x{00E4}/g;    # LATIN SMALL LETTER A WITH DIAERESIS # 00E4
    $line =~ s/\\\|\[Auml\]\\\|/\x{00C4}/g;    # LATIN CAPITAL LETTER A WITH DIAERESIS # 00C4
    $line =~ s/\\\|\[aelig\]\\\|/\x{00E6}/g;    # LATIN SMALL LETTER AE # 00E6
    $line =~ s/\\\|\[AElig\]\\\|/\x{00C6}/g;    # LATIN CAPITAL LETTER AE # 00C6
    $line =~ s/\\\|\[ccedil\]\\\|/\x{00E7}/g;    # LATIN SMALL LETTER C WITH CEDILLA # 00E7
    $line =~ s/\\\|\[Ccedil\]\\\|/\x{00C7}/g;    # LATIN CAPITAL LETTER C WITH CEDILLA # 00C7
    $line =~ s/\\\|\[eth\]\\\|/\x{00F0}/g;    # LATIN SMALL LETTER ETH # 00F0
    $line =~ s/\\\|\[ETH\]\\\|/\x{00D0}/g;    # LATIN CAPITAL LETTER ETH # 00D0
    $line =~ s/\\\|\[eacute\]\\\|/\x{00E9}/g;    # LATIN SMALL LETTER E WITH ACUTE # 00E9
    $line =~ s/\\\|\[Eacute\]\\\|/\x{00C9}/g;    # LATIN CAPITAL LETTER E WITH ACUTE # 00C9
    $line =~ s/\\\|\[ecirc\]\\\|/\x{00EA}/g;    # LATIN SMALL LETTER E WITH CIRCUMFLEX # 00EA
    $line =~ s/\\\|\[Ecirc\]\\\|/\x{00CA}/g;    # LATIN CAPITAL LETTER E WITH CIRCUMFLEX # 00CA
    $line =~ s/\\\|\[egrave\]\\\|/\x{00E8}/g;    # LATIN SMALL LETTER E WITH GRAVE # 00E8
    $line =~ s/\\\|\[Egrave\]\\\|/\x{00C8}/g;    # LATIN CAPITAL LETTER E WITH GRAVE # 00C8
    $line =~ s/\\\|\[euml\]\\\|/\x{00EB}/g;    # LATIN SMALL LETTER E WITH DIAERESIS # 00EB
    $line =~ s/\\\|\[Euml\]\\\|/\x{00CB}/g;    # LATIN CAPITAL LETTER E WITH DIAERESIS # 00CB
    $line =~ s/\\\|\[iacute\]\\\|/\x{00ED}/g;    # LATIN SMALL LETTER I WITH ACUTE # 00ED
    $line =~ s/\\\|\[Iacute\]\\\|/\x{00CD}/g;    # LATIN CAPITAL LETTER I WITH ACUTE # 00CD
    $line =~ s/\\\|\[icirc\]\\\|/\x{00EE}/g;    # LATIN SMALL LETTER I WITH CIRCUMFLEX # 00EE
    $line =~ s/\\\|\[Icirc\]\\\|/\x{00CE}/g;    # LATIN CAPITAL LETTER I WITH CIRCUMFLEX # 00CE
    $line =~ s/\\\|\[igrave\]\\\|/\x{00EC}/g;    # LATIN SMALL LETTER I WITH GRAVE # 00EC
    $line =~ s/\\\|\[Igrave\]\\\|/\x{00CC}/g;    # LATIN CAPITAL LETTER I WITH GRAVE # 00CC
    $line =~ s/\\\|\[iuml\]\\\|/\x{00EF}/g;    # LATIN SMALL LETTER I WITH DIAERESIS # 00EF
    $line =~ s/\\\|\[Iuml\]\\\|/\x{00CF}/g;    # LATIN CAPITAL LETTER I WITH DIAERESIS # 00CF
    $line =~ s/\\\|\[ntilde\]\\\|/\x{00F1}/g;    # LATIN SMALL LETTER N WITH TILDE # 00F1
    $line =~ s/\\\|\[Ntilde\]\\\|/\x{00D1}/g;    # LATIN CAPITAL LETTER N WITH TILDE # 00D1
    $line =~ s/\\\|\[oacute\]\\\|/\x{00F3}/g;    # LATIN SMALL LETTER O WITH ACUTE # 00F3
    $line =~ s/\\\|\[Oacute\]\\\|/\x{00D3}/g;    # LATIN CAPITAL LETTER O WITH ACUTE # 00D3
    $line =~ s/\\\|\[ocirc\]\\\|/\x{00F4}/g;    # LATIN SMALL LETTER O WITH CIRCUMFLEX # 00F4
    $line =~ s/\\\|\[Ocirc\]\\\|/\x{00D4}/g;    # LATIN CAPITAL LETTER O WITH CIRCUMFLEX # 00D4
    $line =~ s/\\\|\[ograve\]\\\|/\x{00F2}/g;    # LATIN SMALL LETTER O WITH GRAVE # 00F2
    $line =~ s/\\\|\[Ograve\]\\\|/\x{00D2}/g;    # LATIN CAPITAL LETTER O WITH GRAVE # 00D2
    $line =~ s/\\\|\[oslash\]\\\|/\x{00F8}/g;    # LATIN SMALL LETTER O WITH STROKE # 00F8
    $line =~ s/\\\|\[Oslash\]\\\|/\x{00D8}/g;    # LATIN CAPITAL LETTER O WITH STROKE # 00D8
    $line =~ s/\\\|\[otilde\]\\\|/\x{00F5}/g;    # LATIN SMALL LETTER O WITH TILDE # 00F5
    $line =~ s/\\\|\[Otilde\]\\\|/\x{00D5}/g;    # LATIN CAPITAL LETTER O WITH TILDE # 00D5
    $line =~ s/\\\|\[ouml\]\\\|/\x{00F6}/g;    # LATIN SMALL LETTER O WITH DIAERESIS # 00F6
    $line =~ s/\\\|\[Ouml\]\\\|/\x{00D6}/g;    # LATIN CAPITAL LETTER O WITH DIAERESIS # 00D6
    $line =~ s/\\\|\[szlig\]\\\|/\x{00DF}/g;    # LATIN SMALL LETTER SHARP S # 00DF
    $line =~ s/\\\|\[thorn\]\\\|/\x{00FE}/g;    # LATIN SMALL LETTER THORN # 00FE
    $line =~ s/\\\|\[THORN\]\\\|/\x{00DE}/g;    # LATIN CAPITAL LETTER THORN # 00DE
    $line =~ s/\\\|\[uacute\]\\\|/\x{00FA}/g;    # LATIN SMALL LETTER U WITH ACUTE # 00FA
    $line =~ s/\\\|\[Uacute\]\\\|/\x{00DA}/g;    # LATIN CAPITAL LETTER U WITH ACUTE # 00DA
    $line =~ s/\\\|\[ucirc\]\\\|/\x{00FB}/g;    # LATIN SMALL LETTER U WITH CIRCUMFLEX # 00FB
    $line =~ s/\\\|\[Ucirc\]\\\|/\x{00DB}/g;    # LATIN CAPITAL LETTER U WITH CIRCUMFLEX # 00DB
    $line =~ s/\\\|\[ugrave\]\\\|/\x{00F9}/g;    # LATIN SMALL LETTER U WITH GRAVE # 00F9
    $line =~ s/\\\|\[Ugrave\]\\\|/\x{00D9}/g;    # LATIN CAPITAL LETTER U WITH GRAVE # 00D9
    $line =~ s/\\\|\[uuml\]\\\|/\x{00FC}/g;    # LATIN SMALL LETTER U WITH DIAERESIS # 00FC
    $line =~ s/\\\|\[Uuml\]\\\|/\x{00DC}/g;    # LATIN CAPITAL LETTER U WITH DIAERESIS # 00DC
    $line =~ s/\\\|\[yacute\]\\\|/\x{00FD}/g;    # LATIN SMALL LETTER Y WITH ACUTE # 00FD
    $line =~ s/\\\|\[Yacute\]\\\|/\x{00DD}/g;    # LATIN CAPITAL LETTER Y WITH ACUTE # 00DD
    $line =~ s/\\\|\[yuml\]\\\|/\x{00FF}/g;    # LATIN SMALL LETTER Y WITH DIAERESIS # 00FF

    # <!ENTITY % ISOlat2 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN">
    $line =~ s/\\\|\[abreve\]\\\|/\x{0103}/g;    # LATIN SMALL LETTER A WITH BREVE # 0103
    $line =~ s/\\\|\[Abreve\]\\\|/\x{0102}/g;    # LATIN CAPITAL LETTER A WITH BREVE # 0102
    $line =~ s/\\\|\[amacr\]\\\|/\x{0101}/g;    # LATIN SMALL LETTER A WITH MACRON # 0101
    $line =~ s/\\\|\[Amacr\]\\\|/\x{0100}/g;    # LATIN CAPITAL LETTER A WITH MACRON # 0100
    $line =~ s/\\\|\[aogon\]\\\|/\x{0105}/g;    # LATIN SMALL LETTER A WITH OGONEK # 0105
    $line =~ s/\\\|\[Aogon\]\\\|/\x{0104}/g;    # LATIN CAPITAL LETTER A WITH OGONEK # 0104
    $line =~ s/\\\|\[cacute\]\\\|/\x{0107}/g;    # LATIN SMALL LETTER C WITH ACUTE # 0107
    $line =~ s/\\\|\[Cacute\]\\\|/\x{0106}/g;    # LATIN CAPITAL LETTER C WITH ACUTE # 0106
    $line =~ s/\\\|\[ccaron\]\\\|/\x{010D}/g;    # LATIN SMALL LETTER C WITH CARON # 010D
    $line =~ s/\\\|\[Ccaron\]\\\|/\x{010C}/g;    # LATIN CAPITAL LETTER C WITH CARON # 010C
    $line =~ s/\\\|\[ccirc\]\\\|/\x{0109}/g;    # LATIN SMALL LETTER C WITH CIRCUMFLEX # 0109
    $line =~ s/\\\|\[Ccirc\]\\\|/\x{0108}/g;    # LATIN CAPITAL LETTER C WITH CIRCUMFLEX # 0108
    $line =~ s/\\\|\[cdot\]\\\|/\x{010B}/g;    # LATIN SMALL LETTER C WITH DOT ABOVE # 010B
    $line =~ s/\\\|\[Cdot\]\\\|/\x{010A}/g;    # LATIN CAPITAL LETTER C WITH DOT ABOVE # 010A
    $line =~ s/\\\|\[dcaron\]\\\|/\x{010F}/g;    # LATIN SMALL LETTER D WITH CARON # 010F
    $line =~ s/\\\|\[Dcaron\]\\\|/\x{010E}/g;    # LATIN CAPITAL LETTER D WITH CARON # 010E
    $line =~ s/\\\|\[dstrok\]\\\|/\x{0111}/g;    # LATIN SMALL LETTER D WITH STROKE # 0111
    $line =~ s/\\\|\[Dstrok\]\\\|/\x{0110}/g;    # LATIN CAPITAL LETTER D WITH STROKE # 0110
    $line =~ s/\\\|\[ecaron\]\\\|/\x{011B}/g;    # LATIN SMALL LETTER E WITH CARON # 011B
    $line =~ s/\\\|\[Ecaron\]\\\|/\x{011A}/g;    # LATIN CAPITAL LETTER E WITH CARON # 011A
    $line =~ s/\\\|\[edot\]\\\|/\x{0117}/g;    # LATIN SMALL LETTER E WITH DOT ABOVE # 0117
    $line =~ s/\\\|\[Edot\]\\\|/\x{0116}/g;    # LATIN CAPITAL LETTER E WITH DOT ABOVE # 0116
    $line =~ s/\\\|\[emacr\]\\\|/\x{0113}/g;    # LATIN SMALL LETTER E WITH MACRON # 0113
    $line =~ s/\\\|\[Emacr\]\\\|/\x{0112}/g;    # LATIN CAPITAL LETTER E WITH MACRON # 0112
    $line =~ s/\\\|\[eogon\]\\\|/\x{0119}/g;    # LATIN SMALL LETTER E WITH OGONEK # 0119
    $line =~ s/\\\|\[Eogon\]\\\|/\x{0118}/g;    # LATIN CAPITAL LETTER E WITH OGONEK # 0118
    $line =~ s/\\\|\[gacute\]\\\|/\x{01F5}/g;    # LATIN SMALL LETTER G WITH ACUTE # 01F5
    $line =~ s/\\\|\[gbreve\]\\\|/\x{011F}/g;    # LATIN SMALL LETTER G WITH BREVE # 011F
    $line =~ s/\\\|\[Gbreve\]\\\|/\x{011E}/g;    # LATIN CAPITAL LETTER G WITH BREVE # 011E
    $line =~ s/\\\|\[Gcedil\]\\\|/\x{0122}/g;    # LATIN CAPITAL LETTER G WITH CEDILLA # 0122
    $line =~ s/\\\|\[gcirc\]\\\|/\x{011D}/g;    # LATIN SMALL LETTER G WITH CIRCUMFLEX # 011D
    $line =~ s/\\\|\[Gcirc\]\\\|/\x{011C}/g;    # LATIN CAPITAL LETTER G WITH CIRCUMFLEX # 011C
    $line =~ s/\\\|\[gdot\]\\\|/\x{0121}/g;    # LATIN SMALL LETTER G WITH DOT ABOVE # 0121
    $line =~ s/\\\|\[Gdot\]\\\|/\x{0120}/g;    # LATIN CAPITAL LETTER G WITH DOT ABOVE # 0120
    $line =~ s/\\\|\[hcirc\]\\\|/\x{0125}/g;    # LATIN SMALL LETTER H WITH CIRCUMFLEX # 0125
    $line =~ s/\\\|\[Hcirc\]\\\|/\x{0124}/g;    # LATIN CAPITAL LETTER H WITH CIRCUMFLEX # 0124
    $line =~ s/\\\|\[hstrok\]\\\|/\x{0127}/g;    # LATIN SMALL LETTER H WITH STROKE # 0127
    $line =~ s/\\\|\[Hstrok\]\\\|/\x{0126}/g;    # LATIN CAPITAL LETTER H WITH STROKE # 0126
    $line =~ s/\\\|\[Idot\]\\\|/\x{0130}/g;    # LATIN CAPITAL LETTER I WITH DOT ABOVE # 0130
    $line =~ s/\\\|\[Imacr\]\\\|/\x{012A}/g;    # LATIN CAPITAL LETTER I WITH MACRON # 012A
    $line =~ s/\\\|\[imacr\]\\\|/\x{012B}/g;    # LATIN SMALL LETTER I WITH MACRON # 012B
    $line =~ s/\\\|\[ijlig\]\\\|/\x{0133}/g;    # LATIN SMALL LIGATURE IJ # 0133
    $line =~ s/\\\|\[IJlig\]\\\|/\x{0132}/g;    # LATIN CAPITAL LIGATURE IJ # 0132
    $line =~ s/\\\|\[inodot\]\\\|/\x{0131}/g;    # LATIN SMALL LETTER DOTLESS I # 0131
    $line =~ s/\\\|\[iogon\]\\\|/\x{012F}/g;    # LATIN SMALL LETTER I WITH OGONEK # 012F
    $line =~ s/\\\|\[Iogon\]\\\|/\x{012E}/g;    # LATIN CAPITAL LETTER I WITH OGONEK # 012E
    $line =~ s/\\\|\[itilde\]\\\|/\x{0129}/g;    # LATIN SMALL LETTER I WITH TILDE # 0129
    $line =~ s/\\\|\[Itilde\]\\\|/\x{0128}/g;    # LATIN CAPITAL LETTER I WITH TILDE # 0128
    $line =~ s/\\\|\[jcirc\]\\\|/\x{0135}/g;    # LATIN SMALL LETTER J WITH CIRCUMFLEX # 0135
    $line =~ s/\\\|\[Jcirc\]\\\|/\x{0134}/g;    # LATIN CAPITAL LETTER J WITH CIRCUMFLEX # 0134
    $line =~ s/\\\|\[kcedil\]\\\|/\x{0137}/g;    # LATIN SMALL LETTER K WITH CEDILLA # 0137
    $line =~ s/\\\|\[Kcedil\]\\\|/\x{0136}/g;    # LATIN CAPITAL LETTER K WITH CEDILLA # 0136
    $line =~ s/\\\|\[kgreen\]\\\|/\x{0138}/g;    # LATIN SMALL LETTER KRA # 0138
    $line =~ s/\\\|\[lacute\]\\\|/\x{013A}/g;    # LATIN SMALL LETTER L WITH ACUTE # 013A
    $line =~ s/\\\|\[Lacute\]\\\|/\x{0139}/g;    # LATIN CAPITAL LETTER L WITH ACUTE # 0139
    $line =~ s/\\\|\[lcaron\]\\\|/\x{013E}/g;    # LATIN SMALL LETTER L WITH CARON # 013E
    $line =~ s/\\\|\[Lcaron\]\\\|/\x{013D}/g;    # LATIN CAPITAL LETTER L WITH CARON # 013D
    $line =~ s/\\\|\[lcedil\]\\\|/\x{013C}/g;    # LATIN SMALL LETTER L WITH CEDILLA # 013C
    $line =~ s/\\\|\[Lcedil\]\\\|/\x{013B}/g;    # LATIN CAPITAL LETTER L WITH CEDILLA # 013B
    $line =~ s/\\\|\[lmidot\]\\\|/\x{0140}/g;    # LATIN SMALL LETTER L WITH MIDDLE DOT # 0140
    $line =~ s/\\\|\[Lmidot\]\\\|/\x{013F}/g;    # LATIN CAPITAL LETTER L WITH MIDDLE DOT # 013F
    $line =~ s/\\\|\[lstrok\]\\\|/\x{0142}/g;    # LATIN SMALL LETTER L WITH STROKE # 0142
    $line =~ s/\\\|\[Lstrok\]\\\|/\x{0141}/g;    # LATIN CAPITAL LETTER L WITH STROKE # 0141
    $line =~ s/\\\|\[nacute\]\\\|/\x{0144}/g;    # LATIN SMALL LETTER N WITH ACUTE # 0144
    $line =~ s/\\\|\[Nacute\]\\\|/\x{0143}/g;    # LATIN CAPITAL LETTER N WITH ACUTE # 0143
    $line =~ s/\\\|\[eng\]\\\|/\x{014B}/g;    # LATIN SMALL LETTER ENG # 014B
    $line =~ s/\\\|\[ENG\]\\\|/\x{014A}/g;    # LATIN CAPITAL LETTER ENG # 014A
    $line =~ s/\\\|\[napos\]\\\|/\x{0149}/g;    # LATIN SMALL LETTER N PRECEDED BY APOSTROPHE # 0149
    $line =~ s/\\\|\[ncaron\]\\\|/\x{0148}/g;    # LATIN SMALL LETTER N WITH CARON # 0148
    $line =~ s/\\\|\[Ncaron\]\\\|/\x{0147}/g;    # LATIN CAPITAL LETTER N WITH CARON # 0147
    $line =~ s/\\\|\[ncedil\]\\\|/\x{0146}/g;    # LATIN SMALL LETTER N WITH CEDILLA # 0146
    $line =~ s/\\\|\[Ncedil\]\\\|/\x{0145}/g;    # LATIN CAPITAL LETTER N WITH CEDILLA # 0145
    $line =~ s/\\\|\[odblac\]\\\|/\x{0151}/g;    # LATIN SMALL LETTER O WITH DOUBLE ACUTE # 0151
    $line =~ s/\\\|\[Odblac\]\\\|/\x{0150}/g;    # LATIN CAPITAL LETTER O WITH DOUBLE ACUTE # 0150
    $line =~ s/\\\|\[Omacr\]\\\|/\x{014C}/g;    # LATIN CAPITAL LETTER O WITH MACRON # 014C
    $line =~ s/\\\|\[omacr\]\\\|/\x{014D}/g;    # LATIN SMALL LETTER O WITH MACRON # 014D
    $line =~ s/\\\|\[oelig\]\\\|/\x{0153}/g;    # LATIN SMALL LIGATURE OE # 0153
    $line =~ s/\\\|\[OElig\]\\\|/\x{0152}/g;    # LATIN CAPITAL LIGATURE OE # 0152
    $line =~ s/\\\|\[racute\]\\\|/\x{0155}/g;    # LATIN SMALL LETTER R WITH ACUTE # 0155
    $line =~ s/\\\|\[Racute\]\\\|/\x{0154}/g;    # LATIN CAPITAL LETTER R WITH ACUTE # 0154
    $line =~ s/\\\|\[rcaron\]\\\|/\x{0159}/g;    # LATIN SMALL LETTER R WITH CARON # 0159
    $line =~ s/\\\|\[Rcaron\]\\\|/\x{0158}/g;    # LATIN CAPITAL LETTER R WITH CARON # 0158
    $line =~ s/\\\|\[rcedil\]\\\|/\x{0157}/g;    # LATIN SMALL LETTER R WITH CEDILLA # 0157
    $line =~ s/\\\|\[Rcedil\]\\\|/\x{0156}/g;    # LATIN CAPITAL LETTER R WITH CEDILLA # 0156
    $line =~ s/\\\|\[sacute\]\\\|/\x{015B}/g;    # LATIN SMALL LETTER S WITH ACUTE # 015B
    $line =~ s/\\\|\[Sacute\]\\\|/\x{015A}/g;    # LATIN CAPITAL LETTER S WITH ACUTE # 015A
    $line =~ s/\\\|\[scaron\]\\\|/\x{0161}/g;    # LATIN SMALL LETTER S WITH CARON # 0161
    $line =~ s/\\\|\[Scaron\]\\\|/\x{0160}/g;    # LATIN CAPITAL LETTER S WITH CARON # 0160
    $line =~ s/\\\|\[scedil\]\\\|/\x{015F}/g;    # LATIN SMALL LETTER S WITH CEDILLA # 015F
    $line =~ s/\\\|\[Scedil\]\\\|/\x{015E}/g;    # LATIN CAPITAL LETTER S WITH CEDILLA # 015E
    $line =~ s/\\\|\[scirc\]\\\|/\x{015D}/g;    # LATIN SMALL LETTER S WITH CIRCUMFLEX # 015D
    $line =~ s/\\\|\[Scirc\]\\\|/\x{015C}/g;    # LATIN CAPITAL LETTER S WITH CIRCUMFLEX # 015C
    $line =~ s/\\\|\[tcaron\]\\\|/\x{0165}/g;    # LATIN SMALL LETTER T WITH CARON # 0165
    $line =~ s/\\\|\[Tcaron\]\\\|/\x{0164}/g;    # LATIN CAPITAL LETTER T WITH CARON # 0164
    $line =~ s/\\\|\[tcedil\]\\\|/\x{0163}/g;    # LATIN SMALL LETTER T WITH CEDILLA # 0163
    $line =~ s/\\\|\[Tcedil\]\\\|/\x{0162}/g;    # LATIN CAPITAL LETTER T WITH CEDILLA # 0162
    $line =~ s/\\\|\[tstrok\]\\\|/\x{0167}/g;    # LATIN SMALL LETTER T WITH STROKE # 0167
    $line =~ s/\\\|\[Tstrok\]\\\|/\x{0166}/g;    # LATIN CAPITAL LETTER T WITH STROKE # 0166
    $line =~ s/\\\|\[ubreve\]\\\|/\x{016D}/g;    # LATIN SMALL LETTER U WITH BREVE # 016D
    $line =~ s/\\\|\[Ubreve\]\\\|/\x{016C}/g;    # LATIN CAPITAL LETTER U WITH BREVE # 016C
    $line =~ s/\\\|\[udblac\]\\\|/\x{0171}/g;    # LATIN SMALL LETTER U WITH DOUBLE ACUTE # 0171
    $line =~ s/\\\|\[Udblac\]\\\|/\x{0170}/g;    # LATIN CAPITAL LETTER U WITH DOUBLE ACUTE # 0170
    $line =~ s/\\\|\[umacr\]\\\|/\x{016B}/g;    # LATIN SMALL LETTER U WITH MACRON # 016B
    $line =~ s/\\\|\[Umacr\]\\\|/\x{016A}/g;    # LATIN CAPITAL LETTER U WITH MACRON # 016A
    $line =~ s/\\\|\[uogon\]\\\|/\x{0173}/g;    # LATIN SMALL LETTER U WITH OGONEK # 0173
    $line =~ s/\\\|\[Uogon\]\\\|/\x{0172}/g;    # LATIN CAPITAL LETTER U WITH OGONEK # 0172
    $line =~ s/\\\|\[uring\]\\\|/\x{016F}/g;    # LATIN SMALL LETTER U WITH RING ABOVE # 016F
    $line =~ s/\\\|\[Uring\]\\\|/\x{016E}/g;    # LATIN CAPITAL LETTER U WITH RING ABOVE # 016E
    $line =~ s/\\\|\[utilde\]\\\|/\x{0169}/g;    # LATIN SMALL LETTER U WITH TILDE # 0169
    $line =~ s/\\\|\[Utilde\]\\\|/\x{0168}/g;    # LATIN CAPITAL LETTER U WITH TILDE # 0168
    $line =~ s/\\\|\[wcirc\]\\\|/\x{0175}/g;    # LATIN SMALL LETTER W WITH CIRCUMFLEX # 0175
    $line =~ s/\\\|\[Wcirc\]\\\|/\x{0174}/g;    # LATIN CAPITAL LETTER W WITH CIRCUMFLEX # 0174
    $line =~ s/\\\|\[ycirc\]\\\|/\x{0177}/g;    # LATIN SMALL LETTER Y WITH CIRCUMFLEX # 0177
    $line =~ s/\\\|\[Ycirc\]\\\|/\x{0176}/g;    # LATIN CAPITAL LETTER Y WITH CIRCUMFLEX # 0176
    $line =~ s/\\\|\[Yuml\]\\\|/\x{0178}/g;    # LATIN CAPITAL LETTER Y WITH DIAERESIS # 0178
    $line =~ s/\\\|\[zacute\]\\\|/\x{017A}/g;    # LATIN SMALL LETTER Z WITH ACUTE # 017A
    $line =~ s/\\\|\[Zacute\]\\\|/\x{0179}/g;    # LATIN CAPITAL LETTER Z WITH ACUTE # 0179
    $line =~ s/\\\|\[zcaron\]\\\|/\x{017E}/g;    # LATIN SMALL LETTER Z WITH CARON # 017E
    $line =~ s/\\\|\[Zcaron\]\\\|/\x{017D}/g;    # LATIN CAPITAL LETTER Z WITH CARON # 017D
    $line =~ s/\\\|\[zdot\]\\\|/\x{017C}/g;    # LATIN SMALL LETTER Z WITH DOT ABOVE # 017C
    $line =~ s/\\\|\[Zdot\]\\\|/\x{017B}/g;    # LATIN CAPITAL LETTER Z WITH DOT ABOVE # 017B

    # <!ENTITY % ISOdia PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN">
    $line =~ s/\\\|\[acute\]\\\|/\x{00B4}/g;    # ACUTE ACCENT # 00B4
    $line =~ s/\\\|\[breve\]\\\|/\x{02D8}/g;    # BREVE # 02D8
    $line =~ s/\\\|\[caron\]\\\|/\x{02C7}/g;    # CARON # 02C7
    $line =~ s/\\\|\[cedil\]\\\|/\x{00B8}/g;    # CEDILLA # 00B8
    $line =~ s/\\\|\[circ\]\\\|/\\textasciicircum /g;    # RING OPERATOR # 005E
    $line =~ s/\\\|\[dblac\]\\\|/\x{02DD}/g;    # DOUBLE ACUTE ACCENT # 02DD
    $line =~ s/\\\|\[die\]\\\|/\x{00A8}/g;    #  # 00A8
    $line =~ s/\\\|\[dot\]\\\|/\x{02D9}/g;    # DOT ABOVE # 02D9
    $line =~ s/\\\|\[grave\]\\\|/\\textasciigrave /g;    # GRAVE ACCENT # 0060
    $line =~ s/\\\|\[macr\]\\\|/\x{00AF}/g;    # MACRON # 00AF
    $line =~ s/\\\|\[ogon\]\\\|/\x{02DB}/g;    # OGONEK # 02DB
    $line =~ s/\\\|\[ring\]\\\|/\x{02DA}/g;    # RING ABOVE # 02DA
    $line =~ s/\\\|\[tilde\]\\\|/\\textasciitilde /g;    # TILDE # 02DC
    $line =~ s/\\\|\[uml\]\\\|/\x{00A8}/g;    #  # 00A8

    # <!ENTITY % ISOcyr1 PUBLIC "ISO 8879:1986//ENTITIES Russian Cyrillic//EN">
    $line =~ s/\\\|\[acy\]\\\|/\x{0430}/g;    # CYRILLIC SMALL LETTER A # 0430
    $line =~ s/\\\|\[Acy\]\\\|/\x{0410}/g;    # CYRILLIC CAPITAL LETTER A # 0410
    $line =~ s/\\\|\[bcy\]\\\|/\x{0431}/g;    # CYRILLIC SMALL LETTER BE # 0431
    $line =~ s/\\\|\[Bcy\]\\\|/\x{0411}/g;    # CYRILLIC CAPITAL LETTER BE # 0411
    $line =~ s/\\\|\[vcy\]\\\|/\x{0432}/g;    # CYRILLIC SMALL LETTER VE # 0432
    $line =~ s/\\\|\[Vcy\]\\\|/\x{0412}/g;    # CYRILLIC CAPITAL LETTER VE # 0412
    $line =~ s/\\\|\[gcy\]\\\|/\x{0433}/g;    # CYRILLIC SMALL LETTER GHE # 0433
    $line =~ s/\\\|\[Gcy\]\\\|/\x{0413}/g;    # CYRILLIC CAPITAL LETTER GHE # 0413
    $line =~ s/\\\|\[dcy\]\\\|/\x{0434}/g;    # CYRILLIC SMALL LETTER DE # 0434
    $line =~ s/\\\|\[Dcy\]\\\|/\x{0414}/g;    # CYRILLIC CAPITAL LETTER DE # 0414
    $line =~ s/\\\|\[iecy\]\\\|/\x{0435}/g;    # CYRILLIC SMALL LETTER IE # 0435
    $line =~ s/\\\|\[IEcy\]\\\|/\x{0415}/g;    # CYRILLIC CAPITAL LETTER IE # 0415
    $line =~ s/\\\|\[iocy\]\\\|/\x{0451}/g;    # CYRILLIC SMALL LETTER IO # 0451
    $line =~ s/\\\|\[IOcy\]\\\|/\x{0401}/g;    # CYRILLIC CAPITAL LETTER IO # 0401
    $line =~ s/\\\|\[zhcy\]\\\|/\x{0436}/g;    # CYRILLIC SMALL LETTER ZHE # 0436
    $line =~ s/\\\|\[ZHcy\]\\\|/\x{0416}/g;    # CYRILLIC CAPITAL LETTER ZHE # 0416
    $line =~ s/\\\|\[zcy\]\\\|/\x{0437}/g;    # CYRILLIC SMALL LETTER ZE # 0437
    $line =~ s/\\\|\[Zcy\]\\\|/\x{0417}/g;    # CYRILLIC CAPITAL LETTER ZE # 0417
    $line =~ s/\\\|\[icy\]\\\|/\x{0438}/g;    # CYRILLIC SMALL LETTER I # 0438
    $line =~ s/\\\|\[Icy\]\\\|/\x{0418}/g;    # CYRILLIC CAPITAL LETTER I # 0418
    $line =~ s/\\\|\[jcy\]\\\|/\x{0439}/g;    # CYRILLIC SMALL LETTER SHORT I # 0439
    $line =~ s/\\\|\[Jcy\]\\\|/\x{0419}/g;    # CYRILLIC CAPITAL LETTER SHORT I # 0419
    $line =~ s/\\\|\[kcy\]\\\|/\x{043A}/g;    # CYRILLIC SMALL LETTER KA # 043A
    $line =~ s/\\\|\[Kcy\]\\\|/\x{041A}/g;    # CYRILLIC CAPITAL LETTER KA # 041A
    $line =~ s/\\\|\[lcy\]\\\|/\x{043B}/g;    # CYRILLIC SMALL LETTER EL # 043B
    $line =~ s/\\\|\[Lcy\]\\\|/\x{041B}/g;    # CYRILLIC CAPITAL LETTER EL # 041B
    $line =~ s/\\\|\[mcy\]\\\|/\x{043C}/g;    # CYRILLIC SMALL LETTER EM # 043C
    $line =~ s/\\\|\[Mcy\]\\\|/\x{041C}/g;    # CYRILLIC CAPITAL LETTER EM # 041C
    $line =~ s/\\\|\[ncy\]\\\|/\x{043D}/g;    # CYRILLIC SMALL LETTER EN # 043D
    $line =~ s/\\\|\[Ncy\]\\\|/\x{041D}/g;    # CYRILLIC CAPITAL LETTER EN # 041D
    $line =~ s/\\\|\[ocy\]\\\|/\x{043E}/g;    # CYRILLIC SMALL LETTER O # 043E
    $line =~ s/\\\|\[Ocy\]\\\|/\x{041E}/g;    # CYRILLIC CAPITAL LETTER O # 041E
    $line =~ s/\\\|\[pcy\]\\\|/\x{043F}/g;    # CYRILLIC SMALL LETTER PE # 043F
    $line =~ s/\\\|\[Pcy\]\\\|/\x{041F}/g;    # CYRILLIC CAPITAL LETTER PE # 041F
    $line =~ s/\\\|\[rcy\]\\\|/\x{0440}/g;    # CYRILLIC SMALL LETTER ER # 0440
    $line =~ s/\\\|\[Rcy\]\\\|/\x{0420}/g;    # CYRILLIC CAPITAL LETTER ER # 0420
    $line =~ s/\\\|\[scy\]\\\|/\x{0441}/g;    # CYRILLIC SMALL LETTER ES # 0441
    $line =~ s/\\\|\[Scy\]\\\|/\x{0421}/g;    # CYRILLIC CAPITAL LETTER ES # 0421
    $line =~ s/\\\|\[tcy\]\\\|/\x{0442}/g;    # CYRILLIC SMALL LETTER TE # 0442
    $line =~ s/\\\|\[Tcy\]\\\|/\x{0422}/g;    # CYRILLIC CAPITAL LETTER TE # 0422
    $line =~ s/\\\|\[ucy\]\\\|/\x{0443}/g;    # CYRILLIC SMALL LETTER U # 0443
    $line =~ s/\\\|\[Ucy\]\\\|/\x{0423}/g;    # CYRILLIC CAPITAL LETTER U # 0423
    $line =~ s/\\\|\[fcy\]\\\|/\x{0444}/g;    # CYRILLIC SMALL LETTER EF # 0444
    $line =~ s/\\\|\[Fcy\]\\\|/\x{0424}/g;    # CYRILLIC CAPITAL LETTER EF # 0424
    $line =~ s/\\\|\[khcy\]\\\|/\x{0445}/g;    # CYRILLIC SMALL LETTER HA # 0445
    $line =~ s/\\\|\[KHcy\]\\\|/\x{0425}/g;    # CYRILLIC CAPITAL LETTER HA # 0425
    $line =~ s/\\\|\[tscy\]\\\|/\x{0446}/g;    # CYRILLIC SMALL LETTER TSE # 0446
    $line =~ s/\\\|\[TScy\]\\\|/\x{0426}/g;    # CYRILLIC CAPITAL LETTER TSE # 0426
    $line =~ s/\\\|\[chcy\]\\\|/\x{0447}/g;    # CYRILLIC SMALL LETTER CHE # 0447
    $line =~ s/\\\|\[CHcy\]\\\|/\x{0427}/g;    # CYRILLIC CAPITAL LETTER CHE # 0427
    $line =~ s/\\\|\[shcy\]\\\|/\x{0448}/g;    # CYRILLIC SMALL LETTER SHA # 0448
    $line =~ s/\\\|\[SHcy\]\\\|/\x{0428}/g;    # CYRILLIC CAPITAL LETTER SHA # 0428
    $line =~ s/\\\|\[shchcy\]\\\|/\x{0449}/g;    # CYRILLIC SMALL LETTER SHCHA # 0449
    $line =~ s/\\\|\[SHCHcy\]\\\|/\x{0429}/g;    # CYRILLIC CAPITAL LETTER SHCHA # 0429
    $line =~ s/\\\|\[hardcy\]\\\|/\x{044A}/g;    # CYRILLIC SMALL LETTER HARD SIGN # 044A
    $line =~ s/\\\|\[HARDcy\]\\\|/\x{042A}/g;    # CYRILLIC CAPITAL LETTER HARD SIGN # 042A
    $line =~ s/\\\|\[ycy\]\\\|/\x{044B}/g;    # CYRILLIC SMALL LETTER YERU # 044B
    $line =~ s/\\\|\[Ycy\]\\\|/\x{042B}/g;    # CYRILLIC CAPITAL LETTER YERU # 042B
    $line =~ s/\\\|\[softcy\]\\\|/\x{044C}/g;    # CYRILLIC SMALL LETTER SOFT SIGN # 044C
    $line =~ s/\\\|\[SOFTcy\]\\\|/\x{042C}/g;    # CYRILLIC CAPITAL LETTER SOFT SIGN # 042C
    $line =~ s/\\\|\[ecy\]\\\|/\x{044D}/g;    # CYRILLIC SMALL LETTER E # 044D
    $line =~ s/\\\|\[Ecy\]\\\|/\x{042D}/g;    # CYRILLIC CAPITAL LETTER E # 042D
    $line =~ s/\\\|\[yucy\]\\\|/\x{044E}/g;    # CYRILLIC SMALL LETTER YU # 044E
    $line =~ s/\\\|\[YUcy\]\\\|/\x{042E}/g;    # CYRILLIC CAPITAL LETTER YU # 042E
    $line =~ s/\\\|\[yacy\]\\\|/\x{044F}/g;    # CYRILLIC SMALL LETTER YA # 044F
    $line =~ s/\\\|\[YAcy\]\\\|/\x{042F}/g;    # CYRILLIC CAPITAL LETTER YA # 042F
    $line =~ s/\\\|\[numero\]\\\|/\x{2116}/g;    # NUMERO SIGN # 2116

    # <!ENTITY % ISOcyr2 PUBLIC "ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN">
    $line =~ s/\\\|\[djcy\]\\\|/\x{0452}/g;    # CYRILLIC SMALL LETTER DJE # 0452
    $line =~ s/\\\|\[DJcy\]\\\|/\x{0402}/g;    # CYRILLIC CAPITAL LETTER DJE # 0402
    $line =~ s/\\\|\[gjcy\]\\\|/\x{0453}/g;    # CYRILLIC SMALL LETTER GJE # 0453
    $line =~ s/\\\|\[GJcy\]\\\|/\x{0403}/g;    # CYRILLIC CAPITAL LETTER GJE # 0403
    $line =~ s/\\\|\[jukcy\]\\\|/\x{0454}/g;    # CYRILLIC SMALL LETTER UKRAINIAN IE # 0454
    $line =~ s/\\\|\[Jukcy\]\\\|/\x{0404}/g;    # CYRILLIC CAPITAL LETTER UKRAINIAN IE # 0404
    $line =~ s/\\\|\[dscy\]\\\|/\x{0455}/g;    # CYRILLIC SMALL LETTER DZE # 0455
    $line =~ s/\\\|\[DScy\]\\\|/\x{0405}/g;    # CYRILLIC CAPITAL LETTER DZE # 0405
    $line =~ s/\\\|\[iukcy\]\\\|/\x{0456}/g;    # CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I # 0456
    $line =~ s/\\\|\[Iukcy\]\\\|/\x{0406}/g;    # CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I # 0406
    $line =~ s/\\\|\[yicy\]\\\|/\x{0457}/g;    # CYRILLIC SMALL LETTER YI # 0457
    $line =~ s/\\\|\[YIcy\]\\\|/\x{0407}/g;    # CYRILLIC CAPITAL LETTER YI # 0407
    $line =~ s/\\\|\[jsercy\]\\\|/\x{0458}/g;    # CYRILLIC SMALL LETTER JE # 0458
    $line =~ s/\\\|\[Jsercy\]\\\|/\x{0408}/g;    # CYRILLIC CAPITAL LETTER JE # 0408
    $line =~ s/\\\|\[ljcy\]\\\|/\x{0459}/g;    # CYRILLIC SMALL LETTER LJE # 0459
    $line =~ s/\\\|\[LJcy\]\\\|/\x{0409}/g;    # CYRILLIC CAPITAL LETTER LJE # 0409
    $line =~ s/\\\|\[njcy\]\\\|/\x{045A}/g;    # CYRILLIC SMALL LETTER NJE # 045A
    $line =~ s/\\\|\[NJcy\]\\\|/\x{040A}/g;    # CYRILLIC CAPITAL LETTER NJE # 040A
    $line =~ s/\\\|\[tshcy\]\\\|/\x{045B}/g;    # CYRILLIC SMALL LETTER TSHE # 045B
    $line =~ s/\\\|\[TSHcy\]\\\|/\x{040B}/g;    # CYRILLIC CAPITAL LETTER TSHE # 040B
    $line =~ s/\\\|\[kjcy\]\\\|/\x{045C}/g;    # CYRILLIC SMALL LETTER KJE # 045C
    $line =~ s/\\\|\[KJcy\]\\\|/\x{040C}/g;    # CYRILLIC CAPITAL LETTER KJE # 040C
    $line =~ s/\\\|\[ubrcy\]\\\|/\x{045E}/g;    # CYRILLIC SMALL LETTER SHORT U # 045E
    $line =~ s/\\\|\[Ubrcy\]\\\|/\x{040E}/g;    # CYRILLIC CAPITAL LETTER SHORT U # 040E
    $line =~ s/\\\|\[dzcy\]\\\|/\x{045F}/g;    # CYRILLIC SMALL LETTER DZHE # 045F
    $line =~ s/\\\|\[DZcy\]\\\|/\x{040F}/g;    # CYRILLIC CAPITAL LETTER DZHE # 040F

    # <!ENTITY % ISOgrk1 PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN">
    $line =~ s/\\\|\[agr\]\\\|/\x{03B1}/g;    #  # 03B1
    $line =~ s/\\\|\[Agr\]\\\|/\x{0391}/g;    # GREEK CAPITAL LETTER ALPHA # 0391
    $line =~ s/\\\|\[bgr\]\\\|/\x{03B2}/g;    # GREEK SMALL LETTER BETA # 03B2
    $line =~ s/\\\|\[Bgr\]\\\|/\x{0392}/g;    # GREEK CAPITAL LETTER BETA # 0392
    $line =~ s/\\\|\[ggr\]\\\|/\x{03B3}/g;    # GREEK SMALL LETTER GAMMA # 03B3
    $line =~ s/\\\|\[Ggr\]\\\|/\x{0393}/g;    # GREEK CAPITAL LETTER GAMMA # 0393
    $line =~ s/\\\|\[dgr\]\\\|/\x{03B4}/g;    # GREEK SMALL LETTER DELTA # 03B4
    $line =~ s/\\\|\[Dgr\]\\\|/\x{0394}/g;    # GREEK CAPITAL LETTER DELTA # 0394
    $line =~ s/\\\|\[egr\]\\\|/\x{03B5}/g;    #  # 03B5
    $line =~ s/\\\|\[Egr\]\\\|/\x{0395}/g;    # GREEK CAPITAL LETTER EPSILON # 0395
    $line =~ s/\\\|\[zgr\]\\\|/\x{03B6}/g;    # GREEK SMALL LETTER ZETA # 03B6
    $line =~ s/\\\|\[Zgr\]\\\|/\x{0396}/g;    # GREEK CAPITAL LETTER ZETA # 0396
    $line =~ s/\\\|\[eegr\]\\\|/\x{03B7}/g;    # GREEK SMALL LETTER ETA # 03B7
    $line =~ s/\\\|\[EEgr\]\\\|/\x{0397}/g;    # GREEK CAPITAL LETTER ETA # 0397
    $line =~ s/\\\|\[thgr\]\\\|/\x{03B8}/g;    #  # 03B8
    $line =~ s/\\\|\[THgr\]\\\|/\x{0398}/g;    # GREEK CAPITAL LETTER THETA # 0398
    $line =~ s/\\\|\[igr\]\\\|/\x{03B9}/g;    # GREEK SMALL LETTER IOTA # 03B9
    $line =~ s/\\\|\[Igr\]\\\|/\x{0399}/g;    # GREEK CAPITAL LETTER IOTA # 0399
    $line =~ s/\\\|\[kgr\]\\\|/\x{03BA}/g;    # GREEK SMALL LETTER KAPPA # 03BA
    $line =~ s/\\\|\[Kgr\]\\\|/\x{039A}/g;    # GREEK CAPITAL LETTER KAPPA # 039A
    $line =~ s/\\\|\[lgr\]\\\|/\x{03BB}/g;    # GREEK SMALL LETTER LAMDA # 03BB
    $line =~ s/\\\|\[Lgr\]\\\|/\x{039B}/g;    # GREEK CAPITAL LETTER LAMDA # 039B
    $line =~ s/\\\|\[mgr\]\\\|/\x{03BC}/g;    # GREEK SMALL LETTER MU # 03BC
    $line =~ s/\\\|\[Mgr\]\\\|/\x{039C}/g;    # GREEK CAPITAL LETTER MU # 039C
    $line =~ s/\\\|\[ngr\]\\\|/\x{03BD}/g;    # GREEK SMALL LETTER NU # 03BD
    $line =~ s/\\\|\[Ngr\]\\\|/\x{039D}/g;    # GREEK CAPITAL LETTER NU # 039D
    $line =~ s/\\\|\[xgr\]\\\|/\x{03BE}/g;    # GREEK SMALL LETTER XI # 03BE
    $line =~ s/\\\|\[Xgr\]\\\|/\x{039E}/g;    # GREEK CAPITAL LETTER XI # 039E
    $line =~ s/\\\|\[ogr\]\\\|/\x{03BF}/g;    # GREEK SMALL LETTER OMICRON # 03BF
    $line =~ s/\\\|\[Ogr\]\\\|/\x{039F}/g;    # GREEK CAPITAL LETTER OMICRON # 039F
    $line =~ s/\\\|\[pgr\]\\\|/\x{03C0}/g;    # GREEK SMALL LETTER PI # 03C0
    $line =~ s/\\\|\[Pgr\]\\\|/\x{03A0}/g;    # GREEK CAPITAL LETTER PI # 03A0
    $line =~ s/\\\|\[rgr\]\\\|/\x{03C1}/g;    # GREEK SMALL LETTER RHO # 03C1
    $line =~ s/\\\|\[Rgr\]\\\|/\x{03A1}/g;    # GREEK CAPITAL LETTER RHO # 03A1
    $line =~ s/\\\|\[sgr\]\\\|/\x{03C3}/g;    # GREEK SMALL LETTER SIGMA # 03C3
    $line =~ s/\\\|\[Sgr\]\\\|/\x{03A3}/g;    # GREEK CAPITAL LETTER SIGMA # 03A3
    $line =~ s/\\\|\[sfgr\]\\\|/\x{03C2}/g;    #  # 03C2
    $line =~ s/\\\|\[tgr\]\\\|/\x{03C4}/g;    # GREEK SMALL LETTER TAU # 03C4
    $line =~ s/\\\|\[Tgr\]\\\|/\x{03A4}/g;    # GREEK CAPITAL LETTER TAU # 03A4
    $line =~ s/\\\|\[ugr\]\\\|/\x{03C5}/g;    # GREEK SMALL LETTER UPSILON # 03C5
    $line =~ s/\\\|\[Ugr\]\\\|/\x{03A5}/g;    #  # 03A5
    $line =~ s/\\\|\[phgr\]\\\|/\x{03C6}/g;    # GREEK SMALL LETTER PHI # 03C6
    $line =~ s/\\\|\[PHgr\]\\\|/\x{03A6}/g;    # GREEK CAPITAL LETTER PHI # 03A6
    $line =~ s/\\\|\[khgr\]\\\|/\x{03C7}/g;    # GREEK SMALL LETTER CHI # 03C7
    $line =~ s/\\\|\[KHgr\]\\\|/\x{03A7}/g;    # GREEK CAPITAL LETTER CHI # 03A7
    $line =~ s/\\\|\[psgr\]\\\|/\x{03C8}/g;    # GREEK SMALL LETTER PSI # 03C8
    $line =~ s/\\\|\[PSgr\]\\\|/\x{03A8}/g;    # GREEK CAPITAL LETTER PSI # 03A8
    $line =~ s/\\\|\[ohgr\]\\\|/\x{03C9}/g;    # GREEK SMALL LETTER OMEGA # 03C9
    $line =~ s/\\\|\[OHgr\]\\\|/\x{03A9}/g;    # GREEK CAPITAL LETTER OMEGA # 03A9

    # <!ENTITY % ISOgrk2 PUBLIC "ISO 8879:1986//ENTITIES Monotoniko Greek//EN">
    $line =~ s/\\\|\[aacgr\]\\\|/\x{03AC}/g;    # GREEK SMALL LETTER ALPHA WITH TONOS # 03AC
    $line =~ s/\\\|\[Aacgr\]\\\|/\x{0386}/g;    # GREEK CAPITAL LETTER ALPHA WITH TONOS # 0386
    $line =~ s/\\\|\[eacgr\]\\\|/\x{03AD}/g;    # GREEK SMALL LETTER EPSILON WITH TONOS # 03AD
    $line =~ s/\\\|\[Eacgr\]\\\|/\x{0388}/g;    # GREEK CAPITAL LETTER EPSILON WITH TONOS # 0388
    $line =~ s/\\\|\[eeacgr\]\\\|/\x{03AE}/g;    # GREEK SMALL LETTER ETA WITH TONOS # 03AE
    $line =~ s/\\\|\[EEacgr\]\\\|/\x{0389}/g;    # GREEK CAPITAL LETTER ETA WITH TONOS # 0389
    $line =~ s/\\\|\[idigr\]\\\|/\x{03CA}/g;    # GREEK SMALL LETTER IOTA WITH DIALYTIKA # 03CA
    $line =~ s/\\\|\[Idigr\]\\\|/\x{03AA}/g;    # GREEK CAPITAL LETTER IOTA WITH DIALYTIKA # 03AA
    $line =~ s/\\\|\[iacgr\]\\\|/\x{03AF}/g;    # GREEK SMALL LETTER IOTA WITH TONOS # 03AF
    $line =~ s/\\\|\[Iacgr\]\\\|/\x{038A}/g;    # GREEK CAPITAL LETTER IOTA WITH TONOS # 038A
    $line =~ s/\\\|\[idiagr\]\\\|/\x{0390}/g;    # GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS # 0390
    $line =~ s/\\\|\[oacgr\]\\\|/\x{03CC}/g;    # GREEK SMALL LETTER OMICRON WITH TONOS # 03CC
    $line =~ s/\\\|\[Oacgr\]\\\|/\x{038C}/g;    # GREEK CAPITAL LETTER OMICRON WITH TONOS # 038C
    $line =~ s/\\\|\[udigr\]\\\|/\x{03CB}/g;    # GREEK SMALL LETTER UPSILON WITH DIALYTIKA # 03CB
    $line =~ s/\\\|\[Udigr\]\\\|/\x{03AB}/g;    # GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA # 03AB
    $line =~ s/\\\|\[uacgr\]\\\|/\x{03CD}/g;    # GREEK SMALL LETTER UPSILON WITH TONOS # 03CD
    $line =~ s/\\\|\[Uacgr\]\\\|/\x{038E}/g;    # GREEK CAPITAL LETTER UPSILON WITH TONOS # 038E
    $line =~ s/\\\|\[udiagr\]\\\|/\x{03B0}/g;    # GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS # 03B0
    $line =~ s/\\\|\[ohacgr\]\\\|/\x{03CE}/g;    # GREEK SMALL LETTER OMEGA WITH TONOS # 03CE
    $line =~ s/\\\|\[OHacgr\]\\\|/\x{038F}/g;    # GREEK CAPITAL LETTER OMEGA WITH TONOS # 038F

    # <!ENTITY % HTMLspecial PUBLIC "-//W3C//ENTITIES Special//EN//HTML">
    $line =~ s/\\\|\[zwnj\]\\\|/\\hspace\{0pt\}/g;      # NEW RFC 2070: zero width non-joiner
    $line =~ s/\\\|\[zwj\]\\\|//g;                      # NEW RFC 2070: zero width joiner
    $line =~ s/\\\|\[lrm\]\\\|/\\almlxxsymbolunprintable /g;            # NEW RFC 2070: left-to-right mark
    $line =~ s/\\\|\[rlm\]\\\|/\\almlxxsymbolunprintable /g;            # NEW RFC 2070: right-to-left mark
    $line =~ s/\\\|\[sbquo\]\\\|/\{\,\}/g;              # NEW: single low-9 quotation mark
    $line =~ s/\\\|\[bdquo\]\\\|/\{\,\,\}/g;            # NEW: double low-9 quotation mark
    $line =~ s/\\\|\[lsaquo\]\\\|/\\ensuremath\{\\langle\}/g;   # ISO proposed: single left-pointing angle quotation mark
    $line =~ s/\\\|\[rsaquo\]\\\|/\\ensuremath\{\\rangle\}/g;   # ISO proposed: single right-pointing angle quotation mark
    $line =~ s/\\\|\[euro\]\\\|/\\almlxxsymboleuro /g;          # NEW: euro sign
    
    # <!ENTITY % HTMLsymbol PUBLIC "-//W3C//ENTITIES Symbols//EN//HTML">
    $line =~ s/\\\|\[Alpha\]\\\|/\{\\rm\{A\}\}/g;               # greek capital letter alpha
    $line =~ s/\\\|\[Beta\]\\\|/\{\\rm\{B\}\}/g;                # greek capital letter beta
    $line =~ s/\\\|\[Epsilon\]\\\|/\{\\rm\{E\}\}/g;             # greek capital letter epsilon
    $line =~ s/\\\|\[Zeta\]\\\|/\{\\rm\{Z\}\}/g;                        # greek capital letter zeta
    $line =~ s/\\\|\[Eta\]\\\|/\{\\rm\{H\}\}/g;                 # greek capital letter eta
    $line =~ s/\\\|\[Iota\]\\\|/\{\\rm\{I\}\}/g;                # greek capital letter iota
    $line =~ s/\\\|\[Kappa\]\\\|/\{\\rm\{K\}\}/g;               # greek capital letter kappa
    $line =~ s/\\\|\[Mu\]\\\|/\{\\rm\{M\}\}/g;                          # greek capital letter mu
    $line =~ s/\\\|\[Nu\]\\\|/\{\\rm\{N\}\}/g;                  # greek capital letter nu
    $line =~ s/\\\|\[Omicron\]\\\|/\{\\rm\{O\}\}/g;             # greek capital letter omicron
    $line =~ s/\\\|\[Rho\]\\\|/\{\\rm\{P\}\}/g;                 # greek capital letter rho
    $line =~ s/\\\|\[Tau\]\\\|/\{\\rm\{T\}\}/g;                 # greek capital letter tau
    $line =~ s/\\\|\[Upsilon\]\\\|/\\ensuremath\{\\Upsilon\}/g; # greek capital letter upsilon U+03A5
    $line =~ s/\\\|\[Chi\]\\\|/\{\\rm\{X\}\}/g;                 # greek capital letter chi
    $line =~ s/\\\|\[epsilon\]\\\|/\\ensuremath\{\\epsilon\}/g; # greek small letter epsilon U+03B5
    $line =~ s/\\\|\[theta\]\\\|/\\ensuremath\{\\theta\}/g;     # greek small letter theta
    $line =~ s/\\\|\[omicron\]\\\|/\{\\rm\{o\}\}/g;             # NEW : greek small letter omicron
    $line =~ s/\\\|\[sigmaf\]\\\|/\\ensuremath\{\\varsigma\}/g; # greek small letter final sigma U+03C2
    $line =~ s/\\\|\[thetasym\]\\\|/\\ensuremath\{\\vartheta\}/g;       # NEW : greek small letter theta symbol
    $line =~ s/\\\|\[upsilon\]\\\|/\\ensuremath\{\\upsilon\}/g; #  greek small letter upsilon U+03C5
    $line =~ s/\\\|\[phi\]\\\|/\\ensuremath\{\\phi\}/g;                 # greek small letter phi
    $line =~ s/\\\|\[upsih\]\\\|/\\ensuremath\{\\Upsilon\}/g;   # NEW : greek upsilon with hook symbol
    $line =~ s/\\\|\[oline\]\\\|/\\=\~/g;               # NEW : overline = spacing overscore
    $line =~ s/\\\|\[frasl\]\\\|/\//g;                  # NEW : fraction slash
    $line =~ s/\\\|\[alefsym\]\\\|/\\ensuremath\{\\aleph\}/g;   # NEW : alef symbol = first transfinite cardinal
    $line =~ s/\\\|\[crarr\]\\\|/\\ensuremath\{\\hookleftarrow\}/g;     # NEW : downwards arrow with corner leftwards  = carriage return
    #
    # Scan to avoid the use of some strange Unicode characters.
    #
    return (&sp_latex_to_sp_latex_unicode_clean ($line));
}
#
# Convert an SP SDATA string into HTML back-end code.
# That is, for example, "\|[circ  ]\|" is converted into "&circ;".
#
# Some standard entities doesn't work on HTML. See &apos; for example.
#
# &sp_sdata_text_to_sp_html (TEXT)
#
sub sp_sdata_text_to_sp_html
{
    my ($line) = $_[0];
    my ($line_new) = "";
    my ($offset) = 0;
    my ($max) = 0;
    my ($char) = "";
    my ($unknown) = "&#x25A0;";
    #
    # Please note that the space is handled because there are
    # LaTeX commands eating spaces...
    # HTML has no problems:
    #
    $line =~ s/\\\|\[simplespace\]\\\|/ /g;    # &simplespace; does not exist.
    #
    # US-ASCII special characters for any typesetting system.
    #
    $line =~ s/\\\|\[excl\]\\\|/!/g;        # ISOnum : EXCLAMATION MARK
    $line =~ s/\\\|\[quot\]\\\|/\"/g;       # ISOnum : QUOTATION MARK
    $line =~ s/\\\|\[num\]\\\|/#/g;        # ISOnum : NUMBER SIGN
    $line =~ s/\\\|\[dollar\]\\\|/\$/g;       # ISOnum : dollar sign
    $line =~ s/\\\|\[percnt\]\\\|/\%/g;       # ISOnum : percent sign
    $line =~ s/\\\|\[amp\]\\\|/&amp;/g;    # ISOnum : ampersand
    $line =~ s/\\\|\[apos\]\\\|/\'/g;        # ISOnum : apostrophe
    $line =~ s/\\\|\[rsquo\]\\\|/\'/g;        # ISOnum : single quotation mark right
    $line =~ s/\\\|\[lpar\]\\\|/\(/g;       # ISOnum : left parenthesis
    $line =~ s/\\\|\[rpar\]\\\|/\)/g;       # ISOnum : right parenthesis
    $line =~ s/\\\|\[ast\]\\\|/*/g;        # ISOnum : asterisk
    $line =~ s/\\\|\[plus\]\\\|/+/g;        # ISOnum : plus sign
    $line =~ s/\\\|\[comma\]\\\|/,/g;        # ISOnum : comma
    $line =~ s/\\\|\[hyphen\]\\\|/-/g;        # ISOnum : hyphen
    $line =~ s/\\\|\[period\]\\\|/./g;        # ISOnum : full stop, period
    $line =~ s/\\\|\[sol\]\\\|/\//g;       # ISOnum : solidus
    #
    # numbers from 0 to 9 are not translated
    #
    $line =~ s/\\\|\[colon\]\\\|/:/g;        # ISOnum : colon
    $line =~ s/\\\|\[semi\]\\\|/;/g;        # ISOnum : semicolon
    $line =~ s/\\\|\[lt\]\\\|/&lt;/g;     # ISOnum : less-than sign
    $line =~ s/\\\|\[equals\]\\\|/=/g;        # ISOnum : equals sign
    $line =~ s/\\\|\[gt\]\\\|/&gt;/g;     # ISOnum : greater-than sign
    $line =~ s/\\\|\[quest\]\\\|/?/g;        # ISOnum : question mark
    $line =~ s/\\\|\[commat\]\\\|/\@/g;       # ISOnum : commercial at
    #
    # letters from A to Z are not translated
    #
    $line =~ s/\\\|\[lsqb\]\\\|/[/g;        # ISOnum : left square bracket
    $line =~ s/\\\|\[bsol\]\\\|/\x{5C}\x{5C}/g;    # ISOnum : reverse solidus - this is special!
    $line =~ s/\\\|\[rsqb\]\\\|/]/g;        # ISOnum : right square bracket
    $line =~ s/\\\|\[circ\]\\\|/^/g;        # ISOnum : circumflex accent
    $line =~ s/\\\|\[lowbar\]\\\|/_/g;        # ISOnum : low line
    $line =~ s/\\\|\[lsquo\]\\\|/\x{60}/g;        # ISOnum : single quotation mark, left
    # letters from a to z are not translated
    $line =~ s/\\\|\[lcub\]\\\|/{/g;        # ISOnum : left curly bracket
    $line =~ s/\\\|\[verbar\]\\\|/|/g;        # ISOnum : vertical bar
    $line =~ s/\\\|\[rcub\]\\\|/}/g;        # ISOnum : right curly bracket
    $line =~ s/\\\|\[tilde\]\\\|/~/g;        # ISOdia : tilde
    #
    # <!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1//EN//HTML">
    #
    $line =~ s/\\\|\[nbsp\]\\\|/&nbsp;/g;   # ISOnum : NO-BREAK SPACE
    $line =~ s/\\\|\[iexcl\]\\\|/&iexcl;/g;  # ISOnum : INVERTED EXCLAMATION MARK
    $line =~ s/\\\|\[cent\]\\\|/&cent;/g;   # ISOnum : CENT SIGN
    $line =~ s/\\\|\[pound\]\\\|/&pound;/g;  # ISOnum : POUND SIGN
    $line =~ s/\\\|\[curren\]\\\|/&curren;/g; # ISOnum : CURRENCY SIGN
    $line =~ s/\\\|\[yen\]\\\|/&yen;/g;    # ISOnum : YEN SIGN
    $line =~ s/\\\|\[brvbar\]\\\|/&brvbar;/g; # ISOnum : BROKEN BAR
    $line =~ s/\\\|\[sect\]\\\|/&sect;/g;   # ISOnum : SECTION SIGN
    $line =~ s/\\\|\[uml\]\\\|/&uml;/g;    # ISOdia : DIAERESIS (ma non  lo stesso, perch  "die" in ISOdia.
    $line =~ s/\\\|\[copy\]\\\|/&copy;/g;   # ISOnum : COPYRIGHT SIGN
    $line =~ s/\\\|\[ordf\]\\\|/&ordf;/g;   # ISOnum : FEMININE ORDINAL INDICATOR
    $line =~ s/\\\|\[laquo\]\\\|/&laquo;/g;  # ISOnum : LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
    $line =~ s/\\\|\[not\]\\\|/&not;/g;    # ISOnum : NOT SIGN
    $line =~ s/\\\|\[shy\]\\\|/&shy;/g;    # ISOnum : SOFT HYPHEN
    $line =~ s/\\\|\[reg\]\\\|/&reg;/g;    # ISOnum : REGISTERED SIGN
    $line =~ s/\\\|\[macr\]\\\|/&macr;/g;   # ISOdia : OVERLINE (MACRON)
    $line =~ s/\\\|\[deg\]\\\|/&deg;/g;    # ISOnum : DEGREE SIGN
    $line =~ s/\\\|\[plusmn\]\\\|/&plusmn;/g; # ISOnum : PLUS-MINUS SIGN
    $line =~ s/\\\|\[sup2\]\\\|/&sup2;/g;   # ISOnum : SUPERSCRIPT TWO
    $line =~ s/\\\|\[sup3\]\\\|/&sup3;/g;   # ISOnum : SUPERSCRIPT THREE
    $line =~ s/\\\|\[acute\]\\\|/&acute;/g;  # ISOdia : ACUTE ACCENT
    $line =~ s/\\\|\[micro\]\\\|/&micro;/g;  # ISOnum : MICRO SIGN
    $line =~ s/\\\|\[para\]\\\|/&para;/g;   # ISOnum : PILCROW SIGN
    $line =~ s/\\\|\[middot\]\\\|/&middot;/g; # ISOnum : MIDDLE DOT
    $line =~ s/\\\|\[cedil\]\\\|/&cedil;/g;  # ISOdia : CEDILLA
    $line =~ s/\\\|\[sup1\]\\\|/&sup1;/g;   # ISOnum : SUPERSCRIPT ONE
    $line =~ s/\\\|\[ordm\]\\\|/&ordm;/g;   # ISOnum : MASCULINE ORDINAL INDICATOR
    $line =~ s/\\\|\[raquo\]\\\|/&raquo;/g;  # ISOnum : RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
    $line =~ s/\\\|\[frac14\]\\\|/&frac14;/g; # ISOnum : VULGAR FRACTION ONE QUARTER
    $line =~ s/\\\|\[frac12\]\\\|/&frac12;/g; # ISOnum : VULGAR FRACTION ONE HALF
    $line =~ s/\\\|\[frac34\]\\\|/&frac34;/g; # ISOnum : VULGAR FRACTION THREE QUARTERS
    $line =~ s/\\\|\[iquest\]\\\|/&iquest;/g; # ISOnum : INVERTED QUESTION MARK
    $line =~ s/\\\|\[Agrave\]\\\|/&Agrave;/g; # ISOlat1: LATIN CAPITAL LETTER A WITH GRAVE
    $line =~ s/\\\|\[Aacute\]\\\|/&Aacute;/g; # ISOlat1: LATIN CAPITAL LETTER A WITH ACUTE
    $line =~ s/\\\|\[Acirc\]\\\|/&Acirc;/g;  # ISOlat1: LATIN CAPITAL LETTER A WITH CIRCUMFLEX
    $line =~ s/\\\|\[Atilde\]\\\|/&Atilde;/g; # ISOlat1: LATIN CAPITAL LETTER A WITH TILDE
    $line =~ s/\\\|\[Auml\]\\\|/&Auml;/g;   # ISOlat1: LATIN CAPITAL LETTER A WITH DIAERESIS
    $line =~ s/\\\|\[Aring\]\\\|/&Aring;/g;  # ISOlat1: LATIN CAPITAL LETTER A WITH RING ABOVE
    $line =~ s/\\\|\[AElig\]\\\|/&AElig;/g;  # ISOlat1: LATIN CAPITAL LETTER AE
    $line =~ s/\\\|\[Ccedil\]\\\|/&Ccedil;/g; # ISOlat1: LATIN CAPITAL LETTER C WITH CEDILLA
    $line =~ s/\\\|\[Egrave\]\\\|/&Egrave;/g; # ISOlat1: LATIN CAPITAL LETTER E WITH GRAVE
    $line =~ s/\\\|\[Eacute\]\\\|/&Eacute;/g; # ISOlat1: LATIN CAPITAL LETTER E WITH ACUTE
    $line =~ s/\\\|\[Ecirc\]\\\|/&Ecirc;/g;  # ISOlat1: LATIN CAPITAL LETTER E WITH CIRCUMFLEX
    $line =~ s/\\\|\[Euml\]\\\|/&Euml;/g;   # ISOlat1: LATIN CAPITAL LETTER E WITH DIAERESIS
    $line =~ s/\\\|\[Igrave\]\\\|/&Igrave;/g; # ISOlat1: LATIN CAPITAL LETTER I WITH GRAVE
    $line =~ s/\\\|\[Iacute\]\\\|/&Iacute;/g; # ISOlat1: LATIN CAPITAL LETTER I WITH ACUTE
    $line =~ s/\\\|\[Icirc\]\\\|/&Icirc;/g;  # ISOlat1: LATIN CAPITAL LETTER I WITH CIRCUMFLEX
    $line =~ s/\\\|\[Iuml\]\\\|/&Iuml;/g;   # ISOlat1: LATIN CAPITAL LETTER I WITH DIAERESIS
    $line =~ s/\\\|\[ETH\]\\\|/&ETH;/g;    # ISOlat1: LATIN CAPITAL LETTER ETH (Icelandic)
    $line =~ s/\\\|\[Ntilde\]\\\|/&Ntilde;/g; # ISOlat1: LATIN CAPITAL LETTER N WITH TILDE
    $line =~ s/\\\|\[Ograve\]\\\|/&Ograve;/g; # ISOlat1: LATIN CAPITAL LETTER O WITH GRAVE
    $line =~ s/\\\|\[Oacute\]\\\|/&Oacute;/g; # ISOlat1: LATIN CAPITAL LETTER O WITH ACUTE
    $line =~ s/\\\|\[Ocirc\]\\\|/&Ocirc;/g;  # ISOlat1: LATIN CAPITAL LETTER O WITH CIRCUMFLEX
    $line =~ s/\\\|\[Otilde\]\\\|/&Otilde;/g; # ISOlat1: LATIN CAPITAL LETTER O WITH TILDE
    $line =~ s/\\\|\[Ouml\]\\\|/&Ouml;/g;   # ISOlat1: LATIN CAPITAL LETTER O WITH DIAERESIS
    $line =~ s/\\\|\[times\]\\\|/&times;/g;  # ISOnum : MULTIPLICATION SIGN
    $line =~ s/\\\|\[Oslash\]\\\|/&Oslash;/g; # ISOlat1: LATIN CAPITAL LETTER O WITH STROKE
    $line =~ s/\\\|\[Ugrave\]\\\|/&Ugrave;/g; # ISOlat1: LATIN CAPITAL LETTER U WITH GRAVE
    $line =~ s/\\\|\[Uacute\]\\\|/&Uacute;/g; # ISOlat1: LATIN CAPITAL LETTER U WITH ACUTE
    $line =~ s/\\\|\[Ucirc\]\\\|/&Ucirc;/g;  # ISOlat1: LATIN CAPITAL LETTER U WITH CIRCUMFLEX
    $line =~ s/\\\|\[Uuml\]\\\|/&Uuml;/g;   # ISOlat1: LATIN CAPITAL LETTER U WITH DIAERESIS
    $line =~ s/\\\|\[Yacute\]\\\|/&Yacute;/g; # ISOlat1: LATIN CAPITAL LETTER Y WITH ACUTE
    $line =~ s/\\\|\[THORN\]\\\|/&THORN;/g;  # ISOlat1: LATIN CAPITAL LETTER THORN (Icelandic)
    $line =~ s/\\\|\[szlig\]\\\|/&szlig;/g;  # ISOlat1: LATIN SMALL LETTER SHARP S (German)
    $line =~ s/\\\|\[agrave\]\\\|/&agrave;/g; # ISOlat1: LATIN SMALL LETTER A WITH GRAVE
    $line =~ s/\\\|\[aacute\]\\\|/&aacute;/g; # ISOlat1: LATIN SMALL LETTER A WITH ACUTE
    $line =~ s/\\\|\[acirc\]\\\|/&acirc;/g;  # ISOlat1: LATIN SMALL LETTER A WITH CIRCUMFLEX
    $line =~ s/\\\|\[atilde\]\\\|/&atilde;/g; # ISOlat1: LATIN SMALL LETTER A WITH TILDE
    $line =~ s/\\\|\[auml\]\\\|/&auml;/g;   # ISOlat1: LATIN SMALL LETTER A WITH DIAERESIS
    $line =~ s/\\\|\[aring\]\\\|/&aring;/g;  # ISOlat1: LATIN SMALL LETTER A WITH RING ABOVE
    $line =~ s/\\\|\[aelig\]\\\|/&aelig;/g;  # ISOlat1: LATIN SMALL LETTER AE
    $line =~ s/\\\|\[ccedil\]\\\|/&ccedil;/g; # ISOlat1: LATIN SMALL LETTER C WITH CEDILLA
    $line =~ s/\\\|\[egrave\]\\\|/&egrave;/g; # ISOlat1: LATIN SMALL LETTER E WITH GRAVE
    $line =~ s/\\\|\[eacute\]\\\|/&eacute;/g; # ISOlat1: LATIN SMALL LETTER E WITH ACUTE
    $line =~ s/\\\|\[ecirc\]\\\|/&ecirc;/g;  # ISOlat1: LATIN SMALL LETTER E WITH CIRCUMFLEX
    $line =~ s/\\\|\[euml\]\\\|/&euml;/g;   # ISOlat1: LATIN SMALL LETTER E WITH DIAERESIS
    $line =~ s/\\\|\[igrave\]\\\|/&igrave;/g; # ISOlat1: LATIN SMALL LETTER I WITH GRAVE
    $line =~ s/\\\|\[iacute\]\\\|/&iacute;/g; # ISOlat1: LATIN SMALL LETTER I WITH ACUTE
    $line =~ s/\\\|\[icirc\]\\\|/&icirc;/g;  # ISOlat1: LATIN SMALL LETTER I WITH CIRCUMFLEX
    $line =~ s/\\\|\[iuml\]\\\|/&iuml;/g;   # ISOlat1: LATIN SMALL LETTER I WITH DIAERESIS
    $line =~ s/\\\|\[eth\]\\\|/&eth;/g;    # ISOlat1: LATIN SMALL LETTER ETH (Icelandic)
    $line =~ s/\\\|\[ntilde\]\\\|/&ntilde;/g; # ISOlat1: LATIN SMALL LETTER N WITH TILDE
    $line =~ s/\\\|\[ograve\]\\\|/&ograve;/g; # ISOlat1: LATIN SMALL LETTER O WITH GRAVE
    $line =~ s/\\\|\[oacute\]\\\|/&oacute;/g; # ISOlat1: LATIN SMALL LETTER O WITH ACUTE
    $line =~ s/\\\|\[ocirc\]\\\|/&ocirc;/g;  # ISOlat1: LATIN SMALL LETTER O WITH CIRCUMFLEX
    $line =~ s/\\\|\[otilde\]\\\|/&otilde;/g; # ISOlat1: LATIN SMALL LETTER O WITH TILDE
    $line =~ s/\\\|\[ouml\]\\\|/&ouml;/g;   # ISOlat1: LATIN SMALL LETTER O WITH DIAERESIS
    $line =~ s/\\\|\[divide\]\\\|/&divide;/g; # ISOnum : DIVISION SIGN
    $line =~ s/\\\|\[oslash\]\\\|/&oslash;/g; # ISOlat1: LATIN SMALL LETTER O WITH STROKE
    $line =~ s/\\\|\[ugrave\]\\\|/&ugrave;/g; # ISOlat1: LATIN SMALL LETTER U WITH GRAVE
    $line =~ s/\\\|\[uacute\]\\\|/&uacute;/g; # ISOlat1: LATIN SMALL LETTER U WITH ACUTE
    $line =~ s/\\\|\[ucirc\]\\\|/&ucirc;/g;  # ISOlat1: LATIN SMALL LETTER U WITH CIRCUMFLEX
    $line =~ s/\\\|\[uuml\]\\\|/&uuml;/g;   # ISOlat1: LATIN SMALL LETTER U WITH DIAERESIS
    $line =~ s/\\\|\[yacute\]\\\|/&yacute;/g; # ISOlat1: LATIN SMALL LETTER Y WITH ACUTE
    $line =~ s/\\\|\[thorn\]\\\|/&thorn;/g;  # ISOlat1: LATIN SMALL LETTER THORN (Icelandic)
    $line =~ s/\\\|\[yuml\]\\\|/&yuml;/g;   # ISOlat1: LATIN SMALL LETTER Y WITH DIAERESIS
    #
    # <!ENTITY % HTMLspecial PUBLIC "-//W3C//ENTITIES Special//EN//HTML">
    #
    $line =~ s/\\\|\[OElig\]\\\|/&OElig;/g;  # ISOlat2: latin capital ligature OE
    $line =~ s/\\\|\[oelig\]\\\|/&oelig;/g;  # ISOlat2: latin small ligature oe
    $line =~ s/\\\|\[Scaron\]\\\|/&Scaron;/g;  # ISOlat2: latin capital letter S with caron
    $line =~ s/\\\|\[scaron\]\\\|/&scaron;/g;  # ISOlat2: latin small letter s with caron
    $line =~ s/\\\|\[Yuml\]\\\|/&Yuml;/g;  # ISOlat2: latin capital letter Y with diaeresis
    $line =~ s/\\\|\[circ\]\\\|/&circ;/g;  # ISOpub : modifier letter circumflex accent
    $line =~ s/\\\|\[tilde\]\\\|/&tilde;/g;  # ISOdia : small tilde
    $line =~ s/\\\|\[ensp\]\\\|/&ensp;/g;  # ISOpub : en space
    $line =~ s/\\\|\[emsp\]\\\|/&emsp;/g;  # ISOpub : em space
    $line =~ s/\\\|\[thinsp\]\\\|/&thinsp;/g;  # ISOpub : thin space
    $line =~ s/\\\|\[zwnj\]\\\|/&zwnj;/g;  # NEW RFC 2070: zero width non-joiner
    $line =~ s/\\\|\[zwj\]\\\|/&zwj;/g;  # NEW RFC 2070: zero width joiner
    $line =~ s/\\\|\[lrm\]\\\|/&lrm;/g;  # NEW RFC 2070: left-to-right mark
    $line =~ s/\\\|\[rlm\]\\\|/&rlm;/g;  # NEW RFC 2070: right-to-left mark
    $line =~ s/\\\|\[ndash\]\\\|/&ndash;/g;  # ISOpub : en dash
    $line =~ s/\\\|\[mdash\]\\\|/&mdash;/g;  # ISOpub : em dash
    $line =~ s/\\\|\[lsquo\]\\\|/&lsquo;/g;  # ISOnum : left single quotation mark
    $line =~ s/\\\|\[rsquo\]\\\|/&rsquo;/g;  # ISOnum : right single quotation mark
    $line =~ s/\\\|\[sbquo\]\\\|/&sbquo;/g;  # NEW: single low-9 quotation mark
    $line =~ s/\\\|\[ldquo\]\\\|/&ldquo;/g;  # ISOnum: left double quotation mark
    $line =~ s/\\\|\[rdquo\]\\\|/&rdquo;/g;  # ISOnum: right double quotation mark
    $line =~ s/\\\|\[bdquo\]\\\|/&bdquo;/g;  # NEW: double low-9 quotation mark
    $line =~ s/\\\|\[dagger\]\\\|/&dagger;/g;  # ISOpub: dagger
    $line =~ s/\\\|\[Dagger\]\\\|/&Dagger;/g;  # ISOpub: double dagger
    $line =~ s/\\\|\[permil\]\\\|/&permil;/g;  # ISOtech: per mille sign
    $line =~ s/\\\|\[lsaquo\]\\\|/&lsaquo;/g;  # ISO proposed: single left-pointing angle quotation mark
    $line =~ s/\\\|\[rsaquo\]\\\|/&rsaquo;/g;  # ISO proposed: single right-pointing angle quotation mark
    $line =~ s/\\\|\[euro\]\\\|/&euro;/g;  # NEW: euro sign
    #
    # <!ENTITY % HTMLsymbol PUBLIC "-//W3C//ENTITIES Symbols//EN//HTML">
    #
    $line =~ s/\\\|\[fnof\]\\\|/&fnof;/g;  # ISOtech: latin small f with hook = function = florin
    $line =~ s/\\\|\[Alpha\]\\\|/&Alpha;/g;  # : greek capital letter alpha
    $line =~ s/\\\|\[Beta\]\\\|/&Beta;/g;  # : greek capital letter beta
    $line =~ s/\\\|\[Gamma\]\\\|/&Gamma;/g;  # ISOgrk3 : greek capital letter gamma
    $line =~ s/\\\|\[Delta\]\\\|/&Delta;/g;  # ISOgrk3 : greek capital letter delta
    $line =~ s/\\\|\[Epsilon\]\\\|/&Epsilon;/g;  # : greek capital letter epsilon
    $line =~ s/\\\|\[Zeta\]\\\|/&Zeta;/g;  # : greek capital letter zeta
    $line =~ s/\\\|\[Eta\]\\\|/&Eta;/g;  # : greek capital letter eta
    $line =~ s/\\\|\[Theta\]\\\|/&Theta;/g;  # ISOgrk3 : greek capital letter theta
    $line =~ s/\\\|\[Iota\]\\\|/&Iota;/g;  # : greek capital letter iota
    $line =~ s/\\\|\[Kappa\]\\\|/&Kappa;/g;  # : greek capital letter kappa
    $line =~ s/\\\|\[Lambda\]\\\|/&Lambda;/g;  # ISOgrk3 : greek capital letter lambda
    $line =~ s/\\\|\[Mu\]\\\|/&Mu;/g;  # : greek capital letter mu
    $line =~ s/\\\|\[Nu\]\\\|/&Nu;/g;  # : greek capital letter nu
    $line =~ s/\\\|\[Xi\]\\\|/&Xi;/g;  # ISOgrk3 : greek capital letter xi
    $line =~ s/\\\|\[Omicron\]\\\|/&Omicron;/g;  # : greek capital letter omicron
    $line =~ s/\\\|\[Pi\]\\\|/&Pi;/g;  # ISOgrk3 : greek capital letter pi
    $line =~ s/\\\|\[Rho\]\\\|/&Rho;/g;  # : greek capital letter rho
    $line =~ s/\\\|\[Sigma\]\\\|/&Sigma;/g;  # ISOgrk3 : greek capital letter sigma
    $line =~ s/\\\|\[Tau\]\\\|/&Tau;/g;  # : greek capital letter tau
    $line =~ s/\\\|\[Upsilon\]\\\|/&Upsilon;/g;  # ISOgrk3 : greek capital letter upsilon
    $line =~ s/\\\|\[Phi\]\\\|/&Phi;/g;  # ISOgrk3 : greek capital letter phi
    $line =~ s/\\\|\[Chi\]\\\|/&Chi;/g;  # : greek capital letter chi
    $line =~ s/\\\|\[Psi\]\\\|/&Psi;/g;  # ISOgrk3 : greek capital letter psi
    $line =~ s/\\\|\[Omega\]\\\|/&Omega;/g;  # ISOgrk3 : greek capital letter omega
    $line =~ s/\\\|\[alpha\]\\\|/&alpha;/g;  # ISOgrk3 : greek small letter alpha
    $line =~ s/\\\|\[beta\]\\\|/&beta;/g;  # ISOgrk3 : greek small letter beta
    $line =~ s/\\\|\[gamma\]\\\|/&gamma;/g;  # ISOgrk3 : greek small letter gamma
    $line =~ s/\\\|\[delta\]\\\|/&delta;/g;  # ISOgrk3 : greek small letter delta
    $line =~ s/\\\|\[epsilon\]\\\|/&epsilon;/g;  # ISOgrk3 : greek small letter epsilon
    $line =~ s/\\\|\[zeta\]\\\|/&zeta;/g;  # ISOgrk3 : greek small letter zeta
    $line =~ s/\\\|\[eta\]\\\|/&eta;/g;  # ISOgrk3 : greek small letter eta
    $line =~ s/\\\|\[theta\]\\\|/&theta;/g;  # ISOgrk3 : greek small letter theta
    $line =~ s/\\\|\[iota\]\\\|/&iota;/g;  # ISOgrk3 : greek small letter iota
    $line =~ s/\\\|\[kappa\]\\\|/&kappa;/g;  # ISOgrk3 : greek small letter kappa
    $line =~ s/\\\|\[lambda\]\\\|/&lambda;/g;  # ISOgrk3 : greek small letter lambda
    $line =~ s/\\\|\[mu\]\\\|/&mu;/g;  # ISOgrk3 : greek small letter mu
    $line =~ s/\\\|\[nu\]\\\|/&nu;/g;  # ISOgrk3 : greek small letter nu
    $line =~ s/\\\|\[xi\]\\\|/&xi;/g;  # ISOgrk3 : greek small letter xi
    $line =~ s/\\\|\[omicron\]\\\|/&omicron;/g;  # NEW : greek small letter omicron
    $line =~ s/\\\|\[pi\]\\\|/&pi;/g;  # ISOgrk3 : greek small letter pi
    $line =~ s/\\\|\[rho\]\\\|/&rho;/g;  # ISOgrk3 : greek small letter rho
    $line =~ s/\\\|\[sigmaf\]\\\|/&sigmaf;/g;  # ISOgrk3 : greek small letter final sigma
    $line =~ s/\\\|\[sigma\]\\\|/&sigma;/g;  # ISOgrk3 : greek small letter sigma
    $line =~ s/\\\|\[tau\]\\\|/&tau;/g;  # ISOgrk3 : greek small letter tau
    $line =~ s/\\\|\[upsilon\]\\\|/&upsilon;/g;  # ISOgrk3 : greek small letter upsilon
    $line =~ s/\\\|\[phi\]\\\|/&phi;/g;  # ISOgrk3 : greek small letter phi
    $line =~ s/\\\|\[chi\]\\\|/&chi;/g;  # ISOgrk3 : greek small letter chi
    $line =~ s/\\\|\[psi\]\\\|/&psi;/g;  # ISOgrk3 : greek small letter psi
    $line =~ s/\\\|\[omega\]\\\|/&omega;/g;  # ISOgrk3 : greek small letter omega
    $line =~ s/\\\|\[thetasym\]\\\|/&thetasym;/g;  # NEW : greek small letter theta symbol
    $line =~ s/\\\|\[upsih\]\\\|/&upsih;/g;  # NEW : greek upsilon with hook symbol
    $line =~ s/\\\|\[piv\]\\\|/&piv;/g;  # ISOgrk3 : greek pi symbol
    $line =~ s/\\\|\[bull\]\\\|/&bull;/g;  # ISOpub  : bullet = black small circle
    $line =~ s/\\\|\[hellip\]\\\|/&hellip;/g;  # ISOpub  : horizontal ellipsis = three dot leader
    $line =~ s/\\\|\[prime\]\\\|/&prime;/g;  # ISOtech : prime = minutes = feet
    $line =~ s/\\\|\[Prime\]\\\|/&Prime;/g;  # ISOtech : double prime = seconds = inches
    $line =~ s/\\\|\[oline\]\\\|/&oline;/g;  # NEW : overline = spacing overscore
    $line =~ s/\\\|\[frasl\]\\\|/&frasl;/g;  # NEW : fraction slash
    $line =~ s/\\\|\[weierp\]\\\|/&weierp;/g;  # ISOamso : script capital P = power set  = Weierstrass p
    $line =~ s/\\\|\[image\]\\\|/&image;/g;  # ISOamso : blackletter capital I = imaginary part
    $line =~ s/\\\|\[real\]\\\|/&real;/g;  # ISOamso : blackletter capital R = real part symbol
    $line =~ s/\\\|\[trade\]\\\|/&trade;/g;  # ISOnum : trade mark sign
    $line =~ s/\\\|\[alefsym\]\\\|/&alefsym;/g;  # NEW : alef symbol = first transfinite cardinal
    $line =~ s/\\\|\[larr\]\\\|/&larr;/g;  # ISOnum : leftwards arrow
    $line =~ s/\\\|\[uarr\]\\\|/&uarr;/g;  # ISOnum: upwards arrow
    $line =~ s/\\\|\[rarr\]\\\|/&rarr;/g;  # ISOnum : rightwards arrow
    $line =~ s/\\\|\[darr\]\\\|/&darr;/g;  # ISOnum : downwards arrow
    $line =~ s/\\\|\[harr\]\\\|/&harr;/g;  # ISOamsa : left right arrow
    $line =~ s/\\\|\[crarr\]\\\|/&crarr;/g;  # NEW : downwards arrow with corner leftwards  = carriage return
    $line =~ s/\\\|\[lArr\]\\\|/&lArr;/g;  # ISOtech : leftwards double arrow
    $line =~ s/\\\|\[uArr\]\\\|/&uArr;/g;  # ISOamsa : upwards double arrow
    $line =~ s/\\\|\[rArr\]\\\|/&rArr;/g;  # ISOtech : rightwards double arrow
    $line =~ s/\\\|\[dArr\]\\\|/&dArr;/g;  # ISOamsa : downwards double arrow
    $line =~ s/\\\|\[hArr\]\\\|/&hArr;/g;  # ISOamsa : left right double arrow
    $line =~ s/\\\|\[forall\]\\\|/&forall;/g;  # ISOtech : for all
    $line =~ s/\\\|\[part\]\\\|/&part;/g;  # ISOtech  : partial differential
    $line =~ s/\\\|\[exist\]\\\|/&exist;/g;  # ISOtech : there exists
    $line =~ s/\\\|\[empty\]\\\|/&empty;/g;  # ISOamso : empty set = null set = diameter
    $line =~ s/\\\|\[nabla\]\\\|/&nabla;/g;  # ISOtech : nabla = backward difference
    $line =~ s/\\\|\[isin\]\\\|/&isin;/g;  # ISOtech : element of
    $line =~ s/\\\|\[notin\]\\\|/&notin;/g;  # ISOtech : not an element of
    $line =~ s/\\\|\[ni\]\\\|/&ni;/g;  # ISOtech : contains as member
    $line =~ s/\\\|\[prod\]\\\|/&prod;/g;  # ISOamsb : n-ary product = product sign
    $line =~ s/\\\|\[sum\]\\\|/&sum;/g;  # ISOamsb : n-ary sumation
    #$line =~ s/\\\|\[minus\]\\\|/&minus;/g;  # ISOtech : minus sign
    $line =~ s/\\\|\[minus\]\\\|/-/g;        # ISOtech: MINUS SIGN
    $line =~ s/\\\|\[lowast\]\\\|/&lowast;/g;  # ISOtech : asterisk operator
    $line =~ s/\\\|\[radic\]\\\|/&radic;/g;  # ISOtech : square root = radical sign
    $line =~ s/\\\|\[prop\]\\\|/&prop;/g;  # ISOtech : proportional to
    $line =~ s/\\\|\[infin\]\\\|/&infin;/g;  # ISOtech : infinity
    $line =~ s/\\\|\[ang\]\\\|/&ang;/g;  # ISOamso : angle
    $line =~ s/\\\|\[and\]\\\|/&and;/g;  # ISOtech : logical and = wedge
    $line =~ s/\\\|\[or\]\\\|/&or;/g;  # ISOtech : logical or = vee
    $line =~ s/\\\|\[cap\]\\\|/&cap;/g;  # ISOtech : intersection = cap
    $line =~ s/\\\|\[cup\]\\\|/&cup;/g;  # ISOtech : union = cup
    $line =~ s/\\\|\[int\]\\\|/&int;/g;  # ISOtech : integral
    $line =~ s/\\\|\[there4\]\\\|/&there4;/g;  # ISOtech : therefore
    $line =~ s/\\\|\[sim\]\\\|/&sim;/g;  # ISOtech : tilde operator = varies with = similar to
    $line =~ s/\\\|\[cong\]\\\|/&cong;/g;  # ISOtech : approximately equal to
    $line =~ s/\\\|\[asymp\]\\\|/&asymp;/g;  # ISOamsr : almost equal to = asymptotic to
    $line =~ s/\\\|\[ne\]\\\|/&ne;/g;  # ISOtech : not equal to
    $line =~ s/\\\|\[equiv\]\\\|/&equiv;/g;  # ISOtech : identical to
    $line =~ s/\\\|\[le\]\\\|/&le;/g;  # ISOtech : less-than or equal to
    $line =~ s/\\\|\[ge\]\\\|/&ge;/g;  # ISOtech : greater-than or equal to
    $line =~ s/\\\|\[sub\]\\\|/&sub;/g;  # ISOtech : subset of
    $line =~ s/\\\|\[sup\]\\\|/&sup;/g;  # ISOtech : superset of
    $line =~ s/\\\|\[nsub\]\\\|/&nsub;/g;  # ISOamsn : not a subset of
    $line =~ s/\\\|\[sube\]\\\|/&sube;/g;  # ISOtech : subset of or equal to
    $line =~ s/\\\|\[supe\]\\\|/&supe;/g;  # ISOtech : superset of or equal to
    $line =~ s/\\\|\[oplus\]\\\|/&oplus;/g;  # ISOamsb : circled plus = direct sum
    $line =~ s/\\\|\[otimes\]\\\|/&otimes;/g;  # ISOamsb : circled times = vector product
    $line =~ s/\\\|\[perp\]\\\|/&perp;/g;  # ISOtech : up tack = orthogonal to = perpendicular
    $line =~ s/\\\|\[sdot\]\\\|/&sdot;/g;  # ISOamsb : dot operator
    $line =~ s/\\\|\[lceil\]\\\|/&lceil;/g;  # ISOamsc  : left ceiling = apl upstile
    $line =~ s/\\\|\[rceil\]\\\|/&rceil;/g;  # ISOamsc  : right ceiling
    $line =~ s/\\\|\[lfloor\]\\\|/&lfloor;/g;  # ISOamsc  : left floor = apl downstile
    $line =~ s/\\\|\[rfloor\]\\\|/&rfloor;/g;  # ISOamsc  : right floor
    $line =~ s/\\\|\[lang\]\\\|/&lang;/g;  # ISOtech : left-pointing angle bracket = bra
    $line =~ s/\\\|\[rang\]\\\|/&rang;/g;  # ISOtech : right-pointing angle bracket = ket
    $line =~ s/\\\|\[loz\]\\\|/&loz;/g;  # ISOpub : lozenge
    $line =~ s/\\\|\[spades\]\\\|/&spades;/g;  # ISOpub : black spade suit
    $line =~ s/\\\|\[clubs\]\\\|/&clubs;/g;  # ISOpub : black club suit = shamrock
    $line =~ s/\\\|\[hearts\]\\\|/&hearts;/g;  # ISOpub : black heart suit = valentine
    $line =~ s/\\\|\[diams\]\\\|/&diams;/g;  # ISOpub : black diamond suit
    #
    # Known entities translated into numbers.
    # May be redundant.
    #
    # <!ENTITY % ISOpub PUBLIC "ISO 8879:1986//ENTITIES Publishing//EN">
    #
    $line =~ s/\\\|\[emsp\]\\\|/&\#x2003;/g;        # em space
    $line =~ s/\\\|\[ensp\]\\\|/&\#x2002;/g;        # en space
    $line =~ s/\\\|\[emsp3\]\\\|/&\#x2004;/g;        # =1/3-em space
    $line =~ s/\\\|\[emsp4\]\\\|/&\#x2005;/g;        # =1/4-em space
    $line =~ s/\\\|\[numsp\]\\\|/&\#x2007;/g;        # =digit space (width of a number)
    $line =~ s/\\\|\[puncsp\]\\\|/&\#x2008;/g;        # =punctuation space (width of comma)
    $line =~ s/\\\|\[thinsp\]\\\|/&\#x2009;/g;        # thin space
    $line =~ s/\\\|\[hairsp\]\\\|/&\#x200A;/g;        # =hair space
    $line =~ s/\\\|\[mdash\]\\\|/&\#x2014;/g;        # em dash
    $line =~ s/\\\|\[ndash\]\\\|/&\#x2013;/g;        # en dash
    $line =~ s/\\\|\[dash\]\\\|/&\#x2010;/g;        # =hyphen (true graphic)
    $line =~ s/\\\|\[blank\]\\\|/&\#x2423;/g;        # =significant blank symbol
    $line =~ s/\\\|\[hellip\]\\\|/&\#x2026;/g;        # horizontal ellipsis = three dot leader
    $line =~ s/\\\|\[nldr\]\\\|/&\#x2025;/g;        # =double baseline dot (en leader)
    $line =~ s/\\\|\[frac13\]\\\|/&\#x2153;/g;        # =fraction one-third
    $line =~ s/\\\|\[frac23\]\\\|/&\#x2154;/g;        # =fraction two-thirds
    $line =~ s/\\\|\[frac15\]\\\|/&\#x2155;/g;        # =fraction one-fifth
    $line =~ s/\\\|\[frac25\]\\\|/&\#x2156;/g;        # =fraction two-fifths
    $line =~ s/\\\|\[frac35\]\\\|/&\#x2157;/g;        # =fraction three-fifths
    $line =~ s/\\\|\[frac45\]\\\|/&\#x2158;/g;        # =fraction four-fifths
    $line =~ s/\\\|\[frac16\]\\\|/&\#x2159;/g;        # =fraction one-sixth
    $line =~ s/\\\|\[frac56\]\\\|/&\#x215A;/g;        # =fraction five-sixths
    $line =~ s/\\\|\[incare\]\\\|/&\#x2105;/g;        # =in-care-of symbol
    $line =~ s/\\\|\[block\]\\\|/&\#x2588;/g;        # =full block
    $line =~ s/\\\|\[uhblk\]\\\|/&\#x2580;/g;        # =upper half block
    $line =~ s/\\\|\[lhblk\]\\\|/&\#x2584;/g;        # =lower half block
    $line =~ s/\\\|\[blk14\]\\\|/&\#x2591;/g;        # =25% shaded block
    $line =~ s/\\\|\[blk12\]\\\|/&\#x2592;/g;        # =50% shaded block
    $line =~ s/\\\|\[blk34\]\\\|/&\#x2593;/g;        # =75% shaded block
    $line =~ s/\\\|\[marker\]\\\|/&\#x25AE;/g;        # =histogram marker
    $line =~ s/\\\|\[cir\]\\\|/&\#x25CB;/g;        # /circ B: =circle, open
    $line =~ s/\\\|\[squ\]\\\|/&\#x25A1;/g;        # =square, open
    $line =~ s/\\\|\[rect\]\\\|/&\#x25AD;/g;        # =rectangle, open
    $line =~ s/\\\|\[utri\]\\\|/&\#x25B5;/g;        # /triangle =up triangle, open
    $line =~ s/\\\|\[dtri\]\\\|/&\#x25BF;/g;        # /triangledown =down triangle, open
    $line =~ s/\\\|\[star\]\\\|/&\#x2606;/g;        # =star, open
    $line =~ s/\\\|\[bull\]\\\|/&\#x2022;/g;        # bullet = black small circle
    $line =~ s/\\\|\[squf\]\\\|/&\#x25AA;/g;        # /blacksquare, square, filled
    $line =~ s/\\\|\[utrif\]\\\|/&\#x25B4;/g;        # /blacktriangle =up tri, filled
    $line =~ s/\\\|\[dtrif\]\\\|/&\#x25BE;/g;        # /blacktriangledown =dn tri, filled
    $line =~ s/\\\|\[ltrif\]\\\|/&\#x25C2;/g;        # /blacktriangleleft R: =l tri, filled
    $line =~ s/\\\|\[rtrif\]\\\|/&\#x25B8;/g;        # /blacktriangleright R: =r tri, filled
    $line =~ s/\\\|\[clubs\]\\\|/&\#x2663;/g;        # black club suit = shamrock
    $line =~ s/\\\|\[diams\]\\\|/&\#x2666;/g;        # black diamond suit
    $line =~ s/\\\|\[hearts\]\\\|/&\#x2665;/g;        # black heart suit = valentine
    $line =~ s/\\\|\[spades\]\\\|/&\#x2660;/g;        # black spade suit
    $line =~ s/\\\|\[malt\]\\\|/&\#x2720;/g;        # /maltese =maltese cross
    $line =~ s/\\\|\[dagger\]\\\|/&\#x2020;/g;        # dagger
    $line =~ s/\\\|\[Dagger\]\\\|/&\#x2021;/g;        # double dagger
    $line =~ s/\\\|\[check\]\\\|/&\#x2713;/g;        # /checkmark =tick, check mark
    $line =~ s/\\\|\[ballot\]\\\|/&\#x2717;/g;        # =ballot cross
    $line =~ s/\\\|\[sharp\]\\\|/&\#x266F;/g;        # /sharp =musical sharp
    $line =~ s/\\\|\[flat\]\\\|/&\#x266D;/g;        # /flat =musical flat
    $line =~ s/\\\|\[male\]\\\|/&\#x2642;/g;        # =male symbol
    $line =~ s/\\\|\[female\]\\\|/&\#x2640;/g;        # =female symbol
    $line =~ s/\\\|\[phone\]\\\|/&\#x260E;/g;        # =telephone symbol
    $line =~ s/\\\|\[telrec\]\\\|/&\#x2315;/g;        # =telephone recorder symbol
    $line =~ s/\\\|\[copysr\]\\\|/&\#x2117;/g;        # =sound recording copyright sign
    $line =~ s/\\\|\[caret\]\\\|/&\#x2041;/g;        # =caret (insertion mark)
    $line =~ s/\\\|\[lsquor\]\\\|/&\#x201A;/g;        # single low-9 quotation mark
    $line =~ s/\\\|\[ldquor\]\\\|/&\#x201E;/g;        # double low-9 quotation mark
    $line =~ s/\\\|\[fflig\]\\\|/&\#xFB00;/g;        # small ff ligature
    $line =~ s/\\\|\[filig\]\\\|/&\#xFB01;/g;        # small fi ligature
    $line =~ s/\\\|\[fjlig\]\\\|/fj/g;          # small fj ligature
    $line =~ s/\\\|\[ffilig\]\\\|/&\#xFB03;/g;        # small ffi ligature
    $line =~ s/\\\|\[ffllig\]\\\|/&\#xFB04;/g;        # small ffl ligature
    $line =~ s/\\\|\[fllig\]\\\|/&\#xFB02;/g;        # small fl ligature
    $line =~ s/\\\|\[mldr\]\\\|/&\#x2026;/g;        # em leader
    $line =~ s/\\\|\[rdquor\]\\\|/&\#x201F;/g;        # rising dbl quote, right (high)
    $line =~ s/\\\|\[rsquor\]\\\|/&\#x201B;/g;        # rising single quote, right (high)
    $line =~ s/\\\|\[vellip\]\\\|/&\#x22EE;/g;        # vertical ellipsis
    $line =~ s/\\\|\[hybull\]\\\|/&\#x2043;/g;        # rectangle, filled (hyphen bullet)
    $line =~ s/\\\|\[loz\]\\\|/&\#x25CA;/g;        # lozenge
    $line =~ s/\\\|\[lozf\]\\\|/&\#x29EB;/g;        # /blacklozenge - lozenge, filled
    $line =~ s/\\\|\[ltri\]\\\|/&\#x25C3;/g;        # /triangleleft B: l triangle, open
    $line =~ s/\\\|\[rtri\]\\\|/&\#x25B9;/g;        # /triangleright B: r triangle, open
    $line =~ s/\\\|\[starf\]\\\|/&\#x2605;/g;        # /bigstar - star, filled
    $line =~ s/\\\|\[natur\]\\\|/&\#x266E;/g;        # /natural - music natural
    $line =~ s/\\\|\[rx\]\\\|/&\#x211E;/g;        # pharmaceutical prescription (Rx)
    $line =~ s/\\\|\[sext\]\\\|/&\#x2736;/g;        # sextile (6-pointed star)
    $line =~ s/\\\|\[target\]\\\|/&\#x2316;/g;        # register mark or target
    $line =~ s/\\\|\[dlcrop\]\\\|/&\#x230D;/g;        # downward left crop mark
    $line =~ s/\\\|\[drcrop\]\\\|/&\#x230C;/g;        # downward right crop mark
    $line =~ s/\\\|\[ulcrop\]\\\|/&\#x230F;/g;        # upward left crop mark
    $line =~ s/\\\|\[urcrop\]\\\|/&\#x230E;/g;        # upward right crop mark
    #
    # <!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN">
    #
    $line =~ s/\\\|\[frac12\]\\\|/&\#x00BD;/g;        # vulgar fraction one half = <pnewline>fraction one half
    $line =~ s/\\\|\[frac14\]\\\|/&\#x00BC;/g;        # vulgar fraction one quarter = <pnewline>fraction one quarter
    $line =~ s/\\\|\[frac34\]\\\|/&\#x00BE;/g;        # vulgar fraction three quarters = <pnewline>fraction three quarters
    $line =~ s/\\\|\[frac18\]\\\|/&\#x215B;/g;        # =fraction one-eighth
    $line =~ s/\\\|\[frac38\]\\\|/&\#x215C;/g;        # =fraction three-eighths
    $line =~ s/\\\|\[frac58\]\\\|/&\#x215D;/g;        # =fraction five-eighths
    $line =~ s/\\\|\[frac78\]\\\|/&\#x215E;/g;        # =fraction seven-eighths
    $line =~ s/\\\|\[sup1\]\\\|/&\#x00B9;/g;        # superscript one = superscript digit one
    $line =~ s/\\\|\[sup2\]\\\|/&\#x00B2;/g;        # superscript two = superscript digit two = squared
    $line =~ s/\\\|\[sup3\]\\\|/&\#x00B3;/g;        # superscript three = superscript <pnewline>digit three = cubed
    $line =~ s/\\\|\[plus\]\\\|/&\#x002B;/g;        # =plus sign
    $line =~ s/\\\|\[plusmn\]\\\|/&\#x00B1;/g;        # plus-minus sign = plus-or-minus sign
    $line =~ s/\\\|\[lt\]\\\|/&\#x003C;/g;        # less-than sign
    $line =~ s/\\\|\[equals\]\\\|/&\#x003D;/g;        # =equals sign R:
    $line =~ s/\\\|\[gt\]\\\|/&\#x003E;/g;        # greater-than sign
    $line =~ s/\\\|\[divide\]\\\|/&\#x00F7;/g;        # division sign
    $line =~ s/\\\|\[times\]\\\|/&\#x00D7;/g;        # multiplication sign
    $line =~ s/\\\|\[curren\]\\\|/&\#x00A4;/g;        # currency sign
    $line =~ s/\\\|\[pound\]\\\|/&\#x00A3;/g;        # pound sign
    $line =~ s/\\\|\[dollar\]\\\|/&\#x0024;/g;        # =dollar sign
    $line =~ s/\\\|\[cent\]\\\|/&\#x00A2;/g;        # cent sign
    $line =~ s/\\\|\[yen\]\\\|/&\#x00A5;/g;        # yen sign = yuan sign
    $line =~ s/\\\|\[num\]\\\|/&\#x0023;/g;        # =number sign
    $line =~ s/\\\|\[percnt\]\\\|/&\#x0025;/g;        # =percent sign
    $line =~ s/\\\|\[amp\]\\\|/&\#x0026;/g;        # ampersand
    $line =~ s/\\\|\[ast\]\\\|/&\#x002A;/g;        # /ast B: asterisk
    $line =~ s/\\\|\[commat\]\\\|/&\#x0040;/g;        # =commercial at
    $line =~ s/\\\|\[lsqb\]\\\|/&\#x005B;/g;        # /lbrack O: =left square bracket
    $line =~ s/\\\|\[bsol\]\\\|/&\#x005C;/g;        # /backslash =reverse solidus
    $line =~ s/\\\|\[rsqb\]\\\|/&\#x005D;/g;        # /rbrack C: =right square bracket
    $line =~ s/\\\|\[lcub\]\\\|/&\#x007B;/g;        # /lbrace O: =left curly bracket
    $line =~ s/\\\|\[horbar\]\\\|/&\#x2015;/g;        # =horizontal bar
    $line =~ s/\\\|\[verbar\]\\\|/&\#x007C;/g;        # /vert =vertical bar
    $line =~ s/\\\|\[rcub\]\\\|/&\#x007D;/g;        # /rbrace C: =right curly bracket
    $line =~ s/\\\|\[micro\]\\\|/&\#x00B5;/g;        # micro sign
    $line =~ s/\\\|\[ohm\]\\\|/&\#x2126;/g;        # =ohm sign
    $line =~ s/\\\|\[deg\]\\\|/&\#x00B0;/g;        # degree sign
    $line =~ s/\\\|\[ordm\]\\\|/&\#x00BA;/g;        # masculine ordinal indicator
    $line =~ s/\\\|\[ordf\]\\\|/&\#x00AA;/g;        # feminine ordinal indicator
    $line =~ s/\\\|\[sect\]\\\|/&\#x00A7;/g;        # section sign
    $line =~ s/\\\|\[para\]\\\|/&\#x00B6;/g;        # pilcrow sign = paragraph sign
    $line =~ s/\\\|\[middot\]\\\|/&\#x00B7;/g;        # middle dot = Georgian comma = <pnewline>Greek middle dot
    $line =~ s/\\\|\[larr\]\\\|/&\#x2190;/g;        # leftwards arrow
    $line =~ s/\\\|\[rarr\]\\\|/&\#x2192;/g;        # rightwards arrow
    $line =~ s/\\\|\[uarr\]\\\|/&\#x2191;/g;        # upwards arrow
    $line =~ s/\\\|\[darr\]\\\|/&\#x2193;/g;        # downwards arrow
    $line =~ s/\\\|\[copy\]\\\|/&\#x00A9;/g;        # copyright sign
    $line =~ s/\\\|\[reg\]\\\|/&\#x00AE;/g;        # registered sign = registered <pnewline>trade mark sign
    $line =~ s/\\\|\[trade\]\\\|/&\#x2122;/g;        # trade mark sign
    $line =~ s/\\\|\[brvbar\]\\\|/&\#x00A6;/g;        # broken bar = broken vertical bar
    $line =~ s/\\\|\[not\]\\\|/&\#x00AC;/g;        # not sign
    $line =~ s/\\\|\[sung\]\\\|/&\#x2669;/g;        # =music note (sung text sign)
    $line =~ s/\\\|\[excl\]\\\|/&\#x0021;/g;        # =exclamation mark
    $line =~ s/\\\|\[iexcl\]\\\|/&\#x00A1;/g;        # inverted exclamation mark
    $line =~ s/\\\|\[quot\]\\\|/&\#x0022;/g;        # quotation mark = APL quote
    $line =~ s/\\\|\[apos\]\\\|/&\#x0027;/g;        # =apostrophe
    $line =~ s/\\\|\[lpar\]\\\|/&\#x0028;/g;        # O: =left parenthesis
    $line =~ s/\\\|\[rpar\]\\\|/&\#x0029;/g;        # C: =right parenthesis
    $line =~ s/\\\|\[comma\]\\\|/&\#x002C;/g;        # P: =comma
    $line =~ s/\\\|\[lowbar\]\\\|/&\#x005F;/g;        # =low line
    $line =~ s/\\\|\[hyphen\]\\\|/&\#x002D;/g;        # =hyphen
    $line =~ s/\\\|\[period\]\\\|/&\#x002E;/g;        # =full stop, period
    $line =~ s/\\\|\[sol\]\\\|/&\#x002F;/g;        # =solidus
    $line =~ s/\\\|\[colon\]\\\|/&\#x003A;/g;        # /colon P:
    $line =~ s/\\\|\[semi\]\\\|/&\#x003B;/g;        # =semicolon P:
    $line =~ s/\\\|\[quest\]\\\|/&\#x003F;/g;        # =question mark
    $line =~ s/\\\|\[iquest\]\\\|/&\#x00BF;/g;        # inverted question mark = turned <pnewline>question mark
    $line =~ s/\\\|\[laquo\]\\\|/&\#x00AB;/g;        # left-pointing double angle <pnewline>quotation mark = left pointing guillemet
    $line =~ s/\\\|\[raquo\]\\\|/&\#x00BB;/g;        # right-pointing double angle <pnewline>quotation mark = right pointing guillemet
    $line =~ s/\\\|\[lsquo\]\\\|/&\#x2018;/g;        # left single quotation mark
    $line =~ s/\\\|\[rsquo\]\\\|/&\#x2019;/g;        # right single quotation mark
    $line =~ s/\\\|\[ldquo\]\\\|/&\#x201C;/g;        # left double quotation mark
    $line =~ s/\\\|\[rdquo\]\\\|/&\#x201D;/g;        # right double quotation mark
    $line =~ s/\\\|\[nbsp\]\\\|/&\#x00A0;/g;        # no-break space = non-breaking space
    $line =~ s/\\\|\[shy\]\\\|/&\#x00AD;/g;        # soft hyphen = discretionary hyphen
    #
    # <!ENTITY % ISObox PUBLIC "ISO 8879:1986//ENTITIES Box and Line Drawing//EN">
    #
    $line =~ s/\\\|\[boxh\]\\\|/&\#x2500;/g;        # horizontal line
    $line =~ s/\\\|\[boxv\]\\\|/&\#x2502;/g;        # vertical line
    $line =~ s/\\\|\[boxur\]\\\|/&\#x2514;/g;        # upper right quadrant
    $line =~ s/\\\|\[boxul\]\\\|/&\#x2518;/g;        # upper left quadrant
    $line =~ s/\\\|\[boxdl\]\\\|/&\#x2510;/g;        # lower left quadrant
    $line =~ s/\\\|\[boxdr\]\\\|/&\#x250C;/g;        # lower right quadrant
    $line =~ s/\\\|\[boxvr\]\\\|/&\#x251C;/g;        # upper and lower right quadrants
    $line =~ s/\\\|\[boxhu\]\\\|/&\#x2534;/g;        # upper left and right quadrants
    $line =~ s/\\\|\[boxvl\]\\\|/&\#x2524;/g;        # upper and lower left quadrants
    $line =~ s/\\\|\[boxhd\]\\\|/&\#x252C;/g;        # lower left and right quadrants
    $line =~ s/\\\|\[boxvh\]\\\|/&\#x253C;/g;        # all four quadrants
    $line =~ s/\\\|\[boxvR\]\\\|/&\#x255E;/g;        # upper and lower right quadrants
    $line =~ s/\\\|\[boxhU\]\\\|/&\#x2568;/g;        # upper left and right quadrants
    $line =~ s/\\\|\[boxvL\]\\\|/&\#x2561;/g;        # upper and lower left quadrants
    $line =~ s/\\\|\[boxhD\]\\\|/&\#x2565;/g;        # lower left and right quadrants
    $line =~ s/\\\|\[boxvH\]\\\|/&\#x256A;/g;        # all four quadrants
    $line =~ s/\\\|\[boxH\]\\\|/&\#x2550;/g;        # horizontal line
    $line =~ s/\\\|\[boxV\]\\\|/&\#x2551;/g;        # vertical line
    $line =~ s/\\\|\[boxUR\]\\\|/&\#x255A;/g;        # upper right quadrant
    $line =~ s/\\\|\[boxUL\]\\\|/&\#x255D;/g;        # upper left quadrant
    $line =~ s/\\\|\[boxDL\]\\\|/&\#x2557;/g;        # lower left quadrant
    $line =~ s/\\\|\[boxDR\]\\\|/&\#x2554;/g;        # lower right quadrant
    $line =~ s/\\\|\[boxVR\]\\\|/&\#x2560;/g;        # upper and lower right quadrants
    $line =~ s/\\\|\[boxHU\]\\\|/&\#x2569;/g;        # upper left and right quadrants
    $line =~ s/\\\|\[boxVL\]\\\|/&\#x2563;/g;        # upper and lower left quadrants
    $line =~ s/\\\|\[boxHD\]\\\|/&\#x2566;/g;        # lower left and right quadrants
    $line =~ s/\\\|\[boxVH\]\\\|/&\#x256C;/g;        # all four quadrants
    $line =~ s/\\\|\[boxVr\]\\\|/&\#x255F;/g;        # upper and lower right quadrants
    $line =~ s/\\\|\[boxHu\]\\\|/&\#x2567;/g;        # upper left and right quadrants
    $line =~ s/\\\|\[boxVl\]\\\|/&\#x2562;/g;        # upper and lower left quadrants
    $line =~ s/\\\|\[boxHd\]\\\|/&\#x2564;/g;        # lower left and right quadrants
    $line =~ s/\\\|\[boxVh\]\\\|/&\#x256B;/g;        # all four quadrants
    $line =~ s/\\\|\[boxuR\]\\\|/&\#x2558;/g;        # upper right quadrant
    $line =~ s/\\\|\[boxUl\]\\\|/&\#x255C;/g;        # upper left quadrant
    $line =~ s/\\\|\[boxdL\]\\\|/&\#x2555;/g;        # lower left quadrant
    $line =~ s/\\\|\[boxDr\]\\\|/&\#x2553;/g;        # lower right quadrant
    $line =~ s/\\\|\[boxUr\]\\\|/&\#x2559;/g;        # upper right quadrant
    $line =~ s/\\\|\[boxuL\]\\\|/&\#x255B;/g;        # upper left quadrant
    $line =~ s/\\\|\[boxDl\]\\\|/&\#x2556;/g;        # lower left quadrant
    $line =~ s/\\\|\[boxdR\]\\\|/&\#x2552;/g;        # lower right quadrant
    #
    # <!ENTITY % ISOtech PUBLIC "ISO 8879:1986//ENTITIES General Technical//EN">
    #
    $line =~ s/\\\|\[aleph\]\\\|/&\#x2135;/g;        # alef symbol = first transfinite cardinal
    $line =~ s/\\\|\[and\]\\\|/&\#x2227;/g;        # logical and = wedge
    $line =~ s/\\\|\[ang90\]\\\|/&\#x221F;/g;        # right (90 degree) angle
    $line =~ s/\\\|\[angsph\]\\\|/&\#x2222;/g;        # /sphericalangle angle-spherical
    $line =~ s/\\\|\[ap\]\\\|/&\#x2248;/g;        # /approx R: approximate
    $line =~ s/\\\|\[becaus\]\\\|/&\#x2235;/g;        # /because R: because
    $line =~ s/\\\|\[bottom\]\\\|/&\#x22A5;/g;        # /bot bottom
    $line =~ s/\\\|\[cap\]\\\|/&\#x2229;/g;        # intersection = cap
    $line =~ s/\\\|\[cong\]\\\|/&\#x2245;/g;        # approximately equal to
    $line =~ s/\\\|\[conint\]\\\|/&\#x222E;/g;        # /oint L: contour integral operator
    $line =~ s/\\\|\[cup\]\\\|/&\#x222A;/g;        # union = cup
    $line =~ s/\\\|\[equiv\]\\\|/&\#x2261;/g;        # identical to
    $line =~ s/\\\|\[exist\]\\\|/&\#x2203;/g;        # there exists
    $line =~ s/\\\|\[forall\]\\\|/&\#x2200;/g;        # for all
    $line =~ s/\\\|\[fnof\]\\\|/&\#x0192;/g;        # latin small f with hook = function = florin
    $line =~ s/\\\|\[ge\]\\\|/&\#x2265;/g;        # greater-than or equal to
    $line =~ s/\\\|\[iff\]\\\|/&\#x21D4;/g;        # /iff if and only if
    $line =~ s/\\\|\[infin\]\\\|/&\#x221E;/g;        # infinity
    $line =~ s/\\\|\[int\]\\\|/&\#x222B;/g;        # integral
    $line =~ s/\\\|\[isin\]\\\|/&\#x2208;/g;        # element of
    $line =~ s/\\\|\[lang\]\\\|/&\#x3008;/g;        # left-pointing angle bracket = bra
    $line =~ s/\\\|\[lArr\]\\\|/&\#x21D0;/g;        # leftwards double arrow
    $line =~ s/\\\|\[le\]\\\|/&\#x2264;/g;        # less-than or equal to
    $line =~ s/\\\|\[minus\]\\\|/&\#x2212;/g;        # minus sign
    $line =~ s/\\\|\[mnplus\]\\\|/&\#x2213;/g;        # /mp B: minus-or-plus sign
    $line =~ s/\\\|\[nabla\]\\\|/&\#x2207;/g;        # nabla = backward difference
    $line =~ s/\\\|\[ne\]\\\|/&\#x2260;/g;        # not equal to
    $line =~ s/\\\|\[ni\]\\\|/&\#x220B;/g;        # contains as member
    $line =~ s/\\\|\[or\]\\\|/&\#x2228;/g;        # logical or = vee
    $line =~ s/\\\|\[par\]\\\|/&\#x2225;/g;        # /parallel R: parallel
    $line =~ s/\\\|\[part\]\\\|/&\#x2202;/g;        # partial differential
    $line =~ s/\\\|\[permil\]\\\|/&\#x2030;/g;        # per mille sign
    $line =~ s/\\\|\[perp\]\\\|/&\#x22A5;/g;        # up tack = orthogonal to = perpendicular
    $line =~ s/\\\|\[prime\]\\\|/&\#x2032;/g;        # prime = minutes = feet
    $line =~ s/\\\|\[Prime\]\\\|/&\#x2033;/g;        # double prime = seconds = inches
    $line =~ s/\\\|\[prop\]\\\|/&\#x221D;/g;        # proportional to
    $line =~ s/\\\|\[radic\]\\\|/&\#x221A;/g;        # square root = radical sign
    $line =~ s/\\\|\[rang\]\\\|/&\#x3009;/g;        # right-pointing angle bracket = ket
    $line =~ s/\\\|\[rArr\]\\\|/&\#x21D2;/g;        # rightwards double arrow
    $line =~ s/\\\|\[sim\]\\\|/&\#x223C;/g;        # tilde operator = varies with = similar to
    $line =~ s/\\\|\[sime\]\\\|/&\#x2243;/g;        # /simeq R: similar, equals
    $line =~ s/\\\|\[square\]\\\|/&\#x25A0;/g;        # /square, square
    $line =~ s/\\\|\[sub\]\\\|/&\#x2282;/g;        # subset of
    $line =~ s/\\\|\[sube\]\\\|/&\#x2286;/g;        # subset of or equal to
    $line =~ s/\\\|\[sup\]\\\|/&\#x2283;/g;        # superset of
    $line =~ s/\\\|\[supe\]\\\|/&\#x2287;/g;        # superset of or equal to
    $line =~ s/\\\|\[there4\]\\\|/&\#x2234;/g;        # therefore
    $line =~ s/\\\|\[Verbar\]\\\|/&\#x2016;/g;        # /Vert dbl vertical bar
    $line =~ s/\\\|\[angst\]\\\|/&\#x212B;/g;        # Angstrom capital A, ring
    $line =~ s/\\\|\[bernou\]\\\|/&\#x212C;/g;        # Bernoulli function (script capital B)
    $line =~ s/\\\|\[compfn\]\\\|/&\#x2218;/g;        # /circ B: composite function (small circle)
    $line =~ s/\\\|\[Dot\]\\\|/&\#x00A8;/g;        # dieresis or umlaut mark
    $line =~ s/\\\|\[DotDot\]\\\|/&\#x20DC;/g;        # four dots above
    $line =~ s/\\\|\[hamilt\]\\\|/&\#x210B;/g;        # Hamiltonian (script capital H)
    $line =~ s/\\\|\[lagran\]\\\|/&\#x2112;/g;        # Lagrangian (script capital L)
    $line =~ s/\\\|\[lowast\]\\\|/&\#x2217;/g;        # asterisk operator
    $line =~ s/\\\|\[notin\]\\\|/&\#x2209;/g;        # not an element of
    $line =~ s/\\\|\[order\]\\\|/&\#x2134;/g;        # order of (script small o)
    $line =~ s/\\\|\[phmmat\]\\\|/&\#x2133;/g;        # physics M-matrix (script capital M)
    $line =~ s/\\\|\[tdot\]\\\|/&\#x20DB;/g;        # three dots above
    $line =~ s/\\\|\[tprime\]\\\|/&\#x2034;/g;        # triple prime
    $line =~ s/\\\|\[wedgeq\]\\\|/&\#x2259;/g;        # /wedgeq R: corresponds to (wedge, equals)
    #
    # <!ENTITY % ISOgrk3 PUBLIC "ISO 8879:1986//ENTITIES Greek Symbols//EN">
    #
    $line =~ s/\\\|\[alpha\]\\\|/&\#x03B1;/g;        # greek small letter alpha
    $line =~ s/\\\|\[beta\]\\\|/&\#x03B2;/g;        # greek small letter beta
    $line =~ s/\\\|\[gamma\]\\\|/&\#x03B3;/g;        # greek small letter gamma
    $line =~ s/\\\|\[Gamma\]\\\|/&\#x0393;/g;        # greek capital letter gamma
    $line =~ s/\\\|\[gammad\]\\\|/&\#x03DC;/g;        # /digamma
    $line =~ s/\\\|\[delta\]\\\|/&\#x03B4;/g;        # greek small letter delta
    $line =~ s/\\\|\[Delta\]\\\|/&\#x0394;/g;        # greek capital letter delta
    $line =~ s/\\\|\[epsi\]\\\|/&\#x03B5;/g;        # greek small letter epsilon
    $line =~ s/\\\|\[epsiv\]\\\|/$unknown/g;        # /varepsilon
    $line =~ s/\\\|\[epsi\]\\\|/&\#x220A;/g;        # /straightepsilon, small epsilon, Greek
    $line =~ s/\\\|\[zeta\]\\\|/&\#x03B6;/g;        # greek small letter zeta
    $line =~ s/\\\|\[eta\]\\\|/&\#x03B7;/g;        # greek small letter eta
    $line =~ s/\\\|\[thetas\]\\\|/&\#x03B8;/g;        # greek small letter theta
    $line =~ s/\\\|\[Theta\]\\\|/&\#x0398;/g;        # greek capital letter theta
    $line =~ s/\\\|\[thetav\]\\\|/&\#x03D1;/g;        # greek small letter theta symbol
    $line =~ s/\\\|\[iota\]\\\|/&\#x03B9;/g;        # greek small letter iota
    $line =~ s/\\\|\[kappa\]\\\|/&\#x03BA;/g;        # greek small letter kappa
    $line =~ s/\\\|\[kappav\]\\\|/&\#x03F0;/g;        # /varkappa
    $line =~ s/\\\|\[lambda\]\\\|/&\#x03BB;/g;        # greek small letter lambda
    $line =~ s/\\\|\[Lambda\]\\\|/&\#x039B;/g;        # greek capital letter lambda
    $line =~ s/\\\|\[mu\]\\\|/&\#x03BC;/g;        # greek small letter mu
    $line =~ s/\\\|\[nu\]\\\|/&\#x03BD;/g;        # greek small letter nu
    $line =~ s/\\\|\[xi\]\\\|/&\#x03BE;/g;        # greek small letter xi
    $line =~ s/\\\|\[Xi\]\\\|/&\#x039E;/g;        # greek capital letter xi
    $line =~ s/\\\|\[pi\]\\\|/&\#x03C0;/g;        # greek small letter pi
    $line =~ s/\\\|\[piv\]\\\|/&\#x03D6;/g;        # greek pi symbol
    $line =~ s/\\\|\[Pi\]\\\|/&\#x03A0;/g;        # greek capital letter pi
    $line =~ s/\\\|\[rho\]\\\|/&\#x03C1;/g;        # greek small letter rho
    $line =~ s/\\\|\[rhov\]\\\|/&\#x03F1;/g;        # /varrho
    $line =~ s/\\\|\[sigma\]\\\|/&\#x03C3;/g;        # greek small letter sigma
    $line =~ s/\\\|\[Sigma\]\\\|/&\#x03A3;/g;        # greek capital letter sigma
    $line =~ s/\\\|\[sigmav\]\\\|/&\#x03C2;/g;        # greek small letter final sigma
    $line =~ s/\\\|\[tau\]\\\|/&\#x03C4;/g;        # greek small letter tau
    $line =~ s/\\\|\[upsi\]\\\|/&\#x03C5;/g;        # greek small letter upsilon
    $line =~ s/\\\|\[Upsi\]\\\|/&\#x03D2;/g;        # greek upsilon with hook symbol
    $line =~ s/\\\|\[phis\]\\\|/&\#x03C6;/g;        # greek small letter phi
    $line =~ s/\\\|\[Phi\]\\\|/&\#x03A6;/g;        # greek capital letter phi
    $line =~ s/\\\|\[phiv\]\\\|/&\#x03D5;/g;        # /varphi - curly or open phi
    $line =~ s/\\\|\[chi\]\\\|/&\#x03C7;/g;        # greek small letter chi
    $line =~ s/\\\|\[psi\]\\\|/&\#x03C8;/g;        # greek small letter psi
    $line =~ s/\\\|\[Psi\]\\\|/&\#x03A8;/g;        # greek capital letter psi
    $line =~ s/\\\|\[omega\]\\\|/&\#x03C9;/g;        # greek small letter omega
    $line =~ s/\\\|\[Omega\]\\\|/&\#x03A9;/g;        # greek capital letter omega
    #
    # <!ENTITY % ISOgrk4 PUBLIC "ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN">
    #
    $line =~ s/\\\|\[b\.alpha\]\\\|/&\#x03B1;/g;        # small alpha, Greek
    $line =~ s/\\\|\[b\.beta\]\\\|/&\#x03B2;/g;        # small beta, Greek
    $line =~ s/\\\|\[b\.gamma\]\\\|/&\#x03B3;/g;        # small gamma, Greek
    $line =~ s/\\\|\[b\.Gamma\]\\\|/&\#x0393;/g;        # capital Gamma, Greek
    $line =~ s/\\\|\[b\.gammad\]\\\|/&\#x03DC;/g;        # digamma
    $line =~ s/\\\|\[b\.delta\]\\\|/&\#x03B4;/g;        # small delta, Greek
    $line =~ s/\\\|\[b\.Delta\]\\\|/&\#x0394;/g;        # capital Delta, Greek
    $line =~ s/\\\|\[b\.epsi\]\\\|/&\#x03B5;/g;        # =small epsilon, Greek
    $line =~ s/\\\|\[b\.epsiv\]\\\|/&\#x03B5;/g;        # variant epsilon
    $line =~ s/\\\|\[b\.epsis\]\\\|/&\#x03B5;/g;        # small epsilon, Greek
    $line =~ s/\\\|\[b\.zeta\]\\\|/&\#x03B6;/g;        # small zeta, Greek
    $line =~ s/\\\|\[b\.eta\]\\\|/&\#x03B7;/g;        # small eta, Greek
    $line =~ s/\\\|\[b\.thetas\]\\\|/&\#x03B8;/g;        # straight theta, small theta, Greek
    $line =~ s/\\\|\[b\.Theta\]\\\|/&\#x0398;/g;        # capital Theta, Greek
    $line =~ s/\\\|\[b\.thetav\]\\\|/&\#x03D1;/g;        # variant theta - curly or open theta
    $line =~ s/\\\|\[b\.iota\]\\\|/&\#x03B9;/g;        # small iota, Greek
    $line =~ s/\\\|\[b\.kappa\]\\\|/&\#x03BA;/g;        # small kappa, Greek
    $line =~ s/\\\|\[b\.kappav\]\\\|/&\#x03F0;/g;        # variant kappa
    $line =~ s/\\\|\[b\.lambda\]\\\|/&\#x03BB;/g;        # small lambda, Greek
    $line =~ s/\\\|\[b\.Lambda\]\\\|/&\#x039B;/g;        # capital Lambda, Greek
    $line =~ s/\\\|\[b\.mu\]\\\|/&\#x03BC;/g;        # small mu, Greek
    $line =~ s/\\\|\[b\.nu\]\\\|/&\#x03BD;/g;        # small nu, Greek
    $line =~ s/\\\|\[b\.xi\]\\\|/&\#x03BE;/g;        # small xi, Greek
    $line =~ s/\\\|\[b\.Xi\]\\\|/&\#x039E;/g;        # capital Xi, Greek
    $line =~ s/\\\|\[b\.pi\]\\\|/&\#x03C0;/g;        # small pi, Greek
    $line =~ s/\\\|\[b\.Pi\]\\\|/&\#x03A0;/g;        # capital Pi, Greek
    $line =~ s/\\\|\[b\.piv\]\\\|/&\#x03D6;/g;        # variant pi
    $line =~ s/\\\|\[b\.rho\]\\\|/&\#x03C1;/g;        # small rho, Greek
    $line =~ s/\\\|\[b\.rhov\]\\\|/&\#x03F1;/g;        # variant rho
    $line =~ s/\\\|\[b\.sigma\]\\\|/&\#x03C3;/g;        # small sigma, Greek
    $line =~ s/\\\|\[b\.Sigma\]\\\|/&\#x03A3;/g;        # capital Sigma, Greek
    $line =~ s/\\\|\[b\.sigmav\]\\\|/&\#x03C2;/g;        # variant sigma
    $line =~ s/\\\|\[b\.tau\]\\\|/&\#x03C4;/g;        # small tau, Greek
    $line =~ s/\\\|\[b\.upsi\]\\\|/&\#x03C5;/g;        # small upsilon, Greek
    $line =~ s/\\\|\[b\.Upsi\]\\\|/&\#x03D2;/g;        # capital Upsilon, Greek
    $line =~ s/\\\|\[b\.phis\]\\\|/&\#x03C6;/g;        # straight phi, small phi, Greek
    $line =~ s/\\\|\[b\.Phi\]\\\|/&\#x03A6;/g;        # capital Phi, Greek
    $line =~ s/\\\|\[b\.phiv\]\\\|/&\#x03D5;/g;        # variant phi - curly or open phi
    $line =~ s/\\\|\[b\.chi\]\\\|/&\#x03C7;/g;        # small chi, Greek
    $line =~ s/\\\|\[b\.psi\]\\\|/&\#x03C8;/g;        # small psi, Greek
    $line =~ s/\\\|\[b\.Psi\]\\\|/&\#x03A8;/g;        # capital Psi, Greek
    $line =~ s/\\\|\[b\.omega\]\\\|/&\#x03C9;/g;        # small omega, Greek
    $line =~ s/\\\|\[b\.Omega\]\\\|/&\#x03A9;/g;        # capital Omega, Greek
    #
    # <!ENTITY % ISOamso PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN">
    #
    $line =~ s/\\\|\[ang\]\\\|/&\#x2220;/g;        # angle
    $line =~ s/\\\|\[angmsd\]\\\|/&\#x2221;/g;        # /measuredangle - angle-measured
    $line =~ s/\\\|\[beth\]\\\|/&\#x2136;/g;        # /beth - beth, Hebrew
    $line =~ s/\\\|\[bprime\]\\\|/&\#x2035;/g;        # /backprime - reverse prime
    $line =~ s/\\\|\[comp\]\\\|/&\#x2201;/g;        # /complement - complement sign
    $line =~ s/\\\|\[daleth\]\\\|/&\#x2138;/g;        # /daleth - daleth, Hebrew
    $line =~ s/\\\|\[ell\]\\\|/&\#x2113;/g;        # /ell - cursive small l
    $line =~ s/\\\|\[empty\]\\\|/&\#x2205;/g;        # empty set = null set = diameter
    $line =~ s/\\\|\[gimel\]\\\|/&\#x2137;/g;        # /gimel - gimel, Hebrew
    $line =~ s/\\\|\[image\]\\\|/&\#x2111;/g;        # blackletter capital I = imaginary part
    $line =~ s/\\\|\[inodot\]\\\|/&\#x0131;/g;        # /imath - small i, no dot
    $line =~ s/\\\|\[jnodot\]\\\|/$unknown/g;        # /jmath - small j, no dot
    $line =~ s/\\\|\[nexist\]\\\|/&\#x2204;/g;        # /nexists - negated exists
    $line =~ s/\\\|\[oS\]\\\|/&\#x24C8;/g;        # /circledS - capital S in circle
    $line =~ s/\\\|\[planck\]\\\|/&\#x210F;/g;        # /hbar - Planck's over 2pi
    $line =~ s/\\\|\[real\]\\\|/&\#x211C;/g;        # blackletter capital R = real part symbol
    $line =~ s/\\\|\[sbsol\]\\\|/&\#xFE68;/g;        # /sbs - short reverse solidus
    $line =~ s/\\\|\[vprime\]\\\|/$unknown/g;        # /varprime - prime, variant
    $line =~ s/\\\|\[weierp\]\\\|/&\#x2118;/g;        # script capital P = power set = Weierstrass p
    #
    # <!ENTITY % ISOamsb PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN">
    #
    $line =~ s/\\\|\[amalg\]\\\|/&\#x2210;/g;        # /amalg B: amalgamation or coproduct
    $line =~ s/\\\|\[Barwed\]\\\|/&\#x2306;/g;        # /doublebarwedge B: log and, dbl bar above
    $line =~ s/\\\|\[barwed\]\\\|/&\#x22BC;/g;        # /barwedge B: logical and, bar above
    $line =~ s/\\\|\[Cap\]\\\|/&\#x22D2;/g;        # /Cap /doublecap B: dbl intersection
    $line =~ s/\\\|\[Cup\]\\\|/&\#x22D3;/g;        # /Cup /doublecup B: dbl union
    $line =~ s/\\\|\[cuvee\]\\\|/&\#x22CE;/g;        # /curlyvee B: curly logical or
    $line =~ s/\\\|\[cuwed\]\\\|/&\#x22CF;/g;        # /curlywedge B: curly logical and
    $line =~ s/\\\|\[diam\]\\\|/&\#x22C4;/g;        # /diamond B: open diamond
    $line =~ s/\\\|\[divonx\]\\\|/&\#x22C7;/g;        # /divideontimes B: division on times
    $line =~ s/\\\|\[intcal\]\\\|/&\#x22BA;/g;        # /intercal B: intercal
    $line =~ s/\\\|\[lthree\]\\\|/&\#x22CB;/g;        # /leftthreetimes B:
    $line =~ s/\\\|\[ltimes\]\\\|/&\#x22C9;/g;        # /ltimes B: times sign, left closed
    $line =~ s/\\\|\[minusb\]\\\|/&\#x229F;/g;        # /boxminus B: minus sign in box
    $line =~ s/\\\|\[oast\]\\\|/&\#x229B;/g;        # /circledast B: asterisk in circle
    $line =~ s/\\\|\[ocir\]\\\|/&\#x229A;/g;        # /circledcirc B: small circle in circle
    $line =~ s/\\\|\[odash\]\\\|/&\#x229D;/g;        # /circleddash B: hyphen in circle
    $line =~ s/\\\|\[odot\]\\\|/&\#x2299;/g;        # /odot B: middle dot in circle
    $line =~ s/\\\|\[ominus\]\\\|/&\#x2296;/g;        # /ominus B: minus sign in circle
    $line =~ s/\\\|\[oplus\]\\\|/&\#x2295;/g;        # circled plus = direct sum
    $line =~ s/\\\|\[osol\]\\\|/&\#x2298;/g;        # /oslash B: solidus in circle
    $line =~ s/\\\|\[otimes\]\\\|/&\#x2297;/g;        # circled times = vector product
    $line =~ s/\\\|\[plusb\]\\\|/&\#x229E;/g;        # /boxplus B: plus sign in box
    $line =~ s/\\\|\[plusdo\]\\\|/&\#x2214;/g;        # /dotplus B: plus sign, dot above
    $line =~ s/\\\|\[rthree\]\\\|/&\#x22CC;/g;        # /rightthreetimes B:
    $line =~ s/\\\|\[rtimes\]\\\|/&\#x22CA;/g;        # /rtimes B: times sign, right closed
    $line =~ s/\\\|\[sdot\]\\\|/&\#x22C5;/g;        # dot operator
    $line =~ s/\\\|\[sdotb\]\\\|/&\#x22A1;/g;        # /dotsquare /boxdot B: small dot in box
    $line =~ s/\\\|\[setmn\]\\\|/&\#x2216;/g;        # /setminus B: reverse solidus
    $line =~ s/\\\|\[sqcap\]\\\|/&\#x2293;/g;        # /sqcap B: square intersection
    $line =~ s/\\\|\[sqcup\]\\\|/&\#x2294;/g;        # /sqcup B: square union
    $line =~ s/\\\|\[ssetmn\]\\\|/$unknown/g;        # /smallsetminus B: sm reverse solidus
    $line =~ s/\\\|\[sstarf\]\\\|/&\#x22C6;/g;        # /star B: small star, filled
    $line =~ s/\\\|\[timesb\]\\\|/&\#x22A0;/g;        # /boxtimes B: multiply sign in box
    $line =~ s/\\\|\[top\]\\\|/&\#x22A4;/g;        # /top top
    $line =~ s/\\\|\[uplus\]\\\|/&\#x228E;/g;        # /uplus B: plus sign in union
    $line =~ s/\\\|\[wreath\]\\\|/&\#x2240;/g;        # /wr B: wreath product
    $line =~ s/\\\|\[xcirc\]\\\|/&\#x25EF;/g;        # /bigcirc B: large circle
    $line =~ s/\\\|\[xdtri\]\\\|/&\#x25BD;/g;        # /bigtriangledown B: big dn tri, open
    $line =~ s/\\\|\[xutri\]\\\|/&\#x25B3;/g;        # /bigtriangleup B: big up tri, open
    $line =~ s/\\\|\[coprod\]\\\|/&\#x2210;/g;        # /coprod L: coproduct operator
    $line =~ s/\\\|\[prod\]\\\|/&\#x220F;/g;        # n-ary product = product sign
    $line =~ s/\\\|\[sum\]\\\|/&\#x2211;/g;        # n-ary sumation
    #
    # <!ENTITY % ISOamsr PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN">
    #
    $line =~ s/\\\|\[ape\]\\\|/&\#x224A;/g;        # /approxeq R: approximate, equals
    $line =~ s/\\\|\[asymp\]\\\|/&\#x224D;/g;        # almost equal to = asymptotic to
    $line =~ s/\\\|\[bcong\]\\\|/&\#x224C;/g;        # /backcong R: reverse congruent
    $line =~ s/\\\|\[bepsi\]\\\|/&\#x220D;/g;        # /backepsilon R: such that
    $line =~ s/\\\|\[bowtie\]\\\|/&\#x22C8;/g;        # /bowtie R:
    $line =~ s/\\\|\[bsim\]\\\|/&\#x223D;/g;        # /backsim R: reverse similar
    $line =~ s/\\\|\[bsime\]\\\|/&\#x22CD;/g;        # /backsimeq R: reverse similar, eq
    $line =~ s/\\\|\[bump\]\\\|/&\#x224E;/g;        # /Bumpeq R: bumpy equals
    $line =~ s/\\\|\[bumpe\]\\\|/&\#x224F;/g;        # /bumpeq R: bumpy equals, equals
    $line =~ s/\\\|\[cire\]\\\|/&\#x2257;/g;        # /circeq R: circle, equals
    $line =~ s/\\\|\[colone\]\\\|/&\#x2254;/g;        # /coloneq R: colon, equals
    $line =~ s/\\\|\[cuepr\]\\\|/&\#x22DE;/g;        # /curlyeqprec R: curly eq, precedes
    $line =~ s/\\\|\[cuesc\]\\\|/&\#x22DF;/g;        # /curlyeqsucc R: curly eq, succeeds
    $line =~ s/\\\|\[cupre\]\\\|/&\#x227C;/g;        # /preccurlyeq R: precedes, curly eq
    $line =~ s/\\\|\[dashv\]\\\|/&\#x22A3;/g;        # /dashv R: dash, vertical
    $line =~ s/\\\|\[ecir\]\\\|/&\#x2256;/g;        # /eqcirc R: circle on equals sign
    $line =~ s/\\\|\[ecolon\]\\\|/&\#x2255;/g;        # /eqcolon R: equals, colon
    $line =~ s/\\\|\[eDot\]\\\|/&\#x2251;/g;        # /doteqdot /Doteq R: eq, even dots
    $line =~ s/\\\|\[esdot\]\\\|/&\#x2250;/g;        # /doteq R: equals, single dot above
    $line =~ s/\\\|\[efDot\]\\\|/&\#x2252;/g;        # /fallingdotseq R: eq, falling dots
    $line =~ s/\\\|\[egs\]\\\|/&\#x22DD;/g;        # /eqslantgtr R: equal-or-gtr, slanted
    $line =~ s/\\\|\[els\]\\\|/&\#x22DC;/g;        # /eqslantless R: eq-or-less, slanted
    $line =~ s/\\\|\[erDot\]\\\|/&\#x2253;/g;        # /risingdotseq R: eq, rising dots
    $line =~ s/\\\|\[fork\]\\\|/&\#x22D4;/g;        # /pitchfork R: pitchfork
    $line =~ s/\\\|\[frown\]\\\|/&\#x2322;/g;        # /frown R: down curve
    $line =~ s/\\\|\[gap\]\\\|/$unknown/g;        # /gtrapprox R: greater, approximate
    $line =~ s/\\\|\[gsdot\]\\\|/&\#x22D7;/g;        # /gtrdot R: greater than, with dot
    $line =~ s/\\\|\[gE\]\\\|/&\#x2267;/g;        # /geqq R: greater, double equals
    $line =~ s/\\\|\[gel\]\\\|/&\#x22DB;/g;        # /gtreqless R: greater, equals, less
    $line =~ s/\\\|\[gEl\]\\\|/&\#x22DB;/g;        # /gtreqqless R: gt, dbl equals, less
    $line =~ s/\\\|\[ges\]\\\|/$unknown/g;        # /geqslant R: gt-or-equal, slanted
    $line =~ s/\\\|\[Gg\]\\\|/&\#x22D9;/g;        # /ggg /Gg /gggtr R: triple gtr-than
    $line =~ s/\\\|\[gl\]\\\|/&\#x2277;/g;        # /gtrless R: greater, less
    $line =~ s/\\\|\[gsim\]\\\|/&\#x2273;/g;        # /gtrsim R: greater, similar
    $line =~ s/\\\|\[Gt\]\\\|/&\#x226B;/g;        # /gg R: dbl greater-than sign
    $line =~ s/\\\|\[lap\]\\\|/$unknown/g;        # /lessapprox R: less, approximate
    $line =~ s/\\\|\[ldot\]\\\|/&\#x22D6;/g;        # /lessdot R: less than, with dot
    $line =~ s/\\\|\[lE\]\\\|/&\#x2266;/g;        # /leqq R: less, double equals
    $line =~ s/\\\|\[lEg\]\\\|/&\#x22DA;/g;        # /lesseqqgtr R: less, dbl eq, greater
    $line =~ s/\\\|\[leg\]\\\|/&\#x22DA;/g;        # /lesseqgtr R: less, eq, greater
    $line =~ s/\\\|\[les\]\\\|/$unknown/g;        # /leqslant R: less-than-or-eq, slant
    $line =~ s/\\\|\[lg\]\\\|/&\#x2276;/g;        # /lessgtr R: less, greater
    $line =~ s/\\\|\[Ll\]\\\|/&\#x22D8;/g;        # /Ll /lll /llless R: triple less-than
    $line =~ s/\\\|\[lsim\]\\\|/&\#x2272;/g;        # /lesssim R: less, similar
    $line =~ s/\\\|\[Lt\]\\\|/&\#x226A;/g;        # /ll R: double less-than sign
    $line =~ s/\\\|\[ltrie\]\\\|/&\#x22B4;/g;        # /trianglelefteq R: left triangle, eq
    $line =~ s/\\\|\[mid\]\\\|/&\#x2223;/g;        # /mid R:
    $line =~ s/\\\|\[models\]\\\|/&\#x22A7;/g;        # /models R:
    $line =~ s/\\\|\[pr\]\\\|/&\#x227A;/g;        # /prec R: precedes
    $line =~ s/\\\|\[prap\]\\\|/$unknown/g;        # /precapprox R: precedes, approximate
    $line =~ s/\\\|\[pre\]\\\|/&\#x227C;/g;        # /preceq R: precedes, equals
    $line =~ s/\\\|\[prsim\]\\\|/&\#x227E;/g;        # /precsim R: precedes, similar
    $line =~ s/\\\|\[rtrie\]\\\|/&\#x22B5;/g;        # /trianglerighteq R: right tri, eq
    $line =~ s/\\\|\[samalg\]\\\|/$unknown/g;        # /smallamalg R: small amalg
    $line =~ s/\\\|\[sc\]\\\|/&\#x227B;/g;        # /succ R: succeeds
    $line =~ s/\\\|\[scap\]\\\|/$unknown/g;        # /succapprox R: succeeds, approximate
    $line =~ s/\\\|\[sccue\]\\\|/&\#x227D;/g;        # /succcurlyeq R: succeeds, curly eq
    $line =~ s/\\\|\[sce\]\\\|/&\#x227D;/g;        # /succeq R: succeeds, equals
    $line =~ s/\\\|\[scsim\]\\\|/&\#x227F;/g;        # /succsim R: succeeds, similar
    $line =~ s/\\\|\[sfrown\]\\\|/$unknown/g;        # /smallfrown R: small down curve
    $line =~ s/\\\|\[smid\]\\\|/$unknown/g;        # /shortmid R:
    $line =~ s/\\\|\[smile\]\\\|/&\#x2323;/g;        # /smile R: up curve
    $line =~ s/\\\|\[spar\]\\\|/$unknown/g;        # /shortparallel R: short parallel
    $line =~ s/\\\|\[sqsub\]\\\|/&\#x228F;/g;        # /sqsubset R: square subset
    $line =~ s/\\\|\[sqsube\]\\\|/&\#x2291;/g;        # /sqsubseteq R: square subset, equals
    $line =~ s/\\\|\[sqsup\]\\\|/&\#x2290;/g;        # /sqsupset R: square superset
    $line =~ s/\\\|\[sqsupe\]\\\|/&\#x2292;/g;        # /sqsupseteq R: square superset, eq
    $line =~ s/\\\|\[ssmile\]\\\|/$unknown/g;        # /smallsmile R: small up curve
    $line =~ s/\\\|\[Sub\]\\\|/&\#x22D0;/g;        # /Subset R: double subset
    $line =~ s/\\\|\[subE\]\\\|/&\#x2286;/g;        # /subseteqq R: subset, dbl equals
    $line =~ s/\\\|\[Sup\]\\\|/&\#x22D1;/g;        # /Supset R: dbl superset
    $line =~ s/\\\|\[supE\]\\\|/&\#x2287;/g;        # /supseteqq R: superset, dbl equals
    $line =~ s/\\\|\[thkap\]\\\|/$unknown/g;        # /thickapprox R: thick approximate
    $line =~ s/\\\|\[thksim\]\\\|/$unknown/g;        # /thicksim R: thick similar
    $line =~ s/\\\|\[trie\]\\\|/&\#x225C;/g;        # /triangleq R: triangle, equals
    $line =~ s/\\\|\[twixt\]\\\|/&\#x226C;/g;        # /between R: between
    $line =~ s/\\\|\[vdash\]\\\|/&\#x22A2;/g;        # /vdash R: vertical, dash
    $line =~ s/\\\|\[Vdash\]\\\|/&\#x22A9;/g;        # /Vdash R: dbl vertical, dash
    $line =~ s/\\\|\[vDash\]\\\|/&\#x22A8;/g;        # /vDash R: vertical, dbl dash
    $line =~ s/\\\|\[veebar\]\\\|/&\#x22BB;/g;        # /veebar B: logical or, bar below
    $line =~ s/\\\|\[vltri\]\\\|/&\#x22B2;/g;        # /vartriangleleft R: l tri, open, var
    $line =~ s/\\\|\[vprop\]\\\|/&\#x221D;/g;        # /varpropto R: proportional, variant
    $line =~ s/\\\|\[vrtri\]\\\|/&\#x22B3;/g;        # /vartriangleright R: r tri, open, var
    $line =~ s/\\\|\[Vvdash\]\\\|/&\#x22AA;/g;        # /Vvdash R: triple vertical, dash
    #
    # <!ENTITY % ISOamsn PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN">
    #
    $line =~ s/\\\|\[gnap\]\\\|/$unknown/g;        # /gnapprox N: greater, not approximate
    $line =~ s/\\\|\[gne\]\\\|/&\#x2269;/g;        # /gneq N: greater, not equals
    $line =~ s/\\\|\[gnE\]\\\|/&\#x2269;/g;        # /gneqq N: greater, not dbl equals
    $line =~ s/\\\|\[gnsim\]\\\|/&\#x22E7;/g;        # /gnsim N: greater, not similar
    $line =~ s/\\\|\[gvnE\]\\\|/&\#x2269;/g;        # /gvertneqq N: gt, vert, not dbl eq
    $line =~ s/\\\|\[lnap\]\\\|/$unknown/g;        # /lnapprox N: less, not approximate
    $line =~ s/\\\|\[lnE\]\\\|/&\#x2268;/g;        # /lneqq N: less, not double equals
    $line =~ s/\\\|\[lne\]\\\|/&\#x2268;/g;        # /lneq N: less, not equals
    $line =~ s/\\\|\[lnsim\]\\\|/&\#x22E6;/g;        # /lnsim N: less, not similar
    $line =~ s/\\\|\[lvnE\]\\\|/&\#x2268;/g;        # /lvertneqq N: less, vert, not dbl eq
    $line =~ s/\\\|\[nap\]\\\|/&\#x2249;/g;        # /napprox N: not approximate
    $line =~ s/\\\|\[ncong\]\\\|/&\#x2247;/g;        # /ncong N: not congruent with
    $line =~ s/\\\|\[nequiv\]\\\|/&\#x2262;/g;        # /nequiv N: not identical with
    $line =~ s/\\\|\[ngE\]\\\|/$unknown/g;        # /ngeqq N: not greater, dbl equals
    $line =~ s/\\\|\[nge\]\\\|/&\#x2271;/g;        # /ngeq N: not greater-than-or-equal
    $line =~ s/\\\|\[nges\]\\\|/&\#x2271;/g;        # /ngeqslant N: not gt-or-eq, slanted
    $line =~ s/\\\|\[ngt\]\\\|/&\#x226F;/g;        # /ngtr N: not greater-than
    $line =~ s/\\\|\[nle\]\\\|/&\#x2270;/g;        # /nleq N: not less-than-or-equal
    $line =~ s/\\\|\[nlE\]\\\|/$unknown/g;        # /nleqq N: not less, dbl equals
    $line =~ s/\\\|\[nles\]\\\|/&\#x2270;/g;        # /nleqslant N: not less-or-eq, slant
    $line =~ s/\\\|\[nlt\]\\\|/&\#x226E;/g;        # /nless N: not less-than
    $line =~ s/\\\|\[nltri\]\\\|/&\#x22EA;/g;        # /ntriangleleft N: not left triangle
    $line =~ s/\\\|\[nltrie\]\\\|/&\#x22EC;/g;        # /ntrianglelefteq N: not l tri, eq
    $line =~ s/\\\|\[nmid\]\\\|/&\#x2224;/g;        # /nmid
    $line =~ s/\\\|\[npar\]\\\|/&\#x2226;/g;        # /nparallel N: not parallel
    $line =~ s/\\\|\[npr\]\\\|/&\#x2280;/g;        # /nprec N: not precedes
    $line =~ s/\\\|\[npre\]\\\|/&\#x22E0;/g;        # /npreceq N: not precedes, equals
    $line =~ s/\\\|\[nrtri\]\\\|/&\#x22EB;/g;        # /ntriangleright N: not rt triangle
    $line =~ s/\\\|\[nrtrie\]\\\|/&\#x22ED;/g;        # /ntrianglerighteq N: not r tri, eq
    $line =~ s/\\\|\[nsc\]\\\|/&\#x2281;/g;        # /nsucc N: not succeeds
    $line =~ s/\\\|\[nsce\]\\\|/&\#x22E1;/g;        # /nsucceq N: not succeeds, equals
    $line =~ s/\\\|\[nsim\]\\\|/&\#x2241;/g;        # /nsim N: not similar
    $line =~ s/\\\|\[nsime\]\\\|/&\#x2244;/g;        # /nsimeq N: not similar, equals
    $line =~ s/\\\|\[nsmid\]\\\|/$unknown/g;        # /nshortmid
    $line =~ s/\\\|\[nspar\]\\\|/$unknown/g;        # /nshortparallel N: not short par
    $line =~ s/\\\|\[nsub\]\\\|/&\#x2284;/g;        # not a subset of
    $line =~ s/\\\|\[nsube\]\\\|/&\#x2288;/g;        # /nsubseteq N: not subset, equals
    $line =~ s/\\\|\[nsubE\]\\\|/&\#x2288;/g;        # /nsubseteqq N: not subset, dbl eq
    $line =~ s/\\\|\[nsup\]\\\|/&\#x2285;/g;        # not superset
    $line =~ s/\\\|\[nsupE\]\\\|/&\#x2289;/g;        # /nsupseteqq N: not superset, dbl eq
    $line =~ s/\\\|\[nsupe\]\\\|/&\#x2289;/g;        # /nsupseteq N: not superset, equals
    $line =~ s/\\\|\[nvdash\]\\\|/&\#x22AC;/g;        # /nvdash N: not vertical, dash
    $line =~ s/\\\|\[nvDash\]\\\|/&\#x22AD;/g;        # /nvDash N: not vertical, dbl dash
    $line =~ s/\\\|\[nVDash\]\\\|/&\#x22AF;/g;        # /nVDash N: not dbl vert, dbl dash
    $line =~ s/\\\|\[nVdash\]\\\|/&\#x22AE;/g;        # /nVdash N: not dbl vertical, dash
    $line =~ s/\\\|\[prnap\]\\\|/$unknown/g;        # /precnapprox N: precedes, not approx
    $line =~ s/\\\|\[prnE\]\\\|/$unknown/g;        # /precneqq N: precedes, not dbl eq
    $line =~ s/\\\|\[prnsim\]\\\|/&\#x22E8;/g;        # /precnsim N: precedes, not similar
    $line =~ s/\\\|\[scnap\]\\\|/$unknown/g;        # /succnapprox N: succeeds, not approx
    $line =~ s/\\\|\[scnE\]\\\|/$unknown/g;        # /succneqq N: succeeds, not dbl eq
    $line =~ s/\\\|\[scnsim\]\\\|/&\#x22E9;/g;        # /succnsim N: succeeds, not similar
    $line =~ s/\\\|\[subne\]\\\|/&\#x228A;/g;        # /subsetneq N: subset, not equals
    $line =~ s/\\\|\[subnE\]\\\|/&\#x228A;/g;        # /subsetneqq N: subset, not dbl eq
    $line =~ s/\\\|\[supne\]\\\|/&\#x228B;/g;        # /supsetneq N: superset, not equals
    $line =~ s/\\\|\[supnE\]\\\|/&\#x228B;/g;        # /supsetneqq N: superset, not dbl eq
    $line =~ s/\\\|\[vsubnE\]\\\|/$unknown/g;        # /varsubsetneqq N: subset not dbl eq, var
    $line =~ s/\\\|\[vsubne\]\\\|/$unknown/g;        # /varsubsetneq N: subset, not eq, var
    $line =~ s/\\\|\[vsupne\]\\\|/$unknown/g;        # /varsupsetneq N: superset, not eq, var
    $line =~ s/\\\|\[vsupnE\]\\\|/$unknown/g;        # /varsupsetneqq N: super not dbl eq, var
    #
    # <!ENTITY % ISOamsa PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN">
    #
    $line =~ s/\\\|\[cularr\]\\\|/&\#x21B6;/g;        # /curvearrowleft A: left curved arrow
    $line =~ s/\\\|\[curarr\]\\\|/&\#x21B7;/g;        # /curvearrowright A: rt curved arrow
    $line =~ s/\\\|\[dArr\]\\\|/&\#x21D3;/g;        # downwards double arrow
    $line =~ s/\\\|\[darr2\]\\\|/&\#x21CA;/g;        # /downdownarrows A: two down arrows
    $line =~ s/\\\|\[dharl\]\\\|/&\#x21C3;/g;        # /downharpoonleft A: dn harpoon-left
    $line =~ s/\\\|\[dharr\]\\\|/&\#x21C2;/g;        # /downharpoonright A: down harpoon-rt
    $line =~ s/\\\|\[lAarr\]\\\|/&\#x21DA;/g;        # /Lleftarrow A: left triple arrow
    $line =~ s/\\\|\[Larr\]\\\|/&\#x219E;/g;        # /twoheadleftarrow A:
    $line =~ s/\\\|\[larr2\]\\\|/&\#x21C7;/g;        # /leftleftarrows A: two left arrows
    $line =~ s/\\\|\[larrhk\]\\\|/&\#x21A9;/g;        # /hookleftarrow A: left arrow-hooked
    $line =~ s/\\\|\[larrlp\]\\\|/&\#x21AB;/g;        # /looparrowleft A: left arrow-looped
    $line =~ s/\\\|\[larrtl\]\\\|/&\#x21A2;/g;        # /leftarrowtail A: left arrow-tailed
    $line =~ s/\\\|\[lhard\]\\\|/&\#x21BD;/g;        # /leftharpoondown A: l harpoon-down
    $line =~ s/\\\|\[lharu\]\\\|/&\#x21BC;/g;        # /leftharpoonup A: left harpoon-up
    $line =~ s/\\\|\[hArr\]\\\|/&\#x21D4;/g;        # left right double arrow
    $line =~ s/\\\|\[harr\]\\\|/&\#x2194;/g;        # left right arrow
    $line =~ s/\\\|\[lrarr2\]\\\|/&\#x21C6;/g;        # /leftrightarrows A: l arr over r arr
    $line =~ s/\\\|\[rlarr2\]\\\|/&\#x21C4;/g;        # /rightleftarrows A: r arr over l arr
    $line =~ s/\\\|\[harrw\]\\\|/&\#x21AD;/g;        # /leftrightsquigarrow A: l&amp;r arr-wavy
    $line =~ s/\\\|\[rlhar2\]\\\|/&\#x21CC;/g;        # /rightleftharpoons A: r harp over l
    $line =~ s/\\\|\[lrhar2\]\\\|/&\#x21CB;/g;        # /leftrightharpoons A: l harp over r
    $line =~ s/\\\|\[lsh\]\\\|/&\#x21B0;/g;        # /Lsh A:
    $line =~ s/\\\|\[map\]\\\|/&\#x21A6;/g;        # /mapsto A:
    $line =~ s/\\\|\[mumap\]\\\|/&\#x22B8;/g;        # /multimap A:
    $line =~ s/\\\|\[nearr\]\\\|/&\#x2197;/g;        # /nearrow A: NE pointing arrow
    $line =~ s/\\\|\[nlArr\]\\\|/&\#x21CD;/g;        # /nLeftarrow A: not implied by
    $line =~ s/\\\|\[nlarr\]\\\|/&\#x219A;/g;        # /nleftarrow A: not left arrow
    $line =~ s/\\\|\[nhArr\]\\\|/&\#x21CE;/g;        # /nLeftrightarrow A: not l&amp;r dbl arr
    $line =~ s/\\\|\[nharr\]\\\|/&\#x21AE;/g;        # /nleftrightarrow A: not l&amp;r arrow
    $line =~ s/\\\|\[nrarr\]\\\|/&\#x219B;/g;        # /nrightarrow A: not right arrow
    $line =~ s/\\\|\[nrArr\]\\\|/&\#x21CF;/g;        # /nRightarrow A: not implies
    $line =~ s/\\\|\[nwarr\]\\\|/&\#x2196;/g;        # /nwarrow A: NW pointing arrow
    $line =~ s/\\\|\[olarr\]\\\|/&\#x21BA;/g;        # /circlearrowleft A: l arr in circle
    $line =~ s/\\\|\[orarr\]\\\|/&\#x21BB;/g;        # /circlearrowright A: r arr in circle
    $line =~ s/\\\|\[rAarr\]\\\|/&\#x21DB;/g;        # /Rrightarrow A: right triple arrow
    $line =~ s/\\\|\[Rarr\]\\\|/&\#x21A0;/g;        # /twoheadrightarrow A:
    $line =~ s/\\\|\[rarr2\]\\\|/&\#x21C9;/g;        # /rightrightarrows A: two rt arrows
    $line =~ s/\\\|\[rarrhk\]\\\|/&\#x21AA;/g;        # /hookrightarrow A: rt arrow-hooked
    $line =~ s/\\\|\[rarrlp\]\\\|/&\#x21AC;/g;        # /looparrowright A: rt arrow-looped
    $line =~ s/\\\|\[rarrtl\]\\\|/&\#x21A3;/g;        # /rightarrowtail A: rt arrow-tailed
    $line =~ s/\\\|\[rarrw\]\\\|/&\#x21DD;/g;        # /rightsquigarrow A: rt arrow-wavy
    $line =~ s/\\\|\[rhard\]\\\|/&\#x21C1;/g;        # /rightharpoondown A: rt harpoon-down
    $line =~ s/\\\|\[rharu\]\\\|/&\#x21C0;/g;        # /rightharpoonup A: rt harpoon-up
    $line =~ s/\\\|\[rsh\]\\\|/&\#x21B1;/g;        # /Rsh A:
    $line =~ s/\\\|\[drarr\]\\\|/&\#x2198;/g;        # /searrow A: SE pointing arrow
    $line =~ s/\\\|\[dlarr\]\\\|/&\#x2199;/g;        # /swarrow A: SW pointing arrow
    $line =~ s/\\\|\[uArr\]\\\|/&\#x21D1;/g;        # upwards double arrow
    $line =~ s/\\\|\[uarr2\]\\\|/&\#x21C8;/g;        # /upuparrows A: two up arrows
    $line =~ s/\\\|\[vArr\]\\\|/&\#x21D5;/g;        # /Updownarrow A: up&amp;down dbl arrow
    $line =~ s/\\\|\[varr\]\\\|/&\#x2195;/g;        # /updownarrow A: up&amp;down arrow
    $line =~ s/\\\|\[uharl\]\\\|/&\#x21BF;/g;        # /upharpoonleft A: up harpoon-left
    $line =~ s/\\\|\[uharr\]\\\|/&\#x21BE;/g;        # /upharpoonright /restriction A: up harp-r
    $line =~ s/\\\|\[xlArr\]\\\|/$unknown/g;        # /Longleftarrow A: long l dbl arrow
    $line =~ s/\\\|\[xhArr\]\\\|/$unknown/g;        # /Longleftrightarrow A: long l&amp;r dbl arr
    $line =~ s/\\\|\[xharr\]\\\|/$unknown/g;        # /longleftrightarrow A: long l&amp;r arr
    $line =~ s/\\\|\[xrArr\]\\\|/$unknown/g;        # /Longrightarrow A: long rt dbl arr
    #
    # <!ENTITY % ISOamsc PUBLIC "ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN">
    #
    $line =~ s/\\\|\[rceil\]\\\|/&\#x2309;/g;        # right ceiling
    $line =~ s/\\\|\[rfloor\]\\\|/&\#x230B;/g;        # right floor
    $line =~ s/\\\|\[rpargt\]\\\|/$unknown/g;        # C: right paren, gt
    $line =~ s/\\\|\[urcorn\]\\\|/&\#x231D;/g;        # /urcorner C: upper right corner
    $line =~ s/\\\|\[drcorn\]\\\|/&\#x231F;/g;        # /lrcorner C: lower right corner
    $line =~ s/\\\|\[lceil\]\\\|/&\#x2308;/g;        # left ceiling = apl upstile
    $line =~ s/\\\|\[lfloor\]\\\|/&\#x230A;/g;        # left floor = apl downstile
    $line =~ s/\\\|\[lpargt\]\\\|/$unknown/g;        # /leftparengtr O: left parenthesis, gt
    $line =~ s/\\\|\[ulcorn\]\\\|/&\#x231C;/g;        # /ulcorner O: upper left corner
    $line =~ s/\\\|\[dlcorn\]\\\|/&\#x231E;/g;        # /llcorner O: lower left corner
    #
    # <!ENTITY % ISOlat1 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN">
    #
    $line =~ s/\\\|\[aacute\]\\\|/&\#x00E1;/g;        # latin small letter a with acute
    $line =~ s/\\\|\[Aacute\]\\\|/&\#x00C1;/g;        # latin capital letter A with acute
    $line =~ s/\\\|\[acirc\]\\\|/&\#x00E2;/g;        # latin capital letter A with circumflex
    $line =~ s/\\\|\[Acirc\]\\\|/&\#x00C2;/g;        # latin small letter a with circumflex
    $line =~ s/\\\|\[agrave\]\\\|/&\#x00E0;/g;        # latin small letter a with grave = <pnewline>latin small letter a grave
    $line =~ s/\\\|\[Agrave\]\\\|/&\#x00C0;/g;        # latin capital letter A with grave = <pnewline>latin capital letter A grave
    $line =~ s/\\\|\[aring\]\\\|/&\#x00E5;/g;        # latin small letter a with ring above = <pnewline>latin small letter a ring
    $line =~ s/\\\|\[Aring\]\\\|/&\#x00C5;/g;        # latin capital letter A with ring above = <pnewline>latin capital letter A ring
    $line =~ s/\\\|\[atilde\]\\\|/&\#x00E3;/g;        # latin small letter a with tilde
    $line =~ s/\\\|\[Atilde\]\\\|/&\#x00C3;/g;        # latin capital letter A with tilde
    $line =~ s/\\\|\[auml\]\\\|/&\#x00E4;/g;        # latin small letter a with diaeresis
    $line =~ s/\\\|\[Auml\]\\\|/&\#x00C4;/g;        # latin capital letter A with diaeresis
    $line =~ s/\\\|\[aelig\]\\\|/&\#x00E6;/g;        # latin small letter ae = latin small ligature ae
    $line =~ s/\\\|\[AElig\]\\\|/&\#x00C6;/g;        # latin capital letter AE = latin capital <pnewline>ligature AE
    $line =~ s/\\\|\[ccedil\]\\\|/&\#x00E7;/g;        # latin small letter c with cedilla
    $line =~ s/\\\|\[Ccedil\]\\\|/&\#x00C7;/g;        # latin capital letter C with cedilla
    $line =~ s/\\\|\[eth\]\\\|/&\#x00F0;/g;        # latin small letter eth
    $line =~ s/\\\|\[ETH\]\\\|/&\#x00D0;/g;        # latin capital letter ETH
    $line =~ s/\\\|\[eacute\]\\\|/&\#x00E9;/g;        # latin small letter e with acute
    $line =~ s/\\\|\[Eacute\]\\\|/&\#x00C9;/g;        # latin capital letter E with acute
    $line =~ s/\\\|\[ecirc\]\\\|/&\#x00EA;/g;        # latin small letter e with circumflex
    $line =~ s/\\\|\[Ecirc\]\\\|/&\#x00CA;/g;        # latin capital letter E with circumflex
    $line =~ s/\\\|\[egrave\]\\\|/&\#x00E8;/g;        # latin small letter e with grave
    $line =~ s/\\\|\[Egrave\]\\\|/&\#x00C8;/g;        # latin capital letter E with grave
    $line =~ s/\\\|\[euml\]\\\|/&\#x00EB;/g;        # latin small letter e with diaeresis
    $line =~ s/\\\|\[Euml\]\\\|/&\#x00CB;/g;        # latin capital letter E with diaeresis
    $line =~ s/\\\|\[iacute\]\\\|/&\#x00ED;/g;        # latin small letter i with acute
    $line =~ s/\\\|\[Iacute\]\\\|/&\#x00CD;/g;        # latin capital letter I with acute
    $line =~ s/\\\|\[icirc\]\\\|/&\#x00EE;/g;        # latin small letter i with circumflex
    $line =~ s/\\\|\[Icirc\]\\\|/&\#x00CE;/g;        # latin capital letter I with circumflex
    $line =~ s/\\\|\[igrave\]\\\|/&\#x00EC;/g;        # latin small letter i with grave
    $line =~ s/\\\|\[Igrave\]\\\|/&\#x00CC;/g;        # latin capital letter I with grave
    $line =~ s/\\\|\[iuml\]\\\|/&\#x00EF;/g;        # latin small letter i with diaeresis
    $line =~ s/\\\|\[Iuml\]\\\|/&\#x00CF;/g;        # latin capital letter I with diaeresis
    $line =~ s/\\\|\[ntilde\]\\\|/&\#x00F1;/g;        # latin small letter n with tilde
    $line =~ s/\\\|\[Ntilde\]\\\|/&\#x00D1;/g;        # latin capital letter N with tilde
    $line =~ s/\\\|\[oacute\]\\\|/&\#x00F3;/g;        # latin small letter o with acute
    $line =~ s/\\\|\[Oacute\]\\\|/&\#x00D3;/g;        # latin capital letter O with acute
    $line =~ s/\\\|\[ocirc\]\\\|/&\#x00F4;/g;        # latin small letter o with circumflex
    $line =~ s/\\\|\[Ocirc\]\\\|/&\#x00D4;/g;        # latin capital letter O with circumflex
    $line =~ s/\\\|\[ograve\]\\\|/&\#x00F2;/g;        # latin small letter o with grave
    $line =~ s/\\\|\[Ograve\]\\\|/&\#x00D2;/g;        # latin capital letter O with grave
    $line =~ s/\\\|\[oslash\]\\\|/&\#x00F8;/g;        # latin capital letter O with stroke = latin <pnewline>capital letter O slash
    $line =~ s/\\\|\[Oslash\]\\\|/&\#x00D8;/g;        # latin capital letter O with stroke = latin <pnewline>capital letter O slash
    $line =~ s/\\\|\[otilde\]\\\|/&\#x00F5;/g;        # latin small letter o with tilde
    $line =~ s/\\\|\[Otilde\]\\\|/&\#x00D5;/g;        # latin capital letter O with tilde
    $line =~ s/\\\|\[ouml\]\\\|/&\#x00F6;/g;        # latin small letter o with diaeresis
    $line =~ s/\\\|\[Ouml\]\\\|/&\#x00D6;/g;        # latin capital letter O with diaeresis
    $line =~ s/\\\|\[szlig\]\\\|/&\#x00DF;/g;        # latin small letter sharp s = ess-zed
    $line =~ s/\\\|\[thorn\]\\\|/&\#x00FE;/g;        # latin small letter thorn with
    $line =~ s/\\\|\[THORN\]\\\|/&\#x00DE;/g;        # latin capital letter THORN
    $line =~ s/\\\|\[uacute\]\\\|/&\#x00FA;/g;        # latin small letter u with acute
    $line =~ s/\\\|\[Uacute\]\\\|/&\#x00DA;/g;        # latin capital letter U with acute
    $line =~ s/\\\|\[ucirc\]\\\|/&\#x00FB;/g;        # latin small letter u with circumflex
    $line =~ s/\\\|\[Ucirc\]\\\|/&\#x00DB;/g;        # latin capital letter U with circumflex
    $line =~ s/\\\|\[ugrave\]\\\|/&\#x00F9;/g;        # latin small letter u with grave
    $line =~ s/\\\|\[Ugrave\]\\\|/&\#x00D9;/g;        # latin capital letter U with grave
    $line =~ s/\\\|\[uuml\]\\\|/&\#x00FC;/g;        # latin small letter u with diaeresis
    $line =~ s/\\\|\[Uuml\]\\\|/&\#x00DC;/g;        # latin capital letter U with diaeresis
    $line =~ s/\\\|\[yacute\]\\\|/&\#x00FD;/g;        # latin small letter y with acute
    $line =~ s/\\\|\[Yacute\]\\\|/&\#x00DD;/g;        # latin capital letter Y with acute
    $line =~ s/\\\|\[yuml\]\\\|/&\#x00FF;/g;        # latin small letter y with diaeresis
    #
    # <!ENTITY % ISOlat2 PUBLIC "ISO 8879:1986//ENTITIES Added Latin 2//EN">
    #
    $line =~ s/\\\|\[abreve\]\\\|/&\#x0103;/g;        # =small a, breve
    $line =~ s/\\\|\[Abreve\]\\\|/&\#x0102;/g;        # =capital A, breve
    $line =~ s/\\\|\[amacr\]\\\|/&\#x0101;/g;        # =small a, macron
    $line =~ s/\\\|\[Amacr\]\\\|/&\#x0100;/g;        # =capital A, macron
    $line =~ s/\\\|\[aogon\]\\\|/&\#x0105;/g;        # =small a, ogonek
    $line =~ s/\\\|\[Aogon\]\\\|/&\#x0104;/g;        # =capital A, ogonek
    $line =~ s/\\\|\[cacute\]\\\|/&\#x0107;/g;        # =small c, acute accent
    $line =~ s/\\\|\[Cacute\]\\\|/&\#x0106;/g;        # =capital C, acute accent
    $line =~ s/\\\|\[ccaron\]\\\|/&\#x010D;/g;        # =small c, caron
    $line =~ s/\\\|\[Ccaron\]\\\|/&\#x010C;/g;        # =capital C, caron
    $line =~ s/\\\|\[ccirc\]\\\|/&\#x0109;/g;        # =small c, circumflex accent
    $line =~ s/\\\|\[Ccirc\]\\\|/&\#x0108;/g;        # =capital C, circumflex accent
    $line =~ s/\\\|\[cdot\]\\\|/&\#x010B;/g;        # =small c, dot above
    $line =~ s/\\\|\[Cdot\]\\\|/&\#x010A;/g;        # =capital C, dot above
    $line =~ s/\\\|\[dcaron\]\\\|/&\#x010F;/g;        # =small d, caron
    $line =~ s/\\\|\[Dcaron\]\\\|/&\#x010E;/g;        # =capital D, caron
    $line =~ s/\\\|\[dstrok\]\\\|/&\#x0111;/g;        # =small d, stroke
    $line =~ s/\\\|\[Dstrok\]\\\|/&\#x0110;/g;        # =capital D, stroke
    $line =~ s/\\\|\[ecaron\]\\\|/&\#x011B;/g;        # =small e, caron
    $line =~ s/\\\|\[Ecaron\]\\\|/&\#x011A;/g;        # =capital E, caron
    $line =~ s/\\\|\[edot\]\\\|/&\#x0117;/g;        # =small e, dot above
    $line =~ s/\\\|\[Edot\]\\\|/&\#x0116;/g;        # =capital E, dot above
    $line =~ s/\\\|\[emacr\]\\\|/&\#x0113;/g;        # =small e, macron
    $line =~ s/\\\|\[Emacr\]\\\|/&\#x0112;/g;        # =capital E, macron
    $line =~ s/\\\|\[eogon\]\\\|/&\#x0119;/g;        # =small e, ogonek
    $line =~ s/\\\|\[Eogon\]\\\|/&\#x0118;/g;        # =capital E, ogonek
    $line =~ s/\\\|\[gacute\]\\\|/&\#x01F5;/g;        # =small g, acute accent
    $line =~ s/\\\|\[gbreve\]\\\|/&\#x011F;/g;        # =small g, breve
    $line =~ s/\\\|\[Gbreve\]\\\|/&\#x011E;/g;        # =capital G, breve
    $line =~ s/\\\|\[Gcedil\]\\\|/&\#x0122;/g;        # =capital G, cedilla
    $line =~ s/\\\|\[gcirc\]\\\|/&\#x011D;/g;        # =small g, circumflex accent
    $line =~ s/\\\|\[Gcirc\]\\\|/&\#x011C;/g;        # =capital G, circumflex accent
    $line =~ s/\\\|\[gdot\]\\\|/&\#x0121;/g;        # =small g, dot above
    $line =~ s/\\\|\[Gdot\]\\\|/&\#x0120;/g;        # =capital G, dot above
    $line =~ s/\\\|\[hcirc\]\\\|/&\#x0125;/g;        # =small h, circumflex accent
    $line =~ s/\\\|\[Hcirc\]\\\|/&\#x0124;/g;        # =capital H, circumflex accent
    $line =~ s/\\\|\[hstrok\]\\\|/&\#x0127;/g;        # =small h, stroke
    $line =~ s/\\\|\[Hstrok\]\\\|/&\#x0126;/g;        # =capital H, stroke
    $line =~ s/\\\|\[Idot\]\\\|/&\#x0130;/g;        # =capital I, dot above
    $line =~ s/\\\|\[Imacr\]\\\|/&\#x012A;/g;        # =capital I, macron
    $line =~ s/\\\|\[imacr\]\\\|/&\#x012B;/g;        # =small i, macron
    $line =~ s/\\\|\[ijlig\]\\\|/&\#x0133;/g;        # =small ij ligature
    $line =~ s/\\\|\[IJlig\]\\\|/&\#x0132;/g;        # =capital IJ ligature
    $line =~ s/\\\|\[inodot\]\\\|/&\#x0131;/g;        # =small i without dot
    $line =~ s/\\\|\[iogon\]\\\|/&\#x012F;/g;        # =small i, ogonek
    $line =~ s/\\\|\[Iogon\]\\\|/&\#x012E;/g;        # =capital I, ogonek
    $line =~ s/\\\|\[itilde\]\\\|/&\#x0129;/g;        # =small i, tilde
    $line =~ s/\\\|\[Itilde\]\\\|/&\#x0128;/g;        # =capital I, tilde
    $line =~ s/\\\|\[jcirc\]\\\|/&\#x0135;/g;        # =small j, circumflex accent
    $line =~ s/\\\|\[Jcirc\]\\\|/&\#x0134;/g;        # =capital J, circumflex accent
    $line =~ s/\\\|\[kcedil\]\\\|/&\#x0137;/g;        # =small k, cedilla
    $line =~ s/\\\|\[Kcedil\]\\\|/&\#x0136;/g;        # =capital K, cedilla
    $line =~ s/\\\|\[kgreen\]\\\|/&\#x0138;/g;        # =small k, Greenlandic
    $line =~ s/\\\|\[lacute\]\\\|/&\#x013A;/g;        # =small l, acute accent
    $line =~ s/\\\|\[Lacute\]\\\|/&\#x0139;/g;        # =capital L, acute accent
    $line =~ s/\\\|\[lcaron\]\\\|/&\#x013E;/g;        # =small l, caron
    $line =~ s/\\\|\[Lcaron\]\\\|/&\#x013D;/g;        # =capital L, caron
    $line =~ s/\\\|\[lcedil\]\\\|/&\#x013C;/g;        # =small l, cedilla
    $line =~ s/\\\|\[Lcedil\]\\\|/&\#x013B;/g;        # =capital L, cedilla
    $line =~ s/\\\|\[lmidot\]\\\|/&\#x0140;/g;        # =small l, middle dot
    $line =~ s/\\\|\[Lmidot\]\\\|/&\#x013F;/g;        # =capital L, middle dot
    $line =~ s/\\\|\[lstrok\]\\\|/&\#x0142;/g;        # =small l, stroke
    $line =~ s/\\\|\[Lstrok\]\\\|/&\#x0141;/g;        # =capital L, stroke
    $line =~ s/\\\|\[nacute\]\\\|/&\#x0144;/g;        # =small n, acute accent
    $line =~ s/\\\|\[Nacute\]\\\|/&\#x0143;/g;        # =capital N, acute accent
    $line =~ s/\\\|\[eng\]\\\|/&\#x014B;/g;        # =small eng, Lapp
    $line =~ s/\\\|\[ENG\]\\\|/&\#x014A;/g;        # =capital ENG, Lapp
    $line =~ s/\\\|\[napos\]\\\|/&\#x0149;/g;        # =small n, apostrophe
    $line =~ s/\\\|\[ncaron\]\\\|/&\#x0148;/g;        # =small n, caron
    $line =~ s/\\\|\[Ncaron\]\\\|/&\#x0147;/g;        # =capital N, caron
    $line =~ s/\\\|\[ncedil\]\\\|/&\#x0146;/g;        # =small n, cedilla
    $line =~ s/\\\|\[Ncedil\]\\\|/&\#x0145;/g;        # =capital N, cedilla
    $line =~ s/\\\|\[odblac\]\\\|/&\#x0151;/g;        # =small o, double acute accent
    $line =~ s/\\\|\[Odblac\]\\\|/&\#x0150;/g;        # =capital O, double acute accent
    $line =~ s/\\\|\[Omacr\]\\\|/&\#x014C;/g;        # =capital O, macron
    $line =~ s/\\\|\[omacr\]\\\|/&\#x014D;/g;        # =small o, macron
    $line =~ s/\\\|\[oelig\]\\\|/&\#x0153;/g;        # latin small ligature oe
    $line =~ s/\\\|\[OElig\]\\\|/&\#x0152;/g;        # latin capital ligature OE
    $line =~ s/\\\|\[racute\]\\\|/&\#x0155;/g;        # =small r, acute accent
    $line =~ s/\\\|\[Racute\]\\\|/&\#x0154;/g;        # =capital R, acute accent
    $line =~ s/\\\|\[rcaron\]\\\|/&\#x0159;/g;        # =small r, caron
    $line =~ s/\\\|\[Rcaron\]\\\|/&\#x0158;/g;        # =capital R, caron
    $line =~ s/\\\|\[rcedil\]\\\|/&\#x0157;/g;        # =small r, cedilla
    $line =~ s/\\\|\[Rcedil\]\\\|/&\#x0156;/g;        # =capital R, cedilla
    $line =~ s/\\\|\[sacute\]\\\|/&\#x015B;/g;        # =small s, acute accent
    $line =~ s/\\\|\[Sacute\]\\\|/&\#x015A;/g;        # =capital S, acute accent
    $line =~ s/\\\|\[scaron\]\\\|/&\#x0161;/g;        # latin small letter s with caron
    $line =~ s/\\\|\[Scaron\]\\\|/&\#x0160;/g;        # latin capital letter S with caron
    $line =~ s/\\\|\[scedil\]\\\|/&\#x015F;/g;        # =small s, cedilla
    $line =~ s/\\\|\[Scedil\]\\\|/&\#x015E;/g;        # =capital S, cedilla
    $line =~ s/\\\|\[scirc\]\\\|/&\#x015D;/g;        # =small s, circumflex accent
    $line =~ s/\\\|\[Scirc\]\\\|/&\#x015C;/g;        # =capital S, circumflex accent
    $line =~ s/\\\|\[tcaron\]\\\|/&\#x0165;/g;        # =small t, caron
    $line =~ s/\\\|\[Tcaron\]\\\|/&\#x0164;/g;        # =capital T, caron
    $line =~ s/\\\|\[tcedil\]\\\|/&\#x0163;/g;        # =small t, cedilla
    $line =~ s/\\\|\[Tcedil\]\\\|/&\#x0162;/g;        # =capital T, cedilla
    $line =~ s/\\\|\[tstrok\]\\\|/&\#x0167;/g;        # =small t, stroke
    $line =~ s/\\\|\[Tstrok\]\\\|/&\#x0166;/g;        # =capital T, stroke
    $line =~ s/\\\|\[ubreve\]\\\|/&\#x016D;/g;        # =small u, breve
    $line =~ s/\\\|\[Ubreve\]\\\|/&\#x016C;/g;        # =capital U, breve
    $line =~ s/\\\|\[udblac\]\\\|/&\#x0171;/g;        # =small u, double acute accent
    $line =~ s/\\\|\[Udblac\]\\\|/&\#x0170;/g;        # =capital U, double acute accent
    $line =~ s/\\\|\[umacr\]\\\|/&\#x016B;/g;        # =small u, macron
    $line =~ s/\\\|\[Umacr\]\\\|/&\#x016A;/g;        # =capital U, macron
    $line =~ s/\\\|\[uogon\]\\\|/&\#x0173;/g;        # =small u, ogonek
    $line =~ s/\\\|\[Uogon\]\\\|/&\#x0172;/g;        # =capital U, ogonek
    $line =~ s/\\\|\[uring\]\\\|/&\#x016F;/g;        # =small u, ring
    $line =~ s/\\\|\[Uring\]\\\|/&\#x016E;/g;        # =capital U, ring
    $line =~ s/\\\|\[utilde\]\\\|/&\#x0169;/g;        # =small u, tilde
    $line =~ s/\\\|\[Utilde\]\\\|/&\#x0168;/g;        # =capital U, tilde
    $line =~ s/\\\|\[wcirc\]\\\|/&\#x0175;/g;        # =small w, circumflex accent
    $line =~ s/\\\|\[Wcirc\]\\\|/&\#x0174;/g;        # =capital W, circumflex accent
    $line =~ s/\\\|\[ycirc\]\\\|/&\#x0177;/g;        # =small y, circumflex accent
    $line =~ s/\\\|\[Ycirc\]\\\|/&\#x0176;/g;        # =capital Y, circumflex accent
    $line =~ s/\\\|\[Yuml\]\\\|/&\#x0178;/g;        # latin capital letter Y with diaeresis
    $line =~ s/\\\|\[zacute\]\\\|/&\#x017A;/g;        # =small z, acute accent
    $line =~ s/\\\|\[Zacute\]\\\|/&\#x0179;/g;        # =capital Z, acute accent
    $line =~ s/\\\|\[zcaron\]\\\|/&\#x017E;/g;        # =small z, caron
    $line =~ s/\\\|\[Zcaron\]\\\|/&\#x017D;/g;        # =capital Z, caron
    $line =~ s/\\\|\[zdot\]\\\|/&\#x017C;/g;        # =small z, dot above
    $line =~ s/\\\|\[Zdot\]\\\|/&\#x017B;/g;        # =capital Z, dot above
    #
    # <!ENTITY % ISOdia PUBLIC "ISO 8879:1986//ENTITIES Diacritical Marks//EN">
    #
    $line =~ s/\\\|\[acute\]\\\|/&\#x00B4;/g;        # acute accent = spacing acute
    $line =~ s/\\\|\[breve\]\\\|/&\#x02D8;/g;        # =breve
    $line =~ s/\\\|\[caron\]\\\|/&\#x02C7;/g;        # =caron
    $line =~ s/\\\|\[cedil\]\\\|/&\#x00B8;/g;        # cedilla = spacing cedilla
    $line =~ s/\\\|\[circ\]\\\|/&\#x005E;/g;        # modifier letter circumflex accent
    $line =~ s/\\\|\[dblac\]\\\|/&\#x02DD;/g;        # =double acute accent
    $line =~ s/\\\|\[die\]\\\|/&\#x00A8;/g;        # diaeresis = spacing diaeresis
    $line =~ s/\\\|\[dot\]\\\|/&\#x02D9;/g;        # =dot above
    $line =~ s/\\\|\[grave\]\\\|/&\#x0060;/g;        # =grave accent
    $line =~ s/\\\|\[macr\]\\\|/&\#x00AF;/g;        # macron = spacing macron = overline = APL overbar
    $line =~ s/\\\|\[ogon\]\\\|/&\#x02DB;/g;        # =ogonek
    $line =~ s/\\\|\[ring\]\\\|/&\#x02DA;/g;        # =ring
    $line =~ s/\\\|\[tilde\]\\\|/&\#x007E;/g;        # small tilde
    $line =~ s/\\\|\[uml\]\\\|/&\#x00A8;/g;        # diaeresis = spacing diaeresis
    #
    # <!ENTITY % ISOcyr1 PUBLIC "ISO 8879:1986//ENTITIES Russian Cyrillic//EN">
    #
    $line =~ s/\\\|\[acy\]\\\|/&\#x0430;/g;        # =small a, Cyrillic
    $line =~ s/\\\|\[Acy\]\\\|/&\#x0410;/g;        # =capital A, Cyrillic
    $line =~ s/\\\|\[bcy\]\\\|/&\#x0431;/g;        # =small be, Cyrillic
    $line =~ s/\\\|\[Bcy\]\\\|/&\#x0411;/g;        # =capital BE, Cyrillic
    $line =~ s/\\\|\[vcy\]\\\|/&\#x0432;/g;        # =small ve, Cyrillic
    $line =~ s/\\\|\[Vcy\]\\\|/&\#x0412;/g;        # =capital VE, Cyrillic
    $line =~ s/\\\|\[gcy\]\\\|/&\#x0433;/g;        # =small ghe, Cyrillic
    $line =~ s/\\\|\[Gcy\]\\\|/&\#x0413;/g;        # =capital GHE, Cyrillic
    $line =~ s/\\\|\[dcy\]\\\|/&\#x0434;/g;        # =small de, Cyrillic
    $line =~ s/\\\|\[Dcy\]\\\|/&\#x0414;/g;        # =capital DE, Cyrillic
    $line =~ s/\\\|\[iecy\]\\\|/&\#x0435;/g;        # =small ie, Cyrillic
    $line =~ s/\\\|\[IEcy\]\\\|/&\#x0415;/g;        # =capital IE, Cyrillic
    $line =~ s/\\\|\[iocy\]\\\|/&\#x0451;/g;        # =small io, Russian
    $line =~ s/\\\|\[IOcy\]\\\|/&\#x0401;/g;        # =capital IO, Russian
    $line =~ s/\\\|\[zhcy\]\\\|/&\#x0436;/g;        # =small zhe, Cyrillic
    $line =~ s/\\\|\[ZHcy\]\\\|/&\#x0416;/g;        # =capital ZHE, Cyrillic
    $line =~ s/\\\|\[zcy\]\\\|/&\#x0437;/g;        # =small ze, Cyrillic
    $line =~ s/\\\|\[Zcy\]\\\|/&\#x0417;/g;        # =capital ZE, Cyrillic
    $line =~ s/\\\|\[icy\]\\\|/&\#x0438;/g;        # =small i, Cyrillic
    $line =~ s/\\\|\[Icy\]\\\|/&\#x0418;/g;        # =capital I, Cyrillic
    $line =~ s/\\\|\[jcy\]\\\|/&\#x0439;/g;        # =small short i, Cyrillic
    $line =~ s/\\\|\[Jcy\]\\\|/&\#x0419;/g;        # =capital short I, Cyrillic
    $line =~ s/\\\|\[kcy\]\\\|/&\#x043A;/g;        # =small ka, Cyrillic
    $line =~ s/\\\|\[Kcy\]\\\|/&\#x041A;/g;        # =capital KA, Cyrillic
    $line =~ s/\\\|\[lcy\]\\\|/&\#x043B;/g;        # =small el, Cyrillic
    $line =~ s/\\\|\[Lcy\]\\\|/&\#x041B;/g;        # =capital EL, Cyrillic
    $line =~ s/\\\|\[mcy\]\\\|/&\#x043C;/g;        # =small em, Cyrillic
    $line =~ s/\\\|\[Mcy\]\\\|/&\#x041C;/g;        # =capital EM, Cyrillic
    $line =~ s/\\\|\[ncy\]\\\|/&\#x043D;/g;        # =small en, Cyrillic
    $line =~ s/\\\|\[Ncy\]\\\|/&\#x041D;/g;        # =capital EN, Cyrillic
    $line =~ s/\\\|\[ocy\]\\\|/&\#x043E;/g;        # =small o, Cyrillic
    $line =~ s/\\\|\[Ocy\]\\\|/&\#x041E;/g;        # =capital O, Cyrillic
    $line =~ s/\\\|\[pcy\]\\\|/&\#x043F;/g;        # =small pe, Cyrillic
    $line =~ s/\\\|\[Pcy\]\\\|/&\#x041F;/g;        # =capital PE, Cyrillic
    $line =~ s/\\\|\[rcy\]\\\|/&\#x0440;/g;        # =small er, Cyrillic
    $line =~ s/\\\|\[Rcy\]\\\|/&\#x0420;/g;        # =capital ER, Cyrillic
    $line =~ s/\\\|\[scy\]\\\|/&\#x0441;/g;        # =small es, Cyrillic
    $line =~ s/\\\|\[Scy\]\\\|/&\#x0421;/g;        # =capital ES, Cyrillic
    $line =~ s/\\\|\[tcy\]\\\|/&\#x0442;/g;        # =small te, Cyrillic
    $line =~ s/\\\|\[Tcy\]\\\|/&\#x0422;/g;        # =capital TE, Cyrillic
    $line =~ s/\\\|\[ucy\]\\\|/&\#x0443;/g;        # =small u, Cyrillic
    $line =~ s/\\\|\[Ucy\]\\\|/&\#x0423;/g;        # =capital U, Cyrillic
    $line =~ s/\\\|\[fcy\]\\\|/&\#x0444;/g;        # =small ef, Cyrillic
    $line =~ s/\\\|\[Fcy\]\\\|/&\#x0424;/g;        # =capital EF, Cyrillic
    $line =~ s/\\\|\[khcy\]\\\|/&\#x0445;/g;        # =small ha, Cyrillic
    $line =~ s/\\\|\[KHcy\]\\\|/&\#x0425;/g;        # =capital HA, Cyrillic
    $line =~ s/\\\|\[tscy\]\\\|/&\#x0446;/g;        # =small tse, Cyrillic
    $line =~ s/\\\|\[TScy\]\\\|/&\#x0426;/g;        # =capital TSE, Cyrillic
    $line =~ s/\\\|\[chcy\]\\\|/&\#x0447;/g;        # =small che, Cyrillic
    $line =~ s/\\\|\[CHcy\]\\\|/&\#x0427;/g;        # =capital CHE, Cyrillic
    $line =~ s/\\\|\[shcy\]\\\|/&\#x0448;/g;        # =small sha, Cyrillic
    $line =~ s/\\\|\[SHcy\]\\\|/&\#x0428;/g;        # =capital SHA, Cyrillic
    $line =~ s/\\\|\[shchcy\]\\\|/&\#x0449;/g;        # =small shcha, Cyrillic
    $line =~ s/\\\|\[SHCHcy\]\\\|/&\#x0429;/g;        # =capital SHCHA, Cyrillic
    $line =~ s/\\\|\[hardcy\]\\\|/&\#x044A;/g;        # =small hard sign, Cyrillic
    $line =~ s/\\\|\[HARDcy\]\\\|/&\#x042A;/g;        # =capital HARD sign, Cyrillic
    $line =~ s/\\\|\[ycy\]\\\|/&\#x044B;/g;        # =small yeru, Cyrillic
    $line =~ s/\\\|\[Ycy\]\\\|/&\#x042B;/g;        # =capital YERU, Cyrillic
    $line =~ s/\\\|\[softcy\]\\\|/&\#x044C;/g;        # =small soft sign, Cyrillic
    $line =~ s/\\\|\[SOFTcy\]\\\|/&\#x042C;/g;        # =capital SOFT sign, Cyrillic
    $line =~ s/\\\|\[ecy\]\\\|/&\#x044D;/g;        # =small e, Cyrillic
    $line =~ s/\\\|\[Ecy\]\\\|/&\#x042D;/g;        # =capital E, Cyrillic
    $line =~ s/\\\|\[yucy\]\\\|/&\#x044E;/g;        # =small yu, Cyrillic
    $line =~ s/\\\|\[YUcy\]\\\|/&\#x042E;/g;        # =capital YU, Cyrillic
    $line =~ s/\\\|\[yacy\]\\\|/&\#x044F;/g;        # =small ya, Cyrillic
    $line =~ s/\\\|\[YAcy\]\\\|/&\#x042F;/g;        # =capital YA, Cyrillic
    $line =~ s/\\\|\[numero\]\\\|/&\#x2116;/g;        # =numero sign
    #
    # <!ENTITY % ISOcyr2 PUBLIC "ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN">
    #
    $line =~ s/\\\|\[djcy\]\\\|/&\#x0452;/g;        # =small dje, Serbian
    $line =~ s/\\\|\[DJcy\]\\\|/&\#x0402;/g;        # =capital DJE, Serbian
    $line =~ s/\\\|\[gjcy\]\\\|/&\#x0453;/g;        # =small gje, Macedonian
    $line =~ s/\\\|\[GJcy\]\\\|/&\#x0403;/g;        # =capital GJE Macedonian
    $line =~ s/\\\|\[jukcy\]\\\|/&\#x0454;/g;        # =small je, Ukrainian
    $line =~ s/\\\|\[Jukcy\]\\\|/&\#x0404;/g;        # =capital JE, Ukrainian
    $line =~ s/\\\|\[dscy\]\\\|/&\#x0455;/g;        # =small dse, Macedonian
    $line =~ s/\\\|\[DScy\]\\\|/&\#x0405;/g;        # =capital DSE, Macedonian
    $line =~ s/\\\|\[iukcy\]\\\|/&\#x0456;/g;        # =small i, Ukrainian
    $line =~ s/\\\|\[Iukcy\]\\\|/&\#x0406;/g;        # =capital I, Ukrainian
    $line =~ s/\\\|\[yicy\]\\\|/&\#x0457;/g;        # =small yi, Ukrainian
    $line =~ s/\\\|\[YIcy\]\\\|/&\#x0407;/g;        # =capital YI, Ukrainian
    $line =~ s/\\\|\[jsercy\]\\\|/&\#x0458;/g;        # =small je, Serbian
    $line =~ s/\\\|\[Jsercy\]\\\|/&\#x0408;/g;        # =capital JE, Serbian
    $line =~ s/\\\|\[ljcy\]\\\|/&\#x0459;/g;        # =small lje, Serbian
    $line =~ s/\\\|\[LJcy\]\\\|/&\#x0409;/g;        # =capital LJE, Serbian
    $line =~ s/\\\|\[njcy\]\\\|/&\#x045A;/g;        # =small nje, Serbian
    $line =~ s/\\\|\[NJcy\]\\\|/&\#x040A;/g;        # =capital NJE, Serbian
    $line =~ s/\\\|\[tshcy\]\\\|/&\#x045B;/g;        # =small tshe, Serbian
    $line =~ s/\\\|\[TSHcy\]\\\|/&\#x040B;/g;        # =capital TSHE, Serbian
    $line =~ s/\\\|\[kjcy\]\\\|/&\#x045C;/g;        # =small kje Macedonian
    $line =~ s/\\\|\[KJcy\]\\\|/&\#x040C;/g;        # =capital KJE, Macedonian
    $line =~ s/\\\|\[ubrcy\]\\\|/&\#x045E;/g;        # =small u, Byelorussian
    $line =~ s/\\\|\[Ubrcy\]\\\|/&\#x040E;/g;        # =capital U, Byelorussian
    $line =~ s/\\\|\[dzcy\]\\\|/&\#x045F;/g;        # =small dze, Serbian
    $line =~ s/\\\|\[DZcy\]\\\|/&\#x040F;/g;        # =capital dze, Serbian
    #
    # <!ENTITY % ISOgrk1 PUBLIC "ISO 8879:1986//ENTITIES Greek Letters//EN">
    #
    $line =~ s/\\\|\[agr\]\\\|/&\#x03B1;/g;        # =small alpha, Greek
    $line =~ s/\\\|\[Agr\]\\\|/&\#x0391;/g;        # greek capital letter alpha
    $line =~ s/\\\|\[bgr\]\\\|/&\#x03B2;/g;        # =small beta, Greek
    $line =~ s/\\\|\[Bgr\]\\\|/&\#x0392;/g;        # greek capital letter beta
    $line =~ s/\\\|\[ggr\]\\\|/&\#x03B3;/g;        # =small gamma, Greek
    $line =~ s/\\\|\[Ggr\]\\\|/&\#x0393;/g;        # =capital Gamma, Greek
    $line =~ s/\\\|\[dgr\]\\\|/&\#x03B4;/g;        # =small delta, Greek
    $line =~ s/\\\|\[Dgr\]\\\|/&\#x0394;/g;        # =capital Delta, Greek
    $line =~ s/\\\|\[egr\]\\\|/&\#x03B5;/g;        # =small epsilon, Greek
    $line =~ s/\\\|\[Egr\]\\\|/&\#x0395;/g;        # greek capital letter epsilon
    $line =~ s/\\\|\[zgr\]\\\|/&\#x03B6;/g;        # =small zeta, Greek
    $line =~ s/\\\|\[Zgr\]\\\|/&\#x0396;/g;        # greek capital letter zeta
    $line =~ s/\\\|\[eegr\]\\\|/&\#x03B7;/g;        # =small eta, Greek
    $line =~ s/\\\|\[EEgr\]\\\|/&\#x0397;/g;        # greek capital letter eta
    $line =~ s/\\\|\[thgr\]\\\|/&\#x03B8;/g;        # =small theta, Greek
    $line =~ s/\\\|\[THgr\]\\\|/&\#x0398;/g;        # =capital Theta, Greek
    $line =~ s/\\\|\[igr\]\\\|/&\#x03B9;/g;        # =small iota, Greek
    $line =~ s/\\\|\[Igr\]\\\|/&\#x0399;/g;        # greek capital letter iota
    $line =~ s/\\\|\[kgr\]\\\|/&\#x03BA;/g;        # =small kappa, Greek
    $line =~ s/\\\|\[Kgr\]\\\|/&\#x039A;/g;        # greek capital letter kappa
    $line =~ s/\\\|\[lgr\]\\\|/&\#x03BB;/g;        # =small lambda, Greek
    $line =~ s/\\\|\[Lgr\]\\\|/&\#x039B;/g;        # =capital Lambda, Greek
    $line =~ s/\\\|\[mgr\]\\\|/&\#x03BC;/g;        # =small mu, Greek
    $line =~ s/\\\|\[Mgr\]\\\|/&\#x039C;/g;        # greek capital letter mu
    $line =~ s/\\\|\[ngr\]\\\|/&\#x03BD;/g;        # =small nu, Greek
    $line =~ s/\\\|\[Ngr\]\\\|/&\#x039D;/g;        # greek capital letter nu
    $line =~ s/\\\|\[xgr\]\\\|/&\#x03BE;/g;        # =small xi, Greek
    $line =~ s/\\\|\[Xgr\]\\\|/&\#x039E;/g;        # =capital Xi, Greek
    $line =~ s/\\\|\[ogr\]\\\|/&\#x03BF;/g;        # greek small letter omicron
    $line =~ s/\\\|\[Ogr\]\\\|/&\#x039F;/g;        # greek capital letter omicron
    $line =~ s/\\\|\[pgr\]\\\|/&\#x03C0;/g;        # =small pi, Greek
    $line =~ s/\\\|\[Pgr\]\\\|/&\#x03A0;/g;        # =capital Pi, Greek
    $line =~ s/\\\|\[rgr\]\\\|/&\#x03C1;/g;        # =small rho, Greek
    $line =~ s/\\\|\[Rgr\]\\\|/&\#x03A1;/g;        # greek capital letter rho
    $line =~ s/\\\|\[sgr\]\\\|/&\#x03C3;/g;        # =small sigma, Greek
    $line =~ s/\\\|\[Sgr\]\\\|/&\#x03A3;/g;        # =capital Sigma, Greek
    $line =~ s/\\\|\[sfgr\]\\\|/&\#x03C2;/g;        # =final small sigma, Greek
    $line =~ s/\\\|\[tgr\]\\\|/&\#x03C4;/g;        # =small tau, Greek
    $line =~ s/\\\|\[Tgr\]\\\|/&\#x03A4;/g;        # greek capital letter tau
    $line =~ s/\\\|\[ugr\]\\\|/&\#x03C5;/g;        # =small upsilon, Greek
    $line =~ s/\\\|\[Ugr\]\\\|/&\#x03A5;/g;        # greek capital letter upsilon
    $line =~ s/\\\|\[phgr\]\\\|/&\#x03C6;/g;        # =small phi, Greek
    $line =~ s/\\\|\[PHgr\]\\\|/&\#x03A6;/g;        # =capital Phi, Greek
    $line =~ s/\\\|\[khgr\]\\\|/&\#x03C7;/g;        # =small chi, Greek
    $line =~ s/\\\|\[KHgr\]\\\|/&\#x03A7;/g;        # greek capital letter chi
    $line =~ s/\\\|\[psgr\]\\\|/&\#x03C8;/g;        # =small psi, Greek
    $line =~ s/\\\|\[PSgr\]\\\|/&\#x03A8;/g;        # =capital Psi, Greek
    $line =~ s/\\\|\[ohgr\]\\\|/&\#x03C9;/g;        # =small omega, Greek
    $line =~ s/\\\|\[OHgr\]\\\|/&\#x03A9;/g;        # =capital Omega, Greek
    #
    # <!ENTITY % ISOgrk2 PUBLIC "ISO 8879:1986//ENTITIES Monotoniko Greek//EN">
    #
    $line =~ s/\\\|\[aacgr\]\\\|/&\#x03AC;/g;        # =small alpha, accent, Greek
    $line =~ s/\\\|\[Aacgr\]\\\|/&\#x0386;/g;        # =capital Alpha, accent, Greek
    $line =~ s/\\\|\[eacgr\]\\\|/&\#x03AD;/g;        # =small epsilon, accent, Greek
    $line =~ s/\\\|\[Eacgr\]\\\|/&\#x0388;/g;        # =capital Epsilon, accent, Greek
    $line =~ s/\\\|\[eeacgr\]\\\|/&\#x03AE;/g;        # =small eta, accent, Greek
    $line =~ s/\\\|\[EEacgr\]\\\|/&\#x0389;/g;        # =capital Eta, accent, Greek
    $line =~ s/\\\|\[idigr\]\\\|/&\#x03CA;/g;        # =small iota, dieresis, Greek
    $line =~ s/\\\|\[Idigr\]\\\|/&\#x03AA;/g;        # =capital Iota, dieresis, Greek
    $line =~ s/\\\|\[iacgr\]\\\|/&\#x03AF;/g;        # =small iota, accent, Greek
    $line =~ s/\\\|\[Iacgr\]\\\|/&\#x038A;/g;        # =capital Iota, accent, Greek
    $line =~ s/\\\|\[idiagr\]\\\|/&\#x0390;/g;        # =small iota, dieresis, accent, Greek
    $line =~ s/\\\|\[oacgr\]\\\|/&\#x03CC;/g;        # =small omicron, accent, Greek
    $line =~ s/\\\|\[Oacgr\]\\\|/&\#x038C;/g;        # =capital Omicron, accent, Greek
    $line =~ s/\\\|\[udigr\]\\\|/&\#x03CB;/g;        # =small upsilon, dieresis, Greek
    $line =~ s/\\\|\[Udigr\]\\\|/&\#x03AB;/g;        # =capital Upsilon, dieresis, Greek
    $line =~ s/\\\|\[uacgr\]\\\|/&\#x03CD;/g;        # =small upsilon, accent, Greek
    $line =~ s/\\\|\[Uacgr\]\\\|/&\#x038E;/g;        # =capital Upsilon, accent, Greek
    $line =~ s/\\\|\[udiagr\]\\\|/&\#x03B0;/g;        # =small upsilon, dieresis, accent, Greek
    $line =~ s/\\\|\[ohacgr\]\\\|/&\#x03CE;/g;        # =small omega, accent, Greek
    $line =~ s/\\\|\[OHacgr\]\\\|/&\#x038F;/g;        # =capital Omega, accent, Greek
    #
    # Extra Unicode characters, converted to "&#nnn;"
    #
    $max = length ($line);
    while (1)
      {
        if ($offset >= $max)
          {
            last;
          }
        else
          {
            $char = substr ($line, $offset, 1);
            if (ord ($char) > 127)
              {
                $line_new = $line_new . "&#" . ord ($char) . ";";
              }
            else
              {
                $line_new = $line_new . $char;
              }
          }
        $offset++;
      }
    $line_new = $line_new . "\n";
    #
    return ($line_new);
}
#
# Jump_sp_element.
#
# &jump_sp_element (INPUT_STREAM, OUTPUT_STREAM, LINE,
#                   CONCLUSION_STRING)
#
sub jump_sp_element
{
    my ($input_stream)  = $_[0];
    my ($output_stream) = $_[1];
    my ($line)          = $_[2];
    my ($conclusion)    = $_[3];
    my ($input_file)    = $_[4];
    my ($line_counter)  = $_[5];
    #
    my ($line_prefix)   = "";
    my ($line_content)  = "";
    #
    # Try to jump.
    #
    while ($line !~ m/^$conclusion$/i)
      {
    	#
        # Tranfer the line, read the next and increase the counter.
	#
        print $output_stream ("$line");
        $line = <$input_stream>;
	#
        $line_counter++;
        &wait_message ("$PROGRAM_EXECUTABLE:$SOURCE_FILE_NAME:$input_file:$line_counter");
	#
      }
    #
    # Last line (the one with the end string) must be transfered.
    #
    print $output_stream ("$line");
    #
    return ($line_counter);
    #
} # jump_sp_element
#
# Transform SP output for some special character, depending on the
# back-end system limitations.
#
# The file ROOT_FILE_NAME.sp2 is created
#
# &sp_to_sp_filter (INPUT_FILE, TYPESETTING) --> OUTPUT_FILE
#
sub sp_to_sp_filter
{
    my ($input_file)            = $_[0];
    my ($typesetting)           = $_[1];
    my ($output_file)           = &root_name ("$input_file", ".sp") . ".sp2";
    my ($line)                  = "";
    my ($n)                     = 0;
    my ($line_prefix)           = "";
    my ($line_content)          = "";
    my ($attribute_name)        = "";
    my ($attribute_type)        = "";
    my ($attribute_value)       = "";
    my ($line_counter)          = 0;

    # Set current file name.

    $CURRENT_FILE_NAME = "$input_file";
    
    # Tell what we are doing.

    &diag_output (sprintf (gettext ("%s:%s: "),
                           $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME), $V_SUPER);
    &diag_output (sprintf (gettext ("post-SP re-elaborations\n")), $V_SUPER);
    
    # Here there is no need to use references for file handler names,
    # but this way we use uniform code.

    my ($input_stream) = "$input_file";
    my ($output_stream) = "$output_file";
    
    ##
    ## Start of filter
    ##
    
    # Open input and output files.

    open ($input_stream, "<:utf8", "$input_file");
    open ($output_stream, ">:utf8", "$output_file");
    
    # Do what is required

    while ($line = <$input_stream>)
      {

        $line_counter++;
        &wait_message ("$PROGRAM_EXECUTABLE:$SOURCE_FILE_NAME:$input_file:$line_counter");
        #
        # Literal text is jumped.
        #
        if ($line =~ m/^\(VERBATIMPRE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)VERBATIMPRE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(ASCIIART$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)ASCIIART\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(URI$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)URI\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(EMAIL$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)EMAIL\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(NUM$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)NUM\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(TEX$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)TEX\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(HTML$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)HTML\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(EPSIMG$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)EPSIMG\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(EPSIMAGE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)EPSIMAGE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(FIGIMG$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)FIGIMG\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(FIGIMAGE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)FIGIMAGE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(GNUPLOTIMG$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)GNUPLOTIMG\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(GNUPLOTIMAGE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)GNUPLOTIMAGE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(LYIMG$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)LYIMG\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(LYIMAGE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)LYIMAGE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(TEXIMG$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)TEXIMG\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(TEXIMAGE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)TEXIMAGE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(LATEXIMG$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)LATEXIMG\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(LATEXIMAGE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)LATEXIMAGE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(EMBIMG$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)EMBIMG\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(HTMLIMG$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)HTMLIMG\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(EMBIMAGE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)EMBIMAGE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(HTMLIMAGE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)HTMLIMAGE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(PRINTEDFONTSIZE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)PRINTEDFONTSIZE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^\(PRINTEDPAGESIZE$/i)
          {
            $line_counter = &jump_sp_element ($input_stream,
                                              $output_stream,
                                              $line,
                                              "\\)PRINTEDPAGESIZE\$",
                                              $input_file,
                                              $line_counter);
          }
        elsif ($line =~ m/^A.* CDATA/i)
          {
            #
            # This is an attribute preceding an element.
	    #
            $attribute_name  = "";
            $attribute_type  = "";
            $attribute_value = "";
	    #
            if ($line =~ m/^A([a-z]*) ([a-z]*) ?(.*)$/i)
              {
                $attribute_name  = $1;
                $attribute_type  = $2;
                $attribute_value = $3;
              }
            #
            # The most attributes are literal.
	    #
            if (uc ($attribute_name) eq "no-one-for-now")
              {
                #
                # Can be converted, but now, there is no need...
		#
                print $output_stream ($line);
              }
            else
              {
                #
                # All the other attributes are verbatim.
                # The line is transfered.
		#
                print $output_stream ($line);
              }

          }
        #
        # Text lines that start with a "-" must be re-elaborated.
	#
        elsif ($line =~ m/^(-)(.*)$/)
          {
            #
            # The line contains text and must be re-elaborated for SGML
            # macros.
            #
            $line_prefix = $1;
            $line_content = $2;
            #
            # Start converting special character into SDATA entities.
	    #
            $line_content = &sp_text_to_sdata ($line_content);
            #
            # Some special symbols for this transformation
            # are declared as SDATA entities, with the
            # form "[name  ]".
            # When SP insert these SDATA entities, they became
            # "\|[name  ]\|".
            # This enshure that the substitution mechanism
            # doesn't do mistakes.
            # Some special characters must be transformed
            # before into "\|[name  ]\|", then they are
            # translated back into the right way.
            # This way, characters that require a special
            # form when used with some programs, may be
            # inserted literally, as long that this
            # can be done for SGML, and also as SGML entities.
	    #
            if ($typesetting eq "LATEX")
              {
                $line_content = &sp_sdata_text_to_sp_latex ($line_content);
              }
            elsif ($typesetting eq "HTML")
              {
                $line_content = &sp_sdata_text_to_sp_html ($line_content);
              }
            
            # Rejoin the line.  

            $line = $line_prefix . $line_content . "\n";
            
            # The line is transfered.

            print $output_stream ($line);
          }
        else
          {
            
            # The line is transfered.

            print $output_stream ($line);
          }
      }
    
    # Close files.

    close ($input_stream);
    close ($output_stream);
    
    # Return the temporary file name.

    return ($output_file);

} # sp_to_sp_filter

# Give page x,y sizes with big point units (PostScript)

sub page_size
{
    my ($page) = $_[0];
    my (@width) = ();

    $page = lc ($page);    

    if ($page eq "11x17")
      {
        $width[0] = 11*72;
        $width[1] = 17*72;
      }
    elsif ($page eq "a0")
      {
        $width[0] = 33.0556*72;
        $width[1] = 46.7778*72;
      }
    elsif ($page eq "a10")
      {
        $width[0] = 1.02778*72;
        $width[1] = 1.45833*72;
      }
    elsif ($page eq "a1")
      {
        $width[0] = 23.3889*72;
        $width[1] = 33.0556*72;
      }
    elsif ($page eq "a2")
      {
        $width[0] = 16.5278*72;
        $width[1] = 23.3889*72;
      }
    elsif ($page eq "a3")
      {
        $width[0] = 11.6944*72;
        $width[1] = 16.5278*72;
      }
    elsif ($page eq "a4")
      {
        $width[0] = 8.26389*72;
        $width[1] = 11.6944*72;
      }
    elsif ($page eq "a5")
      {
        $width[0] = 5.84722*72;
        $width[1] = 8.26389*72;
      }
    elsif ($page eq "a6")
      {
        $width[0] = 4.125*72;
        $width[1] = 5.84722*72;
      }
    elsif ($page eq "a7")
      {
        $width[0] = 2.91667*72;
        $width[1] = 4.125*72;
      }
    elsif ($page eq "a8")
      {
        $width[0] = 2.05556*72;
        $width[1] = 2.91667*72;
      }
    elsif ($page eq "a9")
      {
        $width[0] = 1.45833*72;
        $width[1] = 2.05556*72;
      }
    elsif ($page eq "archa")
      {
        $width[0] = 9*72;
        $width[1] = 12*72;
      }
    elsif ($page eq "archb")
      {
        $width[0] = 12*72;
        $width[1] = 18*72;
      }
    elsif ($page eq "archc")
      {
        $width[0] = 18*72;
        $width[1] = 24*72;
      }
    elsif ($page eq "archd")
      {
        $width[0] = 24*72;
        $width[1] = 36*72;
      }
    elsif ($page eq "arche")
      {
        $width[0] = 36*72;
        $width[1] = 48*72;
      }
    elsif ($page eq "b0")
      {
        $width[0] = 39.3889*72;
        $width[1] = 55.6667*72;
      }
    elsif ($page eq "b1")
      {
        $width[0] = 27.8333*72;
        $width[1] = 39.3889*72;
      }
    elsif ($page eq "b2")
      {
        $width[0] = 19.6944*72;
        $width[1] = 27.8333*72;
      }
    elsif ($page eq "b3")
      {
        $width[0] = 13.9167*72;
        $width[1] = 19.6944*72;
      }
    elsif ($page eq "b4")
      {
        $width[0] = 9.84722*72;
        $width[1] = 13.9167*72;
      }
    elsif ($page eq "b5")
      {
        $width[0] = 6.95833*72;
        $width[1] = 9.84722*72;
      }
    elsif ($page eq "flsa")
      {
        $width[0] = 8.5*72;
        $width[1] = 13*72;
      }
    elsif ($page eq "flse")
      {
        $width[0] = 8.5*72;
        $width[1] = 13*72;
      }
    elsif ($page eq "halfletter")
      {
        $width[0] = 5.5*72;
        $width[1] = 8.5*72;
      }
    elsif ($page eq "ledger")
      {
        $width[0] = 17*72;
        $width[1] = 11*72;
      }
    elsif ($page eq "legal")
      {
        $width[0] = 8.5*72;
        $width[1] = 14*72;
      }
    elsif ($page eq "letter")
      {
        $width[0] = 8.5*72;
        $width[1] = 11*72;
      }
    elsif ($page eq "note")
      {
        $width[0] = 7.5*72;
        $width[1] = 10*72;
      }
    else
      {
        &diag_output (sprintf (gettext ("%s:ERROR: invalid page name: %s\n"),
                               $PROGRAM_EXECUTABLE,
                               $page), $V_ERROR);
        $width[0] = 0;
        $width[1] = 0;
      }
    return @width;
}

# Extract length value.

sub length_value
{
    my ($length) = $_[0];
    $length =~ m/([0-9.,-]+)\s*([a-zA-Z]*)/;
    $length = $1;
    $length =~ s/,/./;
    return ($length);
}

# Extract unit.

sub length_unit
{
    my ($length) = $_[0];
    my ($unit) = $_[0];
    $length =~ m/([0-9.,-]+)\s*([a-zA-Z]*)/;
    $unit = $2;
    return ($unit);
}

# Sum length.

sub length_sum
{
    my ($length1) = $_[0];
    my ($length2) = $_[1];
    my ($unit1) = 0;
    my ($unit2) = 0;

    $length1 =~ m/([0-9.,-]+)\s*([a-zA-Z]*)/;
    $length1 = $1;
    $length1 =~ s/,/./;
    $unit1 = $2;

    $length2 =~ m/([0-9.,-]+)\s*([a-zA-Z]*)/;
    $length2 = $1;
    $length2 =~ s/,/./;
    $unit2 = $2;

    if ($unit1 eq "mm")
      {
        # ok
        ;
      }
    elsif ($unit1 eq "cm")
      {
        $length1 = ($length1 * 10);
      }
    elsif ($unit1 eq "in")
      {
        $length1 = ($length1 * 25.4);
      }
    elsif ($unit1 eq "pt")
      {
        $length1 = (($length1 / 72.27) * 25.4);
      }
    elsif ($unit1 eq "bp")
      {
        $length1 = (($length1 / 72) * 25.4);
      }
    elsif ($unit1 eq "pc")
      {
        $length1 = ($length1 * 25.4 * 72/6);
      }

    if ($unit2 eq "mm")
      {
        # ok
        ;
      }
    elsif ($unit2 eq "cm")
      {
        $length2 = ($length2 * 10);
      }
    elsif ($unit2 eq "in")
      {
        $length2 = ($length2 * 25.4);
      }
    elsif ($unit2 eq "pt")
      {
        $length2 = (($length2 / 72.27) * 25.4);
      }
    elsif ($unit2 eq "bp")
      {
        $length2 = (($length2 / 72) * 25.4);
      }
    elsif ($unit2 eq "pc")
      {
        $length2 = ($length2 * 25.4 * 72/6);
      }

    return (($length1+$length2) . "mm");
}

# Subtract length.

sub length_sub
{
    my ($length1) = $_[0];
    my ($length2) = $_[1];
    my ($unit1) = 0;
    my ($unit2) = 0;

    $length1 =~ m/([0-9.,-]+)\s*([a-zA-Z]*)/;
    $length1 = $1;
    $length1 =~ s/,/./;
    $unit1 = $2;

    $length2 =~ m/([0-9.,-]+)\s*([a-zA-Z]*)/;
    $length2 = $1;
    $length2 =~ s/,/./;
    $unit2 = $2;

    if ($unit1 eq "mm")
      {
        # ok
        ;
      }
    elsif ($unit1 eq "cm")
      {
        $length1 = ($length1 * 10);
      }
    elsif ($unit1 eq "in")
      {
        $length1 = ($length1 * 25.4);
      }
    elsif ($unit1 eq "pt")
      {
        $length1 = (($length1 / 72.27) * 25.4);
      }
    elsif ($unit1 eq "bp")
      {
        $length1 = (($length1 / 72) * 25.4);
      }
    elsif ($unit1 eq "pc")
      {
        $length1 = ($length1 * 25.4 * 72/6);
      }

    if ($unit2 eq "mm")
      {
        # ok
        ;
      }
    elsif ($unit2 eq "cm")
      {
        $length2 = ($length2 * 10);
      }
    elsif ($unit2 eq "in")
      {
        $length2 = ($length2 * 25.4);
      }
    elsif ($unit2 eq "pt")
      {
        $length2 = (($length2 / 72.27) * 25.4);
      }
    elsif ($unit2 eq "bp")
      {
        $length2 = (($length2 / 72) * 25.4);
      }
    elsif ($unit2 eq "pc")
      {
        $length2 = ($length2 * 25.4 * 72/6);
      }

    return (($length1 - $length2) . "mm");
}

# Convert into millimeter without adding the unit of measure.
#
# &convert_to_mm_as_number (VALUE)
#

sub convert_to_mm_as_number
{
    my ($value) = $_[0];
    my ($number) = 0;
    my ($unit) = "";

    $value =~ s/,/./;
    $value =~ m/([0-9.-]*) *(\S*)/;
    $number = $1;
    $unit = $2;

    if ($unit eq "pt")
      {
        return (1/72.27 * 25.4 * $number);
      }
    elsif ($unit eq "bp")
      {
        return (1/72 * 25.4 * $number);
      }
    elsif ($unit eq "in")
      {
        return (1 * 25.4 * $number);
      }
    elsif ($unit eq "pc")
      {
        return (1/6 * 25.4 * $number);
      }
    elsif ($unit eq "cm")
      {
        return (1 * 10 * $number);
      }
    elsif ($unit eq "mm")
      {
        return (1 * $number);
      }
    else
      {
        # problem
        return (0);
      }
}

# Find a bounding box or page size inside a PS or EPS file and return
# x and y width in PostScript's points
#
# ps_x_y_size (PS_FILE_NAME) --> (X_WIDTH, Y_HEITGT)

sub ps_x_y_size
{
    my ($file_name) = $_[0];
    my (@width) = ();
    my ($line) = "";
    my ($page) = "";
    #
    open (PS_INPUT_FILE, "<:utf8", "$file_name");
    #
    while ($line = <PS_INPUT_FILE>)
      {
        #
        # Scan the file to find:
        #    %%BoundingBox: X_OFFSET Y_OFFSET X_MAX Y_MAX
        # or:
        # %%DocumentPaperSizes: PAPER_NAME
        #
        # If there is no more % at the first column, terminate
        # the search.
	#
        if ($line !~ m/^\%/)
          {
            
            # There are no more % comments, so close the loop.
            
            last;
          }

        if ($line =~ m/^\%\%BoundingBox:\s+([0-9+-]+)\s+([0-9+-]+)\s+([0-9+-]+)\s+([0-9+-]+)/)
          {
            $width[0] = $3 - $1;
            $width[1] = $4 - $2;
            last;
          }
        elsif ($line =~ m/^\%\%DocumentPaperSizes:\s+([a-zA-Z0-9]+)/)
          {
            $page = $1;
            @width = &page_size ($page);
            last;
          }     
      }
    close (PS_INPUT_FILE);
    return @width;
}

# Return the LaTeX name for the language system
#
# latex_language_name (LANG) --> NAME

sub latex_language_name
{
    my ($lang) = lc ($_[0]);

    if ($lang eq "en")
      {
        return ("english");
      }
    elsif ($lang eq "eo")
      {
        return ("esperanto");
      }
    elsif ($lang eq "et")
      {
        return ("estonian");
      }
    elsif ($lang eq "fi")
      {
        return ("finnish");
      }
    elsif ($lang eq "fi")
      {
        return ("finnish");
      }
    elsif ($lang eq "fr")
      {
        return ("french");
      }
    elsif ($lang eq "gl")
      {
        return ("galician");
      }
    elsif ($lang eq "de")
      {
        return ("german");
      }
    elsif ($lang eq "el")
      {
        return ("greek");
      }
    elsif ($lang eq "he"
           || $lang eq "iw")
      {
        return ("hebrew");
      }
    elsif ($lang eq "hu")
      {
        return ("hungarian");
      }
    elsif ($lang eq "ga")
      {
        return ("irish");
      }
    elsif ($lang eq "it")
      {
        return ("italian");
      }
    elsif ($lang eq "no")
      {
        return ("norsk");
      }
    elsif ($lang eq "pl")
      {
        return ("polish");
      }
    elsif ($lang eq "pt")
      {
        return ("portuguese");
      }
    elsif ($lang eq "ro")
      {
        return ("romanian");
      }
    elsif ($lang eq "ru")
      {
        return ("russian");
      }
    elsif ($lang eq "gd")
      {
        return ("scottish");
      }
    elsif ($lang eq "es")
      {
        return ("spanish");
      }
    elsif ($lang eq "sk")
      {
        return ("slovak");
      }
    elsif ($lang eq "sl")
      {
        return ("slovene");
      }
    elsif ($lang eq "sv")
      {
        return ("swedish");
      }
    elsif ($lang eq "tr")
      {
        return ("turkish");
      }
    elsif ($lang eq "uk")
      {
        return ("ukrainian");
      }
    else
      {
        return "";
      }
}
#
# Test if EPS or PostScript file has a correct x,y origin from 0,0
# coordinate.
#
# ps_has_origin_from_zero (FILE_NAME)
#
sub ps_from_imagemagick_has_origin_from_zero
{
    my ($file_to_be_tested) = $_[0];
    my ($min_x) = "";
    my ($min_y) = "";
    my ($max_x) = "";
    my ($max_y) = "";
    #
    # Read directory the EPS file, while the usual "gs -sDEVICE=bbox"
    # does not work with EPS generated from ImageMagick (incredible).
    #
    open (TEST_BOUNDING_BOX, "<:utf8", "$file_to_be_tested");
    #
    # Scan the file.
    #
    while ($line = <TEST_BOUNDING_BOX>)
      {
        if ($line =~ m/^\%\%BoundingBox: +([0-9]+) +([0-9]+) +([0-9]+) +([0-9]+)/)
          {
            $min_x = $1;
            $min_y = $2;
            $max_x = $3;
            $max_y = $4;
            last;
          }
      }
    #
    #
    #
    close (TEST_BOUNDING_BOX);
    #
    #
    #
    if ($min_x == 0 && $min_y == 0)
      {
        #
	# OK.
	#
	return 1;
      }
    else
      {
        return 0;
      }
}
#
# Convert PNG image to EPS, with a maximum width or height of 2000. 
#
# latex_png_to_eps_normal (ORIGINAL_PNG_FILE_NAME,
#                          NEW_EPS_FILE_NAME)
#
sub latex_png_to_eps_normal
{
    my ($original_png_file) = $_[0];
    my ($new_eps_file_name) = $_[1];
    #
    my ($identify_string)   = "";
    my ($type)              = 0;
    my ($width)             = 0;
    my ($height)            = 0;
    #
    # Run the "identify" program from ImageMagick to get picture
    # geometry.
    #
    open (IDENTIFY, "identify $original_png_file |");
    $identify_string = <IDENTIFY>;
    close (IDENTIFY);
    #
    if ($identify_string =~ m/^$original_png_file\s+([a-zA-Z0-9]+)\s+([0-9]+)x([0-9]+).*/)
      {
	$type = $1;
	$width = $2;
	$height = $3;
	#
	# Check type.
	#
	if ($type eq "PNG")
	  {
	    #
	    # OK.
	    #
	    ;
	  }
	elsif ($type eq "PNM")
	  {
	    #
	    # OK.
	    #
	    ;
	  }
	else
	  {
            &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: the picture \"$original_png_file\" should be in PNG or PNM format!\n"),
                                   $PROGRAM_EXECUTABLE,
	                           $SOURCE_FILE_NAME,
    	        	           $CURRENT_FILE_NAME,
                    	           $INPUT_STREAM_LINE_COUNTER,
                    		   $original_png_file), $V_WARNING);
	    #
	    # Go on anyway.
	    #
	  }
	#
	# Check if it is already larger or taller then 1000 points.
	#
	if ($height > 2000)
	  {
	    #
	    # Convert proportionally to a height of 2000 points.
	    #
	    &system_diag_output ("$PROGRAM_EXECUTABLE",
    	    	                 "convert -geometry x2000+0+0 -antialias -quality 100 $original_png_file EPS:$new_eps_file_name ",
                    	         $V_NORMAL);
	    #
	  }
	elsif ($width > 2000)
	  {
	    #
	    # Convert proportionally to a width of 2000 points.
	    #
	    &system_diag_output ("$PROGRAM_EXECUTABLE",
    	    	                 "convert -geometry 2000x+0+0 -antialias -quality 100 $original_png_file EPS:$new_eps_file_name ",
                    	         $V_NORMAL);
	    #
	  }
	else
	  {
	    #
	    # Convert.
	    #
	    &system_diag_output ("$PROGRAM_EXECUTABLE",
    	    	                 "convert -antialias -quality 100 $original_png_file EPS:$new_eps_file_name ",
                    	         $V_NORMAL);
	    #
	  }
        #
	# Test if the conversion is fine.
	#
	if (ps_from_imagemagick_has_origin_from_zero ($new_eps_file_name))
	  {
	    #
	    # OK: nothing to do.
	    #
	    ;
	  }
	else
	  {
    	    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: converting file \"%s\" to EPS gives a wrong x,y origin: should be zero but it is not!\n"),
        	                   $PROGRAM_EXECUTABLE,
            	                   $SOURCE_FILE_NAME,
                	           $CURRENT_FILE_NAME,
                    	           $INPUT_STREAM_LINE_COUNTER,
                        	   $original_png_file), $V_ERROR);
	  }
      }
    else
      {
        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot identify file \"%s\"!\n"),
                               $PROGRAM_EXECUTABLE,
                               $SOURCE_FILE_NAME,
                               $CURRENT_FILE_NAME,
                               $INPUT_STREAM_LINE_COUNTER,
                               $original_png_file), $V_ERROR);
	#
	# Try to convert anyway.
	#
        &system_diag_output ("$PROGRAM_EXECUTABLE",
                             "convert -antialias -quality 100 $original_png_file EPS:$new_eps_file_name ",
                             $V_NORMAL);
      }
}
#
# Convert PNG image to EPS, enlarging the original image to 200%,
# but with some limitation, because LaTeX is able to import
# an image not larger then 2000 points (maybe the same
# is for vertical height). 
#
# latex_png_to_eps_enlarged (ORIGINAL_PNG_FILE_NAME,
#                            NEW_EPS_FILE_NAME)
#
sub latex_png_to_eps_enlarged
{
    my ($original_png_file) = $_[0];
    my ($new_eps_file_name) = $_[1];
    #
    my ($identify_string)   = "";
    my ($type)              = 0;
    my ($width)             = 0;
    my ($height)            = 0;
    #
    # Run the "identify" program from ImageMagick to get picture
    # geometry.
    #
    open (IDENTIFY, "identify $original_png_file |");
    $identify_string = <IDENTIFY>;
    close (IDENTIFY);
    #
    if ($identify_string =~ m/^$original_png_file\s+([a-zA-Z0-9]+)\s+([0-9]+)x([0-9]+).*/)
      {
	$type = $1;
	$width = $2;
	$height = $3;
	#
	# Check type.
	#
	if ($type eq "PNG")
	  {
	    #
	    # OK.
	    #
	    ;
	  }
	elsif ($type eq "PNM")
	  {
	    #
	    # OK.
	    #
	    ;
	  }
	else
	  {
            &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: the picture \"$original_png_file\" should be in PNG or PNM format!\n"),
                                   $PROGRAM_EXECUTABLE,
	                           $SOURCE_FILE_NAME,
    	        	           $CURRENT_FILE_NAME,
                    	           $INPUT_STREAM_LINE_COUNTER,
                    		   $original_png_file), $V_WARNING);
	    #
	    # Go on anyway.
	    #
	  }
	#
	# Check if it is already larger or taller then 1000 points.
	#
	if ($height > 1000)
	  {
	    #
	    # Convert proportionally to a height of 2000 points.
	    #
	    &system_diag_output ("$PROGRAM_EXECUTABLE",
    	    	                 "convert -geometry x2000+0+0 -antialias -quality 100 $original_png_file EPS:$new_eps_file_name ",
                    	         $V_NORMAL);
	    #
	  }
	elsif ($width > 1000)
	  {
	    #
	    # Convert proportionally to a width of 2000 points.
	    #
	    &system_diag_output ("$PROGRAM_EXECUTABLE",
    	    	                 "convert -geometry 2000x+0+0 -antialias -quality 100 $original_png_file EPS:$new_eps_file_name ",
                    	         $V_NORMAL);
	    #
	  }
	else
	  {
	    #
	    # Convert proportionally to a 200%.
	    #
	    &system_diag_output ("$PROGRAM_EXECUTABLE",
    	    	                 "convert -geometry 200% -antialias -quality 100 $original_png_file EPS:$new_eps_file_name ",
                    	         $V_NORMAL);
	    #
	  }
      }
    else
      {
        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot identify file \"%s\"!\n"),
                               $PROGRAM_EXECUTABLE,
                               $SOURCE_FILE_NAME,
                               $CURRENT_FILE_NAME,
                               $INPUT_STREAM_LINE_COUNTER,
                               $original_png_file), $V_ERROR);
	#
	# Try to convert anyway.
	#
        &system_diag_output ("$PROGRAM_EXECUTABLE",
                             "convert -antialias -quality 100 $original_png_file EPS:$new_eps_file_name ",
                             $V_NORMAL);
      }
    #
    # Test if the conversion is fine.
    #
    if (ps_from_imagemagick_has_origin_from_zero ($new_eps_file_name))
      {
        #
        # OK: nothing to do.
        #
        ;
      }
    else
      {
        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: converting file \"%s\" to EPS gives a wrong x,y origin: should be zero but it is not!\n"),
		               $PROGRAM_EXECUTABLE,
            	               $SOURCE_FILE_NAME,
            	    	       $CURRENT_FILE_NAME,
                	       $INPUT_STREAM_LINE_COUNTER,
                               $original_png_file), $V_ERROR);
      }
}
#
# Filter EPS files and fix trouble when using eps2eps about the
# BoundingBox values. 
#
# filter_eps (ORIGINAL_EPS_FILE_NAME) --> NEW_EPS_FILE_NAME
#
sub filter_eps
{
    my ($original_eps_file) = $_[0];
    my ($new_eps_file)      = "${original_eps_file}.1.eps";
    my ($new_new_eps_file)  = "${original_eps_file}.2.eps";
    my ($line)              = "";
    my ($eps_bounding_box)  = "";
    #
    # Filter with Ghostscript, like eps2eps does.
    #
    &system_diag_output ("$PROGRAM_EXECUTABLE",
                         "gs -q -sDEVICE=epswrite -sOutputFile=$new_eps_file -dNOPAUSE -dBATCH -dSAFER -dLanguageLevel=1 ${original_eps_file}",
                         $V_NORMAL);
    #
    ## Now, the next problem is thet the %%BoundingBox
    ## instruction is wrong: we need to cut and paste
    ## the original one.
    #
    # Search the original file for the "%%BoundingBox:" line, and save
    # it.
    #
    open (EPS_FILE, "<:utf8", "$original_eps_file");
    while ($line = <EPS_FILE>)
      {
        if ($line =~ m/^\%\%BoundingBox:\s/)
          {
            $eps_bounding_box = $line;
            last;
          }
      }
    close (EPS_FILE);
    #
    # Search the new file and replace the "%%BoundingBox:" line,
    # eliminating also the "%%HiResBoundingBox:" line.
    #
    open (EPS_FILE, "<:utf8", "$new_eps_file");
    open (NEW_EPS_FILE, ">:utf8", "$new_new_eps_file");
    while ($line = <EPS_FILE>)
      {
        if ($line =~ m/^\%\%BoundingBox:\s/)
          {
            $line = $eps_bounding_box;
          }
        if ($line =~ m/^\%\%HiResBoundingBox:\s/)
          {
            $line = "";
          }
        print NEW_EPS_FILE ($line);
      }
    close (NEW_EPS_FILE);
    close (EPS_FILE);
    #
    # Return the name of the filtered and fixed file.
    #
    return ("$new_new_eps_file");
    #
}
#
# Sort the typical array used here.
#
# &sort_generic_array (ARRAY_REF, COMPARE_SUB_ELEMENT, LOW_ELEMENT, UP_ELEMENT)
#
sub sort_generic_array
{
    my ($array)    = $_[0];    # array reference
    my ($x)        = $_[1];    # element used for sort
    my ($a)        = $_[2];    # lower index
    my ($z)        = $_[3];    # upper index 
    my ($k)        = 0;
    my ($exchange) = "";
    #
    # Scan the array from index a to index z.
    #
    for ($a = $a; $a < $z; $a++)
      {
        #
        # Scan the array to place the right element inside $a
        # index.
        #
        for ($k = $a+1; $k <= $z; $k++)
          {
            if (uc (${$array}[$k][$x]) lt uc (${$array}[$a][$x]))
              {
                #
                # Exchange sub-arrays.
                #
                ## There is no need to use "delete ()" to extract
                ## the array element. It works well also
                ## with the simple way.
                #
                $exchange     = ${$array}[$k];
                ${$array}[$k] = ${$array}[$a];
                ${$array}[$a] = $exchange;
                #
              }
          }
        #
        # Show something.
        #
        &wait_message ("sort: $a/$z");
        #
      }
}
#
# Sort index array, completely.
#
# $index_list[x][0]   index name
# $index_list[x][1]   NOT USED anymore
# $index_list[x][2]   entry
# $index_list[x][3]   array of links
# $index_list[x][4]   array of html page numbers
# $index_list[x][5]   array of level-descriptions
# $index_list[x][6]   entry with formatting
# $index_list[x][7]   array of tomes
# $index_list[x][8]   array of parts
# $index_list[x][9]   array of chapters (absolute)
#
# &sort_index_list_completely (LOW_ELEMENT, UP_ELEMENT)
#
sub sort_index_list_completely
{
    my ($array)         = $_[0];  # array
    my ($a)             = $_[1];  # lower index
    my ($z)             = $_[2];  # upper index 
    my ($k)             = 0;
    my ($exchange)      = "";
    #
    for ($a = $a; $a < $z ; $a++)
      {
        #
        # Scan the array to place the right element inside $a
        # index.
        #
        for ($k = $a+1; $k <= $z; $k++)
          {
            if ((uc (${$array}[$k][0]) lt uc (${$array}[$a][0]))
                || (uc (${$array}[$k][0]) eq uc (${$array}[$a][0])
                    && uc (${$array}[$k][2]) lt uc (${$array}[$a][2])))
              {
                #
                # Exchange sub-arrays.
                #
                $exchange     = ${$array}[$k];
                ${$array}[$k] = ${$array}[$a];
                ${$array}[$a] = $exchange;
                #
              }
          }
        #
        # Show something.
        #
        &wait_message ("sort: $a/$z");
        #
      }
}
#
# Change Unicode character into &#NNNN;
#
# &sp_html_unicode_clean (TEXT)
#
sub sp_html_unicode_clean
{
    my ($line)          = $_[0];
    my ($line_new)      = "";
    my ($offset)        = 0;
    my ($max)           = 0;
    my ($char)          = "";

    # Estra Unicode characters, converted to "&#nnn;"

    $max = length ($line);
    while (1)
      {
        if ($offset >= $max)
          {
            last;
          }
        else
          {
            $char = substr ($line, $offset, 1);
            if (ord ($char) > 127)
              {
                $line_new = $line_new . "&#" . ord ($char) . ";";
              }
            else
              {
                $line_new = $line_new . $char;
              }
          }
        $offset++;
      }
    $line_new = $line_new . "\n";

    return ($line_new);
}

# Literal environment transformation for HTML.
    
sub html_literal_verbatim
{
    #
    my ($pre) = $_[0];
    #
    # First convert the escape character and other special symbols
    # for HTML.
    #
    $pre =~ s/\x{26}/\&amp\;/mg;                  # & Must be the first!
    $pre =~ s/\x{3C}/\&lt;/mg;                    # < Must be the second or third!
    $pre =~ s/\x{3E}/\&gt;/mg;                    # > Must be the second or third!
    #
    # Then go on with usual sequence.
    #
    $pre =~ s/\x{20}/\ /mg;                       # SPACE
    $pre =~ s/\x{21}/\!/mg;                       # !
    $pre =~ s/\x{22}/\"/mg;                       # "
    $pre =~ s/\x{23}/\#/mg;                       # #
    $pre =~ s/\x{24}/\$/mg;                       # $
    $pre =~ s/\x{25}/\%/mg;                       # %
    #$pre =~ s/\x{26}/\&/mg;                      # & Must be before!
    $pre =~ s/\x{27}/\'/mg;                       # '
    $pre =~ s/\x{28}/\(/mg;                       # (
    $pre =~ s/\x{29}/\)/mg;                       # )
    $pre =~ s/\x{2A}/\*/mg;                       # *
    $pre =~ s/\x{2B}/\+/mg;                       # +
    $pre =~ s/\x{2C}/\,/mg;                       # ,
    $pre =~ s/\x{2D}/\-/mg;                       # -
    $pre =~ s/\x{2E}/\./mg;                       # .
    $pre =~ s/\x{2F}/\//mg;                       # /
    # numbers from 0 to 9 are not translated
    $pre =~ s/\x{3A}/\:/mg;                       # :
    $pre =~ s/\x{3B}/\;/mg;                       # ;
    #$pre =~ s/\x{3C}/\</mg;                      # < Must be before!
    $pre =~ s/\x{3D}/\=/mg;                       # =
    #$pre =~ s/\x{3E}/\>/mg;                      # > Must be before!
    $pre =~ s/\x{3F}/\?/mg;                       # ?
    $pre =~ s/\x{40}/\@/mg;                       # @
    # letters from A to Z are not translated
    $pre =~ s/\x{5B}/\[/mg;                       # [
    $pre =~ s/\x{5C}/\\/mg;                       # \
    $pre =~ s/\x{5D}/\]/mg;                       # ]
    $pre =~ s/\x{5E}/\^/mg;                       # ^
    $pre =~ s/\x{5F}/\_/mg;                       # _
    $pre =~ s/\x{60}/\`/mg;                       # `
    # letters from a to z are not translated
    $pre =~ s/\x{7B}/\{/mg;                       #
    $pre =~ s/\x{7C}/\|/mg;                       # |
    $pre =~ s/\x{7D}/\}/mg;                       # }
    $pre =~ s/\x{7E}/\~/mg;                       # ~ Must be changed before!
    #
    # ISO 8859-1
    #
    $pre =~ s/\x{A0}/\&nbsp\;/mg;                 # NO-BREAK SPACE
    $pre =~ s/\x{A1}/\&iexcl\;/mg;                # ¡
    $pre =~ s/\x{A2}/\&cent\;/mg;                 # ¢
    $pre =~ s/\x{A3}/\&pound\;/mg;                # £
    $pre =~ s/\x{A4}/\&curren\;/mg;               # ¤
    $pre =~ s/\x{A5}/\&yen\;/mg;                  # ¥
    $pre =~ s/\x{A6}/\&brvbar\;/mg;               # ¦
    $pre =~ s/\x{A7}/\&sect\;/mg;                 # §
    $pre =~ s/\x{A8}/\&die\;/mg;                  # ¨
    $pre =~ s/\x{A9}/\&copy\;/mg;                 # ©
    $pre =~ s/\x{AA}/\&ordf\;/mg;                 # ª
    $pre =~ s/\x{AB}/\&laquo\;/mg;                # «
    $pre =~ s/\x{AC}/\&not\;/mg;                  # ¬
    $pre =~ s/\x{AD}/\&shy\;/mg;                  # ­
    $pre =~ s/\x{AE}/\&reg\;/mg;                  # ®
    $pre =~ s/\x{AF}/\&macr\;/mg;                 # ¯
    $pre =~ s/\x{B0}/\&deg\;/mg;                  # °
    $pre =~ s/\x{B1}/\&plusmn\;/mg;               # ±
    $pre =~ s/\x{B2}/\&sup2\;/mg;                 # ²
    $pre =~ s/\x{B3}/\&sup3\;/mg;                 # ³
    $pre =~ s/\x{B4}/\&acute\;/mg;                # ´         '
    $pre =~ s/\x{B5}/\&micro\;/mg;                # µ
    $pre =~ s/\x{B6}/\&para\;/mg;                 # ¶
    $pre =~ s/\x{B7}/\&middot\;/mg;               # ·
    $pre =~ s/\x{B8}/\&cedil\;/mg;                # ¸
    $pre =~ s/\x{B9}/\&sup1\;/mg;                 # ¹
    $pre =~ s/\x{BA}/\&ordm\;/mg;                 # º
    $pre =~ s/\x{BB}/\&raquo\;/mg;                # »
    $pre =~ s/\x{BC}/\&frac14\;/mg;               # ¼
    $pre =~ s/\x{BD}/\&frac12\;/mg;               # ½
    $pre =~ s/\x{BE}/\&frac34\;/mg;               # ¾
    $pre =~ s/\x{BF}/\&iquest\;/mg;               # ¿
    $pre =~ s/\x{C0}/\&Agrave\;/mg;               # À
    $pre =~ s/\x{C1}/\&Aacute\;/mg;               # Á
    $pre =~ s/\x{C2}/\&Acirc\;/mg;                # Â
    $pre =~ s/\x{C3}/\&Atilde\;/mg;               # Ã
    $pre =~ s/\x{C4}/\&Auml\;/mg;                 # Ä
    $pre =~ s/\x{C5}/\&Aring\;/mg;                # Å
    $pre =~ s/\x{C6}/\&AElig\;/mg;                # Æ
    $pre =~ s/\x{C7}/\&Ccedil\;/mg;               # Ç
    $pre =~ s/\x{C8}/\&Egrave\;/mg;               # È
    $pre =~ s/\x{C9}/\&Eacute\;/mg;               # É
    $pre =~ s/\x{CA}/\&Ecirc\;/mg;                # Ê
    $pre =~ s/\x{CB}/\&Euml\;/mg;                 # Ë
    $pre =~ s/\x{CC}/\&Igrave\;/mg;               # Ì
    $pre =~ s/\x{CD}/\&Iacute\;/mg;               # Í
    $pre =~ s/\x{CE}/\&Icirc\;/mg;                # Î
    $pre =~ s/\x{CF}/\&Iuml\;/mg;                 # Ï
    $pre =~ s/\x{D0}/\&ETH\;/mg;                  # Ð
    $pre =~ s/\x{D1}/\&Ntilde\;/mg;               # Ñ
    $pre =~ s/\x{D2}/\&Ograve\;/mg;               # Ò
    $pre =~ s/\x{D3}/\&Oacute\;/mg;               # Ó
    $pre =~ s/\x{D4}/\&Ocirc\;/mg;                # Ô
    $pre =~ s/\x{D5}/\&Otilde\;/mg;               # Õ
    $pre =~ s/\x{D6}/\&Ouml\;/mg;                 # Ö
    $pre =~ s/\x{D7}/\&times\;/mg;                # ×
    $pre =~ s/\x{D8}/\&Oslash\;/mg;               # Ø
    $pre =~ s/\x{D9}/\&Ugrave\;/mg;               # Ù
    $pre =~ s/\x{DA}/\&Uacute\;/mg;               # Ú
    $pre =~ s/\x{DB}/\&Ucirc\;/mg;                # Û
    $pre =~ s/\x{DC}/\&Uuml\;/mg;                 # Ü
    $pre =~ s/\x{DD}/\&Yacute\;/mg;               # Ý
    $pre =~ s/\x{DE}/\&THORN\;/mg;                # Þ
    $pre =~ s/\x{DF}/\&szlig\;/mg;                # ß
    $pre =~ s/\x{E0}/\&agrave\;/mg;               # à
    $pre =~ s/\x{E1}/\&aacute\;/mg;               # á
    $pre =~ s/\x{E2}/\&acirc\;/mg;                # â
    $pre =~ s/\x{E3}/\&atilde\;/mg;               # ã
    $pre =~ s/\x{E4}/\&auml\;/mg;                 # ä
    $pre =~ s/\x{E5}/\&aring\;/mg;                # å
    $pre =~ s/\x{E6}/\&aelig\;/mg;                # æ
    $pre =~ s/\x{E7}/\&ccedil\;/mg;               # ç
    $pre =~ s/\x{E8}/\&egrave\;/mg;               # è
    $pre =~ s/\x{E9}/\&eacute\;/mg;               # é
    $pre =~ s/\x{EA}/\&ecirc\;/mg;                # ê
    $pre =~ s/\x{EB}/\&euml\;/mg;                 # ë
    $pre =~ s/\x{EC}/\&igrave\;/mg;               # ì
    $pre =~ s/\x{ED}/\&iacute\;/mg;               # í
    $pre =~ s/\x{EE}/\&icirc\;/mg;                # î
    $pre =~ s/\x{EF}/\&iuml\;/mg;                 # ï
    $pre =~ s/\x{F0}/\&eth\;/mg;                  # ð
    $pre =~ s/\x{F1}/\&ntilde\;/mg;               # ñ
    $pre =~ s/\x{F2}/\&ograve\;/mg;               # ò
    $pre =~ s/\x{F3}/\&oacute\;/mg;               # ó
    $pre =~ s/\x{F4}/\&ocirc\;/mg;                # ô
    $pre =~ s/\x{F5}/\&otilde\;/mg;               # õ
    $pre =~ s/\x{F6}/\&ouml\;/mg;                 # ö
    $pre =~ s/\x{F7}/\&divide\;/mg;               # ÷
    $pre =~ s/\x{F8}/\&oslash\;/mg;               # ø
    $pre =~ s/\x{F9}/\&ugrave\;/mg;               # ù
    $pre =~ s/\x{FA}/\&uacute\;/mg;               # ú
    $pre =~ s/\x{FB}/\&ucirc\;/mg;                # û
    $pre =~ s/\x{FC}/\&uuml\;/mg;                 # ü
    $pre =~ s/\x{FD}/\&yacute\;/mg;               # ý
    $pre =~ s/\x{FE}/\&thorn\;/mg;                # þ
    $pre =~ s/\x{FF}/\&yuml;/mg;                  # ÿ
    #
    return &sp_html_unicode_clean ($pre);
}

# Literal environment transformation for LaTeX.
#
# Please note that inside this kind of transformation, there
# cannot be internal \alml... commands.

sub latex_literal_verbatim
{
    my ($pre) = $_[0];
    #
    # First convert the escape character and other special symbols
    # for LaTeX.
    #
    $pre =~ s/\x{5C}/\\textbackslash /mg;                   # \   1st
    $pre =~ s/\x{24}/\\\$/mg;                               # $   2nd
    $pre =~ s/\x{7B}/\$\\\{\$/mg;                           # {   3rd
    $pre =~ s/\x{7D}/\$\\\}\$/mg;                           # }   4th
    $pre =~ s/\\textbackslash /\\textbackslash\{\}/mg;      # \   5th
    $pre =~ s/\x{7E}/\\symbol\{126\}/mg;                    # ~   6th
    $pre =~ s/\x{20}/\~/mg;                                 # " " 7th
    #
    # Then go on with usual sequence.
    #
    # This is different from &sp_to_sp_filter (). 
    #
    #$pre =~ s/\x{21}/\!/mg;                        # !
    $pre =~ s/\x{22}/\\symbol\{34\}/mg;             # "
    $pre =~ s/\x{23}/\\\#/mg;                       # #
    #
    # must be before \x{24}                         # $
    #
    $pre =~ s/\x{25}/\\\%/mg;                       # %
    $pre =~ s/\x{26}/\\\&/mg;                       # &
    $pre =~ s/\x{27}/\{\'\}/mg;                     # ' --> {'}
    #$pre =~ s/\x{28}/\(/mg;                        # (
    #$pre =~ s/\x{29}/\)/mg;                        # )
    #$pre =~ s/\x{2A}/\*/mg;                        # *
    #$pre =~ s/\x{2B}/\+/mg;                        # +
    $pre =~ s/\x{2C}/\{\,\}/mg;                     # , --> {,}
    $pre =~ s/\x{2D}/\{-\}/mg;                      # - --> {-}
    #$pre =~ s/\x{2E}/\./mg;                        # .
    #$pre =~ s/\x{2F}/\//mg;                        # /
    #
    # numbers from 0 to 9 are not translated
    #
    #$pre =~ s/\x{3A}/\:/mg;                        # :
    $pre =~ s/\x{3B}/\;/mg;                         # ;
    $pre =~ s/\x{3C}/\{\<\}/mg;                     # < --> {<}
    #$pre =~ s/\x{3D}/=/mg;                         # =
    $pre =~ s/\x{3E}/\{\>\}/mg;                     # > --> {>}
    #$pre =~ s/\x{3F}/\?/mg;                        # ?
    $pre =~ s/\x{40}/\\symbol\{64\}/mg;             # @
    #
    # letters from A to Z are not translated
    #
    #$pre =~ s/\x{5B}/\[/mg;                        # [
    #
    # must be before \x{5C}                         # \
    #
    #$pre =~ s/\x{5D}/\]/mg;                        # ]
    $pre =~ s/\x{5E}/\\symbol\{94\}/mg;             # ^
    $pre =~ s/\x{5F}/\\\_/mg;                       # _
    $pre =~ s/\x{60}/\{\`\}/mg;                     # ` --> {`} #`
    #
    # letters from a to z are not translated
    #
    # must be before \x{7B}                         # {
    #
    #$pre =~ s/\x{7C}/\|/mg;                        # |
    #
    # must be before \x{7D}                         # }
    #
    # must be before \x{7E}                         # ~
    #
    return (&sp_latex_to_sp_latex_unicode_clean ($pre));
    #
}
#
sub latex_literal_step_0
{
    my ($pre) = $_[0];
    
    # The substitution of "-" into "\mbox{\texttt{-}"
    # is no more applyed, because of troubles with command
    # containing negative values.
    # Anyway, to resolve the problem, now the \[hyphen\] entity
    # is transformed into "{-}", so there is no more hyphen joining
    # inside LaTeX.
    #
    # $pre =~ s/-/\\mbox{\\texttt{-}}/mg;
    
    # Data is returned.
    
    return ($pre);
}

sub latex_literal_step_1
{
    my ($pre) = $_[0];
    
    # The substitution of ",", "'" and "`"
    # is no more necessary because resolved at sp2sp level
    #
    # $pre =~ s/,/,\{\}/mg;
    # $pre =~ s/\'/\'\{\}/mg;
    # $pre =~ s/\`/\`\{\}/mg;
    
    # Data is returned.
    
    return ($pre);
}
#
sub latex_literal_step_2
{
    my ($pre) = $_[0];
    #
    # Add \newline at the end of every line.
    #
    $pre =~ s/$/\\newline/mg;
    #
    # Delete double \newline if present.
    # It may happen if a <BR> was used.
    #
    $pre =~ s/\\newline\\newline$/\\newline/mg;
    #
    # Delete last \newline.
    #
    $pre =~ s/\\newline$//;
    #
    # Change the beguinning of every line.
    #
    #!  $pre =~ s/^/\\nopagebreak[1]\\hspace{0pt}/mg;
    $pre =~ s/^/\\hspace\*{0pt}/mg;
    #    
    # Data is returned.
    #
    return ($pre);
    #
}
#
sub latex_literal_step_3 {
    my ($pre) = $_[0];
    
    # Change space into ~, that is: nbsp: \obeyspaces does not work.

    ## Please note that before it must be protected the end of
    ## commands with an empty group:
    ##
    ##     bla bla \textasciitilde bla bla
    ## ==> bla~bla~\textasciitilde{}bla~bla
    ##
    ##! $pre =~ s/\\([a-zA-Z]+) /\\\1\{\}/mg;
    ##! $pre =~ tr/ /\~/;
    ##
    ## This example works, but currently, real spaces are marked this way
    ## from alml-sp2sp:
    ## "{} "
    ## and that's better.
    ##
    ##!!!!
    ##
    ## In the near future, the space such as "{} " might be
    ## changed into "\ ", that is more correct.
    ## The DTD is arranged to delete duplicate spaces, replacing
    ## also tabs into single space.

    $pre =~ s/\{\} /\~/mg;
    
    # Data is returned.
    
    return ($pre);
}
#
sub latex_literal_step_4
{
    #
    # Please keep this thing, also if you mean not to use it,
    # because it works when nothing else can do.
    #
    my ($pre) = $_[0];
    #
    # This is specific for SYNTAX: a white vertical bar is added,
    # to get a shure vertical spacing.
    #
    $pre =~ s/\\hspace\*{0pt}/\\hspace\*{0pt}{{\\color{white}{\\fontsize{2.618em}{2.618em}\\selectfont\\raisebox{-0.2em}{\|}\\hspace{-1.4ex}}}}/;
    #    
    # Data is returned.
    #
    return ($pre);
    #
}
#
sub latex_literal_step_5
{
    #
    # Please keep this thing, also if you mean not to use it,
    # because it works when nothing else can do.
    #
    my ($pre) = $_[0];
    #
    # This is specific for PRE and VERBATIMPRE: a white vertical bar is added,
    # to get a shure vertical spacing, also inside borders.
    #
    $pre =~ s/^/\\hspace\*{0pt}{{\\color{white}{\\fontsize{1.2em}{1.2em}\\selectfont\\raisebox{-0em}{\\hspace{-1ex}\|}}}}/mg;
    #    
    # Data is returned.
    #
    return ($pre);
    #
}
#
# Translate a PATH name or FILE name, so that it can
# be broken into different lines with LaTeX.
#
sub latex_path_adaptation
{
    my ($path)          = $_[0];
    #
    # Change "/" into "/\hspace{0pt}" so that the text
    # can be broken at it, but delete last one and the first one,
    # if any.
    #
    $path =~ s/\//\/\\hspace{0pt}/mg;
    $path =~ s/\\hspace{0pt}$//;
    $path =~ s/^\/\\hspace{0pt}/\//;
    #
    # Change "\textbackslash{}", or "{\textbackslash}" or
    # "\textbackslash " into # "\textbackslash\hspace{0pt}"
    # so that the text can be broken at it,
    # but delete last one and the first one, if any.
    #
    $path =~ s/\\textbackslash\{\}/\\textbackslash\\hspace{0pt}/mg;
    $path =~ s/\{\\textbackslash\}/\\textbackslash\\hspace{0pt}/mg;
    $path =~ s/\\textbackslash /\\textbackslash\\hspace{0pt}/mg;
    $path =~ s/\\hspace{0pt}$//;
    $path =~ s/^\\textbackslash\\hspace{0pt}/\\textbackslash\{\}/;
    #
    # Change "=" into "=\hspace{0pt}" so that the text
    # can be broken at it,
    # but delete last one and the first one, if any.
    #
    $path =~ s/=/=\\hspace{0pt}/mg;
    $path =~ s/\\hspace{0pt}$//;
    $path =~ s/^=\\hspace{0pt}/=/;
    #
    # Change "{-}" into "{-}\hspace{0pt}"
    # to avoid LaTeX reducing it and let the text
    # can be broken at it.
    #
    $path =~ s/\{-\}/{-}\\hspace{0pt}/mg;
    #
    # Return the transformed URI string.
    #
    return ($path);
}
#
# Translate an adapted PATH name or FILE name, so that it
# cannot be broken inside sub-pieces with LaTeX.
#
sub latex_path_adaptation_sub_box
{
    my ($path)          = $_[0];
    #
    # Use \mbox around unbreakable pieces.
    # Use \\hspace{0pt} as a mark.
    #
    $path =  "\\mbox{" . $path . "}";
    $path =~ s/\\hspace{0pt}/}\\hspace{0pt}\\mbox{/mg;

    return ($path);
}
#
# Translate an adapted URI, so that it
# cannot be broken inside sub-pieces with LaTeX, and also
# selectable (for PDF).
#
sub latex_path_adaptation_sub_box_and_hyperlink
{
    my ($path)          = $_[0];
    my ($uri_verbatim)  = $_[1];
    #
    # Use \mbox around unbreakable pieces.
    # Use \\hspace{0pt} as a mark.
    #
    $path =  "\\mbox{\\href{$uri_verbatim}{" . $path . "}}";
    $path =~ s/\\hspace{0pt}/}}\\hspace{0pt}\\mbox{\\href{$uri_verbatim}{/mg;
    #
    return ($path);
}
#
# Translate a URI, so that it can be broken into different
# lines with LaTeX, and can have hyperref with PDF typesetting.
#
sub latex_uri_adaptation
{
    my ($uri_verbatim) = $_[0];
    my ($uri)          = $_[1];
    #
    $uri = &latex_path_adaptation ($uri);
    $uri = &latex_path_adaptation_sub_box_and_hyperlink ($uri, $uri_verbatim);
    #
    # Return the transformed URI string.
    #
    return ($uri);
}
#
# Literal URI adaptation.
#
sub literal_uri_adaptation
{
    my ($uri) = $_[0];
    #
    $uri =~ s/\x{22}/\%22/mg;         # "
    $uri =~ s/\x{23}/\%23/mg;         # #
    $uri =~ s/\x{26}/\%26/mg;         # &
    #
    $uri =~ s/\x{A0}/\%A0/mg;         # NO-BREAK SPACE
    $uri =~ s/\x{A1}/\%A1/mg;         # ¡
    $uri =~ s/\x{A2}/\%A2/mg;         # ¢
    $uri =~ s/\x{A3}/\%A3/mg;         # £
    $uri =~ s/\x{A4}/\%A4/mg;         # ¤
    $uri =~ s/\x{A5}/\%A5/mg;         # ¥
    $uri =~ s/\x{A6}/\%A6/mg;         # ¦
    $uri =~ s/\x{A7}/\%A7/mg;         # §
    $uri =~ s/\x{A8}/\%A8/mg;         # ¨
    $uri =~ s/\x{A9}/\%A9/mg;         # ©
    $uri =~ s/\x{AA}/\%AA/mg;         # ª
    $uri =~ s/\x{AB}/\%AB/mg;         # «
    $uri =~ s/\x{AC}/\%AC/mg;         # ¬
    $uri =~ s/\x{AD}/\%AD/mg;         # ­
    $uri =~ s/\x{AE}/\%AE/mg;         # ®
    $uri =~ s/\x{AF}/\%AF/mg;         # ¯
    $uri =~ s/\x{B0}/\%B0/mg;         # °
    $uri =~ s/\x{B1}/\%B1/mg;         # ±
    $uri =~ s/\x{B2}/\%B2/mg;         # ²
    $uri =~ s/\x{B3}/\%B3/mg;         # ³
    $uri =~ s/\x{B4}/\%B4/mg;         # ´
    $uri =~ s/\x{B5}/\%B5/mg;         # µ
    $uri =~ s/\x{B6}/\%B6/mg;         # ¶
    $uri =~ s/\x{B7}/\%B7/mg;         # ·
    $uri =~ s/\x{B8}/\%B8/mg;         # ¸
    $uri =~ s/\x{B9}/\%B9/mg;         # ¹
    $uri =~ s/\x{BA}/\%BA/mg;         # º
    $uri =~ s/\x{BB}/\%BB/mg;         # »
    $uri =~ s/\x{BC}/\%BC/mg;         # ¼
    $uri =~ s/\x{BD}/\%BD/mg;         # ½
    $uri =~ s/\x{BE}/\%BE/mg;         # ¾
    $uri =~ s/\x{BF}/\%BF/mg;         # ¿
    $uri =~ s/\x{C0}/\%C0/mg;         # À
    $uri =~ s/\x{C1}/\%C1/mg;         # Á
    $uri =~ s/\x{C2}/\%C2/mg;         # Â
    $uri =~ s/\x{C3}/\%C3/mg;         # Ã
    $uri =~ s/\x{C4}/\%C4/mg;         # Ä
    $uri =~ s/\x{C5}/\%C5/mg;         # Å
    $uri =~ s/\x{C6}/\%C6/mg;         # Æ
    $uri =~ s/\x{C7}/\%C7/mg;         # Ç
    $uri =~ s/\x{C8}/\%C8/mg;         # È
    $uri =~ s/\x{C9}/\%C9/mg;         # É
    $uri =~ s/\x{CA}/\%CA/mg;         # Ê
    $uri =~ s/\x{CB}/\%CB/mg;         # Ë
    $uri =~ s/\x{CC}/\%CC/mg;         # Ì
    $uri =~ s/\x{CD}/\%CD/mg;         # Í
    $uri =~ s/\x{CE}/\%CE/mg;         # Î
    $uri =~ s/\x{CF}/\%CF/mg;         # Ï
    $uri =~ s/\x{D0}/\%D0/mg;         # Ð
    $uri =~ s/\x{D1}/\%D1/mg;         # Ñ
    $uri =~ s/\x{D2}/\%D2/mg;         # Ò
    $uri =~ s/\x{D3}/\%D3/mg;         # Ó
    $uri =~ s/\x{D4}/\%D4/mg;         # Ô
    $uri =~ s/\x{D5}/\%D5/mg;         # Õ
    $uri =~ s/\x{D6}/\%D6/mg;         # Ö
    $uri =~ s/\x{D7}/\%D7/mg;         # ×
    $uri =~ s/\x{D8}/\%D8/mg;         # Ø
    $uri =~ s/\x{D9}/\%D9/mg;         # Ù
    $uri =~ s/\x{DA}/\%DA/mg;         # Ú
    $uri =~ s/\x{DB}/\%DB/mg;         # Û
    $uri =~ s/\x{DC}/\%DC/mg;         # Ü
    $uri =~ s/\x{DD}/\%DD/mg;         # Ý
    $uri =~ s/\x{DE}/\%DE/mg;         # Þ
    $uri =~ s/\x{DF}/\%DF/mg;         # ß
    $uri =~ s/\x{E0}/\%E0/mg;         # à
    $uri =~ s/\x{E1}/\%E1/mg;         # á
    $uri =~ s/\x{E2}/\%E2/mg;         # â
    $uri =~ s/\x{E3}/\%E3/mg;         # ã
    $uri =~ s/\x{E4}/\%E4/mg;         # ä
    $uri =~ s/\x{E5}/\%E5/mg;         # å
    $uri =~ s/\x{E6}/\%E6/mg;         # æ
    $uri =~ s/\x{E7}/\%E7/mg;         # ç
    $uri =~ s/\x{E8}/\%E8/mg;         # è
    $uri =~ s/\x{E9}/\%E9/mg;         # é
    $uri =~ s/\x{EA}/\%EA/mg;         # ê
    $uri =~ s/\x{EB}/\%EB/mg;         # ë
    $uri =~ s/\x{EC}/\%EC/mg;         # ì
    $uri =~ s/\x{ED}/\%ED/mg;         # í
    $uri =~ s/\x{EE}/\%EE/mg;         # î
    $uri =~ s/\x{EF}/\%EF/mg;         # ï
    $uri =~ s/\x{F0}/\%F0/mg;         # ð
    $uri =~ s/\x{F1}/\%F1/mg;         # ñ
    $uri =~ s/\x{F2}/\%F2/mg;         # ò
    $uri =~ s/\x{F3}/\%F3/mg;         # ó
    $uri =~ s/\x{F4}/\%F4/mg;         # ô
    $uri =~ s/\x{F5}/\%F5/mg;         # õ
    $uri =~ s/\x{F6}/\%F6/mg;         # ö
    $uri =~ s/\x{F7}/\%F7/mg;         # ÷
    $uri =~ s/\x{F8}/\%F8/mg;         # ø
    $uri =~ s/\x{F9}/\%F9/mg;         # ù
    $uri =~ s/\x{FA}/\%FA/mg;         # ú
    $uri =~ s/\x{FB}/\%FB/mg;         # û
    $uri =~ s/\x{FC}/\%FC/mg;         # ü
    $uri =~ s/\x{FD}/\%FD/mg;         # ý
    $uri =~ s/\x{FE}/\%FE/mg;         # þ
    $uri =~ s/\x{FF}/\%FF/mg;         # ÿ
    #
    return ($uri);
}
#
#
# &font_size_resize (FONT_SIZE, FONT_FACTOR) --> NEW_FONT_SIZE
#
sub font_size_resize
{
    my ($font_size)        = $_[0];
    my ($factor)           = $_[1];
    my ($unit)             = "";
    my ($size)             = 0;
    my ($font_resized)     = "";
    #
    $font_size    =~ s/,/./;
    $font_size    =~ m/([0-9.]+)\s*([a-zA-Z]*)/;
    $size         = $1;
    $unit         = lc ($2);
    $font_resized = ($size * 1.2) . $unit;
    #
    return ($font_resized);
}
#
# Convert into pixel, meant to be 2 times the typographical
# point.
#
# &convert_to_pixel (VALUE)
#
sub convert_to_pixel
{
    my ($value)         = $_[0];
    my ($number)        = 0;
    my ($unit)          = "";
    my ($pixel)         = 0;

    if ($value eq "")
      {
        # Nothing to do
        return (0);
      }

    #! # If the value has a percentage sign, it is relative
    #! # to the horizontal width, also if it is an heigth.
    #! 
    #! if ($value  =~ m/^([0-9.,]*) *\%$/)
    #!   {
    #!     $value = &convert_width_to_absolute ($value);
    #!   }

    $value =~ m/([0-9.,]*) *([a-zA-Z]*)/;
    $number = $1;
    $unit = $2;

    # Change "," into "." if necessary

    $number =~ tr/,/./;

    if ($number eq ""
            || $number <= 0)
      {

        # problem

        $pixel = 0;
      }
    elsif ($unit eq "pt")
      {
        $pixel = (int (2*($number * (72/72.27))));
      }
    elsif ($unit eq "bp")
      {
        $pixel = (int (2*($number * 1)));
      }
    elsif ($unit eq "in")
      {
        $pixel = (int (2*($number * 72)));
      }
    elsif ($unit eq "pc")
      {
        $pixel = (int (2*($number * 72/6)));
      }
    elsif ($unit eq "cm")
      {
        $pixel = (int (2*(($number / 2.54) * 72)));
      }
    elsif ($unit eq "mm")
      {
        $pixel = (int (2*(($number / 25.4) * 72)));
      }
    else
      {

        # problem

        $pixel = (0);
      }

    &diag_output (sprintf (gettext ("%s:%s:%s: converting %s %s to %s pixel\n"),
                           $PROGRAM_EXECUTABLE,
                           $SOURCE_FILE_NAME,
                           $CURRENT_FILE_NAME,
                           $number,
                           $unit,
                           $pixel,
                           ), $V_NORMAL);

    return ($pixel);
}
#
# Convert into absolute horizontal value
#
# &convert_width_to_absolute (VALUE)
#
sub convert_width_to_absolute
{
    my ($value) = $_[0];
    my ($newvalue) = 0;
    my ($perc)  = 0;
    my ($size)  = 0;
    my ($unit)  = "";
    my ($i)     = 0;
    #
    if ($value eq "")
      {
	#
        # Nothing to do
	#
        return ($value);
      }
    #
    if ($value  =~ m/^([0-9.,]*) *\%$/)
      {
        $perc = $1;
        $perc =~ s/,/./;
      }
    else
      {
	#
        # Nothing to do.
	#
        return ($value);
      }
    #
    # Get document body width.
    #
    $size = $PRINTED_BODY_WIDTH;
    $size =~ s/,/./;
    $size =~ m/([0-9.]+)\s*([a-zA-Z]*)/;
    $size = $1;
    $unit = $2;
    #
    # Calculate percentage.
    #
    $newvalue = (($size * $perc) / 100.0);
    #
    for ($i = $#IS_IT_A_FRAME ; $i >= 0 ; $i--)
      {
	if ($IS_IT_A_FRAME[$i])
          {
	    #
	    # As there is a border and less space, reduce a little.
	    #
    	    $newvalue = ($newvalue * 0.95);
          }
      }
    #
    # Attach unit.
    #
    $newvalue = $newvalue . $unit;
    #
    &diag_output (sprintf (gettext ("%s:%s:%s: converting %s width into %s\n"),
                           $PROGRAM_EXECUTABLE,
                           $SOURCE_FILE_NAME,
                           $CURRENT_FILE_NAME,
                           $value,
                           $newvalue,
                           ), $V_NORMAL);

    return ($newvalue);

}

# SGML post-SP elaboration.
#
# This function elaborate a post-SP output (the SGML parser), and
# take actions.
#
# &sgml_post_sp_elab (INPUT-POST-SP,
#                     TYPESETTING,
#                     TARGET,
#                     DRAFT,
#                     PAGE-NUMBERING,
#                     COMPACT,
#                     LONG,
#                     ORIGINAL_FILE_NAME,
#                     CURRENT_FILE_NAME,
#                     ROOT-NAME)

sub sgml_post_sp_elab
{
    #
    my ($input_file)         = $_[0];
    my ($typesetting)        = $_[1];
    my ($target)             = $_[2];
    my ($draft)              = $_[3];
    my ($page_numbering)     = $_[4];
    #! my ($compact)            = $_[5];
    #! my ($long)               = $_[6];
    #! local ($original_file_name) = $_[7];
    #! local ($current_file_name)  = $_[8];
    #! my ($root_file_name)     = $_[9];
    my ($paper_width)        = $_[10];
    my ($paper_height)       = $_[11];
    #
    # More local variables.
    #
    # We need to define a reference for an input stream.
    # The choiche to use the same file names is just one way to
    # be shure to have ever different names.
    # We could use a random number, maybe.
    # This is useful for recursive call; for this function, there is no
    # need to use this technique; this is only a way to use uniform code.
    #
    my ($input_stream) = "$input_file";
    #
    # Output stack for controlling the output stream.
    #
    local (@output_stack)   = ();
    #
    # The line read.
    #
    my ($line) = "";
    #
    # Parsed character text.
    #
    my ($pcdata) = "";
    #
    # An associative array to receive the SGML element attribute.
    #
    %element_attribute = ();
    #
    # HTML file extension. Default is ".html"
    #
    $html_ext = ".html";
    #
    # Index
    #
    $index_entry_active = 0;
    $index_name = "";
    ##
    ## Local variables specific for the back-end composition process.
    ##
    #
    # Title counters.
    #
    local ($h1section_absolute_counter) = 0;
    local ($intro) = 0;
    local ($tome) = 0;
    local ($tome_present) = 0;  # Boolean
    local ($part) = 0;
    local ($part_present) = 0;  # Boolean
    local ($appendix_present) = 0;  # Boolean
    local ($index_present) = 0;  # Boolean
    local ($intro_present) = 0;  # Boolean
    local ($chapter) = 0;
    local ($unnumbered_chapter) = 0;
    local ($appendix) = 0;
    local ($sect1) = 0;         
    local ($sect2) = 0;         
    local ($sect3) = 0;         
    local ($index) = 0;
    local ($unnumbered) = 0;
    local ($textpoint) = 0;
    local ($textpoint_current) = 0;
    local ($table) = 0;
    local ($absolute_table) = 0;
    local ($figure) = 0;
    local ($absolute_figure) = 0;
    local ($listing) = 0;
    local ($absolute_listing) = 0;
    local ($example) = 0;
    local ($absolute_example) = 0;
    #
    # Current level:
    #       intro-h1                1
    #         intro-h2              2
    #           intro-h3            3
    #             intro-h4          4
    #   tome                       -1
    #     part                      0
    #       chapter-h1              1
    #         chapter-h2            2
    #           chapter-h3          3
    #             chapter-h4        4
    #       unnumbered-h1           1
    #         unnumbered-h2         2
    #           unnumbered-h3       3
    #             unnumbered-h4     4
    #       appendix-h1             1
    #         appendix-h2           2
    #           appendix-h3         3
    #             appendix-h4       4
    #       index-h1                1
    #         index-h2              2
    #           index-h3            3
    #             index-h4          4
    #
    local ($current_level) = "";
    local ($current_level_by_number) = 9999;
    #
    # Current document position:
    #   head
    #   intro
    #   body
    #   appendix
    #   index
    #
    local ($document_position) = "";
    #
    # HTML meta tags.
    #
    # $html_meta_tag[x][0]        name
    # $html_meta_tag[x][1]        lang
    # $html_meta_tag[x][2]        content
    #
    my ($html_meta_tag) = ();
    #!  #
    #!  # HTML human readable file names.
    #!  #
    #!  local ($html_human_readable_file_name_list) = ();
    #
    # Titlepage.
    #
    local ($title) = "";
    local (@subtitles) = ();
    local ($abstract) = "";
    local (@authors) = ();
    local ($date) = "";
    local ($edition) = "";
    local ($version) = "";
    local ($front_cover_top) = "";
    local ($front_cover_bottom) = "";
    local ($back_cover) = "";
    local ($extra_text_before_legal) = "";
    local ($legal_text) = "";
    local ($dedications) = "";
    local ($extra_text_after_dedications) = "";
    #
    # Table of contents.
    #
    # $contents_list[x][0]        level                 -1..4
    # $contents_list[x][1]        tome number
    # $contents_list[x][2]        part number
    # $contents_list[x][3]        chapter number                
    # $contents_list[x][4]        level-description     1.2.3
    # $contents_list[x][5]        title
    # $contents_list[x][6]        html page number
    # $contents_list[x][7]        h1 section absolute counter
    # $contents_list[x][8]        document position: head, intro, body,
    #                               appendix index
    #
    local ($main_contents) = 0;         # True, False
    local ($main_contents_nopages) = 0; # True, False
    local ($contents_levels) = 0;       # chapters and sections per default (2) as defined inside the DTD.
    local ($contents_title) = "";       # the title to present the toc.
    local ($contents_counter) = -1;
    local ($last_contents_level) = 0;
    local (@contents_list) = ();
    #
    # Standard cross reference list.
    #
    # $cross_reference_list[x][0]        level                  -1..4
    # $cross_reference_list[x][1]        tome number
    # $cross_reference_list[x][2]        part number
    # $cross_reference_list[x][3]        chapter number         
    # $cross_reference_list[x][4]        table absolute number          
    # $cross_reference_list[x][5]        figure absolute number         
    # $cross_reference_list[x][6]        level-description      1.2.3
    # $cross_reference_list[x][7]        title
    # $cross_reference_list[x][8]        table level-description
    # $cross_reference_list[x][9]        figure level-description
    # $cross_reference_list[x][10]       original anchor id
    # $cross_reference_list[x][11]       html page number
    # $cross_reference_list[x][12]       listing absolute number         
    # $cross_reference_list[x][13]       listing level-description
    # $cross_reference_list[x][14]       text absolute number
    # $cross_reference_list[x][15]       example absolute number         
    # $cross_reference_list[x][16]       example level-description
    #
    local (@cross_reference_list) = ();
    local ($cross_reference_counter) = -1;
    local ($cross_reference_present) = 1;
    #
    # Indexes.
    #
    # $index_list[x][0]        index name
    # $index_list[x][1]        NOT USED anymore
    # $index_list[x][2]        entry
    # $index_list[x][3]        array of links
    # $index_list[x][4]        array of html page numbers
    # $index_list[x][5]        array of level-descriptions
    # $index_list[x][6]        entry with formatting
    # $index_list[x][7]        array of tomes
    # $index_list[x][8]        array of parts
    # $index_list[x][9]        array of chapters (absolute)
    #
    local ($index_entry_counter) = 0;
    local (@index_list) = ();
    #
    # Headers title informations.
    #
    local ($tome_heading_title) = "";
    local ($tome_heading_id) = "";
    local ($h0_title) = "";
    local ($h0_id) = "";
    local ($h1_title) = "";
    local ($h1_id) = "";
    local ($h2_title) = "";
    local ($h2_id) = "";
    local ($h3_title) = "";
    local ($h3_id) = "";
    local ($h4_title) = "";
    local ($h4_id) = "";
    #
    # Last useful information.
    #
    local ($last_heading_title) = "";
    local ($last_anchor_id) = "";
    local ($last_bookmark) = "";
    local ($last_table_id) = "";
    local ($last_figure_id) = "";
    local ($last_listing_id) = "";
    local ($last_example_id) = "";
    local ($last_quote_uri) = "";
    local ($last_html_page_title) = "";
    #
    # Syntax.
    #
    local ($syntax_separation) = "";
    #
    # Tables, figures and listings.
    #
    local ($table_caption) = "";
    local ($figure_caption) = "";
    local ($listing_caption) = "";
    local ($example_caption) = "";
    local ($table_position) = "";
    local ($figure_position) = "";
    local ($listing_position) = "";
    local ($example_position) = "";
    local ($figure_separation) = "";
    local ($listing_separation) = "";
    local ($listing_split) = 0;
    #
    # Table columns width.
    #
    # $table_columns_width[x][0]        first column width
    # $table_columns_width[x][1]        second column width
    # ...
    # $table_columns_width[x][n]        (n+1)th column width
    #
    local (@table_columns_width) = ();
    local ($table_columns_width_counter) = -1;
    local ($table_column_counter) = -1;
    #
    # Workinfo list.
    #
    # $workinfo_list[x][0]        work name
    # $workinfo_list[x][1]        work license
    # $workinfo_list[x][2]        work license text
    # $workinfo_list[x][3]        work notes
    # $workinfo_list[x][4]        section number
    # $workinfo_list[x][5]        HTML page counter
    # $workinfo_list[x][6]        array of section numbers
    # $workinfo_list[x][7]        array of HTML page numbers
    # $workinfo_list[x][8]        work info serial number
    # $workinfo_list[x][9]        array of work info serial numbers
    #
    local (@workinfo_list)         = ();
    local ($workinfo_name)         = "";
    local ($workinfo_license)      = "";
    local ($workinfo_license_text) = "";
    local ($workinfo_counter)      = 0;
    local ($workinfo_html_page)    = 0;
    #
    # No modificable sections.
    #
    # $nomod_sections_list[x][0]    level         -1..4
    # $nomod_sections_list[x][1]    description   section 1.2
    # $nomod_sections_list[x][2]    title
    # $nomod_sections_list[x][3]    html page
    #
    local (@nomod_sections_list)      = ();
    local ($nomod_sections_counter)   = -1;
    #
    # doc info list.
    #
    # $docinfo_list[x][0]       level           -1..4
    # $docinfo_list[x][1]       description     section 1.2
    # $docinfo_list[x][2]       title
    # $docinfo_list[x][3]       notes and history
    # $docinfo_list[x][4]       html page number
    #
    # This array, is used directly, without the help of a specific
    # function!
    #
    my ($docinfo_list)         = ();
    local ($docinfo_counter)      = -1;
    #
    # PS handling.
    #
    local ($ps_picture_counter)   = 0;
    #
    # HTML handling.
    #
    local ($html_page_counter)    = 0;
    local ($html_max_page)        = 0;
    local ($html_back_cover_page) = 0;
    local ($html_picture_counter) = 0;
    local ($html_footnote)        = "";
    local (@html_footnote_list)   = ();
    local (@html_page_tome_link_list) = ();
    local (@html_page_part_link_list) = ();
    #
    # LaTeX handling.
    #
    local ($latex_footnote)       = "";
    local (@latex_footnote_list)  = ();
    #
    # $html_page_fixed_link_list[x][0]        html page number
    # $html_page_fixed_link_list[x][1]        link description
    #
    local (@html_page_fixed_link_list) = ();
    #
    # Preformatted width.
    #
    $g_preformatted_column_width   = "";  # Usually, default is 80.

    $g_preformatted_border         = 0;
    $g_preformatted_numbering      = "";  # Line numbering: "" means no numbering.

    # Every section header start a "{\samapage" that must be closed with a "}".
    $header_to_be_closed   = 0; # boolean
    $next_element_after_header_to_be_closed   = "";     # element name
    $next_element_after_header_to_be_closed_nest_level = 0; # the same element inside a nest

    
    # This is for SHEETH1 and SLIDEH1 to be kept on a page.

    local ($slide_to_be_closed)   = 0;  # boolean
    
    # Current table and tabular informations.

    local ($g_we_are_inside_a_tabular) = "0";

    local ($current_table_content) = "";
    local ($current_table_splitable) = 0;
    local ($current_table_status) = "";

    local ($current_tabular_splitable) = "0";
    local ($current_tabular_border) = "0";
    local ($current_tabular_columns) = "0";
    local ($current_tabular_columns_zoom) = "0";
    local (@current_tabular_columnfractions_list) = ();
    local ($current_tabular_column_index) = 0;
    local ($current_tabular_have_header) = 0;
    
    # Current figure informations.

    local ($current_figure_content) = "";
    
    # Language list.
    
    local (@language_list) = "()";
    
    # Indented text.

    local ($text_indent_level) = 0;
    local ($floating_block) = 0;
    
    # Current man page.

    local ($current_man_page_name) = "";
    local ($current_man_page_section) = "";
    
    ##
    ## Sub functions.
    ##
    
    # This function is like print, but may redirect output to a stack
    # waiting to have more data.
    #
    # &output ( STRING );

    sub output
    {
        my ($output_line) = $_[0];
        #
        if ($#output_stack >= 0)
          {
            #
            # Output must be added to the top element of the stack.
            #
            $output_stack[$#output_stack] = $output_stack[$#output_stack]
                                            . $output_line;
          }
        else
          {
            #
            # Output is sent to the output stream.
            #
            print $CURRENT_OUTPUT_STREAM ($output_line);
          }
    }
    #
    # Direct the output stream into another stack level.
    #
    # &push_output ();
    #
    sub push_output
    {
        # Add one empty element at the top of the stack.
        $output_stack[$#output_stack+1]     = "";
    }
    #
    # Extract the last stack level.
    #
    # &pop_output ();
    #
    sub pop_output
    {

        # Check if it is possible.

        if ($#output_stack >= 0)
          {
            #
            # Extract and delete one element at the top of the stack,
            # then return the value.
            #
            return (delete ($output_stack[$#output_stack]));
            #
            #! my ($output_line) = delete ($output_stack[$#output_stack]);
            #! $#output_stack--;
            #! return ($output_line);
          }
        else
          {
            #
            # The stack is empty.
            #
            return ("");
          }
    }
    #
    # Create the string corresponding to the section number.
    #
    sub current_section_number
    {
        my ($section_number_string) = "";
        #
        if ($current_level eq "intro-h1")
          {
            $section_number_string = "i"
                                     . $intro;
          }
        elsif ($current_level eq "intro-h2")
          {
            $section_number_string = "i"
                                     . $intro
                                     . "."
                                     . $sect1;
          }
        elsif ($current_level eq "intro-h3")
          {
            $section_number_string = "i"
                                     . $intro
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2;
          }
        elsif ($current_level eq "intro-h4")
          {
            $section_number_string = "i"
                                     . $intro
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2
                                     . "."
                                     . $sect3;
          }
        elsif ($current_level eq "tome")
          {
            $section_number_string = uc &integer_to_roman ($tome);
          }
        elsif ($current_level eq "part")
          {
            $section_number_string = lc &integer_to_roman ($part);
          }
        elsif ($current_level eq "chapter-h1")
          {
            $section_number_string = $chapter;
          }
        elsif ($current_level eq "chapter-h2")
          {
            $section_number_string = $chapter
                                     . "."
                                     . $sect1;
          }
        elsif ($current_level eq "chapter-h3")
          {
            $section_number_string = $chapter
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2;
          }
        elsif ($current_level eq "chapter-h4")
          {
            $section_number_string = $chapter
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2
                                     . "."
                                     . $sect3;
          }
        elsif ($current_level eq "unnumbered-h1")
          {
            $section_number_string = "u"
                                     . $unnumbered_chapter;
          }
        elsif ($current_level eq "unnumbered-h2")
          {
            $section_number_string = "u"
                                     . $intro
                                     . "."
                                     . $sect1;
          }
        elsif ($current_level eq "unnumbered-h3")
          {
            $section_number_string = "i"
                                     . $unnumbered_chapter
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2;
          }
        elsif ($current_level eq "unnumbered-h4")
          {
            $section_number_string = "i"
                                     . $unnumbered_chapter
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2
                                     . "."
                                     . $sect3;
          }
        elsif ($current_level eq "appendix-h1")
          {
            $section_number_string = uc &integer_to_alphabet ($appendix);
          }
        elsif ($current_level eq "appendix-h2")
          {
            $section_number_string = uc &integer_to_alphabet ($appendix)
                                     . "."
                                     . $sect1;
          }
        elsif ($current_level eq "appendix-h3")
          {
            $section_number_string = uc &integer_to_alphabet ($appendix)
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2;
          }
        elsif ($current_level eq "appendix-h4")
          {
            $section_number_string = uc &integer_to_alphabet ($appendix)
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2
                                     . "."
                                     . $sect3;
          }
        elsif ($current_level eq "index-h1")
          {
            $section_number_string = "x"
                                     . $index;
          }
        elsif ($current_level eq "index-h2")
          {
            $section_number_string = "x"
                                     . $index
                                     . "."
                                     . $sect1;
          }
        elsif ($current_level eq "index-h3")
          {
            $section_number_string = "x"
                                     . $index
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2;
          }
        elsif ($current_level eq "index-h4")
          {
            $section_number_string = "x"
                                     . $index
                                     . "."
                                     . $sect1
                                     . "."
                                     . $sect2
                                     . "."
                                     . $sect3;
          }
        else
          {
            $section_number_string = "##unknown-level##";
          }

        return $section_number_string;
    }

    
    # Create the string corresponding to the definition and section
    # number.
    

    sub current_section_number_complete
    {
        my ($section_number_complete_string) = "";

        if ($current_level eq "intro-h1"
            || $current_level eq "intro-h2"
            || $current_level eq "intro-h3"
            || $current_level eq "intro-h4")
          {
            $section_number_complete_string
              = &intro_def
                . " "
                . &current_section_number ();
          }
        elsif ($current_level eq "tome")
          {
            $section_number_complete_string
              = &tome_def ()
                . " "
                . &current_section_number ();
          }
        elsif ($current_level eq "part")
          {
            $section_number_complete_string
              = &part_def ()
                . " "
                . &current_section_number ();
          }
        elsif ($current_level eq "chapter-h1")
          {
            $section_number_complete_string
              = &chapter_def ()
                . " "
                . &current_section_number ();
          }
        elsif ($current_level eq "chapter-h2"
               || $current_level eq "chapter-h3"
               || $current_level eq "chapter-h4")
          {
            $section_number_complete_string
              = &section_def ()
                . " "
                . &current_section_number ();
          }
        elsif ($current_level eq "unnumbered-h1"
            || $current_level eq "unnumbered-h2"
            || $current_level eq "unnumbered-h3"
            || $current_level eq "unnumbered-h4")
          {
            $section_number_complete_string
              = &section_def
                . " "
                . &current_section_number ();
          }
        elsif ($current_level eq "appendix-h1"
               || $current_level eq "appendix-h2"
               || $current_level eq "appendix-h3"
               || $current_level eq "appendix-h4")
          {
            $section_number_complete_string
              = &appendix_def
                . " "
                . &current_section_number ();
          }
        elsif ($current_level eq "index-h1"
               || $current_level eq "index-h2"
               || $current_level eq "index-h3"
               || $current_level eq "index-h4")
          {
            $section_number_complete_string
              = &index_def ()
                . " "
                . &current_section_number ();
          }
        else
          {
            $section_number_complete_string = "##unknown-section##";
          }

        return $section_number_complete_string;
    }
    #
    # Create the string corresponding to the table number.
    #
    sub current_table_number
    {
        my ($table_number_string) = "";
	#
        if ($current_level eq "intro-h1"
            || $current_level eq "intro-h2"
            || $current_level eq "intro-h3"
            || $current_level eq "intro-h4")
          {
            $table_number_string = "i"
                                     . $intro
                                     . "."
                                     . $table;
          }
        elsif ($current_level eq "tome")
          {
            $table_number_string = uc &integer_to_roman ($tome)
                                   . "."
                                   . $table;
          }
        elsif ($current_level eq "part")
          {
            $table_number_string = lc &integer_to_roman ($part)
                                   . "."
                                   . $table;
          }
        elsif ($current_level eq "chapter-h1"
               || $current_level eq "chapter-h2"
               || $current_level eq "chapter-h3"
               || $current_level eq "chapter-h4")
          {
            $table_number_string = $chapter
                                   . "."
                                   . $table;
          }
        elsif ($current_level eq "unnumbered-h1"
            || $current_level eq "unnumbered-h2"
            || $current_level eq "unnumbered-h3"
            || $current_level eq "unnumbered-h4")
          {
            $table_number_string = "u"
                                     . $unnumbered_chapter
                                     . "."
                                     . $table;
          }
        elsif ($current_level eq "appendix-h1"
               || $current_level eq "appendix-h2"
               || $current_level eq "appendix-h3"
               || $current_level eq "appendix-h4")
          {
            $table_number_string = uc &integer_to_alphabet ($appendix)
                                   . "."
                                   . $table;
          }
        elsif ($current_level eq "index-h1"
               || $current_level eq "index-h2"
               || $current_level eq "index-h3"
               || $current_level eq "index-h4")
          {
            $table_number_string = "x"
                                   . $index
                                   . "."
                                   . $table;
          }
        else
          {
            $table_number_string = "0"
                                   . $absolute_table;
          }
	#
        return $table_number_string;
    }
    #
    # Create the string corresponding to the figure number.
    #
    sub current_figure_number
    {
        my ($figure_number_string) = "";

        if ($current_level eq "intro-h1"
            || $current_level eq "intro-h2"
            || $current_level eq "intro-h3"
            || $current_level eq "intro-h4")
          {
            $figure_number_string = "i"
                                     . $intro
                                     . "."
                                     . $figure;
          }
        elsif ($current_level eq "tome")
          {
            $figure_number_string = uc &integer_to_roman ($tome)
                                   . "."
                                   . $figure;
          }
        elsif ($current_level eq "part")
          {
            $figure_number_string = lc &integer_to_roman ($part)
                                   . "."
                                   . $figure;
          }
        elsif ($current_level eq "chapter-h1"
               || $current_level eq "chapter-h2"
               || $current_level eq "chapter-h3"
               || $current_level eq "chapter-h4")
          {
            $figure_number_string = $chapter
                                   . "."
                                   . $figure;
          }
        elsif ($current_level eq "unnumbered-h1"
               || $current_level eq "unnumbered-h2"
               || $current_level eq "unnumbered-h3"
               || $current_level eq "unnumbered-h4")
          {
            $figure_number_string = "u"
                                     . $unnumbered_chapter
                                     . "."
                                     . $figure;
          }
        elsif ($current_level eq "appendix-h1"
               || $current_level eq "appendix-h2"
               || $current_level eq "appendix-h3"
               || $current_level eq "appendix-h4")
          {
            $figure_number_string = uc &integer_to_alphabet ($appendix)
                                   . "."
                                   . $figure;
          }
        elsif ($current_level eq "index-h1"
               || $current_level eq "index-h2"
               || $current_level eq "index-h3"
               || $current_level eq "index-h4")
          {
            $figure_number_string = "x"
                                   . $index
                                   . "."
                                   . $figure;
          }
        else
          {
            $figure_number_string = "0"
                                   . $absolute_figure;
          }

        return $figure_number_string;
    }
    #
    # Create the string corresponding to the listing number.
    #
    sub current_listing_number
    {
        my ($listing_number_string) = "";
	#
        if ($current_level eq "intro-h1"
            || $current_level eq "intro-h2"
            || $current_level eq "intro-h3"
            || $current_level eq "intro-h4")
          {
            $listing_number_string = "i"
                                     . $intro
                                     . "."
                                     . $listing;
          }
        elsif ($current_level eq "tome")
          {
            $listing_number_string = uc &integer_to_roman ($tome)
                                   . "."
                                   . $listing;
          }
        elsif ($current_level eq "part")
          {
            $listing_number_string = lc &integer_to_roman ($part)
                                   . "."
                                   . $listing;
          }
        elsif ($current_level eq "chapter-h1"
               || $current_level eq "chapter-h2"
               || $current_level eq "chapter-h3"
               || $current_level eq "chapter-h4")
          {
            $listing_number_string = $chapter
                                   . "."
                                   . $listing;
          }
        elsif ($current_level eq "unnumbered-h1"
               || $current_level eq "unnumbered-h2"
               || $current_level eq "unnumbered-h3"
               || $current_level eq "unnumbered-h4")
          {
            $listing_number_string = "u"
                                     . $unnumbered_chapter
                                     . "."
                                     . $listing;
          }
        elsif ($current_level eq "appendix-h1"
               || $current_level eq "appendix-h2"
               || $current_level eq "appendix-h3"
               || $current_level eq "appendix-h4")
          {
            $listing_number_string = uc &integer_to_alphabet ($appendix)
                                   . "."
                                   . $listing;
          }
        elsif ($current_level eq "index-h1"
               || $current_level eq "index-h2"
               || $current_level eq "index-h3"
               || $current_level eq "index-h4")
          {
            $listing_number_string = "x"
                                   . $index
                                   . "."
                                   . $listing;
          }
        else
          {
            $listing_number_string = "0"
                                   . $absolute_listing;
          }
	#
        return $listing_number_string;
    }
    #
    # Create the string corresponding to the example number.
    #
    sub current_example_number
    {
        my ($example_number_string) = "";
	#
        if ($current_level eq "intro-h1"
            || $current_level eq "intro-h2"
            || $current_level eq "intro-h3"
            || $current_level eq "intro-h4")
          {
            $example_number_string = "i"
                                     . $intro
                                     . "."
                                     . $example;
          }
        elsif ($current_level eq "tome")
          {
            $example_number_string = uc &integer_to_roman ($tome)
                                   . "."
                                   . $example;
          }
        elsif ($current_level eq "part")
          {
            $example_number_string = lc &integer_to_roman ($part)
                                   . "."
                                   . $example;
          }
        elsif ($current_level eq "chapter-h1"
               || $current_level eq "chapter-h2"
               || $current_level eq "chapter-h3"
               || $current_level eq "chapter-h4")
          {
            $example_number_string = $chapter
                                   . "."
                                   . $example;
          }
        elsif ($current_level eq "unnumbered-h1"
               || $current_level eq "unnumbered-h2"
               || $current_level eq "unnumbered-h3"
               || $current_level eq "unnumbered-h4")
          {
            $example_number_string = "u"
                                     . $unnumbered_chapter
                                     . "."
                                     . $example;
          }
        elsif ($current_level eq "appendix-h1"
               || $current_level eq "appendix-h2"
               || $current_level eq "appendix-h3"
               || $current_level eq "appendix-h4")
          {
            $example_number_string = uc &integer_to_alphabet ($appendix)
                                   . "."
                                   . $example;
          }
        elsif ($current_level eq "index-h1"
               || $current_level eq "index-h2"
               || $current_level eq "index-h3"
               || $current_level eq "index-h4")
          {
            $example_number_string = "x"
                                   . $index
                                   . "."
                                   . $example;
          }
        else
          {
            $example_number_string = "0"
                                   . $absolute_example;
          }
	#
        return $example_number_string;
    }
    #
    # Scan and join double items inside workinfo array.
    #
    # &scan_and_join_doubles_workinfo_list ()
    #
    sub scan_and_join_doubles_workinfo_list
    {
        my ($i) = 0;        # scan
        my ($j) = 0;        # scan
        my ($last_work_name) = "";
        my (@sections_list) = ();
        my (@html_page_numbers_list) = ();
        my (@serial_numbers_list) = ();
        
        # $workinfo_list[x][0]        work name
        # $workinfo_list[x][1]        work license
        # $workinfo_list[x][2]        work license text
        # $workinfo_list[x][3]        work notes
        # $workinfo_list[x][4]        section number
        # $workinfo_list[x][5]        HTML page counter
        # $workinfo_list[x][6]        array of section numbers
        # $workinfo_list[x][7]        array of HTML page numbers
        # $workinfo_list[x][8]        work info serial number
        # $workinfo_list[x][9]        array of work info serial numbers
        
        # Scan the array to find duplicates.

        for ($i = 0; $i <= $#workinfo_list; $i++)
          {
            if ((uc ($workinfo_list[$i][0]) eq $last_work_name)
                && $workinfo_list[$i][0] ne "")
              {
                
                # Save references inside temporary arrays.

                $sections_list[$#sections_list+1] = $workinfo_list[$i][4];
                $html_page_numbers_list[$#html_page_numbers_list+1] = $workinfo_list[$i][5];
                $serial_numbers_list[$#serial_numbers_list+1] = $workinfo_list[$i][8];
                
                # Eliminate previous element (the last is the best).

                &diag_output (sprintf (gettext ("%s:%s:%s:%s: work name %s already declared\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       $CURRENT_FILE_NAME,
                                       $INPUT_STREAM_LINE_COUNTER,
                                       $last_work_name), $V_WARNING);

                splice (@workinfo_list, ($i-1), 1);
                
                # $i index must be decremented as it will incremented
                # anyway from the for loop. In fact, $i should remain
                # as is, within the next loop.

                $i--;
              }
            else
              {
                
                # The work name is changed: save references inside
                # previous element.

                if ($i > 0)
                  {
                    
                    # OK, this is not the first array element.

                    for ($j = 0; $j <= $#sections_list; $j++)
                      {
                        $workinfo_list[$i-1][6][$j] = $sections_list[$j];
                      }
                    for ($j = 0; $j <= $#html_page_numbers_list; $j++)
                      {
                        $workinfo_list[$i-1][7][$j] = $html_page_numbers_list[$j];
                      }
                    for ($j = 0; $j <= $#serial_numbers_list; $j++)
                      {
                        $workinfo_list[$i-1][9][$j] = $serial_numbers_list[$j];
                      }

                  }
                
                # Reset and save references inside temporary arrays.

                @sections_list = ();
                @html_page_numbers_list = ();
                @serial_numbers_list = ();

                $sections_list[$#sections_list+1] = $workinfo_list[$i][4];
                $html_page_numbers_list[$#html_page_numbers_list+1] = $workinfo_list[$i][5];
                $serial_numbers_list[$#serial_numbers_list+1] = $workinfo_list[$i][8];
                
                # Update last work name variable.

                $last_work_name = uc ($workinfo_list[$i][0]);
              }
          }
        
        # Finally must save last temporary array values.

        if ($i > 0)
          {
            
            # OK, this is not the first array element.

            for ($j = 0; $j <= $#sections_list; $j++)
              {
                $workinfo_list[$i-1][6][$j] = $sections_list[$j];
              }
            for ($j = 0; $j <= $#html_page_numbers_list; $j++)
              {
                $workinfo_list[$i-1][7][$j] = $html_page_numbers_list[$j];
              }
            for ($j = 0; $j <= $#serial_numbers_list; $j++)
              {
                $workinfo_list[$i-1][9][$j] = $serial_numbers_list[$j];
              }
          }

    }
    #
    # Change from 12345 to 12 345
    #
    # &integer_to_string (INTEGER_TO_BE_SPLITTED, SEPARATION_STRING)
    #
    sub integer_to_string
    {
        my ($integer) = $_[0];
        my ($sep) = $_[1];
        my ($upper) = "";
        my ($lower) = "";

        if ($integer eq "")
          {

            # No more upper decomposition.

            return ("");
          }
        elsif ($integer =~ m/^[0-9]{1,3}$/)
          {

            # No more upper decomposition.

            return ($integer);
          }
        elsif ($integer =~ m/^([0-9]+)([0-9][0-9][0-9])$/)
          {

            # Split recusively.

            $upper = $1;
            $lower = $2;
            return (&integer_to_string ($upper, $sep) . $sep . $lower);
          }
        else
          {

            # There is a mistake. Return as-is.

            return ($integer);
          }
    }
    
    # Change from 12345 to 123 45
    #
    # &decimal_to_string (DECIMAL_TO_BE_SPLITTED, SEPARATION_STRING)

    sub decimal_to_string
    {
        my ($decimal) = $_[0];
        my ($sep) = $_[1];
        my ($upper) = "";
        my ($lower) = "";
        if ($decimal eq "")
          {

            # No more lower decomposition.

            return ("");
          }
        elsif ($decimal =~ m/^[0-9]{1,3}$/)
          {

            # No more upper decomposition.

            return ($decimal);
          }
        elsif ($decimal =~ m/^([0-9][0-9][0-9])([0-9]+)$/)
          {

            # Split recusively.

            $upper = $1;
            $lower = $2;
            return ($upper . $sep . &decimal_to_string ($lower, $sep));
          }
        else
          {

            # There is a mistake. Return as-is.

            return ($decimal);
          }
    }
    #
    # Generate a human readable unique file name, using the
    # array @human_readable_file_name_list.
    #
    # &human_readable_file_name (STARTING_NAME, EXTENTION)
    #
    sub human_readable_file_name
    {
        my ($starting_name) = $_[0];
        my ($file_extention) = $_[1];
        my ($adapted_name) = "";
        my ($extention_counter) = 0;
        my ($extention) = "";
        my ($max_name_length) = 60;
        my ($n) = 0;
	#
	# Calculate max name lenght.
	#
	if ($file_extention eq "")
	  {
	     #
	     # No known extention.
	     #
	     $max_name_length = 50;
	  }
	else
	  {
	     $max_name_length = 60;
	  }
        #
        # Join multiple lines.
        #
        $adapted_name = $starting_name;
        $adapted_name =~ s/\n/ /ms;
        #
        # To lower case.
        #
        $adapted_name = lc ($adapted_name);
        #
        # Eliminate HTML elements.
        #
        $adapted_name =~ s/<(.*?)>//g;
	#
	# Translate some accented letters ("&#...;").
	#
        $adapted_name =~ s/\x{0026}\x{0023}192;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}193;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}194;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}195;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}196;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}197;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}198;/ae/g;
        $adapted_name =~ s/\x{0026}\x{0023}199;/c/g;
        $adapted_name =~ s/\x{0026}\x{0023}200;/e/g;
        $adapted_name =~ s/\x{0026}\x{0023}201;/e/g;
        $adapted_name =~ s/\x{0026}\x{0023}202;/e/g;
        $adapted_name =~ s/\x{0026}\x{0023}203;/e/g;
        $adapted_name =~ s/\x{0026}\x{0023}204;/i/g;
        $adapted_name =~ s/\x{0026}\x{0023}205;/i/g;
        $adapted_name =~ s/\x{0026}\x{0023}206;/i/g;
        $adapted_name =~ s/\x{0026}\x{0023}207;/i/g;
        $adapted_name =~ s/\x{0026}\x{0023}208;/d/g;
        $adapted_name =~ s/\x{0026}\x{0023}209;/n/g;
        $adapted_name =~ s/\x{0026}\x{0023}210;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}211;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}212;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}213;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}214;/o/g;
	#
        $adapted_name =~ s/\x{0026}\x{0023}216;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}217;/u/g;
        $adapted_name =~ s/\x{0026}\x{0023}218;/u/g;
        $adapted_name =~ s/\x{0026}\x{0023}219;/u/g;
        $adapted_name =~ s/\x{0026}\x{0023}220;/u/g;
        $adapted_name =~ s/\x{0026}\x{0023}221;/y/g;
	#
        $adapted_name =~ s/\x{0026}\x{0023}223;/ss/g;
        $adapted_name =~ s/\x{0026}\x{0023}224;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}225;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}226;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}227;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}228;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}229;/a/g;
        $adapted_name =~ s/\x{0026}\x{0023}230;/ae/g;
        $adapted_name =~ s/\x{0026}\x{0023}231;/c/g;
        $adapted_name =~ s/\x{0026}\x{0023}232;/e/g;
        $adapted_name =~ s/\x{0026}\x{0023}233;/e/g;
        $adapted_name =~ s/\x{0026}\x{0023}234;/e/g;
        $adapted_name =~ s/\x{0026}\x{0023}235;/e/g;
        $adapted_name =~ s/\x{0026}\x{0023}236;/i/g;
        $adapted_name =~ s/\x{0026}\x{0023}237;/i/g;
        $adapted_name =~ s/\x{0026}\x{0023}238;/i/g;
        $adapted_name =~ s/\x{0026}\x{0023}239;/i/g;
	#
        $adapted_name =~ s/\x{0026}\x{0023}241;/n/g;
        $adapted_name =~ s/\x{0026}\x{0023}242;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}243;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}244;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}245;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}246;/o/g;
        #
        $adapted_name =~ s/\x{0026}\x{0023}248;/o/g;
        $adapted_name =~ s/\x{0026}\x{0023}249;/u/g;
        $adapted_name =~ s/\x{0026}\x{0023}250;/u/g;
        $adapted_name =~ s/\x{0026}\x{0023}251;/u/g;
        $adapted_name =~ s/\x{0026}\x{0023}252;/u/g;
        $adapted_name =~ s/\x{0026}\x{0023}253;/y/g;
	#
        $adapted_name =~ s/\x{0026}\x{0023}255;/y/g;
        #
        # Adapt the rest.
        #
        $adapted_name =~ tr/a-z0-9/\_/c;
        #
        # Eliminate too mani "_".
        #
        $adapted_name =~ s/\_+/_/g;
        $adapted_name =~ s/^\_//;
        $adapted_name =~ s/_$//;
        #
        # Reduce to 60 characters max.
        # It must be done because Joliet file system cannot
        # distinguish names after the first 64 characters.
        #
        $adapted_name =~ m/^(.{1,$max_name_length})/;
        $adapted_name = $1;
        #
        # If the name is "index" and the file extention is
        # ".html" or ".htm", it must be changed immediately,
        # because the name "index.htm*" is reserved.
        #
        if ($adapted_name eq "index" 
           && ($file_extention eq ".html" || $file_extention eq ".htm"))
          {
            $adapted_name = "title_index";
          }
        #
        # Scan @human_readable_file_name_list.
        #
        for ($n = 0 ; $n <= $#human_readable_file_name_list ; $n++)
          { 
            if ($human_readable_file_name_list[$n]
                eq ("$adapted_name" . "$extention" . "$file_extention"))
              {
                #
                # This name already exists.
                #
                $extention_counter++;
                $extention = "_" . $extention_counter;
                #
                # Next loop.
                #
                next;
              }
          }
        #
        # Finally add the name.
        #
        $#human_readable_file_name_list++;
        $human_readable_file_name_list[$#human_readable_file_name_list]
          = "$adapted_name" . "$extention" . "$file_extention";
        #
        return ("$adapted_name" . "$extention" . "$file_extention");
    }
    #
    # Put a block of text (monospaced) inside a table to get border and
    # numbering.
    #
    sub latex_block_inside_table {
        my ($pre)                     = $_[0];
        my ($line_number)             = $_[1];
        my ($border)                  = $_[2];
        my ($we_are_inside_a_tabular) = $_[3];

        my ($line)        = "";
        my ($latex_temp_file) = &temporary_file ($TEMP_FILE_NAME_PREFIX);
        my ($out)         = "";
	#
        # Must be opened as usual 8 bit file, otherwise,
        # Perl will not create the file!
	#
        open (LATEX_TEMP_FILE, ">:utf8", "${latex_temp_file}.tex");
        print LATEX_TEMP_FILE ("$pre");
        close (LATEX_TEMP_FILE);
	#
        # Begin a table, with two or one single column.
	#
        if ($we_are_inside_a_tabular)
          {
            #
            # Please note that a longtable cannot stay inside a
            # another longtable, but a tabular can stay inside
            # a longtable. :-)
            #
            $out = $out . "\\begin{tabular}";
          }
        else
          {
            $out = $out . "\\begin{longtable}";
          }
        if ($border)
          {
            if ($line_number ne "")
              {
                $out = $out . "{|l|l|}";
              }
            else
              {
                $out = $out . "{|l|}";
              }
          }
        else
          {
            if ($line_number ne "")
              {
                $out = $out . "{ll}";
              }
            else
              {
                $out = $out . "{l}";
              }
          }
        $out = $out . "\n";
        if ($border)
          {
            if ($we_are_inside_a_tabular)
              {
                $out = $out . "\\hline";
                $out = $out . "\n";
              }
            else
              {
                $out = $out . "\\hline";
                $out = $out . "\n";
                $out = $out . "\\endhead";
                $out = $out . "\n";
                $out = $out . "\\hline";
                $out = $out . "\n";
                $out = $out . "\\endfoot";
                $out = $out . "\n";
              }
          }     
        open (LATEX_TEMP_FILE, "<:utf8", "${latex_temp_file}.tex");
        while ($line = <LATEX_TEMP_FILE>)
          {
            chomp ($line);
            if ($line_number ne "")
              {

                
                # The line number column is present.
                

                $out = $out . "{\\fboxrule=0mm\\fboxsep=0.5mm\\fbox{\\parbox{0.046\\textwidth}{$line_number}}}";
                $out = $out . "&";
                $out = $out . "{\\fboxrule=0mm\\fboxsep=0.5mm\\fbox{\\parbox{0.878\\textwidth}{\\begin{ttfamily}$line\\end{ttfamily}}}}";
                $out = $out . "\\\\";
                $out = $out . "\n";
              }
            else
              {

                
                # The line number column is not present.
                

                $out = $out . "{\\fboxrule=0mm\\fboxsep=0.5mm\\fbox{\\parbox{0.960\\textwidth}{\\begin{ttfamily}$line\\end{ttfamily}}}}";
                $out = $out . "\\\\";
                $out = $out . "\n";
              }
            if ($line_number ne "")
              {
                $line_number++;
              }
          }
        close (LATEX_TEMP_FILE);
        if ($border)
          {
            $out = $out . "\\hline";
            $out = $out . "\n";
          }
        if ($we_are_inside_a_tabular)
          {
            $out = $out . "\\end{tabular}";
          }
        else
          {
            $out = $out . "\\end{longtable}";
          }
        $out = $out . "\n";
        #
        # Remove temporary files now.
	#
        system ("rm -f ${latex_temp_file}*");
        #
        # Data is returned.
        #
        return ($out);
    }
    #
    # Adapt a text (monospaced) for a numbered/unnumbered listing
    # with HTML.
    #
    sub html_block {
        my ($pre)         = $_[0];
        my ($line_number) = $_[1];
        my ($line)        = "";
        my ($html_temp_file) = &temporary_file ($TEMP_FILE_NAME_PREFIX);
        my ($out)         = "";
        my ($line_number_spaced) = "";
        #
        # Must be opened as usual 8 bit file, otherwise,
        # Perl will not create the file!
        #
        open (HTML_TEMP_FILE, "> ${html_temp_file}.html");
        print HTML_TEMP_FILE ("$pre");
        close (HTML_TEMP_FILE);
        #
        # Scan the file.
        #
        open (HTML_TEMP_FILE, "<:utf8", "${html_temp_file}.html");
        while ($line = <HTML_TEMP_FILE>)
          {
            chomp ($line);
            if ($line_number ne "")
              {
                #
                # The line number column is present.
                #
                $line_number_spaced = &spaces (7) . $line_number . " ";
                $line_number_spaced = substr ($line_number_spaced, -8, 8);
              }
            $out = $out . "<STRONG>"
                        . $line_number_spaced
                        . "</STRONG>"
                        . $line
                        . "\n";
            if ($line_number ne "")
              {
                $line_number++;
              }
          }
        close (HTML_TEMP_FILE);
        #
        # Remove temporary files now.
        #
        system ("rm -f ${html_temp_file}*");
        #
        # Data is returned.
        #
        return ($out);
        #
    }
    #
    # This is the pre-elaboration process to save generic cross
    # reference information.
    #
    # &sgml_tag_elab_first_pass (TYPE, ELEMENT, %ATTRIBUTES,
    #                            TYPESETTING,
    #                            TARGET,
    #                            DRAFT,
    #                            PAGE-NUMBERING,
    #                            COMPACT,
    #                            LONG,
    #                            ORIGINAL_NAME,
    #                            ROOT_FILE_NAME)
    #
    sub sgml_tag_elab_first_pass
    {
        #
        # Function arguments.
        #
        my ($type)               = $_[0];
        my ($element)            = $_[1];
        my ($attributes)         = $_[2];
        my ($typesetting)        = $_[3];
        my ($target)             = $_[4];
        my ($draft)              = $_[5];
        my ($page_numbering)     = $_[6];
        #! my ($compact)            = $_[7];
        #! my ($long)               = $_[8];
        #! local ($original_file_name) = $_[9];
        #! local ($current_file_name)  = $_[10];
        #! my ($root_file_name)     = $_[11];
        my ($paper_width)        = $_[12];
        my ($paper_height)       = $_[13];
	#
        # Add a cross reference inside the cross reference array.
	#
        sub add_cross_reference_list
        {
            my ($n) = 0;
            #
	    # Check manual anchor id.
	    #
            if ($last_anchor_id =~ m/^alml/)
              {
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: anchor prefix \"alml\" is reserved. You have used: \"$last_anchor_id\"\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       $CURRENT_FILE_NAME,
                                       $INPUT_STREAM_LINE_COUNTER,
                                       $last_anchor_id), $V_ERROR);
              }
            if ($last_anchor_id =~ m/^toc$/)
              {
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: anchor id \"toc\" is reserved.\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       $CURRENT_FILE_NAME,
                                       $INPUT_STREAM_LINE_COUNTER), $V_ERROR);
              }
            #
            # $cross_reference_list[x][0]        level                  -1..4
            # $cross_reference_list[x][1]        tome number
            # $cross_reference_list[x][2]        part number
            # $cross_reference_list[x][3]        chapter number         
            # $cross_reference_list[x][4]        table absolute number          
            # $cross_reference_list[x][5]        figure absolute number         
            # $cross_reference_list[x][6]        level-description      1.2.3
            # $cross_reference_list[x][7]        title
            # $cross_reference_list[x][8]        table level-description
            # $cross_reference_list[x][9]        figure level-description
            # $cross_reference_list[x][10]       original anchor id
            # $cross_reference_list[x][11]       html page number
            # $cross_reference_list[x][12]       listing absolute number         
            # $cross_reference_list[x][13]       listing level-description
            # $cross_reference_list[x][14]       text absolute number
	    # $cross_reference_list[x][15]       example absolute number         
	    # $cross_reference_list[x][16]       example level-description
            #
            # Scan to see if it already exists.
            #
            for ($n = 0;
                 $n <= $#cross_reference_list;
                 $n++)
              {
                if ($last_anchor_id ne ""
                    && $cross_reference_list[$n][10] eq $last_anchor_id)
                  {
		    #
                    # The same anchor was already found.
                    # This is an error that must be shown.
		    #
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: anchor already used %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           $last_anchor_id), $V_ERROR);
                  }
              }
            #
            # Add anyway the anchor.
            #
            $#cross_reference_list++;
            $cross_reference_list[$#cross_reference_list] = ();
            $cross_reference_list[$#cross_reference_list][0]
              = $current_level_by_number;
            $cross_reference_list[$#cross_reference_list][1]
              = $tome;
            if ($part_present)
              {
                $cross_reference_list[$#cross_reference_list][2]
                  = $part;
              }
            else
              {
                $cross_reference_list[$#cross_reference_list][2]
                  = 0;
              }
            $cross_reference_list[$#cross_reference_list][3]
              = $chapter;
            $cross_reference_list[$#cross_reference_list][4]
              = $table;
            $cross_reference_list[$#cross_reference_list][5]
              = $figure;
            $cross_reference_list[$#cross_reference_list][6]
              = &current_section_number ();
            $cross_reference_list[$#cross_reference_list][7]
              = $last_heading_title;
            $cross_reference_list[$#cross_reference_list][8]
              = &current_table_number ();
            $cross_reference_list[$#cross_reference_list][9]
              = &current_figure_number ();
            $cross_reference_list[$#cross_reference_list][10]
              = $last_anchor_id;
            $cross_reference_list[$#cross_reference_list][11]
              = $html_page_counter;
            $cross_reference_list[$#cross_reference_list][12]
              = $listing;
            $cross_reference_list[$#cross_reference_list][13]
              = &current_listing_number ();
            $cross_reference_list[$#cross_reference_list][14]
              = $textpoint_current;
            $cross_reference_list[$#cross_reference_list][15]
              = $example;
            $cross_reference_list[$#cross_reference_list][16]
              = &current_example_number ();
        }
        #
        # Add an item inside the main toc array.
        #
        sub add_contents_list
        {
            #
            # $contents_list[x][0]        level                 -1..4
            # $contents_list[x][1]        tome number
            # $contents_list[x][2]        part number
            # $contents_list[x][3]        chapter number                
            # $contents_list[x][4]        level-description     1.2.3
            # $contents_list[x][5]        title
            # $contents_list[x][6]        html page number
            # $contents_list[x][7]        h1 section absolute counter
            # $contents_list[x][8]        document position: head, intro,
            #                               body, appendix, index
            #
            # Save into main toc.
            #
            $#contents_list++;
            $contents_list[$#contents_list] = ();
            $contents_list[$#contents_list][0]
              = $current_level_by_number;
            $contents_list[$#contents_list][1]
              = $tome;
            if ($part_present)
              {
                $contents_list[$#contents_list][2]
                  = $part;
              }
            else
              {
                $contents_list[$#contents_list][2]
                  = 0;
              }
            $contents_list[$#contents_list][3]
              = $chapter;
            $contents_list[$#contents_list][4]
              = &current_section_number ();
            $contents_list[$#contents_list][5]
              = $last_heading_title;
            $contents_list[$#contents_list][6]
              = $html_page_counter;
            $contents_list[$#contents_list][7]
              = $h1section_absolute_counter;
            $contents_list[$#contents_list][8]
              = $document_position;
        }
        #
        # Add an item inside the index list.
        #
        sub add_index_list
        {
            my ($name) = $_[0];
            my ($emph_entry) = $_[1];
            my ($entry) = $_[2];
            my ($number) = $_[3];
            my ($html_page) = $_[4];
            my ($current_level) = $_[5];
            my ($current_tome) = $_[6];
            my ($current_part) = $_[7];
            my ($current_chapter) = $_[8];
            #
            my ($n) = 0;
            #
            # Scan the @index_list to find the same entry.
            #
            # $index_list[x][0]        index name
            # $index_list[x][1]        NOT USED anymore
            # $index_list[x][2]        entry
            # $index_list[x][3]        array of links
            # $index_list[x][4]        array of html page numbers
            # $index_list[x][5]        array of level-descriptions
            # $index_list[x][6]        entry with formatting
            # $index_list[x][7]        array of tomes
            # $index_list[x][8]        array of parts
            # $index_list[x][9]        array of chapters (absolute)
            #
            for ($n = 0;
                 $n <= $#index_list;
                 $n++)
              {
                if ($index_list[$n][0] eq $name
                    && $index_list[$n][2] eq $entry
                    && $index_list[$n][6] eq $emph_entry)
                  {
                    # There is already the same entry.
                    # Add a new link to the sub-array.
                    $#{$index_list[$n][3]}++;
                    $index_list[$n][3][$#{$index_list[$n][3]}] = $number;
                    $#{$index_list[$n][4]}++;
                    $index_list[$n][4][$#{$index_list[$n][4]}] = $html_page;
                    $#{$index_list[$n][5]}++;
                    $index_list[$n][5][$#{$index_list[$n][5]}] = $current_level;
                    $#{$index_list[$n][7]}++;
                    $index_list[$n][7][$#{$index_list[$n][7]}] = $current_tome;
                    $#{$index_list[$n][8]}++;
                    $index_list[$n][8][$#{$index_list[$n][8]}] = $current_part;
                    $#{$index_list[$n][9]}++;
                    $index_list[$n][9][$#{$index_list[$n][9]}] = $current_chapter;

                    &diag_output (sprintf (gettext ("%s:%s: index \"%s\": added again \"%s\"\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $name, $entry), $V_NORMAL);
                    last;
                  }
              }
            #
            # if the entry wasn't found, add it.
            #
            if ($n > $#index_list)
              {
                $#index_list++;
                $index_list[$n][0] = $name;
                $index_list[$n][2] = $entry;
                $index_list[$n][3] = ();
                $index_list[$n][3][0] = $number;
                $index_list[$n][4] = ();
                $index_list[$n][4][0] = $html_page;
                $index_list[$n][5] = ();
                $index_list[$n][5][0] = $current_level;
                $index_list[$n][6] = $emph_entry;
                $index_list[$n][7] = ();
                $index_list[$n][7][0] = $current_tome;
                $index_list[$n][8] = ();
                $index_list[$n][8][0] = $current_part;
                $index_list[$n][9] = ();
                $index_list[$n][9][0] = $current_chapter;

                &diag_output (sprintf (gettext ("%s:%s: index \"%s\": added \"%s\"\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       $name, $entry), $V_NORMAL);
              }
        }
        #
        # Chech if the index entry is contained inside the current tome
        # part or chapter.
        #
        sub valid_section_index_entry
        {
            my ($array_pointer)   = $_[0];
            my ($index_context)   = $_[1];
            my ($current_tome)    = $_[2];
            my ($current_part)    = $_[3];
            my ($current_chapter) = $_[4];
            my ($n) = 0;
            #
            # $index_list[x][0]        index name
            # $index_list[x][1]        NOT USED anymore
            # $index_list[x][2]        entry
            # $index_list[x][3]        array of links
            # $index_list[x][4]        array of html page numbers
            # $index_list[x][5]        array of level-descriptions
            # $index_list[x][6]        entry with formatting
            # $index_list[x][7]        array of tomes
            # $index_list[x][8]        array of parts
            # $index_list[x][9]        array of chapters (absolute)

            if ($index_context eq "all")
              {
                # Good in any way.
                return (1);
              }
            elsif ($index_context eq "tome")
              {
                # Scan sub array.
                for ($n = 0;
                     $n <= $#{$index_list[$array_pointer][7]};
                     $n++)
                  {
                    if ($index_list[$array_pointer][7][$n] == $current_tome)
                      {
                        # OK.
                        return (1);
                      }
                  }
              }
            elsif ($index_context eq "part")
              {
                # Scan sub array.
                for ($n = 0;
                     $n <= $#{$index_list[$array_pointer][8]};
                     $n++)
                  {
                    if ($index_list[$array_pointer][8][$n] == $current_part)
                      {
                        # OK.
                        return (1);
                      }
                  }
              }
            elsif ($index_context eq "chapter")
              {
                # Scan sub array.
                for ($n = 0;
                     $n <= $#{$index_list[$array_pointer][9]};
                     $n++)
                  {
                    if ($index_list[$array_pointer][9][$n] == $current_chapter)
                      {
                        # OK.
                        return (1);
                      }
                  }
              }
            else
              {
                # Something went wrong.
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: wrong index context: \"%s\"\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       $CURRENT_FILE_NAME,
                                       $INPUT_STREAM_LINE_COUNTER,
                                       $index_context), $V_ERROR);
                return (0);
              }
            # If we are here, no match was found.
            return (0);
        }
        #
        # Add an item inside the workinfo array.
        #
        sub add_workinfo_list
        {
            
            # $workinfo_list[x][0]        work name
            # $workinfo_list[x][1]        work license
            # $workinfo_list[x][2]        work license text
            # $workinfo_list[x][3]        work notes
            # $workinfo_list[x][4]        section number
            # $workinfo_list[x][5]        HTML page counter
            # $workinfo_list[x][6]        array of section numbers
            # $workinfo_list[x][7]        array of HTML page numbers
            # $workinfo_list[x][8]        work info serial number
            # $workinfo_list[x][9]        array of work info serial numbers
            
            # Save into the array.

            $#workinfo_list++;
            $workinfo_list[$#workinfo_list] = ();
            $workinfo_list[$#workinfo_list][0] = $workinfo_name;
            $workinfo_list[$#workinfo_list][1] = $workinfo_license;
            $workinfo_list[$#workinfo_list][2] = $workinfo_license_text;
            $workinfo_list[$#workinfo_list][3] = $workinfo_notes;
            $workinfo_list[$#workinfo_list][4] = &current_section_number ();
            $workinfo_list[$#workinfo_list][5] = $html_page_counter;
            $workinfo_list[$#workinfo_list][6] = ();
            $workinfo_list[$#workinfo_list][7] = ();
            $workinfo_list[$#workinfo_list][8] = $workinfo_counter;
            $workinfo_list[$#workinfo_list][9] = ();

        }
        
        # Add an item inside the nomod sections array.
        sub add_nomod_sections_list
        {
            # $nomod_sections_list[x][0]    level         -1..4
            # $nomod_sections_list[x][1]    description   section 1.2
            # $nomod_sections_list[x][2]    title
            # $nomod_sections_list[x][3]    html page
            #
            $#nomod_sections_list++;
            $nomod_sections_list[$#nomod_sections_list] = ();
            $nomod_sections_list[$#nomod_sections_list][0]
              = $current_level_by_number;
            $nomod_sections_list[$#nomod_sections_list][1]
              = &current_section_number_complete ();
            $nomod_sections_list[$#nomod_sections_list][2]
              = $last_heading_title;
            $nomod_sections_list[$#nomod_sections_list][3]
              = $html_page_counter;
        }
        
        # Add an item inside the language array.
        
        sub add_language_list
        {
            my ($lang) = lc ($_[0]);
            my ($n) = 0;

            for ($n = 0; $n <= $#language_list; $n++)
              {
                if ($language_list[$n] eq $lang)
                  {
                    
                    # There is no need to add again the language.
                    
                    return;
                  }         
              }
            
            # If we are here, the new language must be added.
            
            $#language_list++;
            $language_list[$#language_list] = $lang;

            return;
        }
        #
        # Element handlers.
        # Element names and attribute names are uppercase.
        #
        if ($element eq "ALML")
          {
            if ($type eq "start")
              {
                #
                # Reset all counters.
                #
                $intro = 0;
                $tome = 0;
                $part = 0;
                $tome_present = 0;
                $part_present = 0;
                $appendix_present = 0;
                $index_present = 0;
                $intro_present = 0;
                $chapter = 0;
                $h1section_absolute_counter = 0;
                $appendix = 0;
                $sect1 = 0;         
                $sect2 = 0;         
                $sect3 = 0;         
                $index = 0;
                $table = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
                $absolute_table = 0;
                $picture =  0;
                $absolute_figure = 0;
                $absolute_listing = 0;
                $absolute_example = 0;
                $unnumbered = 0;
                $current_level = "";
                $current_level_by_number = 9999;
                $document_position = "";
                $html_page_counter = 0;
                #
                # Save administrative information.
                #
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                $DOCUMENT_LANGUAGE = $CURRENT_LANGUAGE;
                $TOME_LANGUAGE = $CURRENT_LANGUAGE;
                $PART_LANGUAGE = $CURRENT_LANGUAGE;
                $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                $DOCUMENT_SPACING = lc ${$attributes}{'SPACING'};
                #
                # Add inside the language array.
                #
                &add_language_list ($CURRENT_LANGUAGE);
              }
            else
              {
                # Nothing to do here.
                ;
              }
          }
        elsif ($element eq "HEAD")
          {
            if ($type eq "start")
              {
                # Save the document position.
                $document_position = "head";
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "MAINCONTENTS")
          {
            if ($type eq "start")
              {
                my ($nopages) = lc (${$attributes}{'NOPAGES'});
                
                # As there is the table of contents, the
                # HTML page counter is incremented.

                $html_page_counter++;
                
                # Activate main table of contents.
                # This is used to know how to handle the html page counter.

                $main_contents = 1;
                if ($nopages eq "true")
                  {
                    $main_contents_nopages = 1;
                  }
                else
                  {
                    $main_contents_nopages = 0;
                  }
                #
                # Save navigation link information.
                #
                # $html_page_fixed_link_list[x][0]        html page number
                # $html_page_fixed_link_list[x][1]        link description
                #
                $#html_page_fixed_link_list++;
                $html_page_fixed_link_list[$#html_page_fixed_link_list][0]
                  = $html_page_counter;
                $html_page_fixed_link_list[$#html_page_fixed_link_list][1]
                  = "&contents_def";
              }
            else
              {
                
                # Nothing to do.

                ;
              }
          }
        elsif ($element eq "INTRO")
          {
            if ($type eq "start")
              {
                
                # Save the information.

                $document_position = "intro";

                $tome_present = 0;
                $part_present = 0;
                $index_present = 0;
                $appendix_present = 0;
                $intro_present = 1;

              }
            else
              {

                
                # Reset current level by number
                

                $current_level_by_number = 9999;

                # Nothing else to do.
                ;
              }
          }
        elsif ($element eq "BODY")
          {
            if ($type eq "start")
              {

                # Save the information.

                $document_position = "body";
                
                # Reset intro counter;

                $intro = 0;
              }
            else
              {
                
                # Reset current level by number

                $current_level_by_number = 9999;
                
                # Nothing else to do.

                ;
              }
          }
        elsif ($element eq "APPENDIX")
          {
            if ($type eq "start")
              {
                
                # Save the information.

                $document_position = "appendix";
                
                # Reset chapter, part and tome counter.

                $chapter = 0;
                $part = 0;
                $tome = 0;
                #
                # Set appendix present.
                #
                $tome_present = 0;
                $part_present = 0;
                $appendix_present = 1;
                $index_present = 0;
                $intro_present = 0;
              }
            else
              {
                #
                # Reset current level by number
                #
                $current_level_by_number = 9999;
                #
                # Nothing else to do.
                #
                ;
              }
          }
        elsif ($element eq "INDEX")
          {
            if ($type eq "start")
              {
                
                # Save the information.

                $document_position = "index";

                
                # Reset appendix, chapter, part and tome counter.
                

                $appendix = 0;
                $chapter = 0;
                $part = 0;
                $tome = 0;
                
                # Set index present.

                $tome_present = 0;
                $part_present = 0;
                $index_present = 1;
                $appendix_present = 0;
                $intro_present = 0;

              }
            else
              {
                # Reset current level by number
                $current_level_by_number = 9999;

                # Nothing else to do.
                ;
              }
          }
        elsif ($element eq "NAVLINK")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($navlink) = "";
                $navlink = &pop_output ();
                #
                # Save navigation link information.
                #
                # $html_page_fixed_link_list[x][0]        html page number
                # $html_page_fixed_link_list[x][1]        link description
                #
                $#html_page_fixed_link_list++;
                $html_page_fixed_link_list[$#html_page_fixed_link_list][0]
                  = $html_page_counter;
                $html_page_fixed_link_list[$#html_page_fixed_link_list][1]
                  = $navlink;
              }
          }
        elsif ($element eq "TOMEHEADING")
          {
            if ($type eq "start")
              {
                #
                # Increment HTML page counter an save into tome list.
                #
                $html_page_counter++;
                $#html_page_tome_link_list++;
                $html_page_tome_link_list[$#html_page_tome_link_list]
                  = $html_page_counter;
                #
                # Save anchor information.
                #
                $tome_heading_id = ${$attributes}{'ID'};
                $last_anchor_id = $tome_heading_id;
                #
                # Save and set language information.
                #
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $DOCUMENT_LANGUAGE;
                  }
                $TOME_LANGUAGE = $CURRENT_LANGUAGE;
                $PART_LANGUAGE = $CURRENT_LANGUAGE;
                $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                #
                # Add inside the language array.
                #
                &add_language_list ($CURRENT_LANGUAGE);
                #
                # Here start a tome. Do some preparations.
                # Tome happens only inside a body.
		#
                $current_level = "tome";
                $current_level_by_number = -1;
                $tome++;
                $tome_present = 1;
                $part_present = 0;
                $appendix_present = 0;
                $index_present = 0;
                $intro_present = 0;
		#
                # tables and figures are reset.
		#
                $table = 0;
                $figure = 0;
                $listing = 0;
                $example = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
		#
                # part counter doesnt change.
                # chapter counter doesnt change.
		#
                $sect1 = 0;             
                $sect2 = 0;             
                $sect3 = 0;             
		#
                # Send the output stream to a new stack level.        
		#
                &push_output ();
              }
            else
              {
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $tome_heading_title = &pop_output ();
                $last_heading_title = $tome_heading_title;
		#
                # Save into main toc.
		#
                &add_contents_list ();
		#
                # Save into cross reference list.
		#
                &add_cross_reference_list ();
                #
                &diag_output (sprintf (gettext ("%s:%s: %s\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       &current_section_number_complete ()), $V_NORMAL);
              }
          }
        elsif ($element eq "H0")
          {
            if ($type eq "start")
              {
		#
                # Increment HTML page counter an save into part list.
		#
                $html_page_counter++;
                $#html_page_part_link_list++;
                $html_page_part_link_list[$#html_page_part_link_list]
                  = $html_page_counter;
		#
                # Save anchor information.
		#
                $h0_id = ${$attributes}{'ID'};
                $last_anchor_id = $h0_id;
		#
                # Save and set language information.
		#
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $TOME_LANGUAGE;
                  }
                $PART_LANGUAGE = $CURRENT_LANGUAGE;
                $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                #
                # Add inside the language array.
                #
                &add_language_list ($CURRENT_LANGUAGE);
		#
                # Here start a part. Do some preparations.
                # Tome happens only inside a body.
		#
                $current_level = "part";
                $current_level_by_number = 0;
                $part++;
                $part_present = 1;
		#
                # tables and figures are reset.
		#
                $table = 0;
                $figure = 0;
                $listing = 0;
                $example = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
		#
                # chapter counter doesnt change.
		#
                $sect1 = 0;             
                $sect2 = 0;             
                $sect3 = 0;             
		#
                # Send the output stream to a new stack level.
		#
                &push_output ();
              }
            else
              {
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $h0_title = &pop_output ();
                $last_heading_title = $h0_title;
		#
                # Save into main toc.
		#
                &add_contents_list ();
		#
                # Save into cross reference list.
		#
                &add_cross_reference_list ();
		#
                &diag_output (sprintf (gettext ("%s:%s: %s\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       &current_section_number_complete ()), $V_NORMAL);
              }
          }
        elsif ($element eq "H1"
               || $element eq "SLIDEH1"
               || $element eq "SHEETH1"
               || $element eq "UNNUMBEREDH1")
          {
            if ($type eq "start")
              {
                #
                # Increment HTML page counter.
                #
                $html_page_counter++;
                #
                # Save anchor information.
                #
                $h1_id = ${$attributes}{'ID'};
                $last_anchor_id = $h1_id;
                #
                # Save and set language information.
                #
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $PART_LANGUAGE;
                  }
                $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                #
                # Add inside the language array.
                #
                &add_language_list ($CURRENT_LANGUAGE);
                #
                # Here start a chapter. Do some preparations.
                #
                $current_level_by_number = 1;
                #
                # tables and figures are reset.
                #
                $table = 0;
                $figure = 0;
                $listing = 0;
                $example = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
		#
		#
		#
                if ($element eq "UNNUMBEREDH1")
                  {
                    $current_level = "unnumbered-h1";
                    $unnumbered_chapter++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;         
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "intro")
                  {
                    $current_level = "intro-h1";
                    $intro++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;         
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "body")
                  {
                    $current_level = "chapter-h1";
                    $chapter++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;         
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "appendix")
                  {
                    $current_level = "appendix-h1";
                    $appendix++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h1";
                    $index++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
                #
                $h1_title = &pop_output ();
                $last_heading_title = $h1_title;
                #
                # Save into main toc.
                #
                &add_contents_list ();
                #
                # Save into cross reference list.
                #
                &add_cross_reference_list ();
                #
                &diag_output (sprintf (gettext ("%s:%s: %s\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       &current_section_number_complete ()), $V_NORMAL);
              }
          }
        elsif ($element eq "H2"
               || $element eq "FAQH2")
          {
            if ($type eq "start")
              {
                # Save anchor information.
                $h2_id = ${$attributes}{'ID'};
                $last_anchor_id = $h2_id;

                # Here start a section. Do some preparations.
                $current_level_by_number = 2;
                if ($document_position eq "intro")
                  {
                    $current_level = "intro-h2";
                    $sect1++;           
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "body")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h2";
                      }
                    else
                      {
                        $current_level = "chapter-h2";
                      }
                    $sect1++;           
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "appendix")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h2";
                      }
                    else
                      {
                        $current_level = "appendix-h2";
                      }
                    $sect1++;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h2";
                    $sect1++;
                    $sect2 = 0;
                    $sect3 = 0;
                  }

                # Send the output stream to a new stack level.        
                &push_output ();
              }
            else
              {
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $h2_title = &pop_output ();
                $last_heading_title = $h2_title;
		#
                # Save into main toc.
		#
                &add_contents_list ();
                # Save into cross reference list.
                &add_cross_reference_list ();
              }
          }
        elsif ($element eq "H3"
               || $element eq "FAQH3")
          {
            if ($type eq "start")
              {
	        #
                # Save anchor information.
		#
                $h3_id = ${$attributes}{'ID'};
                $last_anchor_id = $h3_id;
		#
                # Here start a section. Do some preparations.
		#
                $current_level_by_number = 3;
		#
                if ($document_position eq "intro")
                  {
                    $current_level = "intro-h3";
                    $sect2++;           
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "body")
                  {
		    #
                    # If previous level was unnumbered, remains unnumbered.
		    #
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h3";
                      }
                    else
                      {
                        $current_level = "chapter-h3";
                      }
                    $sect2++;           
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "appendix")
                  {
		    #
                    # If previous level was unnumbered, remains unnumbered.
		    #
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h3";
                      }
                    else
                      {
                        $current_level = "appendix-h3";
                      }
                    $sect2++;
                    $sect3 = 0;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h3";
                    $sect2++;
                    $sect3 = 0;
                  }
		#
                # Send the output stream to a new stack level.
		#
                &push_output ();
              }
            else
              {
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $h3_title = &pop_output ();
                $last_heading_title = $h3_title;
		#
                # Save into main toc.
		#
                &add_contents_list ();
		#
                # Save into cross reference list.
		#
                &add_cross_reference_list ();
              }
          }
        elsif ($element eq "H4")
          {
            if ($type eq "start")
              {
                # Save anchor information.
                $h4_id = ${$attributes}{'ID'};
                $last_anchor_id = $h4_id;

                # Here start a section. Do some preparations.
                $current_level_by_number = 4;
                if ($document_position eq "intro")
                  {
                    $current_level = "intro-h4";
                    $sect3++;           
                  }
                elsif ($document_position eq "body")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h3";
                      }
                    else
                      {
                        $current_level = "chapter-h4";
                      }
                    $sect3++;
                  }
                elsif ($document_position eq "appendix")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h3";
                      }
                    else
                      {
                        $current_level = "appendix-h4";
                      }
                    $sect3++;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h4";
                    $sect3++;
                  }

                # Send the output stream to a new stack level.        
                &push_output ();
              }
            else
              {
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
                $h4_title = &pop_output ();
                $last_heading_title = $h4_title;

                # Save into main toc.
                &add_contents_list ();
                # Save into cross reference list.
                &add_cross_reference_list ();
              }
          }
        elsif ($element eq "DIV")
          {
            if ($type eq "start")
              {
                
                # Save and set language information.

                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $CHAPTER_LANGUAGE;
                  }
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                
                # Add inside the language array.

                &add_language_list ($CURRENT_LANGUAGE);
        
              }
            else
              {
                
                # Nothing to do.
                
                ;
              }
          }
        elsif ($element eq "SPAN")
          {
            if ($type eq "start")
              {
                
                # Save and set language information.

                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $DIV_LANGUAGE;
                  }
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                
                # Add inside the language array.

                &add_language_list ($CURRENT_LANGUAGE);
        
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "ANCHOR")
          {
            if ($type eq "start")
              {
                my ($anchor_type) = "";
		#
                # Save anchor type.
		#
                $anchor_type = uc (${$attributes}{'TYPE'});
		#
                # Save anchor information.
		#
                $last_anchor_id = ${$attributes}{'ID'};
		#
		#
		#
		if    ($anchor_type eq "HIDDEN")
		  {
		    $textpoint_current = 0;
		  }
		elsif ($anchor_type eq "VISIBLE")
		  {
		    #
		    # Increment visible anchor number/letter.
		    #
		    $textpoint++;
		    #
		    # Copy to text point current.
		    #
		    $textpoint_current = $textpoint;
		    #
		  }
		else
		  {
		    #
		    # Illegal value.
		    #
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: ANCHOR TYPE unknown: %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
					   $anchor_type), $V_ERROR);
		  }
		#
                # Save into cross reference list.
		#
                &add_cross_reference_list ();
              }
            else
              {
		#
                # Reset the text point current value.
		#
		$textpoint_current = 0;
		#
              }
          }
        elsif ($element eq "EXTERNALANCHOR")
          {
	    #
            # Nothing to do.
	    #
            ;
          }
        elsif ($element eq "TABLE")
          {
            if ($type eq "start")
              {
                my ($id) = "";
		#
                # Increment and reset table counters.
		#
                $table++;
                $absolute_table++;
                $table_columns_width_counter = ($absolute_table -1);
                $#table_columns_width++;
                $table_columns_width[$#table_columns_width] = ();
		#
                # Save anchor information.
		#
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
		    #
                    # Define a unique label.
		    #
                    $id = "table" . $absolute_table;
                  }
                $last_table_id = $id;
                $last_anchor_id = $id;
		#
                # Save into cross reference list.
		#
                &add_cross_reference_list ();
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "TROW")
          {
            if ($type eq "start")
              {
		#
                # Here start a new raw, so, also columns counter is reset.
		#
                $table_column_counter = -1;
		#
                # Save output.
		#
                &push_output ();
              }
            else
              {
                my ($cell) = "";
                my ($cell_length) = 0;
		#
                # Recall output (if any).
		#
                $cell = &pop_output ();
		#
                # Eliminate residual tag
                # (but need to save an emergency space, for elements that
                # translate into some strings).
		#
                $cell =~ s/<.*?>/\_/ig;
		#
                # Substitute residual SGML/HTML macro with "?".
		#
                $cell =~ s/&[a-z]+;/\?/ig;
		#
                # Calculate the string length.
		#
                $cell_length = length ($cell);
		#
                # Save the bigger.
		#
                $table_column_counter++;
                $table_columns_width[$#table_columns_width][$table_column_counter]
                  = &max ($table_columns_width[$#table_columns_width][$table_column_counter],
                          $cell_length);
              }
          }
        elsif ($element eq "COLSEP")
          {
            if ($type eq "start")
              {
                my ($cell) = "";
                my ($cell_length) = 0;
		#
                # Recall output (if any).
		#
                $cell = &pop_output ();
		#
                # Eliminate residual tag
                # (but need to save an emergency space, for elements that
                # translate into some strings).
		#
                $cell =~ s/<.*?>/\_/ig;
		#
                # Substitute residual SGML/HTML macro with "?".
		#
                $cell =~ s/&[a-z]+;/\?/ig;
		#
                # Calculate the string length.
		#
                $cell_length = length ($cell);
		#
                # Save the bigger.
		#
                $table_column_counter++;
                $table_columns_width[$#table_columns_width][$table_column_counter]
                  = &max ($table_columns_width[$#table_columns_width][$table_column_counter],
                          $cell_length);
              }
            else
              {
		#
                # Save output.
		#
                &push_output ();
              }
          }
        elsif ($element eq "FIGURE")
          {
            if ($type eq "start")
              {
                my ($id) = "";
		#
                # Increment and reset figure counters.
		#
                $figure++;
                $absolute_figure++;
		#
                # Save anchor information.
		#
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
		    #
                    # Define a unique label.
		    #
                    $id = "figure" . $absolute_figure;
                  }
                $last_figure_id = $id;
                $last_anchor_id = $id;
		#
                # Save into cross reference list.
		#
                &add_cross_reference_list ();
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "LISTING")
          {
            if ($type eq "start")
              {
                my ($id) = "";
		#
                # Increment and reset figure counters.
		#
                $listing++;
                $absolute_listing++;
		#
                # Save anchor information.
		#
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
		    #
                    # Define a unique label.
		    #
                    $id = "listing" . $absolute_listing;
                  }
                $last_listing_id = $id;
                $last_anchor_id = $id;
		#
                # Save into cross reference list.
		#
                &add_cross_reference_list ();
              }
            else
              {
	        #
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "EXAMPLE")
          {
            if ($type eq "start")
              {
                my ($id) = "";
		#
                # Increment and reset example counters.
		#
                $example++;
                $absolute_example++;
		#
                # Save anchor information.
		#
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
		    #
                    # Define a unique label.
		    #
                    $id = "example" . $absolute_example;
                  }
                $last_example_id = $id;
                $last_anchor_id = $id;
		#
                # Save into cross reference list.
		#
                &add_cross_reference_list ();
              }
            else
              {
	        #
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "INDEXENTRY")
          {
            if ($type eq "start")
              {
                #
                # The index entry is scanned.
                #
                $index_entry_active = 1;
                #
                # Save index attributes.
                #
                $index_name = ${$attributes}{'INDEX'};
                #
                # Save INDEXENTRY element.
                #
                &push_output ();
              }
            else
              {
                my ($n) = 0;
                my ($entry) = "";
                my ($emph_entry) = "";
                #
                $emph_entry = &pop_output ();
                #
                # Need some elaboration to eliminate typesetting code.
                #
                if ($typesetting eq "LATEX")
                  {
                    $entry = $emph_entry;
                    $entry =~ s/\\almlaacodeindexentry\{(.*?)}/$1/mg;
                  }
                elsif ($typesetting eq "HTML")
                  {
                    $entry = $emph_entry;
                    $entry =~ s/<\/?CODE>//mg;
                  }
                else
                  {
                    $entry = $emph_entry;
                  }
                #
                # Increment the index entry counter.
                #
                $index_entry_counter++;
                #
                # Save the index entry inside the index list.
                #
                &add_index_list ($index_name, $emph_entry, $entry, $index_entry_counter, $html_page_counter, &current_section_number (), $tome, $part, $h1section_absolute_counter);
                #
                # The index entry scan is terminated.
                #
                $index_entry_active = 0;
                #
              }
          }
        elsif ($element eq "SPECIAL")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                my ($n) = 0;
                my ($special) = "";
                my ($entry) = "";
                $special = ${$attributes}{'SPECIAL'};
                #
                # Recall output (if any).
                #
                $entry = &pop_output ();
                #
                # Print the entry (maybe it is inside an index or other
                # sort of information).
                #
                # We need to see these "special" things on draft
                # typesetting.
                #
                if ($typesetting eq "LATEX")
                  {
                    &output ("\\almlbaspecialname{$entry}{$special}");
                  }
                else
                  {
                    &output ($entry);
                  }
                #
                # increment the index entry counter and
                # save the index entry inside the index list.
                #
                $index_entry_counter++;
                &add_index_list ($special, $entry, $entry, $index_entry_counter, $html_page_counter, &current_section_number (), $tome, $part, $h1section_absolute_counter);
                #
              }
          }
        elsif ($element eq "WORKINFO")
          {
            if ($type eq "start")
              {
                #
                # Reset global variables.
                #
                $workinfo_name         = "";
                $workinfo_license      = "";
                $workinfo_license_text = "";
                $workinfo_notes        = "";
              }
            else
              {
                #
                # increment the workinfo counter.
                #
                $workinfo_counter++;
                #
                # Add the workinfo insiede the array.
                #
                &add_workinfo_list ();
              }
          }
        elsif ($element eq "WORKNAME")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_name = &pop_output ();
              }
          }
        elsif ($element eq "WORKLICENSE")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_license = &pop_output ();
              }
          }
        elsif ($element eq "WORKLICENSETEXT")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_license_text = &pop_output ();
              }
          }
        elsif ($element eq "WORKNOTES")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_notes = &pop_output ();
              }
          }
        elsif ($element eq "NOMOD")
          {
            if ($type eq "start")
              {
                # Just add inside the @nomod_sections_list array.
                &add_nomod_sections_list ();
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "DOCINFO")
          {
            if ($type eq "start")
              {
		#
                # Add a new element inside the docinfo array and
                # prepare it with default values.
                #
                # $docinfo_list[x][0]       level               -1..4
                # $docinfo_list[x][1]       description     section 1.2
                # $docinfo_list[x][2]       title
                # $docinfo_list[x][3]       notes and history
                # $docinfo_list[x][4]       html page number
                #
                $#docinfo_list++;
                $docinfo_list[$#docinfo_list] = ();
                $docinfo_list[$#docinfo_list][0]
                  = $current_level_by_number;
                $docinfo_list[$#docinfo_list][1]
                  = &current_section_number_complete ();
                $docinfo_list[$#docinfo_list][2]
                  = $last_heading_title;
                $docinfo_list[$#docinfo_list][3] = "";
                $docinfo_list[$#docinfo_list][4] = $html_page_counter;
		#
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output (if any).
                #
                $docinfo_list[$#docinfo_list][3] = &pop_output ();
		#
              }
          }
        elsif ($element eq "DESCRIPTION")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $DOCUMENT_DESCRIPTION = &pop_output ();
              }
          }
        elsif ($element eq "KEYWORDS")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $DOCUMENT_KEYWORDS = &pop_output ();
              }
          }
        elsif ($element eq "HTMLMETA")
          {
            if ($type eq "start")
              {
                my ($name) = "";
                my ($lang) = "";
                $name = (${$attributes}{'NAME'});
                $lang = (${$attributes}{'LANG'});

                # HTML meta tags.
                #
                # $html_meta_tag[x][0]        name
                # $html_meta_tag[x][1]        lang
                # $html_meta_tag[x][2]        content
                #
                $#html_meta_tag++;
                $html_meta_tag[$#html_meta_tag] = ();
                $html_meta_tag[$#html_meta_tag][0] = $name;
                $html_meta_tag[$#html_meta_tag][1] = $lang;

                # Save output.
                &push_output ();
              }
            else
              {
                my ($content) = "";
                # Recall the meta-content.
                $content = &pop_output ();
                $html_meta_tag[$#html_meta_tag][2] = $content;
              }
          }
        elsif ($element eq "CHAPTERDEFINITION")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $DOCUMENT_CHAPTER_DEFINITION = &pop_output ();
              }
          }
        elsif ($element eq "PARTDEFINITION")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $DOCUMENT_PART_DEFINITION = &pop_output ();
              }
          }
        elsif ($element eq "TOMEDEFINITION")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $DOCUMENT_TOME_DEFINITION = &pop_output ();
              }
          }
        elsif ($element eq "PRINTEDFONTSIZE")
          {
            if ($type eq "start")
              {
		#
                # Save output.
		#
                &push_output ();
              }
            else
              {
                my ($font_type) = "";
                my ($size) = "";
                my ($unit) = "";
                $font_type = uc (${$attributes}{'TYPE'});
                #
                # Recall the font size.
                # Modify "," with ".".
                #
                $size = &pop_output ();
                $size =~ s/,/./;
                $size =~ m/([0-9.]+)\s*([a-zA-Z]*)/;
                $size = $1;
                $unit = $2;
		#
                if ($unit eq "")
                  {
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: PRINTEDFONTSIZE must have a unit of measure!\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER), $V_ERROR);
                    $unit = "bp";
                  }
		#
                if ($font_type eq "TITLE")
                  {
                    $PRINTED_FONT_SIZE_TITLE = $size . $unit;
                    $PRINTED_FONT_HEIGHT_TITLE = ($size * 1.2) . $unit;
                  }
                elsif ($font_type eq "TOMEHEADING")
                  {
                    $PRINTED_FONT_SIZE_TOMEHEADING = $size . $unit;
                    $PRINTED_FONT_HEIGHT_TOMEHEADING = ($size * 1.2) . $unit;
                  }
                elsif ($font_type eq "H0")
                  {
                    $PRINTED_FONT_SIZE_H0 = $size . $unit;
                    $PRINTED_FONT_HEIGHT_H0 = ($size * 1.2) . $unit;
                  }
                elsif ($font_type eq "H1")
                  {
                    $PRINTED_FONT_SIZE_H1 = $size . $unit;
                    $PRINTED_FONT_HEIGHT_H1 = ($size * 1.2) . $unit;
                  }
                elsif ($font_type eq "H2")
                  {
                    $PRINTED_FONT_SIZE_H2 = $size . $unit;
                    $PRINTED_FONT_HEIGHT_H2 = ($size * 1.2) . $unit;
                  }
                elsif ($font_type eq "H3")
                  {
                    $PRINTED_FONT_SIZE_H3 = $size . $unit;
                    $PRINTED_FONT_HEIGHT_H3 = ($size * 1.2) . $unit;
                  }
                elsif ($font_type eq "H4")
                  {
                    $PRINTED_FONT_SIZE_H4 = $size . $unit;
                    $PRINTED_FONT_HEIGHT_H4 = ($size * 1.2) . $unit;
                  }
                elsif ($font_type eq "NORMAL")
                  {
                    $PRINTED_FONT_SIZE_NORMAL = $size . $unit;
                    $PRINTED_FONT_HEIGHT_NORMAL = ($size * 1.2) . $unit;
                  }                 
                elsif ($font_type eq "TABLE")
                  {
                    $PRINTED_FONT_SIZE_TABLE = $size . $unit;
                    $PRINTED_FONT_HEIGHT_TABLE = ($size * 1.2) . $unit;
                  }
                elsif ($font_type eq "EXAMPLE")
                  {
                    $PRINTED_FONT_SIZE_EXAMPLE = $size . $unit;
                    $PRINTED_FONT_HEIGHT_EXAMPLE = ($size * 1.2) . $unit;
                  }
                else
                  {
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: wrong type inside printedfontsize element: %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           $font_type), $V_ERROR);
                  }
              }
          }
        elsif ($element eq "PRINTEDPAGESIZE")
          {
            if ($type eq "start")
              {
		#
                # Save output.
		#
                &push_output ();
              }
            else
              {
                my ($page_size_type) = "";
                my ($size) = "";
                my ($unit) = "";
                $page_size_type = uc (${$attributes}{'TYPE'});
                #
                # Recall the font size.
                # Modify "," with ".".
                #
                $size = &pop_output ();
                $size =~ s/,/./;
                $size =~ m/([0-9.]+)\s*([a-zA-Z]*)/;
                $size = $1;
                $unit = $2;
		#
                if ($page_size_type eq "TOPMARGIN")
                  {
                    $PRINTED_TOP_MARGIN = $size . $unit;
                  }
                elsif ($page_size_type eq "BOTTOMMARGIN")
                  {
                    $PRINTED_BOTTOM_MARGIN = $size . $unit;
                  }
                elsif ($page_size_type eq "INTERNALMARGIN")
                  {
                    $PRINTED_INTERNAL_MARGIN = $size . $unit;
                  }
                elsif ($page_size_type eq "BODYWIDTH")
                  {
                    $PRINTED_BODY_WIDTH = $size . $unit;
                  }
              }
          }
        elsif ($element eq "PRINTWORKINFO")
          {
            if ($type eq "start")
              {
                #
                # Save the HTML page number for WORKINFO.
                #
                $workinfo_html_page = $html_page_counter;
                #
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif (   ($element eq "HTML")
               || ($element eq "ASCIIART")
               || ($element eq "IMAGE")
               || ($element eq "EMBIMG")     || ($element eq "EMBIMAGE")
               || ($element eq "HTMLIMG")    || ($element eq "HTMLIMAGE")
               || ($element eq "EPSIMG")     || ($element eq "EPSIMAGE")
               || ($element eq "FIGIMG")     || ($element eq "FIGIMAGE")
               || ($element eq "GNUPLOTIMG") || ($element eq "GNUPLOTIMAGE")
               || ($element eq "LYIMG")      || ($element eq "LYIMAGE")
               || ($element eq "TEXIMG")     || ($element eq "TEXIMAGE")
               || ($element eq "LATEXIMG")   || ($element eq "LATEXIMAGE")
              )
          {
            #
            # Just nothing to do about cross references.
            #
            ;
          }
        elsif ($element eq "FOOTNOTE")
          {
            #
            # We need to remove output at this stage, because it goes
	    # inside headers and indexes.
            #
            if ($type eq "start")
              {
		#
                # Save output.
		#
                &push_output ();
              }
            else
              {
		#
                # Remove output.
		#
                &pop_output ();
              }
          }
        elsif ($element eq "COPY")
          {
            #
            # Just nothing to do about copy at the moment.
            #
            ;
          }
        else
          {
            if ($typesetting eq "LATEX")
              {
                #
                # Call the basic %block; and %inline; sub process for LaTeX.
                #
                &sgml_tag_elab_latex_basic
                    ($type,
                     $element,
                     $attributes,
                     $typesetting,
                     $target,
                     $draft,
                     $page_numbering,
                     "", #! $compact,
                     "", #! $long,
                     "", #! $original_file_name,
                     "", #! $current_file_name,
                     "", #! $root_file_name,
                     $paper_width,
                     $paper_height);
              }
            elsif ($typesetting eq "HTML")
              {
                #
                # Call the basic %block; and %inline; sub process for LaTeX.
                #
                &sgml_tag_elab_html_basic
                    ($type,
                     $element,
                     $attributes,
                     $typesetting,
                     $target,
                     $draft,
                     $page_numbering,
                     "", #! $compact,
                     "", #! $long,
                     "", #! $original_file_name,
                     "", #! $current_file_name,
                     "", #! $root_file_name,
                     $paper_width,
                     $paper_height);
              }
          }

    } # sgml_tag_elab_first_pass
    #
    # This is the sub elaboration process specific, for basic %block;
    # and %inline; elements, for the LaTeX back-end.
    #
    # &sgml_tag_elab_latex_basic (TYPE, ELEMENT, %ATTRIBUTES,
    #                             TYPESETTING,
    #                             TARGET,
    #                             DRAFT,
    #                             PAGE-NUMBERING,
    #                             COMPACT,
    #                             LONG,
    #                             ORIGINAL_NAME,
    #                             ROOT_FILE_NAME)
    #
    sub sgml_tag_elab_latex_basic
    {
        #
        # Function arguments.
        #
        my ($type)               = $_[0];
        my ($element)            = $_[1];
        my ($attributes)         = $_[2];
        my ($typesetting)        = $_[3];
        my ($target)             = $_[4];
        my ($draft)              = $_[5];
        my ($page_numbering)     = $_[6];
        #! my ($compact)            = $_[7];
        #! my ($long)               = $_[8];
        #! my ($original_file_name) = $_[9];
        #! my ($current_file_name)  = $_[10];
        #! my ($root_file_name)     = $_[11];
        my ($paper_width)        = $_[12];
        my ($paper_height)       = $_[13];
        #
        # Print LaTeX footnotes at the end of a chapter.
        #
        # &latex_standard_footnotes ()
        #
        sub latex_standard_footnotes
        {
            #
            # Print footnotes.
            #
            if ($#latex_footnote_list >= 0)
              {
                #
                &output ("\n");
                &output ("\\rule{\\linewidth}{0.5pt}");
                &output ("\n");
                for ($n = 0; $n <= $#latex_footnote_list; $n++)
                  {
                    $m = $n +1;
                    &output ("\n");
                    &output ("\\hypertarget{almlfootnote:$h1section_absolute_counter:$m}{}");
                    &output ("\\hyperlink{almlfootnote-ref:$h1section_absolute_counter:$m}{");
                    &output ("{\\raisebox{0.75ex}{\\fontsize{0.6em}{1em}\\selectfont{$m}}}");
                    &output ("} ");
                    &output ($latex_footnote_list[$n]);
                    &output ("\n");
                  }
              }
            #
            # Reset footnote list.
            #
            @latex_footnote_list = ();
        }
        #
        # Element handlers.
        # Element names and attribute names are uppercase.
        #
        if ($element eq "P")
          {
            if ($type eq "start")
              {
                my ($font_size) = 0;
                my ($font_height) = 0;
                $font_size = ${$attributes}{'PRINTEDFONTSIZE'};
                #
                # Extract the font size.
                # Modify "," with ".".
                #
                if ($font_size ne "")
                  {
                    $font_size =~ s/,/./;
                    $font_height = &font_size_resize ($font_size, 1.2);
                  }
                #
                # Start the paragraph.
                #
                &output ("\n");
                &output ("{\n");
                #
                # Change the font size if required.
                #
                if ($font_size ne "")
                  {             
                    #
                    # Need an extra empty line.
                    #
                    &output ("\n");
                    #
                    # Set the font size.
                    #
                    &output ("\\fontsize{$font_size}{$font_height}\\selectfont\n");
                  }             
              }
            else
              {
                #
                # The extra empty line is inserted to close the
                # paragraph inside the font definition (inside the curly
                # brakets); otherwise, the base line spacing will not be
                # taken into consideration.
                #
                &output ("\n");
                &output ("\n");
                &output ("}\n");
                &output ("\n");
                #
              }
          }
        elsif ($element eq "FOOTNOTE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.
                #
                &push_output ();
              }
            else
              {
                #
                my ($n) = 0;
                #
                # Recall output (if any).
                #
                $latex_footnote = &pop_output ();
                #
                # Prepare a new element inside the footnote array.
                #
                $#latex_footnote_list++;
                $n = $#latex_footnote_list +1;
                #
                # Insert the footnote link.
                #
                &output ("\\almlaafootnotemark{\\hypertarget{almlfootnote-ref:$h1section_absolute_counter:$n}{}\\hyperlink{almlfootnote:$h1section_absolute_counter:$n}{$n}}");
                #
                # Insert the footnote inside the array.
                #
                $latex_footnote_list[$#latex_footnote_list] = $latex_footnote;
              }
          }
        elsif ($element eq "BLOCKFOOTNOTE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.
                #
                &push_output ();
              }
            else
              {
                #
                my ($n) = 0;
                #
                # Recall output (if any).
                #
                $latex_footnote = &pop_output ();
                #
                # Prepare a new element inside the footnote array.
                #
                $#latex_footnote_list++;
                $n = $#latex_footnote_list +1;
                #
                # Insert the footnote link.
                #
                &output ("\n");
                &output ("\n");
                &output ("\\almlaafootnotemark{\\hypertarget{almlfootnote-ref:$h1section_absolute_counter:$n}{}\\hyperlink{almlfootnote:$h1section_absolute_counter:$n}{$n}}");
                &output ("\n");
                &output ("\n");
                #
                # Insert the footnote inside the array.
                #
                $latex_footnote_list[$#latex_footnote_list] = $latex_footnote;
              }
          }
        elsif ($element eq "QUOTEINFO")
          {
            if ($type eq "start")
              {
                &output ("\\footnote{");
              }
            else
              {
                &output ("}\n");
              }
          }
        elsif ($element eq "BR")
          {
            if ($type eq "start")
              {
                #
                # Insert the \newline code and add a new line inside
                # the TeX source. This will be good inside preformatted
                # text like syntax.
                #
                &output ("\\newline");
                &output ("\n");
              }
            else
              {

                
                # Nothing to do.
                

                ;
              }
          }
        elsif ($element eq "URI")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($uri_literal) = "";
                my ($uri_print)   = "";
                my ($uri_complex) = "";
                #
                $uri_literal = &pop_output ();
                $uri_print   = &latex_literal_verbatim ($uri_literal);
                #
                # Correct the uri.
                #
                $uri_literal = &literal_uri_adaptation ($uri_literal);
                #
                # LaTeX needs more adaptation.
                #
                $uri_literal =~ s/\%/\\\%/g;
                #
                # The URI string need adaptations.
                #
                $uri_complex = &latex_uri_adaptation ($uri_literal, $uri_print);
                #
                # Print it out.
                #
                &output ("\\almlaauri{");
                &output ("$uri_complex");
                &output ("}");
                #
              }
          }
        elsif ($element eq "EMAIL")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($email_literal) = "";
                my ($email_print)   = "";
                my ($email_complex) = "";
                #
                $email_literal = &pop_output ();
                $email_print   = &latex_literal_verbatim ($email_literal);
		#
		# Must protect the e-mail
		#
                $email_print   =~ s/\./\\emaildot /mg;                # "." --> ""
                $email_print   =~ s/\\symbol\{64\}/\\emailcommat /mg; # "@" --> "(ad)"
                #
                # Print it out.
                #
                &output ("\\almlaauri{");
                &output ("$email_print");
                &output ("}");
                #
              }
          }
        elsif ($element eq "MAN")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                &output ("\\almlbbman{$current_man_page_name}{$current_man_page_section}");
              }
          }
        elsif ($element eq "MANSECT")
          {
            if ($type eq "start")
              {
                $current_man_page_name = &pop_output ();
                &push_output ();
              }
            else
              {
                $current_man_page_section = &pop_output ();
              }
          }
        elsif ($element eq "BIBREF")
          {
            if ($type eq "start")
              {
                &output ("\\almlaabibref{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "EM")
          {
            if ($type eq "start")
              {
                &output ("\\almlaaem{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "BIG")
          {
            if ($type eq "start")
              {
                &output ("\\almlaabig{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "SMALL")
          {
            if ($type eq "start")
              {
                &output ("\\almlaasmall{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "STRONG")
          {
            if ($type eq "start")
              {
                &output ("\\almlaastrong{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "ACRONYM")
          {
            if ($type eq "start")
              {
                &output ("\\almlaaacronym{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "DACRONYM")
          {
            if ($type eq "start")
              {
                &output ("\\almlaadacronym{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "KBD")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($kbd) = "";
                $kbd = &pop_output ();
		#
                # Replace "{-}" with \mbox{\texttt{-}}.
		#
                $kbd =~ s/\{-\}/\\almlxxsymbolminus{}/g;
		#
                &output ("\\almlaakbd{");
                &output ("$kbd");
                &output ("}");
              }
          }
        elsif ($element eq "KP")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($kp) = "";
                $kp = &pop_output ();
		#
                # Replace "{-}" with \mbox{\texttt{-}}.
		#
                $kp =~ s/\{-\}/\\almlxxsymbolminus{}/g;
		#
                &output ("\\almlaakp{");
                &output ("$kp");
                &output ("}");
              }
          }
        elsif ($element eq "VKBD")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($vkbd) = "";
                $vkbd = &pop_output ();
		#
                # Replace "{-}" with \mbox{\texttt{-}}.
		#
                $vkbd =~ s/\{-\}/\\almlxxsymbolminus{}/g;
		#
                &output ("\\almlaavkbd{");
                &output ("$vkbd");
                &output ("}");
              }
          }
        elsif ($element eq "REVISION")
          {
            if ($type eq "start")
              {
                &output ("\[{\\itshape{}");
              }
            else
              {
                &output ("}\]");
              }
          }
        elsif ($element eq "BUTTON")
          {
            if ($type eq "start")
              {
                &output ("\\almlaabutton{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "MENUITEM")
          {
            if ($type eq "start")
              {
                &output ("\\almlaamenuitem{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "ASCIICODE")
          {
            if ($type eq "start")
              {
                &output ("\\almlaaasciicode{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "CODE")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($code) = "";
                $code = &pop_output ();
                #
                # There is a different implementation if
                # we are inside a INDEXENTRY element.
                #
                if ($index_entry_active)
                  {
                    &output ("\\almlaacodeindexentry{");
                    &output ("$code");
                    &output ("}");
                  }
                else
                  {

                    # Do some transformations for good printing,
                    # but it is no more necessary.

                    #$code = &latex_literal_step_0 ($code);
                    #$code = &latex_literal_step_1 ($code);

                    &output ("\\almlaacode{");
                    &output ("$code");
                    &output ("}");
                  }
              }
          }
        elsif ($element eq "SAMP")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($samp) = "";
                $samp = &pop_output ();


                
                # Do some transformations for good printing,
                # but it is no more necessary.
                

                #$samp = &latex_literal_step_0 ($samp);
                #$samp = &latex_literal_step_1 ($samp);


                
                # Use \mbox around unbreakable pieces.
                # Please note that true spaces are marked as "{} ":
                # 1. put a \mbox{...} around the SAMP element;
                # 2. replace spaces with the stop and start of an \mbox:
                #    "} \mbox{"
                #
                #!!!! In the near future, the space such as "{} " might be
                #!!!! changed into "\ ", that is more correct.
                #!!!! The DTD is arranged to delete duplicate spaces, replacing
                #!!!! also tabs into single space.
                #
                

                $samp =  "\\mbox{" . $samp . "}";
                $samp =~ s/\{\} /} \\mbox{/mg;

                &output ("\\almlaasamp{");
                &output ("$samp");
                &output ("}");
              }
          }
        elsif ($element eq "STRDFN")
          {
            if ($type eq "start")
              {
                &output ("\\almlaadefstr{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "KERNELOPTION")
          {
            if ($type eq "start")
              {
		#
                &output ("\\almlaakerneloption{");
		#
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: the element \"kerneloption\" is obsolete; you might use \"menuitem\" instead.\n"),
                             $PROGRAM_EXECUTABLE,
                             $SOURCE_FILE_NAME,
                             $CURRENT_FILE_NAME,
                             $INPUT_STREAM_LINE_COUNTER), $V_WARNING);
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "FILE")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($file) = "";
                $file = &pop_output (); 


                
                # The PATH string needs adaptations.
                

                $file = &latex_path_adaptation ($file);
                $file = &latex_path_adaptation_sub_box ($file);


                
                # Print it out.
                

                &output ("\\almlaafile{");
                &output ($file);
                &output ("}");
              }
          }
        elsif ($element eq "URISTR")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($file) = "";
                $file = &pop_output (); 
                #
                # The URI string need adaptations.
                #
                $file = &latex_path_adaptation ($file);
                $file = &latex_path_adaptation_sub_box ($file);
                #
                # Print it out.
                #
                &output ("\\almlaauristr{");
                &output ($file);
                &output ("}");
              }
          }
        elsif ($element eq "SUP")
          {
            if ($type eq "start")
              {
                &output ("\\almlaasup{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "SUB")
          {
            if ($type eq "start")
              {
                &output ("\\almlaasub{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "PWR")
          {
            if ($type eq "start")
              {
                &output ("\\almlaapwr{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "EXA")
          {
            if ($type eq "start")
              {
                &output ("\\almlbbnumberwithbase{");
              }
            else
              {
                &output ("}{16}");
              }
          }
        elsif ($element eq "DEC")
          {
            if ($type eq "start")
              {
                &output ("\\almlbbnumberwithbase{");
              }
            else
              {
                &output ("}{10}");
              }
          }
        elsif ($element eq "OCT")
          {
            if ($type eq "start")
              {
                &output ("\\almlbbnumberwithbase{");
              }
            else
              {
                &output ("}{8}");
              }
          }
        elsif ($element eq "BIN")
          {
            if ($type eq "start")
              {
                &output ("\\almlbbnumberwithbase{");
              }
            else
              {
                &output ("}{2}");
              }
          }
        elsif ($element eq "NUM")
          {
            if ($type eq "start")
              {
                #
                # Save data here.
                #
                push_output ();
              }
            else
              {
                my ($num) = "";
                my ($int) = "";
                my ($dec) = "";
                my ($point) = "";
                my ($sep) = "";
                my ($plus) = "";
                my ($minus) = "";


                
                # Recall output.
                

                $num = &pop_output ();


                
                # The separator is a thin space.
                

                $sep = "\\mbox{\\hspace{0.2ex}}";
                $plus = "+";
                $minus = "\\almlxxsymbolminus{}";


                
                # Now, start elaboration, to separate each three digits.
                

                if ($num =~ m/^([+-]?)([0-9]*)([.,]?)([0-9]*)$/)
                  {
                    $sign  = $1;
                    $int   = $2;
                    $point = $3;
                    $dec   = $4;
                    $int   = &integer_to_string ($int, $sep);
                    $dec   = &decimal_to_string ($dec, $sep);


                    
                    # Correct integer side if necessary.
                    

                    if ($int eq "")
                      {
                        $int = "0";
                      }


                    
                    # Set the sign prefix.
                    

                    if ($sign eq "+")
                      {
                        $sign = $plus;
                      }
                    elsif ($sign eq "-")
                      {
                        $sign = $minus;
                      }
                    else
                      {
                        $sign = "";
                      }

                    if ($dec eq "")
                      {

                        
                        # Nothing after the decimal marker.
                        

                        &output ("\\almlbaspecialname{");
                        &output ($sign . $int);
                        &output ("}{}");
                      }
                    else
                      {
                        &output ("\\almlbaspecialname{");
                        &output ($sign . $int . $point . $dec);
                        &output ("}{}");
                      }
                  }
                else
                  {

                    
                    # This is not a valid number.
                    

                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: wrong number %s\n"),
                                  $PROGRAM_EXECUTABLE,
                                  $SOURCE_FILE_NAME,
                                  $CURRENT_FILE_NAME,
                                  $INPUT_STREAM_LINE_COUNTER,
                                  $num), $V_ERROR);


                    
                    # Anyway, print it out.
                    

                    &output ($num);
                  }
              }
          }
        elsif ($element eq "TEX")
          {
            if ($type eq "start")
              {
                #
                # Nothing to do here;
                #
                ;
              }
            else
              {

                
                # Nothing to do here;
                

                ;
              }
          }
        elsif ($element eq "IFTEX")
          {
            if ($type eq "start")
              {
		#
                # Nothing to do here;
		#
                ;
              }
            else
              {
		#
                # Nothing to do here;
		#
                ;
              }
          }
        elsif ($element eq "HTML")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Loose HTML content.
                #
                &pop_output ();
              }
          }
        elsif ($element eq "IFHTML")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Loose HTML content.
                #
                &pop_output ();
              }
          }
        elsif ($element eq "BLOCKQUOTE")
          {
            if ($type eq "start")
              {
                &output ("\n\\begin{quote}\n");
                #
                # Text indent level.
                #
                $text_indent_level++;
              }
            else
              {

                
                # Text indent level.
                

                $text_indent_level--;

                &output ("\n\\end{quote}\n");
              }
          }
        elsif ($element eq "FRAME")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("\\begin{center}");
                &output ("\n");
                &output ("{");
                &output ("\\color{red}");
                &output ("\\fboxrule=0.3mm");
                &output ("\\fboxsep=0.4em");
                &output ("\\fbox{\\noindent");
                &output ("\\begin{minipage}{0.97\\linewidth}");
                &output ("\\color{black}");
              }
            else
              {
                &output ("\n");
                &output ("\n");
                &output ("\\end{minipage}}");
                &output ("}");
                &output ("\\end{center}\n");
              }
          }
        elsif ($element eq "PRE")
          {
            if ($type eq "start")
              {

                
                # Save attributes.
                

                $g_preformatted_column_width = ${$attributes}{'WIDTH'};
                $g_preformatted_border       = ${$attributes}{'BORDER'};
                $g_preformatted_numbering    = ${$attributes}{'NUMBERING'};


                
                # Correct min and max.
                

                if ($g_preformatted_column_width eq "")
                  {
                    $g_preformatted_column_width = 80;
                  }
                elsif ($g_preformatted_column_width < 30)
                  {
                    $g_preformatted_column_width = 30;
                  }
                elsif ($g_preformatted_column_width > 200)
                  {
                    $g_preformatted_column_width = 200;
                  }


                
                # Send the output stream to a new stack level.        
                

                &push_output ();
              }
            else
              {
                my ($pre) = "";
                my ($indent_factor) = 0;
                if ($floating_block)
                  {
                    $indent_factor = 1;
                  }
                else
                  {
                    $indent_factor = 0.94**$text_indent_level;
                  }
                my ($font_size) =
                    (int ((46.3 * $indent_factor
                                * &convert_to_mm_as_number ($PRINTED_BODY_WIDTH))
                          / $g_preformatted_column_width)) / 10;
                my ($font_spacing) = $font_size*1.2;
                

                
                # The normal mode for output() function is re-established.
                

                $pre = &pop_output ();


                
                # Do some transformations for good printing.
                

                #$pre = &latex_literal_step_0 ($pre);
                #$pre = &latex_literal_step_1 ($pre);
                #$pre = &latex_literal_step_2 ($pre);
                $pre = &latex_literal_step_3 ($pre);
                $pre = &latex_literal_step_5 ($pre);

                &output ("\n");


                
                # The \par at the beguinning and at the end, is
                # necessary because the font change is inside {...},
                # and without the last one the base line skip does not
                # take affect. So, the first \par is there for simmetry.
                

                &output ("{\n");
                &output ("\\par");
                &output ("\n");

                if ($g_we_are_inside_a_tabular)
                  {
          
                    
                    # As the tabular environment will be used, no
                    # back vertical movement is to be done.
                    

                    ;
                  }
                else
                  {
                    &output ("\n");
                    # &output ("\\vspace{-2ex}");
                    # &output ("\n");
                  }

                if ($g_preformatted_column_width eq "0")
                  {

                    
                    # This means no font change at all.
                    

                    ;
                  }
                else
                  {
                    &output ("\\fontsize{$font_size}{$font_spacing}\\selectfont\n");
                  }

                output (&latex_block_inside_table ($pre, $g_preformatted_numbering, $g_preformatted_border, $g_we_are_inside_a_tabular));

                &output ("\\par\n");
                &output ("}\n");

              }
          }
        elsif ($element eq "PNEWLINE")
          {
            if ($type eq "start")
              {
                #
                # Please note that there cannot be any space inside
                # the LaTeX command, because spaces are changed into
                # unbreakable spaces. So, "\lower0.5ex"
                # or \lower{0.5ex} must be so.
                #
                &output ("{\\raisebox{-0.5ex}{\$\\hookleftarrow\$}}");
                &output ("\\newline");
                &output ("{\\raisebox{0.5ex}{\$\\hookrightarrow\$}}");
                #
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "VERBATIMPRE.ORIG") # !!!!
          {
            if ($type eq "start")
              {

                
                # Save column width.
                

                $g_preformatted_column_width = ${$attributes}{'WIDTH'};


                
                # Correct min and max.
                

                if ($g_preformatted_column_width eq "")
                  {
                    $g_preformatted_column_width = 80;
                  }
                elsif ($g_preformatted_column_width < 30)
                  {
                    $g_preformatted_column_width = 30;
                  }
                elsif ($g_preformatted_column_width > 200)
                  {
                    $g_preformatted_column_width = 200;
                  }


                
                # Send the output stream to a new stack level.        
                

                &push_output ();
              }
            else
              {
                my ($pre) = "";
                my ($indent_factor) = 0;
                if ($floating_block)
                  {
                    $indent_factor = 1;
                  }
                else
                  {
                    $indent_factor = 0.94**$text_indent_level;
                  }
                my ($font_size) =
                    (int ((46.3 * $indent_factor
                                * &convert_to_mm_as_number ($PRINTED_BODY_WIDTH))
                          / $g_preformatted_column_width)) / 10;
                my ($font_spacing) = $font_size*1.2;


                
                # The normal mode for output() function is re-established.
                

                $pre = &pop_output ();


                
                # Do some transformations for good printing.
                

                $pre = &latex_literal_verbatim ($pre);
                $pre = &latex_literal_step_2 ($pre);
                #$pre = &latex_literal_step_3 ($pre);
                &output ("\n");


                
                # The \par at the beguinning and at the end, is
                # necessary because the font change is inside {...},
                # and without the last one the base line skip does not
                # take affect. So, the first \par is there for simmetry.
                

                &output ("{\n");
                &output ("\\par\n");
                if ($g_preformatted_column_width eq "0")
                  {

                    
                    # This means no font change at all.
                    

                    ;
                  }
                else
                  {
                    &output ("\\fontsize{$font_size}{$font_spacing}\\selectfont\n");
                  }
                &output ("{");
                &output ("\\begin{ttfamily}\n");
                &output ("$pre\n");
                &output ("\\end{ttfamily}");
                &output ("}");
                &output ("\\par\n");
                &output ("}\n");
              }
          }
        elsif ($element eq "VERBATIMPRE")
          {
            if ($type eq "start")
              {
		#
                # Save attributes.
                #
                $g_preformatted_column_width = ${$attributes}{'WIDTH'};
                $g_preformatted_border       = ${$attributes}{'BORDER'};
                $g_preformatted_numbering    = ${$attributes}{'NUMBERING'};
                #
                # Correct min and max.
                #
                if ($g_preformatted_column_width eq "")
                  {
                    $g_preformatted_column_width = 80;
                  }
                elsif ($g_preformatted_column_width < 30)
                  {
                    $g_preformatted_column_width = 30;
                  }
                elsif ($g_preformatted_column_width > 200)
                  {
                    $g_preformatted_column_width = 200;
                  }


                
                # Send the output stream to a new stack level.        
                

                &push_output ();
              }
            else
              {
                my ($pre) = "";
                my ($indent_factor) = 0;
                if ($floating_block)
                  {
                    $indent_factor = 1;
                  }
                else
                  {
                    $indent_factor = 0.94**$text_indent_level;
                  }
                my ($font_size) =
                    (int ((46.3 * $indent_factor
                                * &convert_to_mm_as_number ($PRINTED_BODY_WIDTH))
                          / $g_preformatted_column_width)) / 10;
                my ($font_spacing) = $font_size*1.2;


                
                # The normal mode for output() function is re-established.
                

                $pre = &pop_output ();


                
                # Do some transformations for good printing.
                

                $pre = &latex_literal_verbatim ($pre);
                #$pre = &latex_literal_step_2 ($pre);
                #$pre = &latex_literal_step_3 ($pre);
                $pre = &latex_literal_step_5 ($pre);

                &output ("\n");


                
                # The \par at the beguinning and at the end, is
                # necessary because the font change is inside {...},
                # and without the last one the base line skip does not
                # take affect. So, the first \par is there for simmetry.
                

                &output ("{\n");
                &output ("\\par");
                &output ("\n");

                if ($g_we_are_inside_a_tabular)
                  {
          
                    
                    # As the tabular environment will be used, no
                    # back vertical movement is to be done.
                    

                    ;
                  }
                elsif ($g_preformatted_border)
                  {
                    &output ("\n");
                    &output ("\\vspace{-1ex}");
                    &output ("\n");
                  }
                else
                  {

                    
                    # No back vertical movement is to be done.
                    

                    ;
                  }

                if ($g_preformatted_column_width eq "0")
                  {

                    
                    # This means no font change at all.
                    

                    ;
                  }
                else
                  {
                    &output ("\\fontsize{$font_size}{$font_spacing}\\selectfont\n");
                  }

                output (&latex_block_inside_table ($pre, $g_preformatted_numbering, $g_preformatted_border, $g_we_are_inside_a_tabular));

                &output ("\\par\n");
                &output ("}\n");
              }
          }
        elsif ($element eq "SYNTAX")
          {
            if ($type eq "start")
              {
                my ($sep) = "";
		#
                # Save attributes.
		#
                $sep = lc ${$attributes}{'SEP'};
		#
                # It is supposed that the value is valid.
		#
                $syntax_separation = $sep;
		#
                # Save column width.
		#
                $g_preformatted_column_width = ${$attributes}{'WIDTH'};
		#
                # Correct min and max.
		#
                if ($g_preformatted_column_width eq "")
                  {
                    $g_preformatted_column_width = 80;
                  }
                elsif ($g_preformatted_column_width < 30)
                  {
                    $g_preformatted_column_width = 30;
                  }
                elsif ($g_preformatted_column_width > 200)
                  {
                    $g_preformatted_column_width = 200;
                  }
		#
                # Send the output stream to a new stack level.        
		#
                &push_output ();
              }
            else
              {
                my ($syntax) = "";
                my ($indent_factor) = 0;
                if ($floating_block)
                  {
                    $indent_factor = 1;
                  }
                else
                  {
                    $indent_factor = 0.94**$text_indent_level;
                  }
		#
		# Calculate font size.
		# The vertical spacing is 1.618 times the vertical height
		# (golden ratio).
		#
                my ($font_size) =
                    (int ((46.3 * $indent_factor
                                * &convert_to_mm_as_number ($PRINTED_BODY_WIDTH))
                          / $g_preformatted_column_width)) / 10;
		#
                my ($font_spacing) = $font_size*1.618;
		#
                # The normal mode for output() function is re-established.
		#
                $syntax = &pop_output ();
		#
                # Do some transformations for good printing.
		#
                #$syntax = &latex_literal_step_0 ($syntax);
                #$syntax = &latex_literal_step_1 ($syntax);
                $syntax = &latex_literal_step_2 ($syntax);
                $syntax = &latex_literal_step_3 ($syntax);
                $syntax = &latex_literal_step_4 ($syntax);
		#
                # The following "%" is there to avoid the addition
                # of a minimal horizontal space at the beguinning
                # of the line, when inside the cell of a table.
		#
                &output ("%");
		#
                &output ("\n");
                &output ("% <". "$element" . ">\n");
                #
                # Border required?
                #
                if ($syntax_separation eq "box"
                    || $syntax_separation eq "border")
                  {
                    &output ("{");
                    &output ("\\color{cyan}");
                    &output ("\\fboxsep=1mm");
                    &output ("\\fboxrule=0.1mm");
                    &output ("\n");
                    &output ("\\fbox");
                    &output ("{");
                    &output ("\\color{black}");
                    &output ("\\noindent");
                    &output ("\\begin{minipage}{0.98\\linewidth}   % minipage inside \\fbox");
                    &output ("\n");
                  }
                else
                  {
                    #!  &output ("{\\samepage");
                    #!  &output ("\n");
		    ;
                  }
		#
		# Isolate the font change.
		#
                &output ("{");
		#
                if ($g_preformatted_column_width eq "0")
                  {
                    #
                    # This means no font change at all.
                    #
                    ;
                  }
                else
                  {
                    &output ("\\fontsize{$font_size}{$font_spacing}\\selectfont");
                    &output ("\n");
                  }
		#!  #
		#!  # Put here a vertical space to be separated from the
		#!  # outside. Should be 0.309 em, meant to be the
		#!  # half of 0.618 (golden ratio).
		#!  # Must be with asterisk to work also inside a frame
		#!  #
                #!  &output ("\\vspace*{0.309em}");
                #!  &output ("\n");
		#
                &output ("{");
                &output ("\\begin{ttfamily}");
                &output ("$syntax");
                &output ("\\end{ttfamily}");
                &output ("}");
                &output ("\\par");
                &output ("\n");
		#!  #
		#!  # Put here a vertical space to be separated from the
		#!  # outside. The number 0.309 is meant to be the
		#!  # half of 0.618 (golden ratio).
		#!  # Must be with asterisk to work also inside a frame
		#!  #
                #!  &output ("\\vspace*{0.309em}");
                #!  &output ("\n");
		#
		# Close the isolation font change.
		#
                &output ("}");
                &output ("\n");
                #
                # Border required?
                #
                if ($syntax_separation eq "box"
                    || $syntax_separation eq "border")
                  {
                    &output ("\\end{minipage}    % minipage inside \\fbox");
                    &output ("\n");
                    &output ("} % End \\fbox");
                    &output ("\n");
                    &output ("} % End \\color");
                    &output ("\n");
                  }
                else
                  {
                    #!  &output ("}% samepage-end from $element");
                    #!  &output ("\n");
		    ;
                  }
		#
                &output ("% </". "$element" . ">");
		#
                # There it the need of an empty line to avoid two
                # syntax elements to interfere with alignment.
		#
                &output ("\n");
                &output ("\n");
		#
              }
          }
        elsif ($element eq "SNEWLINE")
          {
            if ($type eq "start")
              {
                &output ("{\\raisebox{-0.5ex}{\$\\hookleftarrow\$}}");
                &output ("\\newline");
                &output ("{\\raisebox{0.5ex}{\$\\hookrightarrow\$}}");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "DL")
          {
            if ($type eq "start")
              {
                &output ("\n\\begin{list}{}{}");
              }
            else
              {
                &output ("\n\\end{list}\n");
              }
          }
        elsif ($element eq "DT")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("\\item\\hspace{-0,25in}");
              }
            else
              {
                &output ("\\nopagebreak");
                &output ("\n");
              }
          }
        elsif ($element eq "DD")
          {
            if ($type eq "start")
              {

                
                # An empty line is necessary to distantiate from
                # a syntax code.
                

                &output ("\n");


                
                # Text indent level.
                

                $text_indent_level++;
              }
            else
              {

                
                # Text indent level.
                

                $text_indent_level--;

                &output ("");
              }
          }
        elsif ($element eq "OL")
          {
            if ($type eq "start")
              {
                &output ("\n\\begin{enumerate}");
              }
            else
              {
                &output ("\n\\end{enumerate}\n");
              }
          }
        elsif ($element eq "UL")
          {
            if ($type eq "start")
              {
                &output ("\n\\begin{itemize}");
              }
            else
              {
                &output ("\n\\end{itemize}\n");
              }
          }
        elsif ($element eq "LI")
          {
            if ($type eq "start")
              {
                &output ("\n\\item ");


                
                # Text indent level.
                

                $text_indent_level++;

              }
            else
              {


                
                # Text indent level.
                

                $text_indent_level--;

                &output ("");
              }
          }
        elsif ($element eq "SEGMENT")
          {
            if ($type eq "start")
              {
		#
		# This is obsolete; warn the user.
		#
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: element \"segment\" is obsolete; please use \"dl\" instead.\n"),
                             $PROGRAM_EXECUTABLE,
                             $SOURCE_FILE_NAME,
                             $CURRENT_FILE_NAME,
                             $INPUT_STREAM_LINE_COUNTER), $V_WARNING);
                #
                # Reset vertical spacing.
                #
                &output ("\\vspace{0pt}");
                &output ("\n");
                &output ("\n");
                #
                # Begin list.
                #
                &output ("\\begin{list}{}{}");
                #
                # Text indent level.
                #
                $text_indent_level++;
              }
            else
              {
                #
                # Text indent level.
                #
                $text_indent_level--;
		#
                &output ("\n\\end{list}\n");
              }
          }
        elsif ($element eq "SEGMENTHEAD")
          {
            if ($type eq "start")
              {

                
                # Text indent level.
                

                $text_indent_level--;


                
                # Reset vertical spacing.
                

                &output ("\\vspace{0pt}");
                &output ("\n");
                &output ("\n");


                
                # Insert list item.
                

                &output ("\n");
                &output ("\\item\\hspace{-0,25in}\\begin{sffamily}");
              }
            else
              {
                &output ("\\end{sffamily}");
                &output ("\n");
                &output ("\n");


                
                # Text indent level.
                

                $text_indent_level++;

              }
          }
        elsif ($element eq "VAR")
          {
            if ($type eq "start")
              {
                &output ("\\almlaavar{");
              }
            else
              {
                &output ("}");
              }
          }
        elsif ($element eq "SYNSQB")
          {
            if ($type eq "start")
              {
                &output ("\\almlxxsynlsqb{}");
              }
            else
              {
                &output ("\\almlxxsynrsqb{}\\hspace{0pt}");
              }
          }
        elsif ($element eq "SYNCUB")
          {
            if ($type eq "start")
              {
                &output ("\\almlxxsynlcub{}");
              }
            else
              {
                &output ("\\almlxxsynrcub{}\\hspace{0pt}");
              }
          }
        elsif ($element eq "SYNVERBAR")
          {
            if ($type eq "start")
              {
                &output ("\\hspace{0pt}\\almlxxsynverbar{}");
              }
            else
              {

                
                # Nothing to do.
                

                ;
              }
          }
        elsif ($element eq "SYNELLIPSIS")
          {
            if ($type eq "start")
              {
                &output ("\\almlxxsynellipsis{}");
              }
            else
              {

                
                # Nothing to do.
                

                ;
              }
          }
        elsif ($element eq "SYNSTAR")
          {
            if ($type eq "start")
              {
                &output ("\\almlxxsynstar{}");
              }
            else
              {

                
                # Nothing to do.
                

                ;
              }
          }
        elsif ($element eq "RESULT")
          {
            if ($type eq "start")
              {
                &output ("\\almlxxresult{}");
              }
            else
              {

                
                # Nothing to do.
                

                ;
              }
          }
        elsif ($element eq "HR")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("\\rule{\\linewidth}{0.5pt}\n");
              }
            else
              {

                
                # Nothing to do.
                

                ;
              }
          }
        elsif ($element eq "NEWPAGE")
          {
            if ($type eq "start")
              {
                &output ("\\almlzznewpage{}\n");
              }
            else
              {

                
                # Nothing to do.
                

                ;
              }
          }
        elsif ($element eq "HEIGHTREQUIRED")
          {
            if ($type eq "start")
              {
                my ($height)= ${$attributes}{'HEIGHT'};
                &output ("\\almlazbreakpageiflessthen{$height}");
                &output ("\n");
              }
            else
              {

                
                # Nothing to do.
                

                ;
              }
          }
        elsif ($element eq "BOTTOMPAGE")
          {
            if ($type eq "start")
              {
                &output ("\\almlzzvfill{}");
                &output ("\n");
              }
            else
              {
                &output ("\\almlzznewpage{}");
                &output ("\n");
              }
          }
        elsif ($element eq "COMMAND")
          {
            if ($type eq "start")
              {

                # Save column width.

                $g_preformatted_column_width = ${$attributes}{'WIDTH'};

                # Correct min and max.

                if ($g_preformatted_column_width eq "")
                  {

                    # Default command font is a little bigger than
                    # syntax and preformatted text.
                    

                    $g_preformatted_column_width = 70;
                  }
                elsif ($g_preformatted_column_width < 30)
                  {
                    $g_preformatted_column_width = 30;
                  }
                elsif ($g_preformatted_column_width > 200)
                  {
                    $g_preformatted_column_width = 200;
                  }


                
                # Send the output stream to a new stack level.        
                

                &push_output ();
              }
            else
              {
                my ($command) = "";
                my ($indent_factor) = 0;
                if ($floating_block)
                  {
                    $indent_factor = 1;
                  }
                else
                  {
                    $indent_factor = 0.94**$text_indent_level;
                  }
                  
                my ($font_size) =
                    (int ((46.3 * $indent_factor
                                * &convert_to_mm_as_number ($PRINTED_BODY_WIDTH))
                          / $g_preformatted_column_width)) / 10;
                my ($font_spacing) = $font_size*1.2;

                # The normal mode for output() function is re-established.

                $command = &pop_output ();

                # Print the command.

                &output ("\n");
                &output ("\\vspace{0.3em}");
                &output ("{\\fontsize{$font_size}{$font_spacing}\\selectfont\n");
                &output ("{");
                &output ("$command");
                &output ("}");
                &output ("\\par}");
                &output ("\\vspace{0.3em}\n");
              }
          }
        elsif ($element eq "PROMPT")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($prompt) = "";
                $prompt = &pop_output ();


                #
                ## Replace "-" with \mbox{\texttt{-}}.
                #
                #
                #$prompt =~ s/\{-\}/\\almlxxsymbolminus{}/g;

                &output ("\\begin{ttfamily}");
                &output ("$prompt");
                &output ("\\end{ttfamily}");
              }
          }
        elsif ($element eq "TYPE")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($type_in) = "";
                $type_in = &pop_output ();
                #
                # Replace some characters.
                #
                #$type = &latex_literal_step_0 ($type);
                #$type = &latex_literal_step_1 ($type);
		#
                &output ("{\\bfseries\\ttfamily{}");
                &output ("$type_in");
                &output ("\\hspace{0.5ex}}");
              }
          }
        elsif ($element eq "CNEWLINE")
          {
            if ($type eq "start")
              {
                &output ("{\\raisebox{-0.5ex}{\$\\hookleftarrow\$}}");
                &output ("\\newline");
                &output ("{\\raisebox{0.5ex}{\$\\hookrightarrow\$}}");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "ENDOFCHAPTER")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("\\almlzzvfillhalf{}\\nopagebreak{\\scriptsize\\slshape{}");
              }
            else
              {

                
                # It is necessary to close the paragraph before the
                # closing "}" to have the right base line skip.
                

                &output ("\\par}\n");
              }
          }
        elsif ($element eq "BACKCOVER")
          {
            if ($type eq "start")
              {

                
                # Save output.
                

                &push_output ();
              }
            else
              {
                
                # Recall output.

                $back_cover = &pop_output ();
                
                # With %block; elements, there is a line feed character
                # at the top of the string. I don't know why.
                # Anyway, we have to delete this extra line feed.

                $back_cover =~ s/^\n?(.*)$/$1/s;
              }
          }

    } # sgml_tag_elab_latex_basic
    #
    # This is the elaboration process specific for the LaTeX back-end.
    #
    # &sgml_tag_elab_latex (TYPE, ELEMENT, %ATTRIBUTES,
    #                       TYPESETTING,
    #                       TARGET,
    #                       DRAFT,
    #                       PAGE-NUMBERING,
    #                       COMPACT,
    #                       LONG,
    #                       ORIGINAL_NAME,
    #                       ROOT_FILE_NAME)
    #    
    sub sgml_tag_elab_latex
    {
        #
        # Function arguments.
        #
        my ($type)               = $_[0];
        my ($element)            = $_[1];
        my ($attributes)         = $_[2];
        my ($typesetting)        = $_[3];
        my ($target)             = $_[4];
        my ($draft)              = $_[5];
        my ($page_numbering)     = $_[6];
        #! my ($compact)            = $_[7];
        #! my ($long)               = $_[8];
        #! local ($original_file_name) = $_[9];
        #! my ($current_file_name)  = $_[10];
        #! my ($root_file_name)     = $_[11];
        my ($paper_width)        = $_[12];
        my ($paper_height)       = $_[13];
        #
        # Separate arguments of a previous LaTeX command.
        #
        sub latex_command_arguments_deletion
        {
            my ($arguments)      = $_[0];
            my ($string)         = $_[1];
            my ($arg)            = "";
            my (@args)           = ();
            my ($i)              = 0;
            #
            sub latex_group_location
            {
                my ($a)              = $_[0];
                my ($z)              = $_[1];
                my ($string)         = $_[2];
                my ($i)              = 0;
                my ($c)              = 0;
                my ($sublevels)      = 0;
		#
                # Find the next "}"
                #
                if (substr ($string, 0, 1) ne "{")
                  {
                    #
                    # The first character must be an open brace.
                    #
                    &diag_output (sprintf (gettext ("%s:%s:DEBUG:latex_group_location: lost initial open brace\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME),
                                  $V_ERROR);
                    return (-1);
                  }
		#
                $i = $a;
                while ($i <= $z)
                  {
                    $c = substr ($string, $i, 1);
                    if ($c eq "{")
                      {
			#
                        # New level.
			#
                        $sublevels++;
                      }
                    elsif ($c eq "}")
                      {
			#
                        # Close one level.
			#
                        $sublevels--;
                        if ($sublevels == 0)
                          {
    			    #
                            # Stop.
    			    #
                            last;
                          }
                      }
                    $i++;
                  }
		#
                if ($i <= $z)
                  {
                    return ($i);
                  }
                else
                  {
		    #
                    # Cannot find the group close brace.
		    #
                    &diag_output (sprintf (gettext ("%s:%s:DEBUG:latex_group_location: lost closing brace\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME),
                                  $V_ERROR);
                    return (-1);
                  }
            }
	    #
            while ($arguments > 0)
              {
                $string =~ m/^[[:blank:]\n]*(.*)$/s;
                $string = $1;
                $i = &latex_group_location (0, length ($string), $string);
                if ($i >= 0)
                  {
                    $arg = substr ($string, 1, $i-1);
                    $string = substr ($string, $i+1);
                  }
                else 
                  {
                    $arg = "";
                  }
                $args[$#args+1] = $arg;
                $arguments--;
              }
            return (@args, $string);
	    #
        } #latex_command_arguments_deletion
        #
        # LaTeX filter commands for page headers
        #
        sub latex_header_clean
        {
            my ($string)         = $_[0];
            my ($string_orig)    = "";
            my ($pre)            = "";
            my ($post)           = "";
            my ($a)              = "";
            my ($b)              = "";
            my ($c)              = "";
            my ($d)              = "";
	    #
            while ($string ne $string_orig)
              {
                $string_orig = $string;
		#
                if ($string =~ m/^(.*)\\almlss[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlyy[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\hypertarget(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $c;
                  }
                elsif ($string =~ m/^(.*)\\footnote(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlaafootnotemark(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\nolinebreak(.*)$/s)
                  {
                    $string = $1 . $2;
                  }
                elsif ($string =~ m/^(.*)\\almlazlabel(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlazvisiblelabel(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlbzpdfbookmark(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $c;
                  }
                elsif ($string =~ m/^(.*)\\almlbzindexentrydraft(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $c;
                  }
                elsif ($string =~ m/^(.*)\\almlbaspecialname(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . "{" . $a . "}" . $c;
                  }
                elsif ($string =~ m/^(.*)\\mbox(\{.*)$/s)
                  {
                    $string = $1 . $2;
                  }
                elsif ($string =~ m/^(.*)\\hspace(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
              }
            return ($string);
        }
        #
        # HTML filter commands for things like headers.
        #
        sub html_header_clean
        {
            my ($string)         = $_[0];
            my ($string_orig)    = "";
            my ($pre)            = "";
            my ($post)           = "";
            my ($a)              = "";
            my ($b)              = "";
            my ($c)              = "";
            my ($d)              = "";
	    #
            while ($string ne $string_orig)
              {
                $string_orig = $string;
		#
		# Remove footnotes.
		#
                if ($string =~ m/^(.*)<!--ALML FOOTNOTE-->.*?<!\/--ALML FOOTNOTE-->(.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    $string = $pre . $post;
                  }
		#
		# Remove "A" elements.
		#
                while ($string =~ m/^(.*)<a[> ].*?<\/a>(.*)$/is)
                  {
                    $pre  = $1;
                    $post = $2;
                    $string = $pre . $post;
                  }
		#
		# Remove extra spaces before and after.
		#
                if ($string =~ m/^ *(.*?) *$/is)
                  {
                    $string = $1;
                  }
              }
            return ($string);
        }
	#
        # LaTeX filter most commands.
        #
        sub latex_filter_most_commands
        {
            my ($string)         = $_[0];
            my ($string_orig)    = "";
            my ($pre)            = "";
            my ($post)           = "";
            my ($a)              = "";
            my ($b)              = "";
            my ($c)              = "";
            my ($d)              = "";
	    #
            while ($string ne $string_orig)
              {
                $string_orig = $string;
		#
                if ($string =~ m/^(.*)\\almlxxsynellipsis *([^a-zA-Z].*)$/s)
                  {
                    $string = $1 . "..." . $2;
                  }
                elsif ($string =~ m/^(.*)\\almlxxsynstar *([^a-zA-Z].*)$/s)
                  {
                    $string = $1 . "*" . $2;
                  }
                elsif ($string =~ m/^(.*)\\almlxxsymbolminus *([^a-zA-Z].*)$/s)
                  {
                    $string = $1 . "-" . $2;
                  }
        #!!!!   elsif ($string =~ m/^(.*)\\almlxxsymbolplus *([^a-zA-Z].*)$/s)
        #!!!!     {
        #!!!!       $string = $1 . "+" . $2;
        #!!!!     }
        #!!!!   elsif ($string =~ m/^(.*)\\almlxxsymbolequals *([^a-zA-Z].*)$/s)
        #!!!!     {
        #!!!!       $string = $1 . "=" . $2;
        #!!!!     }
        #!!!!   elsif ($string =~ m/^(.*)\\almlxxsymbolnum *([^a-zA-Z].*)$/s)
        #!!!!     {
        #!!!!       $string = $1 . "\\\#" . $2;
        #!!!!     }
        #!!!!   elsif ($string =~ m/^(.*)\\almlxxsymbolamp *([^a-zA-Z].*)$/s)
        #!!!!     {
        #!!!!       $string = $1 . "\\\&" . $2;
        #!!!!     }
        #!!!!   elsif ($string =~ m/^(.*)\\almlxxsymbolcommat *([^a-zA-Z].*)$/s)
        #!!!!     {
        #!!!!       $string = $1 . "\@" . $2;
        #!!!!     }
                elsif ($string =~ m/^(.*)\\almlxxsymboleuro *([^a-zA-Z].*)$/s)
                  {
                    $string = $1 . "EUR" . $2;
                  }
                elsif ($string =~ m/^(.*)\\almlss[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlyy[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlzz[a-z]*(\{.*)$/s)
                  {
                    $string = $1 . $2;
                  }
                elsif ($string =~ m/^(.*)\\almlaz[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlaakbd(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . "[" . $a . "]" . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlaakp(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . "num(" . $a . ")" . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlaavkbd(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . "{<}" . $a . "{>}" . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlaasup(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . "sup(" . $a . ")" . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlaasub(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . "sub(" . $a . ")" . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlaapwr(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . "pwr(" . $a . ")" . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlaa[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $a . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlbz[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $c;
                  }
                elsif ($string =~ m/^(.*)\\almlba[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $a . $c;
                  }
                elsif ($string =~ m/^(.*)\\almlbbman(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $a . "(" . $b . ")" . $c;
                  }
                elsif ($string =~ m/^(.*)\\almlbbnumberwithbase(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $a . "base(" . $b . ")" . $c;
                  }
                elsif ($string =~ m/^(.*)\\almlbb[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $a . $b . $c;
                  }
                elsif ($string =~ m/^(.*)\\almlcz[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c, $d) = &latex_command_arguments_deletion (3, $post);
                    $string = $pre . $d;
                  }
                elsif ($string =~ m/^(.*)\\almlca[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c, $d) = &latex_command_arguments_deletion (3, $post);
                    $string = $pre . $a . $d;
                  }
                elsif ($string =~ m/^(.*)\\almlcb[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c, $d) = &latex_command_arguments_deletion (3, $post);
                    $string = $pre . $a . $b . $d;
                  }
                elsif ($string =~ m/^(.*)\\almlcc[a-z]*(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c, $d) = &latex_command_arguments_deletion (3, $post);
                    $string = $pre . $a . $b . $c . $d;
                  }
                elsif ($string =~ m/^(.*)\\mbox(\{.*)$/s)
                  {
                    $string = $1 . $2;
                  }
                elsif ($string =~ m/^(.*)\\hspace(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\hypertarget(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $c;
                  }
                elsif ($string =~ m/^(.*)\\hyperlink(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $c;
                  }
                elsif ($string =~ m/^(.*)\\href(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b, $c) = &latex_command_arguments_deletion (2, $post);
                    $string = $pre . $b . $c;
                  }
                elsif ($string =~ m/^(.*)\\footnote(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\almlaafootnotemark(\{.*)$/s)
                  {
                    $pre  = $1;
                    $post = $2;
                    ($a, $b) = &latex_command_arguments_deletion (1, $post);
                    $string = $pre . $b;
                  }
                elsif ($string =~ m/^(.*)\\nolinebreak(.*)$/s)
                  {
                    $string = $1 . $2;
                  }
              }
            #
            return ($string);
        }
        #
        # LaTeX filter commands for PDF bookmarks
        #
        sub latex_filter_commands_for_pdf_bookmarks
        {
            my ($string)         = $_[0];
            my ($string_orig)    = "";
            my ($pre)            = "";
            my ($post)           = "";
            my ($a)              = "";
            my ($b)              = "";
            my ($c)              = "";
            my ($d)              = "";
	    #
            sub latex_filter_unicode_for_pdf_bookmarks
            {
                my ($line) = $_[0];
                my ($line_new) = "";
                my ($offset) = 0;
                my ($max) = 0;
                my ($char) = "";
                my ($unknown) = "*";

                $max = length ($line);
                while (1)
                  {
                    if ($offset >= $max)
                      {
                        last;
                      }
                    else
                      {
                        $char = substr ($line, $offset, 1);

                        if  ($char ge "\x{00FF}")
                          {
                            $line_new = $line_new . $unknown;
                          }
                        else
                          {
                            $line_new = $line_new . $char;
                          }
                      }
                    $offset++;
                  }
                $line_new = $line_new . "\n";
                return ($line_new);
            }
            #
            $string = &latex_filter_most_commands ($string);
            #
            while ($string ne $string_orig)
              {
                $string_orig = $string;

                if ($string =~ m/^(.*)\\guillemotleft([^a-zA-Z].*)$/s)
                  {
                    $string = $1 . "''" . $2;
                  }
                elsif ($string =~ m/^(.*)\\guillemotright([^a-zA-Z].*)$/s)
                  {
                    $string = $1 . "''" . $2;
                  }
                elsif ($string =~ m/^(.*)\x{00AB}(.*)$/s)
                  {
                    $string = $1 . "''" . $2;
                  }
                elsif ($string =~ m/^(.*)\x{00BB}(.*)$/s)
                  {
                    $string = $1 . "''" . $2;
                  }
                elsif ($string =~ m/^(.*)\\almlxxsymbolcommat([^a-zA-Z].*)$/s)
                  {
                    $string = $1 . "\@" . $2;
                  }
                elsif ($string =~ m/^(.*)\x{00B0}(.*)$/s)
                  {
                    $string = $1 . "o" . $2;
                  }
                elsif ($string =~ m/^(.*)\x{0022}(.*)$/s)
                  {
                    $string = $1 . "''" . $2;
                  }
                elsif ($string =~ m/^(.*)\\emaildot([^a-zA-Z].*)$/s)
                  {
                    $string = $1 . "~" . $2;
                  }
                elsif ($string =~ m/^(.*)\\emailcommat([^a-zA-Z].*)$/s)
                  {
                    $string = $1 . "(ad)" . $2;
                  }
              }
	    #
            $string = &latex_filter_unicode_for_pdf_bookmarks ($string);
            # 
            return ($string);
        }
	#
        # Filter a valid file name.
        #
        sub human_readable_file_name_from_pdf_bookmark_header
        {
            my ($file_name)         = $_[0];
	    #
            # Replace spaces with underscore.
            #
            $file_name =~ s/\s/\_/gs;
	    #
            # Replace some common accented letters to unaccented ones.
            #
            $file_name =~ s/\x{00C0}/a/gs;
            $file_name =~ s/\x{00C1}/a/gs;
            $file_name =~ s/\x{00C2}/a/gs;
            $file_name =~ s/\x{00C3}/a/gs;
            $file_name =~ s/\x{00C4}/a/gs;
            $file_name =~ s/\x{00C5}/a/gs;
            $file_name =~ s/\x{00C6}/ae/gs;
            $file_name =~ s/\x{00C7}/c/gs;
            $file_name =~ s/\x{00C8}/e/gs;
            $file_name =~ s/\x{00C9}/e/gs;
            $file_name =~ s/\x{00CA}/e/gs;
            $file_name =~ s/\x{00CB}/e/gs;
            $file_name =~ s/\x{00CC}/i/gs;
            $file_name =~ s/\x{00CD}/i/gs;
            $file_name =~ s/\x{00CE}/i/gs;
            $file_name =~ s/\x{00CF}/i/gs;
            $file_name =~ s/\x{00D0}/d/gs;
            $file_name =~ s/\x{00D1}/n/gs;
            $file_name =~ s/\x{00D2}/o/gs;
            $file_name =~ s/\x{00D3}/o/gs;
            $file_name =~ s/\x{00D4}/o/gs;
            $file_name =~ s/\x{00D5}/o/gs;
            $file_name =~ s/\x{00D6}/o/gs;
            $file_name =~ s/\x{00D7}/x/gs;
            $file_name =~ s/\x{00D8}/o/gs;
            $file_name =~ s/\x{00D9}/u/gs;
            $file_name =~ s/\x{00DA}/u/gs;
            $file_name =~ s/\x{00DB}/u/gs;
            $file_name =~ s/\x{00DC}/u/gs;
            $file_name =~ s/\x{00DD}/y/gs;
	    #
            $file_name =~ s/\x{00DF}/ss/gs;
            $file_name =~ s/\x{00E0}/a/gs;
            $file_name =~ s/\x{00E1}/a/gs;
            $file_name =~ s/\x{00E2}/a/gs;
            $file_name =~ s/\x{00E3}/a/gs;
            $file_name =~ s/\x{00E4}/a/gs;
            $file_name =~ s/\x{00E5}/a/gs;
            $file_name =~ s/\x{00E6}/ae/gs;
            $file_name =~ s/\x{00E7}/c/gs;
            $file_name =~ s/\x{00E8}/e/gs;
            $file_name =~ s/\x{00E9}/e/gs;
            $file_name =~ s/\x{00EA}/e/gs;
            $file_name =~ s/\x{00EB}/e/gs;
            $file_name =~ s/\x{00EC}/i/gs;
            $file_name =~ s/\x{00ED}/i/gs;
            $file_name =~ s/\x{00EE}/i/gs;
            $file_name =~ s/\x{00EF}/i/gs;
            $file_name =~ s/\x{00F0}/d/gs;
            $file_name =~ s/\x{00F1}/n/gs;
            $file_name =~ s/\x{00F2}/o/gs;
            $file_name =~ s/\x{00F3}/o/gs;
            $file_name =~ s/\x{00F4}/o/gs;
            $file_name =~ s/\x{00F5}/o/gs;
            $file_name =~ s/\x{00F6}/o/gs;
	    #
            $file_name =~ s/\x{00F8}/o/gs;
            $file_name =~ s/\x{00F9}/u/gs;
            $file_name =~ s/\x{00FA}/u/gs;
            $file_name =~ s/\x{00FB}/u/gs;
            $file_name =~ s/\x{00FC}/u/gs;
            $file_name =~ s/\x{00FD}/y/gs;
	    #
            $file_name =~ s/\x{00FF}/y/gs;
	    #
	    # Eliminate punctuation.
	    #
            $file_name =~ s/[\,\.\;\:\!\?]//gs;
	    #
	    # Replace non strict-alphanumeric characters with underscore.
	    #
            $file_name =~ s/[^a-zA-Z0-9-]/\_/gs;
	    #
	    # Eliminate multiple underscores.
	    #
            $file_name =~ s/\_+/\_/gs;
	    #
	    # Eliminate underscores at the beguinning and end
	    # of the name.
	    #
            $file_name =~ s/^[_]*//;
            $file_name =~ s/[_]*$//;
	    #
	    # To lower case.
	    #
            $file_name = lc ($file_name);
	    #
	    # Reuse the function &human_readable_file_name (), that
	    # was made originally for HTML.
	    #
	    # Something is redundant, but it is not a problem.
	    #
	    $file_name = &human_readable_file_name ("$file_name", "");
            #
            # Return what is remained.
            #
            return ($file_name);
        }
	#
        # PDF bookmarks.
        #
        sub latex_pdf_bookmark_safe_correction
        {
            my ($header)         = $_[0];
    	    #
            $header = &latex_filter_commands_for_pdf_bookmarks ($header);
            #
            # Non breaking space are normal spaces.
            #
            $header =~ s/\~/ /gs;
	    #
            # Unknown symbols replaced with a point.
            #
            $header =~ s/\\symbol\{[0-9]+\}/\./gs;
            $header =~ s/\\ding\{[0-9]+\}/\./gs;
            $header =~ s/\\ensuremath\{\\[a-zA-Z]+\}/\./gs;
            #
            # Delete unknown commands.
            # Please note that command should NOT finish with the
            # empty group anymore.
            #
            $header =~ s/\\[a-zA-Z]+ /\./gs;
	    #
            # Replace empty groups with a single space.
	    #
            $header =~ s/\{\}/ /gs;
	    #
            # Replace single curly brackets with nothing.
	    #
            $header =~ s/\{//gs;
            $header =~ s/\}//gs;
	    #
            # Eliminate multiple spaces.
            #
            $header =~ s/\s+/ /gs;
            #
            # Return what is remained.
            #
            return ($header);
        }
	#
        # PDF bookmarks levels
        #
        sub latex_pdf_bookmark_level
        {
            #
            # Level is a number from -1 to 4 (from tome to h4)
            #
            my ($level)         = $_[0];
	    #
            if ($level == -1)
              {
                #
                # It is a tome and must be 1 (first)
                #
                $level = 1;
              }
            elsif ($level == 0)
              {
                #
                # It is a part: it depends on the presence of tomes.
    		#
                if ($tome_present)
                  {
                    $level = 2;
                  }
                else
                  {
                    $level = 1;
                  }
              }
            else
              {
                #
                # It is a chapter or a deeper section.
                #
                if ($tome_present)
                  {
                    $level++;
                  }
                if ($part_present)
                  {
                    $level++;
                  }
		#
                if ($appendix_present)
                  {
                    ;
                  }
                elsif ($index_present)
                  {
                    ;
                  }
                elsif ($intro_present)
                  {
                    ;
                  }
              }
	    #
            return ($level);
        }
	#
        # Sections.
        #
        sub latex_chapter_intro
        {
            my ($title)          = $_[0];
            my ($header)         = &latex_header_clean ($title);
	    #
            &output ("% Chapter introduction");
            &output ("\n");
            &output ("% New page, left or right.");
            &output ("\n");
            &output ("\\almlzznewpage{}");
            &output ("\n");
            &output ("% First page should be plain.");
            &output ("\n");
            &output ("\\thispagestyle{plain}");
            &output ("\n");
            &output ("% Define the header also if unused.");
            &output ("\n");
            &output ("\\markboth{\\normalfont\\sffamily $header}{\\normalfont\\sffamily $header}\n");
            &output ("% Print chapter title.");
            &output ("\n");
            if ($PRINTED_FONT_SIZE_H1 eq "")
              {
                &output ("\\Huge");
              }
            else
              {
                &output ("\\fontsize{$PRINTED_FONT_SIZE_H1}{$PRINTED_FONT_HEIGHT_H1}\\selectfont");
              }
            &output ("\\sffamily $title\\par\n");
            &output ("\\vspace{5pt}\n");
            &output ("\\normalsize\n");
            &output ("\\normalfont\n");
            &output ("% Next pages remain plain.\n");
            &output ("\\almlzzstylepagenormal{}\n");
        }

        sub latex_chapter_index
        {
            my ($title)          = $_[0];
            my ($header)         = &latex_header_clean ($title);
	    #
            &output ("% Chapter index");
            &output ("% New page, left or right.\n");
            &output ("\\almlzznewpage{}\n");
            &output ("% First page should be plain.\n");
            &output ("\\thispagestyle{plain}\n");
            &output ("% Define the header also if unused.\n");
            &output ("\\markboth{\\normalfont\\sffamily $header}{\\normalfont\\sffamily $header}\n");

            &output ("% Print chapter title.\n");
            if ($PRINTED_FONT_SIZE_H1 eq "")
              {
                &output ("\\Huge");
              }
            else
              {
                &output ("\\fontsize{$PRINTED_FONT_SIZE_H1}{$PRINTED_FONT_HEIGHT_H1}\\selectfont");
              }
            &output ("\\sffamily $title\\par\n");
            &output ("\\vspace{5pt}\n");
            &output ("\\normalsize\n");
            &output ("\\normalfont\n");
            &output ("% Next pages remain plain.\n");
            &output ("\\almlzzstylepagenormal{}\n");
        }
	#
        sub latex_chapter_numbered
        {
            my ($title)          = $_[0];
            my ($page_numbering) = $_[1];
            my ($header)         = &latex_header_clean ($title);
            my ($tome_header)    = &latex_header_clean ($tome_heading_title);
	    #
            &output ("% Chapter numbered");
            &output ("% New page, left or right.\n");
            &output ("\\almlzznewpage{}\n");
            &output ("% Increment chapter counter.\n");
            &output ("\\stepcounter{chapter}\n");
            &output ("% Define the header also if unused.\n");
	    #
            if ($document_position eq "body"
                && $page_numbering eq "tome")
              {
                &output ("\\markboth{\\normalfont\\sffamily ");
                &output (&tome_def ());
                &output (" ");
                &output (uc (&integer_to_roman ($tome)));
                &output (" ~ $tome_header}{\\normalfont\\sffamily $header}");
                &output ("\n");
              }
            else
              {
                &output ("\\markboth{\\normalfont\\sffamily $header}{\\normalfont\\sffamily $header}\n");
              }
	    #
            &output ("% First page should be empty.\n");
            &output ("\\thispagestyle{empty}\n");
            &output ("% Move a little bit up.\n");
            &output ("\\vspace*{-16mm}\n");
            &output ("% Print the chapter number.\n");
            &output ("{{\\raisebox{3mm}{\\arabic{page}}}\\hfill");
            &output ("\\small\\rmfamily\\itshape\n");
            &output (ucfirst (&chapter_def ()));
            &output (" ~ \\normalfont\n");
            if ($PRINTED_FONT_SIZE_H1 eq "")
              {
                &output ("\\Huge");
              }
            else
              {
                &output ("\\fontsize{$PRINTED_FONT_SIZE_H1}{$PRINTED_FONT_HEIGHT_H1}\\selectfont");
              }
            &output ("\\sffamily\n");
            &output ("\\arabic{chapter}\n");
            &output ("\\par}\\nobreak\n");
            &output ("\\nobreak\\vspace{-3.5mm}\\nobreak\n");
            &output ("% Print chapter title.\n");
            if ($PRINTED_FONT_SIZE_H1 eq "")
              {
                &output ("\\Huge");
              }
            else
              {
                &output ("\\fontsize{$PRINTED_FONT_SIZE_H1}{$PRINTED_FONT_HEIGHT_H1}\\selectfont");
              }
            &output ("\\sffamily $title");
            &output ("\\par\\nobreak\n");
            &output ("\\vspace{5pt}\n");
            &output ("\\normalsize\n");
            &output ("\\normalfont\n");
            &output ("% Next pages are with headers.\n");
            &output ("\\almlzzstylepageheader{}\n");
        }

        sub latex_chapter_unnumbered
        {
            my ($title)          = $_[0];
            my ($page_numbering) = $_[1];
            my ($header)         = &latex_header_clean ($title);
            my ($tome_header)    = &latex_header_clean ($tome_heading_title);
	    #
            &output ("% Chapter unnumbered");
            &output ("% New page, left or right.\n");
            &output ("\\almlzznewpage{}\n");
            &output ("% Define the header also if unused.\n");

            if ($document_position eq "body"
                && $page_numbering eq "tome")
              {
                &output ("\\markboth{\\normalfont\\sffamily ");
                &output (&tome_def ());
                &output (" ");
                &output (uc (&integer_to_roman ($tome)));
                &output (" ~ $tome_header}{\\normalfont\\sffamily $header}");
                &output ("\n");
              }
            else
              {
                &output ("\\markboth{\\normalfont\\sffamily $header}{\\normalfont\\sffamily $header}\n");
              }

            &output ("% First page should be plain.\n");
            &output ("\\thispagestyle{plain}\n");
            &output ("% Print chapter title.\n");
            if ($PRINTED_FONT_SIZE_H1 eq "")
              {
                &output ("\\Huge");
              }
            else
              {
                &output ("\\fontsize{$PRINTED_FONT_SIZE_H1}{$PRINTED_FONT_HEIGHT_H1}\\selectfont");
              }
            &output ("\\sffamily $title");
            &output ("\\par\\nobreak\n");
            &output ("\\vspace{5pt}\n");
            &output ("\\normalsize\n");
            &output ("\\normalfont\n");
            &output ("% Next pages remain plain.\n");
            &output ("\\almlzzstylepagenormal{}\n");
        }
	#
        sub latex_chapter_presentation_slide
        {
            my ($title)          = $_[0];
            my ($header)         = &latex_header_clean ($title);
	    #
            &output ("% Chapter presentation slide");
            &output ("% New page, left or right.\n");
            &output ("% Cannot use half new page because the {\\samepage...}\n");
            &output ("% does not work well for big blocks.\n");
            &output ("\\almlzznewpage{}\n");
            &output ("% Increment chapter counter.\n");
            &output ("\\stepcounter{chapter}\n");
            &output ("% Pages should be empty.\n");
            &output ("\\thispagestyle{empty}");
            &output ("\n");
            &output ("% Move a little bit up.\n");
            &output ("\\vspace*{-16mm}\n");
            &output ("% Print the chapter number.\n");
            &output ("{{\\raisebox{3mm}{\\arabic{page}}}\\hfill");
            &output (" ~ \\normalfont\n");
            &output ("\\Large\\sffamily\n");
            &output ("\\arabic{chapter}\n");
            &output (" ~ \\small\\rmfamily\\itshape\n");
            &output (lc (&presentation_slide_def ()));
            &output ("\\normalfont\n");
            &output ("\\nobreak\n");
            &output ("\\par}\\nobreak\n");
            &output ("\\nobreak\\vspace{-10pt}\\nobreak\n");
            &output ("% Print chapter title.\n");
            if ($PRINTED_FONT_SIZE_H1 eq "")
              {
                &output ("\\Huge");
              }
            else
              {
                &output ("\\fontsize{$PRINTED_FONT_SIZE_H1}{$PRINTED_FONT_HEIGHT_H1}\\selectfont");
              }
            &output ("\\sffamily $title");
            &output ("\\par\\nobreak\n");
            &output ("\\vspace{5pt}\n");
            &output ("\\normalsize\n");
            &output ("\\normalfont\n");
        }

        sub latex_chapter_summary_sheet
        {
            my ($title)          = $_[0];
            my ($header)         = &latex_header_clean ($title);
	    #
            &output ("% Chapter summary sheet");
            &output ("% New page, left or right.\n");
            &output ("% Cannot use half new page because the {\\samepage...}\n");
            &output ("% does not work well for big blocks.\n");
            &output ("\\almlzznewpage{}\n");
            &output ("% Increment chapter counter.\n");
            &output ("\\stepcounter{chapter}\n");
            &output ("% Pages should be empty.\n");
            &output ("\\thispagestyle{empty}");
            &output ("\n");
            &output ("% Move a little bit up.\n");
            &output ("\\vspace*{-16mm}\n");
            &output ("% Print the chapter number.\n");
            &output ("{{\\raisebox{3mm}{\\arabic{page}}}\\hfill");
            &output (" ~ \\normalfont\n");
            &output ("\\Large\\sffamily\n");
            &output ("\\arabic{chapter}\n");
            &output (" ~ \\small\\rmfamily\\itshape\n");
            &output (lc (&summary_sheet_def ()));
            &output ("\\normalfont\n");
            &output ("\\nobreak\n");
            &output ("\\par}\\nobreak\n");
            &output ("\\nobreak\\vspace{-10pt}\\nobreak\n");
            &output ("% Print chapter title.\n");
            if ($PRINTED_FONT_SIZE_H1 eq "")
              {
                &output ("\\Huge");
              }
            else
              {
                &output ("\\fontsize{$PRINTED_FONT_SIZE_H1}{$PRINTED_FONT_HEIGHT_H1}\\selectfont");
              }
            &output ("\\sffamily $title");
            &output ("\\par\\nobreak\n");
            &output ("\\vspace{5pt}\n");
            &output ("\\normalsize\n");
            &output ("\\normalfont\n");
        }

        sub latex_chapter_appendix
        {
            my ($title)          = $_[0];
            my ($page_numbering) = $_[1];
            my ($header)         = &latex_header_clean ($title);
	    #
            &output ("% Chapter appendix");
            &output ("% New page, left or right.\n");
            &output ("\\almlzznewpage{}\n");
            &output ("% Increment chapter counter.\n");
            &output ("\\stepcounter{chapter}\n");
            &output ("% Define the header also if unused.\n");

            if ($page_numbering eq "tome")
              {
                &output ("\\markboth{\\normalfont\\sffamily ");
                &output (&appendix_def ());
                &output ("}{\\normalfont\\sffamily $header}");
                &output ("\n");
              }
            else
              {
                &output ("\\markboth{\\normalfont\\sffamily $header}{\\normalfont\\sffamily $header}\n");
              }

            &output ("\\markboth{\\normalfont\\sffamily $header}{\\normalfont\\sffamily $header}\n");

            &output ("% First page should be empty.\n");
            &output ("\\thispagestyle{empty}\n");
            &output ("% Move a little bit up.\n");
            &output ("\\vspace*{-16mm}\n");
            &output ("% Print the chapter number.\n");
            &output ("{{\\raisebox{3mm}{\\arabic{page}}}\\hfill");
            &output ("\\small\\rmfamily\\itshape\n");
            &output (ucfirst (&appendix_def ()));
            &output (" ~ \\normalfont\n");
            if ($PRINTED_FONT_SIZE_H1 eq "")
              {
                &output ("\\Huge");
              }
            else
              {
                &output ("\\fontsize{$PRINTED_FONT_SIZE_H1}{$PRINTED_FONT_HEIGHT_H1}\\selectfont");
              }
            &output ("\\sffamily\n");
            &output ("\\Alph{chapter}\n");
            &output ("\\nobreak\n");
            &output ("\\par}\\nobreak\n");
            &output ("\\nobreak\\vspace{-10pt}\\nobreak\n");
            &output ("% Print chapter title.\n");
            if ($PRINTED_FONT_SIZE_H1 eq "")
              {
                &output ("\\Huge");
              }
            else
              {
                &output ("\\fontsize{$PRINTED_FONT_SIZE_H1}{$PRINTED_FONT_HEIGHT_H1}\\selectfont");
              }
            &output ("\\sffamily $title");
            &output ("\\par\\nobreak\n");
            &output ("\\vspace{5pt}\n");
            &output ("\\normalsize\n");
            &output ("\\normalfont\n");
            &output ("% Next pages remain plain.\n");
            &output ("\\almlzzstylepageheader{}\n");
        }
        #
        # Table of contents.
        #
        # latex_table_of_contents (TOC_LEVEL,
        #                          SECTION,
        #                          CONTENTS_LEVELS,
        #                          CONTENTS_NOPAGES,
        #                          TOC_PAGE_NUMBERING)
        #
        #
        sub latex_table_of_contents
        {
            my ($toc_level)                  = $_[0];
            my ($section)                    = $_[1];
            my ($deep)                       = $_[2];
            my ($nopages)                    = $_[3];
            my ($numbering)                  = $_[4];
	    #
            my ($n)                          = 0;
            my ($previous_html_page_number)  = 0;
	    #
            &diag_output (sprintf (gettext
                                   ("%s:%s: TOC: level %s, section %s, deep %s, nopages %s, numbering %s.\n"),
                                   $PROGRAM_EXECUTABLE,
                                   $SOURCE_FILE_NAME,
                                   $toc_level,
                                   $section,
                                   $deep,
                                   $nopages,
                                   $numbering), $V_SUPER);
            #
            # Table of contents.
            #
            # $contents_list[x][0]        level                 -1..4
            # $contents_list[x][1]        tome number
            # $contents_list[x][2]        part number
            # $contents_list[x][3]        chapter number                
            # $contents_list[x][4]        level-description     1.2.3
            # $contents_list[x][5]        title
            # $contents_list[x][6]        html page number
            # $contents_list[x][7]        h1 section absolute counter
            # $contents_list[x][8]        document position: head,
            #                               intro, body, appendix,
            #                               index
            #
            #
            # Last contents level is level 1 for chapter, parts and
            # tome, as well. For sections (H2), it is level 2; for
            # subsections (H3), it is level 3, and so on.
            #
    	    #
            # Jump, if necessary, to the beguinning of a particular
            # section.
	    #
            if ($toc_level < -1)
              {
        	#
                # This is a main table of contents.
                # Reset last contents level
        	#
                $last_contents_level = 0;
              }
            elsif ($toc_level == -1)
              {
        	#
                # Tome contents. Find the right one.
        	#
                for ($n = 0 ;
                     $n <= $#contents_list && $contents_list[$n][1] < $section ;
                     $n++)
                  { 
		    #
                    # Do nothing; just jump it.
		    #
                    ;
                  }
    	        #
                # Now $n is on the first tome entry, or after the end of
                # the array.
    	        #
                if($n > $#contents_list)
                  {
    	    	    #
                    # The array is finished, and there is no tome.
    	    	    #
                    ;
                  }
                elsif ($contents_list[$n][1] == $section)
                  {
    	    	    #
                    # OK, just jump this entry, that is obvious.
    	    	    #
                    $n++;
                  }
    		#
                # Reset last contents level
    		#
                $last_contents_level = 0;
              }
            elsif ($toc_level == 0)
              {
    		#
                # Part contents. Find the right one.
    		#
                for ($n = 0 ;
                     $n <= $#contents_list && $contents_list[$n][2] < $section ;
                     $n++)
                  { 
    		    #
                    # Do nothing; just jump it.
    		    #
                    ;
                  }
                #
                # Now $n is on the first part entry, or after the end of
                # the array.
                #
                if($n > $#contents_list)
                  {
            	    #
                    # The array is finished, and there is no part.
            	    #
                    ;
                  }
                elsif ($contents_list[$n][2] == $section)
                  {
            	    #
                    # OK, just jump this entry, that is obvious.
            	    #
                    $n++;
                  }
		#
                # Reset last contents level
		#
                $last_contents_level = 0;
              }
            elsif ($toc_level == 1)
              {
		#
                # Chapter contents. Find the right one.
		#
                for ($n = 0 ;
                     $n <= $#contents_list && $contents_list[$n][7] < $section ;
                     $n++)
                  { 
		    #
                    # Do nothing; just jump it.
		    #
                    ;
                  }
		#
                # Now $n is on the first chapter entry, or after the end of
                # the array.
		#
                if($n > $#contents_list)
                  {
		    #
                    # The array is finished, and there is no part.
		    #
                    ;
                  }
                elsif ($contents_list[$n][7] == $section)
                  {
		    #
                    # OK, just jump this entry, that is obvious.
		    #
                    $n++;
                  }
		#
                # Reset last contents level
		#
                $last_contents_level = 1;
              }
	    #
            # Scan the contents list array.
	    #
            for ($n = $n ;
                 $n <= $#contents_list ;
                 $n++)
              { 
		#
                # Save html page number. It is used to know when
                # a chapter is finished.
		#
                $previous_html_page_number = $contents_list[$n][6];
		#
                # Check if inside the section requested
		#
                if ($toc_level < -1)
                  {
		    #
                    # This is a main table of contents; all the
                    # array is scanned.
		    #
                    ;
                  }
                elsif ($toc_level == -1)
                  {
		    #
                    # This is a tome contents.
		    #
                    if ($contents_list[$n][1] > $section)
                      {
			#
                        # The tome is finished.
			#
                        last;
                      }
                  }
                elsif ($toc_level == 0)
                  {
                    #
                    # This is a part contents.
                    #
                    if ($contents_list[$n][0] == -1)
                      {
                	#
                        # This is a tome item; jump it.
                	#
                        next;
                      }
                    if ($contents_list[$n][2] > $section)
                      {
                	#
                        # The part is finished.
                	#
                        last;
                      }
                  }
                elsif ($toc_level == 1)
                  {
        	    #
                    # This is a chapter contents.
        	    #
                    if ($contents_list[$n][0] < 1)
                      {
        		#
                        # This is a part or tome item; jump it.
        		#
                        next;
                      }
                    if ($contents_list[$n][7] > $section)
                      {
        		#
                        # The chapter is finished.
        		#
                        last;
                      }
                  }
    		#
                # If we are here, the item is right, and is to be
                # included inside the table of contents.
    		#
                if ($contents_list[$n][0] == -1)
                  {
                    #
                    # Tome
                    #
                    #
                    # Open listing sublevels if necessary.
                    #
                    while ($last_contents_level < 1)
                      {
                    	#
                        # We have to add an indent level.
                    	#
                        &output ("\n");
                        &output ("\\begin{list}{}{}");
                        $last_contents_level++;
                      }

                    
                    # Close listing levels if necessary.
                    

                    while ($last_contents_level > 1)
                      {

                        
                        # We have to close an indent level.
                        

                        &output ("\n");
                        &output ("\\end{list}");
                        $last_contents_level--;
                      }

                    
                    # Put the list item for this tome.
                    

                    &output ("\n");
                    &output ("\\item\\hspace{-0,25in}");


                    
                    # Start the hyperlink.
                    

                    &output ("\\hyperlink{almltitle$n}");
                    &output ("{");


                    
                    # Insert the tome informations.
                    

                    &output ("\\begin{Large}");
                    &output (ucfirst (&tome_def ()));
                    &output (" ");
                    &output ($contents_list[$n][4]);
                    &output (" ~ ");
                    &output ($contents_list[$n][5]);
                    &output ("\\end{Large}");

                    
                    # Put the page number anyway, also if it is reset
                    # to 1.
                    

                    if (!$nopages)
                      {

                        
                        # Output page number only when required.
                        

                        &output ("\\dotfill{}");
                        if ($numbering eq "tome"
                            && $toc_level < -1)
                          {

                            
                            # Add the tome prefix.
                            

                            &output ($contents_list[$n][1]);
                            &output ("-");
                          }
                        &output ("\\almlczpageref{0}{000}{almltitle$n}");
                      }


                    
                    # Close the hyperlink to the start of tome.
                    

                    &output ("}");
                    &output ("\n");


                    
                    # Set last contents level.
                    

                    $last_contents_level = 1;

                  }
                elsif ($contents_list[$n][0] == 0)
                  {

                    ####################################################
                    # Part
                    ####################################################

                    
                    # Open listing sublevels if necessary.
                    

                    while ($last_contents_level < 1)
                      {

                        
                        # We have to add an indent level.
                        

                        &output ("\n");
                        &output ("\\begin{list}{}{}");
                        $last_contents_level++;
                      }

                    
                    # Close listing levels if necessary.
                    

                    while ($last_contents_level > 1)
                      {

                        
                        # We have to close an indent level.
                        

                        &output ("\n");
                        &output ("\\end{list}");
                        $last_contents_level--;
                      }

                    
                    # Put the list item for this part.
                    

                    &output ("\n\\item\\hspace{-0,25in}");


                    
                    # Start the hyperlink.
                    

                    &output ("\\hyperlink{almltitle$n}");
                    &output ("{");


                    
                    # Insert part informations.
                    

                    &output ("\\begin{large}");
                    &output (ucfirst (&part_def ()));
                    &output (" ");
                    &output ($contents_list[$n][4]);
                    &output (" ~ ");
                    &output ($contents_list[$n][5]);
                    &output ("\\end{large}");
                    if (!$nopages)
                      {

                        
                        # Output page number only when required.
                        # It the page numbering is reset at each
                        # tome, the page should be shown with tome
                        # prefix, unless otherwise specified.
                        

                        &output ("\\dotfill{}");
                        if ($numbering eq "tome"
                            && $toc_level < -1)
                          {

                            
                            # Add the tome prefix.
                            

                            &output ($contents_list[$n][1]);
                            &output ("-");
                          }
                        &output ("\\almlczpageref{0}{000}{almltitle$n}");
                      }


                    
                    # Close the hyperlink to the start of part.
                    

                    &output ("}");
                    &output ("\n");


                    
                    # Set last contents level.
                    

                    $last_contents_level = 1;
                  }
                elsif ($contents_list[$n][0] == 1
                       && ($deep >= 1
                           || $contents_list[$n][4] =~ m/^[ixu][0-9]/
                           || $contents_list[$n][4] =~ m/^[A-Z]/))
                  {

                    ####################################################
                    # Any kind of chapter.
                    ####################################################

                    
                    # Open listing sublevels if necessary.
                    

                    while ($last_contents_level < 1)
                      {

                        
                        # We have to add an indent level.
                        

                        &output ("\n");
                        &output ("\\begin{list}{}{}");
                        $last_contents_level++;
                      }

                    
                    # Close listing levels if necessary.
                    

                    while ($last_contents_level > 1)
                      {

                        
                        # We have to close an indent level.
                        

                        &output ("\n");
                        &output ("\\end{list}");
                        $last_contents_level--;
                      }


                    
                    # Put the list item for this chapter.
                    

                    &output ("\n\\item\\hspace{-0,25in}");


                    
                    # Start the hyperlink.
                    

                    &output ("\\hyperlink{almltitle$n}");
                    &output ("{");


                    
                    # Put the number of chapter if required.
                    

                    if ($contents_list[$n][8] eq "intro"
                        || $contents_list[$n][8] eq "index"
                        || $contents_list[$n][4] =~ m/^[u][0-9]/)
                      {

                        
                        # This is an introduction, an index or
                        # an unnumbered chapter:
                        # don't add the number at the beguinning.
                        

                        ;
                      }
                    elsif ($contents_list[$n][8] eq "appendix")
                      {

                        
                        # This is an appendix.
                        

                        &output (ucfirst (&appendix_def ()));
                        &output (" ");
                        &output ($contents_list[$n][4]);
                        &output (" ~ ");
                      }
                    else
                      {

                        
                        # This is a standard chapter inside a body.
                        

                        &output ($contents_list[$n][4]);
                        &output (" ~ ");
                      }


                    
                    # Put the title.
                    

                    &output ($contents_list[$n][5]);


                    
                    # Now it is the turn of showing pages.
                    

                    if (!$nopages)
                      {

                        
                        # Output page number only as requested.
                        

                        &output ("\\dotfill{}");


                        
                        # Might need tome number prefix.
                        

                        if ($numbering eq "tome"
                            && $toc_level < -1)
                          {
                            if ($contents_list[$n][8] eq "intro"
                                || $contents_list[$n][8] eq "index")
                              {                                 

                                
                                # This is an introduction or an index
                                # that has no tome prefix.
                                

                                ;
                              }
                            elsif ($contents_list[$n][8] eq "appendix")
                              {

                                
                                # This is an appendix, with a special
                                # prefix.
                                

                                &output ("A-");
                              }
                            else
                              {

                                
                                # This is a chapter inside a body,
                                # and the tome prefix is needed.
                                

                                &output ($contents_list[$n][1]);
                                &output ("-");
                              }
                          }
                        &output ("\\almlczpageref{0}{000}{almltitle$n}");
                      }


                    
                    # Close the hyperlink to the start of part.
                    

                    &output ("}");
                    &output ("\n");


                    
                    # Set last contents level.
                    

                    $last_contents_level = 1;
                  }
                elsif ($contents_list[$n][0] == 2
                       && $deep >= 2)
                  {

                    ####################################################
                    # Section.
                    ####################################################


                    
                    # Open listing sublevels if necessary.
                    

                    while ($last_contents_level < 2)
                      {

                        
                        # We have to add an indent level.
                        

                        &output ("\n");
                        &output ("\\begin{list}{}{}");
                        $last_contents_level++;
                      }

                    
                    # Close listing levels if necessary.
                    

                    while ($last_contents_level > 2)
                      {

                        
                        # We have to close an indent level.
                        

                        &output ("\n");
                        &output ("\\end{list}");
                        $last_contents_level--;
                      }


                    
                    # Put the list item for this section.
                    

                    &output ("\n");
                    &output ("\\item\\hspace{-0,25in}");


                    
                    # Start the hyperlink.
                    

                    &output ("\\hyperlink{almltitle$n}");
                    &output ("{");


                    
                    # Put the number of section if required.
                    

                    if ($contents_list[$n][8] eq "intro"
                        || $contents_list[$n][8] eq "index"
                        || $contents_list[$n][4] =~ m/^[u][0-9]/)
                      {

                        
                        # This is an introduction, an index or
                        # an unnumbered chapter:
                        # don't add the number at the beguinning.
                        

                        ;
                      }
                    else
                      {

                        
                        # This is a standard chapter inside a body.
                        

                        &output ($contents_list[$n][4]);
                        &output (" ~ ");
                      }
                    
                    # Put the title.

                    &output ($contents_list[$n][5]);
                    
                    # Now it is the turn of showing pages.

                    if (!$nopages)
                      {

                        
                        # Output page number only if required.
                        

                        &output ("\\dotfill{}");


                        
                        # Might need tome number prefix.
                        

                        if ($numbering eq "tome"
                            && $toc_level < -1)
                          {
                            if ($contents_list[$n][8] eq "intro"
                                || $contents_list[$n][8] eq "index")
                              {                                 

                                
                                # This is an introduction or an index
                                # that has no tome prefix.
                                

                                ;
                              }
                            elsif ($contents_list[$n][8] eq "appendix")
                              {

                                
                                # This is an appendix, with a special
                                # prefix.
                                

                                &output ("A-");
                              }
                            else
                              {

                                
                                # This is a chapter inside a body,
                                # and the tome prefix is needed.
                                

                                &output ($contents_list[$n][1]);
                                &output ("-");
                              }
                          }
                        &output ("\\almlczpageref{0}{000}{almltitle$n}");
                      }


                    
                    # Close the hyperlink to the start of part.
                    

                    &output ("}");
                    &output ("\n");


                    
                    # Set last contents level.
                    

                    $last_contents_level = 2;
                  }
                elsif ($contents_list[$n][0] == 3
                       && $deep >= 3)
                  {

                    ####################################################
                    # Subsection.
                    ####################################################

                    
                    # Open listing sublevels if necessary.
                    

                    while ($last_contents_level < 3)
                      {

                        
                        # We have to add an indent level.
                        

                        &output ("\n");
                        &output ("\\begin{list}{}{}");
                        $last_contents_level++;
                      }

                    
                    # Close listing levels if necessary.
                    

                    while ($last_contents_level > 3)
                      {

                        
                        # We have to close an indent level.
                        

                        &output ("\n");
                        &output ("\\end{list}");
                        $last_contents_level--;
                      }

                    
                    # Put the list item for this chapter.
                    

                    &output ("\n");
                    &output ("\\item\\hspace{-0,25in}");


                    
                    # Start the hyperlink.
                    

                    &output ("\\hyperlink{almltitle$n}");
                    &output ("{");


                    
                    # Put the number of section if required.
                    

                    if ($contents_list[$n][8] eq "intro"
                        || $contents_list[$n][8] eq "index"
                        || $contents_list[$n][4] =~ m/^[u][0-9]/)
                      {

                        
                        # This is an introduction, an index or
                        # an unnumbered chapter:
                        # don't add the number at the beguinning.
                        

                        ;
                      }
                    else
                      {

                        
                        # This is a standard chapter inside a body.
                        

                        &output ($contents_list[$n][4]);
                        &output (" ~ ");
                      }
                    
                    # Put the title.

                    &output ($contents_list[$n][5]);
                    
                    # Now it is the turn of showing pages.

                    if (!$nopages)
                      {

                        
                        # Output page number only if required.
                        

                        &output ("\\dotfill{}");


                        
                        # Might need tome number prefix.
                        

                        if ($numbering eq "tome"
                            && $toc_level < -1)
                          {
                            if ($contents_list[$n][8] eq "intro"
                                || $contents_list[$n][8] eq "index")
                              {                                 

                                
                                # This is an introduction or an index
                                # that has no tome prefix.
                                

                                ;
                              }
                            elsif ($contents_list[$n][8] eq "appendix")
                              {

                                
                                # This is an appendix, with a special
                                # prefix.
                                

                                &output ("A-");
                              }
                            else
                              {

                                
                                # This is a chapter inside a body,
                                # and the tome prefix is needed.
                                

                                &output ($contents_list[$n][1]);
                                &output ("-");
                              }
                          }
                        &output ("\\almlczpageref{0}{000}{almltitle$n}");
                      }


                    
                    # Close the hyperlink to the start of part.
                    

                    &output ("}");
                    &output ("\n");


                    
                    # Set last contents level.
                    

                    $last_contents_level = 3;
                  }
                elsif ($contents_list[$n][0] == 4
                       && $deep >= 4)
                  {

                    ####################################################
                    # Sub-subsection.
                    ####################################################

                    
                    # Open listing sublevels if necessary.
                    

                    while ($last_contents_level < 4)
                      {

                        
                        # We have to add an indent level.
                        

                        &output ("\n");
                        &output ("\\begin{list}{}{}");
                        $last_contents_level++;
                      }

                    
                    # Close listing levels if necessary.
                    

                    while ($last_contents_level > 4)
                      {

                        
                        # We have to close an indent level.
                        

                        &output ("\n");
                        &output ("\\end{list}");
                        $last_contents_level--;
                      }

                    
                    # Put the list item for this chapter.
                    

                    &output ("\n");
                    &output ("\\item\\hspace{-0,25in}");



                    
                    # Start the hyperlink.
                    

                    &output ("\\hyperlink{almltitle$n}");
                    &output ("{");

                    
                    # Put the number of section if required.
                    

                    if ($contents_list[$n][8] eq "intro"
                        || $contents_list[$n][8] eq "index"
                        || $contents_list[$n][4] =~ m/^[u][0-9]/)
                      {

                        
                        # This is an introduction, an index or
                        # an unnumbered chapter:
                        # don't add the number at the beguinning.
                        

                        ;
                      }
                    else
                      {

                        
                        # This is a standard chapter inside a body.
                        

                        &output ($contents_list[$n][4]);
                        &output (" ~ ");
                      }
                    
                    # Put the title.

                    &output ($contents_list[$n][5]);
                    
                    # Now it is the turn of showing pages.

                    if (!$nopages)
                      {

                        
                        # Output page number only if required.
                        

                        &output ("\\dotfill{}");


                        
                        # Might need tome number prefix.
                        

                        if ($numbering eq "tome"
                            && $toc_level < -1)
                          {
                            if ($contents_list[$n][8] eq "intro"
                                || $contents_list[$n][8] eq "index")
                              {                                 

                                
                                # This is an introduction or an index
                                # that has no tome prefix.
                                

                                ;
                              }
                            elsif ($contents_list[$n][8] eq "appendix")
                              {

                                
                                # This is an appendix, with a special
                                # prefix.
                                

                                &output ("A-");
                              }
                            else
                              {

                                
                                # This is a chapter inside a body,
                                # and the tome prefix is needed.
                                

                                &output ($contents_list[$n][1]);
                                &output ("-");
                              }
                          }
                        &output ("\\almlczpageref{0}{000}{almltitle$n}");
                      }


                    
                    # Close the hyperlink to the start of part.
                    

                    &output ("}");
                    &output ("\n");


                    
                    # Set last contents level.
                    

                    $last_contents_level = 4;
                  }
              }

            
            # Close final levels.
            

            if ($toc_level < 1)
              {
                while ($last_contents_level > 0)
                 {

                    
                    # We have to close an indent level.
                    

                    &output ("\n");
                    &output ("\\end{list}");
                    $last_contents_level--;
                 }
              }
            else
              {
                while ($last_contents_level > 1)
                 {

                    
                    # We have to close an indent level.
                    

                    &output ("\n");
                    &output ("\\end{list}");
                    $last_contents_level--;
                 }
              }
        } # latex_table_of_contents ()


        ################################################################
        # Before the true analisys, we have to check if there
        # is a block of "{\samepage", made by a section header,
        # that must be closed with a "}".
        # Othere block like these might be after all the if/elsif block.
        ################################################################


        
        # Headers
        

        if ($type eq "start")
          {
            if ($header_to_be_closed)
              {
                # This element happens just after an header.
                if ($element eq "P"
                    || $element eq "SYNTAX"
                    || $element eq "COMMAND"
                    || $element eq "FRAME")
                  {
                    # That's ok.
                    $next_element_after_header_to_be_closed = $element;
                    # Reset.
                    $header_to_be_closed = 0;
                    $next_element_after_header_to_be_closed_nest_level = 0;
                  }
                else
                  {
                    # Don't do it.
                    &output ("}% samepage-end Sorry\n");
                    # Reset.
                    $next_element_after_header_to_be_closed = "";
                    $header_to_be_closed = 0;
                    $next_element_after_header_to_be_closed_nest_level = 0;
                  }
              }
            elsif ($next_element_after_header_to_be_closed eq $element)
              {
                # This means that the element that is to be closed
                # has now a new nest level
                # (should not happen if it is only P, SYNTAX or COMMAND).
                $next_element_after_header_to_be_closed_nest_level++;
              }
          }
        #
        # SHEETH1 and SLIDEH1 all in a page.
        #
        if (($type eq "start" && ($element eq "H1"
                                  || $element eq "SHEETH1"
                                  || $element eq "SLIDEH1"
                                  || $element eq "UNNUMBEREDH1")
	    )
            || ($type ne "start" && ($element eq "INTRO"
                                     || $element eq "BODY"
                                     || $element eq "APPENDIX"
                                     || $element eq "INDEX")
               )
           )
          {
            if ($slide_to_be_closed)
              {
                # Then close the slide.
                &output ("}% samepage-end for a SLIDEH1 or SHEETH1\n");
                # Reset.
                $slide_to_be_closed = 0;
              }
          }
        #
        # Element handlers.
        # Element names and attribute names are uppercase.
        #
        if ($element eq "ALML")
          {
            if ($type eq "start")
              {
                #
                # Reset counters, flags and arrays.
                #
                $intro = 0;
                $tome = 0;
                $part = 0;
                $tome_present = 0;
                $part_present = 0;
                $appendix_present = 0;
                $index_present = 0;
                $intro_present = 0;
                $chapter = 0;
                $unnumbered_chapter = 0;
                $h1section_absolute_counter = 0;
                $appendix = 0;
                $sect1 = 0;         
                $sect2 = 0;         
                $sect3 = 0;         
                $index = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
                $table = 0;
                $absolute_table = 0;
                $picture =  0;
                $absolute_figure = 0;
                $absolute_listing = 0;
                $absolute_example = 0;
                $unnumbered = 0;
                $current_level = "";
                $document_position = "";
                #
                $index_entry_counter = 0;
                $workinfo_counter = 0;
                #
                @latex_footnote_list = ();
                #
                # Save administrative information.
                #
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                $DOCUMENT_LANGUAGE = $CURRENT_LANGUAGE;
                $TOME_LANGUAGE = $CURRENT_LANGUAGE;
                $PART_LANGUAGE = $CURRENT_LANGUAGE;
                $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                $DOCUMENT_SPACING = lc ${$attributes}{'SPACING'};
              }
            else
              {
		#
                # Print back cover page.
		#
                if ($back_cover ne "")
                  {
		    #
                    # Need a back cover page.
		    #
                    # Set language information to document language.
		    #
                    $CURRENT_LANGUAGE = $DOCUMENT_LANGUAGE;
		    #
                    &output ("\\almlzznewpage{}\n");
                    &output ("\\ifodd \\arabic{page}\n");
                    &output ("    % need another white page\n");
                    &output ("    \\almlzzstylepageempty{}\n");
                    &output ("    ~\n");
                    &output ("    \\almlzznewpage{}\n");
                    &output ("\\else\n");
                    &output ("    % need other two white pages\n");
                    &output ("    \\almlzzstylepageempty{}\n");
                    &output ("    ~\n");
                    &output ("    \\almlzznewpage{}\n");
                    &output ("    ~\n");
                    &output ("    \\almlzznewpage{}\n");
                    &output ("\\fi\n");
                    &output ("\\almlzzstylepageempty{}\n");
                    &output ("\n\\null");
                    #
                    if ($back_cover ne "")
                      {
                        &output ("$back_cover");
                      }
                  }
                #
                # To get the \arabic{page} to work correctly,
                # must distantiate from the last block of text.
                #
                &output ("\n");
                &output ("\n");
                &output ("% Save page location.");
                &output ("\n");
                &output ("\\immediate\\write\\almlssauxpagelocation{eof{}pageoffset{\\arabic{pageoffset}}relativepage{\\arabic{page}}}");
                &output ("\n");
                #
                # Close the Page location output (with a final
		# diagnostic record).
                #
                &output ("\\immediate\\write\\almlssauxpagelocation{EOF}");
                &output ("\n");
                &output ("\\immediate\\closeout\\almlssauxpagelocation");
                &output ("\n");
                #!  #
                #!  # Close the title list output (with a final
		#!  # diagnostic record).
                #!  #
                #!  &output ("\\immediate\\write\\almlssauxtitles{EOF}");
                #!  &output ("\n");
                #!  &output ("\\immediate\\closeout\\almlssauxtitles");
                #!  &output ("\n");
                #
                # Close the Page references output (with a final diag
                # record).
                #
                &output ("\\immediate\\write\\almlssauxpageref{EOF}");
                &output ("\n");
                &output ("\\immediate\\closeout\\almlssauxpageref");
                &output ("\n");
                #
                # Close the Debug output (with a final diag record).
                #
                &output ("\\immediate\\write\\almlssauxdebug{EOF}");
                &output ("\n");
                &output ("\\immediate\\closeout\\almlssauxdebug");
                &output ("\n");
                #
                # Close the LaTeX source.
                #
                &output ("\n");
                &output ("\\end{document}");
                &output ("\n");
                #
              }
          }
        elsif ($element eq "HEAD")
          {
            if ($type eq "start")
              {
                # Save the document position.
                $document_position = "head";
              }
            else
              {
		#
                # End of header: compose into LaTeX.
		#
                my ($n) = 0;
                my ($line) = "";
                my ($headheight) = "";
                my ($headsep) = "";
                my ($footskip) = "";
                my ($topmargin) = "";
                my ($textheight) = "";
                my ($oddsidemargin) = "";
                my ($evensidemargin) = "";
		#
                # This is a book with Babel support for all available
                # languages.
		#
                &output ("\\documentclass{book}\n");
                &output ("\\usepackage[autogenerated,warnunknown,postscript]{ucs}\n");
                &output ("\\usepackage[utf8]{inputenc}\n");
                &output ("\\usepackage[");
                for ($n = 0; $n <= $#language_list; $n++)
                  {
                    if (&latex_language_name($language_list[$n]) ne "")
                      {
                        &output (&latex_language_name($language_list[$n]));
                        &output (",");
                      }
                  }
                &output ("]{babel}\n");
		#
                # Use LaTeX symbols
		#
                &output ("\\usepackage{latexsym}\n");
		#
                # Use Euro symbol
		#
                &output ("\\usepackage{eurosym}\n");
		#
                # Define the book title.
		#
                &output ("\\newcommand\\almlaabooktitle{$title}\n");
		#
                # Set page format.
		#
                &output ("\\setlength\\paperwidth{$paper_width}\n");
                &output ("\\setlength\\paperheight{$paper_height}\n");
                #
                # Never stop on errors. Look inside log file instead.
                #
                &output ("\\nonstopmode\n");
                # Control warnings.
                #&output ("\\tracingstats=1\n");
                
		#
                # Define a command for PDF bookmarks.
                # The command is necessary to obtain accented letters.
                # \almlbzpdfbookmark{LEVEL}{BOOKMARK_TEXT}
                #
                &output ("\\newcommand\\almlbzpdfbookmark[2]{\\special{pdf: out #1 << /Title (#2) /Dest [ \@thispage /FitH \@ypos ] >>}}\n");
                #
                # Include some more TeX packages.
                #
                &output ("\\usepackage{url}");
                &output ("\n");
                &output ("\\usepackage{epsfig}");
                &output ("\n");
                &output ("\\usepackage\[OT2,T1\]{fontenc} % OT2 is used for Russian; T1 must be the last.");
                &output ("\n");
                &output ("\\usepackage{amssymb} % for some math symbols");
                &output ("\n");
                &output ("\\usepackage{amsfonts} % for some math symbols");
                &output ("\n");
                &output ("\\usepackage{amsbsy} % for some math symbols");
                &output ("\n");
                &output ("\\usepackage{pifont} % for some ding symbols");
                &output ("\n");
                &output ("\\usepackage{textcomp} % for command like \\text...");
                &output ("\n");
                &output ("\\usepackage{color}");
                &output ("\n");
                &output ("\\usepackage{wasysym} % for some ding symbols");
                &output ("\n");
                &output ("\\usepackage{mathrsfs} % for some math");
                &output ("\n");
                &output ("\\usepackage{longtable}");
                &output ("\n");
                &output ("\\usepackage\[dvipdfm\]{hyperref}");
                &output ("\n");
		#
                # Internal configuration starts here.
		#
                &output ("\n");
                &output ("% Internal configuration\n");
		#
                # Save space commands.
                #
                # The special formats to save space are not working well
                # at the moment. It must be decided how to set it,
                # because of the problem with "plain" pages, because
                # the page number might be mixed with footnotes and
                # with tables.
		#
                &output ("\\newcommand\\almlzznewpagehalf{\\clearpage}\n");
                &output ("\\newcommand\\almlzznewpage{\\clearpage}\n");
                &output ("\\newcommand\\almlzznewpagedouble{\\cleardoublepage}\n");
                &output ("\\newcommand\\almlzzendofpage{\\newpage}\n");
                &output ("\\newcommand\\almlzzvfill{~\n\n\\vfill}\n");
                &output ("\\newcommand\\almlzzvfillhalf{~\n\n\\vfill}\n");
                &output ("\\newcommand\\almlzzstylepageempty{\\pagestyle{empty}}\n");
                &output ("\\newcommand\\almlzzstylepagenormal{\\pagestyle{plain}}\n");
                &output ("\\newcommand\\almlzzstylepageheader{\\pagestyle{myheadings}}\n");
		#
		# Special characters.
		#
                &output ("\\newcommand{\\emaildot}{\x{00B7}}");
                &output ("\\newcommand{\\emailcommat}{\\mbox\{\x{2009}({\\raisebox{0.30ex}{\\fontsize{0.5em}{0.7em}\\selectfont{\\hspace{-0.5ex}ad\\hspace{-0.5ex}}}})\x{2009}}}");
		#
                # Special words or names.
		#
                &output ("\n");
                if ($draft)
                  {
                    &output ("\\newcommand{\\almlbaspecialname}[2]{\\underline{{#1}}{\\raisebox{-0.25ex}{\\fontsize{0.6em}{1em}\\selectfont{#2}}}}");
                  }
                else
                  {
                    &output ("\\newcommand{\\almlbaspecialname}[2]{{{#1}}}");
                  }
                &output ("\n");
		#
                # Menu items.
		#
                &output ("\\newcommand{\\almlaamenuitem}[1]{\\underline{\\fontsize{0.8em}{1.3em}\\selectfont\\slshape\\ttfamily{}#1}}");
                #
                # Stranger definition.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaadefstr}[1]{{\\textit{#1}}}");
                &output ("\n");
		#
                # Metasyntactic variable.
                # The extra space before and after the VAR element
                # is necessary to separate more VAR elements for
                # the reader.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaavar}[1]{");
                &output ("\\mbox{\\hspace{0.05em}{\\normalfont\\bfseries\\itshape{}#1\\/}\\hspace{0.05em}}");
                &output ("}");
                &output ("\n");
                #
                # Kernel option.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaakerneloption}[1]{{\\itshape{#1}\\/}}");
                &output ("\n");
                #
                # Syntax symbols.
                #
                &output ("\n");
                &output ("\\newcommand\\almlxxsynlsqb{\\hspace{-0.3ex}{\\fontsize{1.618em}{2.618em}\\selectfont\\raisebox{-0.146em}{[}}\\hspace{-0.3ex}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsynrsqb{\\hspace{-0.3ex}{\\fontsize{1.618em}{2.618em}\\selectfont\\raisebox{-0.146em}{]}}\\hspace{-0.2ex}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsynlcub{\\hspace{-0.3ex}{\\fontsize{1.618em}{2.618em}\\selectfont\\raisebox{-0.146em}{\\symbol{123}}}\\hspace{-0.3ex}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsynrcub{\\hspace{-0.3ex}{\\fontsize{1.618em}{2.618em}\\selectfont\\raisebox{-0.146em}{\\symbol{125}}}\\hspace{-0.3ex}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsynverbar{\\hspace{-0.3ex}{\\fontsize{1.618em}{2.618em}\\selectfont\\raisebox{-0.146em}{|}}\\hspace{-0.3ex}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsynellipsis{{\\normalfont\\fontsize{0.8em}{1.3em}\\selectfont\\raisebox{0.25ex}{...}}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsynstar{{\\normalfont\\fontsize{1.618em}{2.618em}\\selectfont\\raisebox{-0.66ex}{\\symbol{42}}}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxresult{{\$\\Rightarrow\$}}");
                &output ("\n");
		#
                # Special macros to be used inside the UCS package.
                # The names are described inside the UCS package
                # documentation.
		#
                &output ("\\newcommand\\unicodesmall[1]{\\almlaasmall{#1}}");
                &output ("\n");
		#
                # Special characters that have to be used inside
                # a latin language.
                #
                # But there is a problem: when such symbols gets inside
                # some special environment, TeX brakes like this:
                # ! TeX capacity exceeded, sorry [input stack size=1500].
                # This means that the language cannot be changed there.
		#
                #	&output ("\n");
                #	&output ("\\newcommand\\almlxxsymbolplus{\\foreignlanguage{english}{+}}") ;
                #	&output ("\n");
                #	&output ("\\newcommand\\almlxxsymbolequals{\\foreignlanguage{english}{=}}");
                #	&output ("\n");
                #	&output ("\\newcommand\\almlxxsymbolnum{\\foreignlanguage{english}{\\#}}");
                #	&output ("\n");
                #	&output ("\\newcommand\\almlxxsymbolamp{\\foreignlanguage{english}{\\&}}");
                #	&output ("\n");
                #	&output ("\\newcommand\\almlxxsymbolcommat{\\foreignlanguage{english}{\@}}");
                #	&output ("\n");
                #	&output ("\\newcommand\\almlxxsymbolangst{{\\selectlanguage{english}{\\AA}}}");
		#
		#
                # More special characters.
		#
                &output ("\n");
                &output ("\\newcommand\\almlxxsymbolunprintable{\\ensuremath{\\square}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsymbolminus{\\mbox{\\texttt{-}}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsymboleuro{\\euro}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsymbolnu{\\ensuremath{\\nu}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsymbolhstrok{{\\leavevmode\\raise .7ex\\rlap{-}h}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsymbolhhstrok{{\\leavevmode\\raise .55ex\\rlap{\\kern .2ex --}H}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsymboltstrok{{\\leavevmode\\raise .25ex\\rlap{\\kern .1ex -}t}}");
                &output ("\n");
                &output ("\\newcommand\\almlxxsymbolttstrok{{\\leavevmode\\raise .25ex\\rlap{\\kern .22ex --}T}}");
                &output ("\n");
		#
                # Unicode characters.
		#
                &output ("\\DeclareUnicodeCharacter{291}{\\almlxxsymbolunprintable}% U+0123");                                          #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{309}{\\\^j}% U+0135");                                              #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{312}{\\textsc{k}}% U+0138");                                                # LATIN SMALL LETTER KRA
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{329}{{n\\kern-.2em\\textsf{\'}}}% U+0149");                                 # LATIN SMALL LETTER N PRECEDED BY APOSTROPHE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{736}{\\almlxxsymbolunprintable}% U+02E0");                                          #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{979}{\\almlxxsymbolunprintable}% U+03D3");                                          #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{980}{\\almlxxsymbolunprintable}% U+03D4");                                          #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1024}{\\almlxxsymbolunprintable}% U+0400");                                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1037}{\\almlxxsymbolunprintable}% U+040D");                                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1104}{\\almlxxsymbolunprintable}% U+0450");                                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1117}{\\almlxxsymbolunprintable}% U+045D");                                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1120}{\\almlxxsymbolunprintable}% U+0460");                                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1121}{\\almlxxsymbolunprintable}% U+0461");                                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8208}{{\x{2D}}}% U+2010");                                                  # HYPHEN
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8213}{\\rule\{1em\}\{1pt\}}% U+2015");                                      # HORIZONTAL BAR
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8214}{\\textbardbl}% U+2016");                                              # DOUBLE VERTICAL LINE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8219}{`}% U+201B");                                                         # SINGLE HIGH-REVERSED-9 QUOTATION MARK
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8223}{\\textquotedblleft}% U+201F");                                        # DOUBLE HIGH-REVERSED-9 QUOTATION MARK
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8245}{\\ensuremath{\^\\backprime}}% U+2035"); # REVERSED PRIME
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8254}{\\=\~}% U+203E"); # OVERLINE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8257}{\\ensuremath\{\\bigwedge\}}% U+2041");                                # CARET INSERTION POINT
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8259}{{\\leavevmode\\vrule width 1ex height .8ex depth -.6ex}}% U+2043");   # HYPHEN BULLET
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8260}{/}% U+2044"); # FRACTION SLASH
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8411}{\\almlxxsymbolunprintable}% U+20DB");                                 # COMBINING THREE DOTS ABOVE # 20DC
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8412}{\\almlxxsymbolunprintable}% U+20DC");                                 # COMBINING FOUR DOTS ABOVE # 20DC
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8471}{\\almlxxsymbolunprintable}% U+2117");                                 # SOUND RECORDING COPYRIGHT
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8478}{\\almlxxsymbolunprintable }% U+211E");                                # PRESCRIPTION TAKE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8592}{\\ensuremath{\\leftarrow}}% U+2190");                                 # LEFTWARDS ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8598}{\\ensuremath{\\nwarrow}}% U+2196"); # NORTH WEST ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8599}{\\ensuremath{\\nearrow}}% U+2197"); # NORTH EAST ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8600}{\\ensuremath{\\searrow}}% U+2198"); # SOUTH EAST ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8601}{\\ensuremath{\\swarrow}}% U+2199"); # SOUTH WEST ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8602}{\\ensuremath{\\nleftarrow}}% U+219A"); # LEFTWARDS ARROW WITH STROKE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8603}{\\ensuremath{\\nrightarrow}}% U+219B"); # RIGHTWARDS ARROW WITH STROKE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8606}{\\ensuremath{\\twoheadleftarrow}}% U+219E"); # LEFTWARDS TWO HEADED ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8608}{\\ensuremath{\\twoheadrightarrow}}% U+21A0"); # RIGHTWARDS TWO HEADED ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8610}{\\ensuremath{\\leftarrowtail}}% U+21A2"); # LEFTWARDS ARROW WITH TAIL
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8611}{\\ensuremath{\\rightarrowtail}}% U+21A3"); # RIGHTWARDS ARROW WITH TAIL
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8614}{\\ensuremath{\\mapsto}}% U+21A6"); # RIGHTWARDS ARROW FROM BAR
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8617}{\\ensuremath{\\hookleftarrow}}% U+21A9"); # LEFTWARDS ARROW WITH HOOK
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8618}{\\ensuremath{\\hookrightarrow}}% U+21AA"); # RIGHTWARDS ARROW WITH HOOK
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8619}{\\ensuremath{\\looparrowleft}}% U+21AB"); # LEFTWARDS ARROW WITH LOOP
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8620}{\\ensuremath{\\looparrowright}}% U+21AC"); # RIGHTWARDS ARROW WITH LOOP
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8621}{\\ensuremath{\\leftrightsquigarrow}}% U+21AD"); # LEFT RIGHT WAVE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8622}{\\ensuremath{\\nLeftrightarrow}}% U+21AE"); # LEFT RIGHT ARROW WITH STROKE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8624}{\\ensuremath{\\Lsh}}% U+21B0"); # UPWARDS ARROW WITH TIP LEFTWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8625}{\\ensuremath{\\Rsh}}% U+21B1"); # UPWARDS ARROW WITH TIP RIGHTWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8629}{\\ensuremath{\\hookleftarrow}}% U+21B5"); # DOWNWARDS ARROW WITH CORNER LEFTWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8630}{\\ensuremath{\\curvearrowleft}}% U+21B6"); # ANTICLOCKWISE TOP SEMICIRCLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8631}{\\ensuremath{\\curvearrowright}}% U+21B7"); # CLOCKWISE TOP SEMICIRCLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8634}{\\ensuremath{\\circlearrowleft}}% U+21BA"); # ANTICLOCKWISE OPEN CIRCLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8635}{\\ensuremath{\\circlearrowright}}% U+21BB"); # CLOCKWISE OPEN CIRCLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8636}{\\ensuremath{\\leftharpoonup}}% U+21BC"); # LEFTWARDS HARPOON WITH BARB UPWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8637}{\\ensuremath{\\leftharpoondown}}% U+21BD"); # LEFTWARDS HARPOON WITH BARB DOWNWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8638}{\\ensuremath{\\upharpoonright}}% U+21BE"); # UPWARDS HARPOON WITH BARB RIGHTWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8639}{\\ensuremath{\\upharpoonleft}}% U+21BF"); # UPWARDS HARPOON WITH BARB LEFTWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8640}{\\ensuremath{\\rightharpoonup}}% U+21C0"); # RIGHTWARDS HARPOON WITH BARB UPWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8641}{\\ensuremath{\\rightharpoondown}}% U+21C1"); # RIGHTWARDS HARPOON WITH BARB DOWNWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8642}{\\ensuremath{\\downharpoonright}}% U+21C2"); # DOWNWARDS HARPOON WITH BARB RIGHTWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8643}{\\ensuremath{\\downharpoonleft}}% U+21C3"); # DOWNWARDS HARPOON WITH BARB LEFTWARDS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8644}{\\ensuremath{\\rightleftarrows}}% U+21C4"); # RIGHTWARDS ARROW OVER LEFTWARDS ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8646}{\\ensuremath{\\leftrightarrows}}% U+21C6"); # LEFTWARDS ARROW OVER RIGHTWARDS ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8647}{\\ensuremath{\\leftleftarrows}}% U+21C7"); # LEFTWARDS PAIRED ARROWS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8648}{\\ensuremath{\\upuparrows}}% U+21C8"); # UPWARDS PAIRED ARROWS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8649}{\\ensuremath{\\rightrightarrows}}% U+21C9"); # RIGHTWARDS PAIRED ARROWS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8650}{\\ensuremath{\\downdownarrows}}% U+21CA"); # DOWNWARDS PAIRED ARROWS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8651}{\\ensuremath{\\leftrightharpoons}}% U+21CB"); # LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8653}{\\ensuremath{\\nLeftarrow}}% U+21CD"); # LEFTWARDS DOUBLE ARROW WITH STROKE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8654}{\\ensuremath{\\nLeftrightarrow}}% U+21CE"); # LEFT RIGHT DOUBLE ARROW WITH STROKE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8655}{\\ensuremath{\\nRightarrow}}% U+21CF"); # RIGHTWARDS DOUBLE ARROW WITH STROKE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8656}{\\ensuremath\{\\Leftarrow\}}% U+21D0");                               # LEFTWARDS DOUBLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8657}{\\ensuremath{\\Uparrow}}% U+21D1"); # UPWARDS DOUBLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8659}{\\ensuremath{\\Downarrow}}% U+21D3"); # DOWNWARDS DOUBLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8661}{\\ensuremath{\\Updownarrow}}% U+21D5"); # UP DOWN DOUBLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8666}{\\ensuremath{\\Lleftarrow}}% U+21DA"); # LEFTWARDS TRIPLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8667}{\\ensuremath{\\Rrightarrow}}% U+21DB"); # RIGHTWARDS TRIPLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8669}{\\ensuremath{\\rightsquigarrow}}% U+21DD"); # RIGHTWARDS SQUIGGLE ARROW
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8714}{\\ensuremath{\\epsilon}}% U+220A"); # SMALL ELEMENT OF
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8717}{\\ensuremath{\\backepsilon}}% U+220D"); # SMALL CONTAINS AS MEMBER
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8735}{\\ensuremath{\\mathord{\\hbox\{\\vrule width .4pt height 1ex depth 0pt \\kern -.4pt \\vrule width 1ex height .4pt depth 0pt}}}}% U+221F");    # RIGHT ANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8780}{\\ensuremath{{{\\mathrel{\\raise -.3ex \\hbox{\$\\displaystyle\\backsim\$}\\atop \\raise.3ex\\hbox{\$\\displaystyle =\$}}}}}}% U+224C"); # ALL EQUAL TO
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8788}{\\ensuremath{:=}}% U+2254"); # COLON EQUALS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8789}{\\ensuremath{=:}}% U+2255"); # EQUALS COLON
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8793}{\\ensuremath\{\\stackrel\{\\wedge\}\{=\}\}}% U+2259");                # ESTIMATES
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8871}{\\ensuremath{\\models}}% U+22A7"); # MODELS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8872}{\\ensuremath{\\vDash}}% U+22A8"); # TRUE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8876}{\\ensuremath{\\nvdash}}% U+22AC"); # DOES NOT PROVE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8877}{\\ensuremath{\\nvDash}}% U+22AD"); # NOT TRUE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8879}{\\ensuremath{\\nVDash}}% U+22AF"); # NEGATED DOUBLE VERTICAL BAR DOUBLE RIGHT TURNSTILE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8924}{\\ensuremath{\\eqslantless}}% U+22DC"); # EQUAL TO OR LESS-THAN
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8925}{\\ensuremath{\\eqslantgtr}}% U+22DD"); # EQUAL TO OR GREATER-THAN
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8966}{\\ensuremath{\\doublebarwedge}}% U+2306"); # PERSPECTIVE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8972}{{\\leavevmode \\vrule width .2pt height -2pt depth 12pt \\kern 2pt {\\vrule width 10pt height 0.2 pt depth  0pt }}}% U+2190");        # BOTTOM RIGHT CROP
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8973}{{\\leavevmode{\\vrule width 10pt height 0.2 pt depth  0pt } \\kern 2pt \\vrule width .2pt  height -2pt depth 12pt}}% U+230D");        # BOTTOM LEFT CROP
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8974}{{\\leavevmode \\vrule width .2pt height 12pt depth -2pt\\kern 2pt {\\vrule width 10pt height 0.2 pt depth  0pt }}}% U+230E");         # TOP RIGHT CROP
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8975}{{\\leavevmode{\\vrule width 10pt height 0.2 pt depth  0pt } \\kern 2pt \\vrule width .2pt  height 12pt depth -2pt}}% U+230F");        # TOP LEFT CROP
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8981}{\\recorder}% U+2315");                                                # TELEPHONE RECORDER
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8982}{\\ensuremath\{\\oplus\}}% U+2316");                                   # POSITION INDICATOR
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8988}{\\ensuremath{\\ulcorner}}% U+231C"); # TOP LEFT CORNER
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8989}{\\ensuremath{\\urcorner}}% U+231D"); # TOP RIGHT CORNER
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8990}{\\ensuremath{\\llcorner}}% U+231E"); # BOTTOM LEFT CORNER
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8991}{\\ensuremath{\\lrcorner}}% U+231F"); # BOTTOM RIGHT CORNER
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8994}{\\ensuremath{\\frown}}% U+2322"); # FROWN
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8995}{\\ensuremath{\\smile}}% U+2323"); # SMILE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9251}{\\textvisiblespace}% U+2423");                                        # OPEN BOX
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9416}{\\almlxxsymbolunprintable}% U+24C8");                                 # (S)
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9472}{\\almlxxsymbolunprintable}% U+2500");    # BOX DRAWINGS LIGHT HORIZONTAL # 2500
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9474}{\\almlxxsymbolunprintable}% U+2502");    # BOX DRAWINGS LIGHT VERTICAL # 2502
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9484}{\\almlxxsymbolunprintable}% U+250C");    # BOX DRAWINGS LIGHT DOWN AND RIGHT # 250C
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9488}{\\almlxxsymbolunprintable}% U+2510");    # BOX DRAWINGS LIGHT DOWN AND LEFT # 2510
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9492}{\\almlxxsymbolunprintable}% U+2514");    # BOX DRAWINGS LIGHT UP AND RIGHT # 2514
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9496}{\\almlxxsymbolunprintable}% U+2518");    # BOX DRAWINGS LIGHT UP AND LEFT # 2518
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9500}{\\almlxxsymbolunprintable}% U+251C");    # BOX DRAWINGS LIGHT VERTICAL AND RIGHT # 251C
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9508}{\\almlxxsymbolunprintable}% U+2524");    # BOX DRAWINGS LIGHT VERTICAL AND LEFT # 2524
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9516}{\\almlxxsymbolunprintable}% U+252C");    # BOX DRAWINGS LIGHT DOWN AND HORIZONTAL # 252C
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9524}{\\almlxxsymbolunprintable}% U+2534");    # BOX DRAWINGS LIGHT UP AND HORIZONTAL # 2534
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9532}{\\almlxxsymbolunprintable}% U+253C");    # BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL # 253C
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9552}{\\almlxxsymbolunprintable}% U+2550");    # BOX DRAWINGS DOUBLE HORIZONTAL # 2550
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9553}{\\almlxxsymbolunprintable}% U+2551");    # BOX DRAWINGS DOUBLE VERTICAL # 2551
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9554}{\\almlxxsymbolunprintable}% U+2552");    # BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE # 2552
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9555}{\\almlxxsymbolunprintable}% U+2553");    # BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE # 2553
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9556}{\\almlxxsymbolunprintable}% U+2554");    # BOX DRAWINGS DOUBLE DOWN AND RIGHT # 2554
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9557}{\\almlxxsymbolunprintable}% U+2555");    # BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE # 2555
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9559}{\\almlxxsymbolunprintable}% U+2557");    # BOX DRAWINGS DOUBLE DOWN AND LEFT # 2557
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9558}{\\almlxxsymbolunprintable}% U+2556");    # BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE # 2556
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9560}{\\almlxxsymbolunprintable}% U+2558");    # BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE # 2558
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9561}{\\almlxxsymbolunprintable}% U+2559");    # BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE # 2559
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9562}{\\almlxxsymbolunprintable}% U+255A");    # BOX DRAWINGS DOUBLE UP AND RIGHT # 255A
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9563}{\\almlxxsymbolunprintable}% U+255B");    # BOX DRAWINGS UP SINGLE AND LEFT DOUBLE # 255B
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9564}{\\almlxxsymbolunprintable}% U+255C");    # BOX DRAWINGS UP DOUBLE AND LEFT SINGLE # 255C
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9565}{\\almlxxsymbolunprintable}% U+255D");    # BOX DRAWINGS DOUBLE UP AND LEFT # 255D
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9566}{\\almlxxsymbolunprintable}% U+255E");    # BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE # 255E
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9567}{\\almlxxsymbolunprintable}% U+255F");    # BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE # 255F
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9568}{\\almlxxsymbolunprintable}% U+2560");    # BOX DRAWINGS DOUBLE VERTICAL AND RIGHT # 2560
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9569}{\\almlxxsymbolunprintable}% U+2561");    # BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE # 2561
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9570}{\\almlxxsymbolunprintable}% U+2562");    # BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE # 2562
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9571}{\\almlxxsymbolunprintable}% U+2563");    # BOX DRAWINGS DOUBLE VERTICAL AND LEFT # 2563
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9572}{\\almlxxsymbolunprintable}% U+2564");    # BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE # 2564
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9573}{\\almlxxsymbolunprintable}% U+2565");    # BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE # 2565
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9574}{\\almlxxsymbolunprintable}% U+2566");    # BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL # 2566
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9575}{\\almlxxsymbolunprintable}% U+2567");    # BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE # 2567
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9576}{\\almlxxsymbolunprintable}% U+2568");    # BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE # 2568
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9577}{\\almlxxsymbolunprintable}% U+2569");    # BOX DRAWINGS DOUBLE UP AND HORIZONTAL # 2569
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9578}{\\almlxxsymbolunprintable}% U+256A");    # BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE # 256A
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9579}{\\almlxxsymbolunprintable}% U+256B");    # BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE # 256B
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9580}{\\almlxxsymbolunprintable}% U+256C");    # BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL # 256C
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9589}{\\almlxxsymbolunprintable}% U+2557");    # BOX DRAWINGS DOUBLE DOWN AND LEFT # 2557
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9600}{{\\leavevmode\\vrule width 1ex height 1.2ex depth -.6ex}}% U+2580");  # UPPER HALF BLOCK
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9604}{{\\leavevmode\\vrule width 1ex height .6ex depth 0pt}}% U+2584");                                     # 
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9608}{{\\leavevmode\\vrule width 1ex height 1.2ex depth 0pt}}% U+2588");                                    # 
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9617}{\\textcolor[gray]{.75}{{\\leavevmode\\vrule width 1ex height 1.2ex depth 0pt}}}% U+2591");                                    # 
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9618}{\\textcolor[gray]{.5}{{\\leavevmode\\vrule width 1ex height 1.2ex depth 0pt}}}% U+2592");                                     # 
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9619}{\\textcolor[gray]{.25}{{\\leavevmode\\vrule width 1ex height 1.2ex depth 0pt}}}% U+2593");                                    # 
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9633}{\\ensuremath\{\\square\}}% U+25A1");                                  # WHITE SQUARE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9642}{\\ensuremath\{\\blacksquare\}}% U+25AA");                             # BLACK SMALL SQUARE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9645}{{\\fboxrule 0.2 bp \\fboxsep 3 bp \\fbox\{~~}\}}% U+25AD");           # WHITE RECTANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9646}{{\\leavevmode\\kern .5ex\\vrule width .5ex height 1.2ex depth 0pt}}% U+25AE");        # BLACK VERTICAL RECTANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9651}{\\ensuremath{\\bigtriangleup}}% U+25B3"); # WHITE UP-POINTING TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9652}{\\ensuremath{\\blacktriangle}}% U+25B4");                             # BLACK UP-POINTING SMALL TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9653}{\\ensuremath{\\triangle}}% U+25B5");                                  # WHITE UP-POINTING SMALL TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9656}{\\ensuremath{\\blacktriangleright}}% U+25B8");                        # BLACK RIGHT-POINTING SMALL TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9657}{\\ensuremath{\\triangleright}}% U+25B9");                             # WHITE RIGHT-POINTING SMALL TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9661}{\\ensuremath{\\bigtriangledown}}% U+25BD"); # WHITE DOWN-POINTING TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9662}{\\ensuremath{\\blacktriangledown}}% U+25BE");                         # BLACK DOWN-POINTING SMALL TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9663}{\\ensuremath{\\triangledown}}% U+25BF");                              # WHITE DOWN-POINTING SMALL TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9666}{\\ensuremath{\\blacktriangleleft}}% U+25C2");                         # BLACK LEFT-POINTING SMALL TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9667}{\\ensuremath{\\triangleleft}}% U+25C3");                              # WHITE LEFT-POINTING SMALL TRIANGLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9674}{\\ensuremath{\\lozenge}}% U+25CA");                           # LOZENGE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9675}{\\ensuremath{\\circ}}% U+25CB");                                      # WHITE CIRCLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9711}{\\ensuremath{\\bigcirc}}% U+25EF"); # LARGE CIRCLE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9734}{\\ding{73}}% U+2606");                                                # WHITE STAR
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9792}{\\female}% U+2640");                                                  # FEMALE SIGN
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9794}{\\male}% U+2642");                                                    # MALE SIGN
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{9833}{\\eighthnote}% U+2669");                                              # EIGHTH NOTE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{10731}{\\ensuremath{\\blacklozenge}}% U+29EB");                             # BLACK LOZENGE
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{12296}{\\ensuremath{\\langle}}% U+3008");                                   # LEFT ANGLE BRACKET
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{12297}{\\ensuremath{\\rangle}}% U+3009");                                   # RIGHT ANGLE BRACKET
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{58113}{\\ensuremath{\\shortmid}}% U+E301");                                 #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{58385}{\\ensuremath{\\gnapprox}}% U+E411");                                 #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{65128}{\\ensuremath{\\smallsetminus}}% U+FE68");                            # SMALL REVERSE SOLIDUS
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{58026}{\\ensuremath{\\nshortmid}}% U+E2AA");                                #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{58035}{\\ensuremath{\\precneqq}}% U+E2B3");                                 #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{58037}{\\ensuremath{\\succneqq}}% U+E2B5");                                 #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{58040}{\\ensuremath{\\varsubsetneqq}}% U+E2B8");                            #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{58001}{\\ensuremath{\\rlap{\$\>\$\}\,)}}% U+E291");                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{58018}{\\ensuremath{\\lnapprox}}% U+E2A2");                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{295}{{\\leavevmode\\raise .7ex\\rlap{-}h}}% U+0127");                       #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{294}{{\\leavevmode\\raise .55ex\\rlap{\\kern .2ex --}H}}% U+0126");                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{359}{{\\leavevmode\\raise .25ex\\rlap{\\kern .1ex -}t}}% U+0167");                  #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{358}{{\\leavevmode\\raise .25ex\\rlap{\\kern .22ex --}T}}% U+0166");                        #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1111}{\\\"\\i}% U+0457");                   #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1031}{\\almlxxsymbolunprintable}% U+0407}");                        #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1118}{\\u\{u\}}% U+045E}");                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{1038}{\\u\{U\}}% U+040E}");                         #
                &output ("\n");
                &output ("\\DeclareUnicodeCharacter{8491}{{\\selectlanguage{english}{\\AA}}}% U+212B");                         #
                &output ("\n");
		#
                # Index entry for draft typesetting.
		#
                &output ("\n");
                &output ("\\newcommand{\\almlbzindexentrydraft}[2]{");
                &output ("\\hspace{0pt}");
                &output ("{\\fontsize{0.6em}{1em}\\selectfont\\textrm{\[");
                &output (&index_def ());
                &output (":#1: #2\]}}");
                &output ("}");
                &output ("\n");
                #
                # IFREF for draft typesetting.
		#
                &output ("\n");
                &output ("\\newcommand{\\almlaaifref}[1]");
                &output ("{");
                &output ("{\\color{cyan}#1}");
                &output ("}");
                &output ("\n");
		#
                # Need to define a CODE command to be able to delete it
                # from indexes.
		#
                &output ("\n");
                &output ("\\newcommand{\\almlaacodeindexentry}[1]{{\\texttt{#1}}}");
                &output ("\n");
                #! \mbox{} will make troubles with long <code>...</code>.
                #! &output ("\\newcommand{\\almlaacode}[1]{\\mbox{\\fontsize{0.9em}{1.3em}\\selectfont\\bfseries\\ttfamily{}#1}}");
                &output ("\\newcommand{\\almlaacode}[1]{{\\fontsize{0.9em}{1.3em}\\selectfont\\bfseries\\ttfamily{}#1}}");
                &output ("\n");
		#
                # SAMP.
		#
                &output ("\n");
                &output ("\\newcommand{\\almlaasamp}[1]{{\\fontsize{0.9em}{1.3em}\\selectfont{}`{\\bfseries\\ttfamily{}#1}'}}");
                &output ("\n");
		#
                # FILE.
		#
                &output ("\n");
                &output ("\\newcommand{\\almlaafile}[1]{{\\fontsize{0.9em}{1.3em}\\selectfont{}`\\nolinebreak{\\ttfamily{}#1}\\nolinebreak'}}");
                &output ("\n");

                
                # ASCIICODE.
                

                &output ("\n");
                &output ("\\newcommand{\\almlaaasciicode}[1]{{\\itshape\\fontsize{0.8em}{1.3em}\\selectfont\$<\$#1\$>\$}}");
                &output ("\n");

                
                # BUTTON.
                

                &output ("\n");
                &output ("\\newcommand{\\almlaabutton}[1]{\\fbox{\\fontsize{0.8em}{1.3em}\\selectfont\\scshape\\ttfamily{}#1}}");
                &output ("\n");
                #
                # KBD.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaakbd}[1]{\\mbox{\\fontsize{0.8em}{1.3em}\\selectfont\[\\hspace{2pt}{\\itshape{}#1\\/}\\hspace{2pt}\]}}");
                &output ("\n");
                #
                # KP.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaakp}[1]{\\mbox{\\fboxsep=0.4mm\\fboxrule=0.2mm\\fbox{\\fontsize{0.9em}{1.3em}\\selectfont\\bfseries{}#1\\/}}}");
                &output ("\n");
                #
                # VKBD.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaavkbd}[1]{\\mbox{\\fontsize{0.8em}{1.3em}\\selectfont{<}\\hspace{2pt}{\\itshape{}#1\\/}\\hspace{2pt}{>}}}");
                &output ("\n");
                #
                # ACRONYM.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaaacronym}[1]{{\\scshape{}#1}}");
                &output ("\n");
                #
                # DACRONYM.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaadacronym}[1]{{\\itshape{}#1\\/}}");
                &output ("\n");
                #
                # SMALL.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaasmall}[1]{{\\fontsize{0.8em}{1.3em}\\selectfont{}#1}}");
                &output ("\n");
                #
                # BIG.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaabig}[1]{{\\fontsize{1.2em}{2em}\\selectfont{}#1}}");
                &output ("\n");
                #
                # STRONG.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaastrong}[1]{{\\bfseries{}#1}}");
                &output ("\n");
		#
                # EM.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaaem}[1]{{\\itshape{}#1\\/}}");
                &output ("\n");
                #
                # MAN + MANSECT
                #
                &output ("\n");
                &output ("\\newcommand{\\almlbbman}[2]{\\mbox{\\itshape{}#1\\/\\rmfamily{}(#2)}}");
                &output ("\n");
                #
                # URI.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaauri}[1]{{\\fontsize{0.8em}{1.3em}\\selectfont\\slshape\\ensuremath{\\langle}#1\\ensuremath{\\rangle}}}");
                &output ("\n");

                
                # URISTR
                

                &output ("\n");
                &output ("\\newcommand{\\almlaauristr}[1]{{\\ttfamily\\slshape{}#1\\/}}");
                &output ("\n");

                
                # BIBREF
                

                &output ("\n");
                &output ("\\newcommand{\\almlaabibref}[1]{{\\itshape{}#1\\/}}");
                &output ("\n");
                #
                # SUB, SUP, PWR, EXA, DEC, OCT, BIN.
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaasub}[1]{{\\raisebox{-0.25ex}{\\fontsize{0.6em}{1em}\\selectfont{#1}}}}");
                &output ("\\newcommand{\\almlaasup}[1]{{\\raisebox{0.75ex}{\\fontsize{0.6em}{1em}\\selectfont{#1}}}}");
                &output ("\\newcommand{\\almlaapwr}[1]{{\\raisebox{0.75ex}{\\fontsize{0.6em}{1em}\\selectfont{#1}}}}");
                &output ("\\newcommand{\\almlbbnumberwithbase}[2]{\\mbox{#1{\\raisebox{-0.25ex}{\\fontsize{0.6em}{1em}\\selectfont{#2}}}}}");
                &output ("\n");
                #
                # Footnote mark
                #
                &output ("\\newcommand{\\almlaafootnotemark}[1]{{\\raisebox{0.75ex}{\\fontsize{0.6em}{1em}\\selectfont{#1}}}}");
                #
                # PDF hypersetup
                #
                &output ("\n");
                &output ("\\hypersetup{");
                &output ("\n");
                if ($#authors == 0)
                  {
                    &output ("    pdfauthor={" . &latex_pdf_bookmark_safe_correction ($authors[0]) . "},");
                    &output ("\n");
                  }
                &output ("    pdftitle={" . &latex_pdf_bookmark_safe_correction ($title) . "},");
                &output ("\n");
                if ($#subtitles == 0)
                  {
                    &output ("    pdfsubject={" . &latex_pdf_bookmark_safe_correction ($subtitles[0]) . "},");
                    &output ("\n");
                  }
                &output ("    pdfkeywords={" . &latex_pdf_bookmark_safe_correction ($DOCUMENT_KEYWORDS) . "}");
                &output ("\n");
                &output ("}");
                &output ("\n");

                
                # No hyphenation:
                #
                # for unknown reasons, \hyphenation{nohyphenation}
                # does not work. So, we use high \lefthyphenmin and
                # \righthyphenmin values. But it seems to work only
                # for block of text, so it is useless.
                
                #&output ("\n");
                #&output ("\\newcommand{\\AlmlNoHyphenation}{\\lefthyphenmin=100 \\righthyphenmin=100}\n");

                
                # Margins and spaces.
                

                &output ("\n");
                &output ("\\marginparwidth 0.0 in\n");
                &output ("\\parindent 0.0 in\n");
                &output ("% Headers are made with the \"normal\" size.\n");
                $headheight = (&length_value ($PRINTED_FONT_SIZE_NORMAL)
                               * 1.3)
                              . &length_unit ($PRINTED_FONT_SIZE_NORMAL);
                &output ("\\headheight $headheight\n");
                $headsep = (&length_value ($PRINTED_FONT_SIZE_NORMAL)
                            * 1.9)
                           . &length_unit ($PRINTED_FONT_SIZE_NORMAL);
                &output ("\\headsep $headsep\n");
                $footskip = (&length_value ($PRINTED_FONT_SIZE_NORMAL)
                             * 2.7)
                            . &length_unit ($PRINTED_FONT_SIZE_NORMAL);
                &output ("\\footskip $footskip\n");
                &output ("% Calculate top margin subtracting the 1 inch standard and the header size.\n");
                $topmargin = $PRINTED_TOP_MARGIN;
                $topmargin = &length_sub ($topmargin, "1in");
                $topmargin = &length_sub ($topmargin, $headheight);
                $topmargin = &length_sub ($topmargin, $headsep);
                &output ("\\topmargin $topmargin\n");
                &output ("% Calculate body text length.\n");
                $textheight = $paper_height;
                $textheight = &length_sub ($textheight, "1in");
                $textheight = &length_sub ($textheight, $headheight);
                $textheight = &length_sub ($textheight, $headsep);
                $textheight = &length_sub ($textheight, $PRINTED_BOTTOM_MARGIN);
                $textheight = &length_sum ($textheight, "1.5cm"); # don't know why I need this extra length.
                $textheight = &length_sub ($textheight, "0.5cm"); # subtract a security space.
                &output ("\\textheight $textheight\n");
                &output ("\n");

                # H margins.
                # Using internal margin for rigth and left pages.

                &output ("\\textwidth $PRINTED_BODY_WIDTH\n");

                $oddsidemargin = $PRINTED_INTERNAL_MARGIN;
                $oddsidemargin = &length_sub ($oddsidemargin, "1in");
                &output ("\\oddsidemargin $oddsidemargin\n");

                $evensidemargin = $paper_width;
                $evensidemargin = &length_sub ($evensidemargin, $PRINTED_BODY_WIDTH);
                $evensidemargin = &length_sub ($evensidemargin, $PRINTED_INTERNAL_MARGIN);
                $evensidemargin = &length_sub ($evensidemargin, "1in");
                &output ("\\evensidemargin $evensidemargin\n");


                
                # This is for DVIPS.
                

                &output ("\\special{papersize=$paper_width,$paper_height} % for DVIPS\n");

                &output ("\n");
                &output ("\\renewcommand{\\baselinestretch}{1}\n");
                &output ("\\addtolength{\\parskip}{1.5 ex}\n");

                # \framebox configuration.
                &output ("\n");
                &output ("\\fboxrule 0.2 bp\n");
                &output ("\\fboxsep 1 bp\n");

                # Less troubles about text line break and vertical space.
                &output ("\n");
                &output ("\\sloppy\n");
                &output ("\\raggedbottom\n");

                # Configure the \url package: use the same external
                # formatting.
                &output ("\n");
                &output ("\\urlstyle{same}");

                # Create and set the page offset counter.
                &output ("\n");
                &output ("\\newcounter{pageoffset}\n");
                &output ("\\setcounter{pageoffset}{0}\n");

                # Create and set the tome counter.
                &output ("\n");
                &output ("\\newcounter{tome}\n");
                &output ("\\setcounter{tome}{0}\n");


                
                # Define the starting page numbering.
                

                &output ("\n");
                if ($page_numbering eq "plain")
                  {
                    &output ("\\pagenumbering{arabic}\n");
                    &output ("\\setcounter{page}{1}\n");
                  }
                else
                  {
                    &output ("\\pagenumbering{Roman}\n");
                    &output ("\\setcounter{page}{1}\n");
                  }

                
                # Define how does it work the \almlzzstartofbody command.
                

                &output ("\n");
                if ($page_numbering eq "plain")
                  {
                    &output ("\\newcommand{\\almlzzstartofbody}{}");
                    &output ("\n");
                  }
                else
                  {
                    &output ("\\newcommand{\\almlzzstartofbody}\n");
                    &output ("{\n");
                    &output ("    \\ifodd \\arabic{page}\n");
                    &output ("        \\almlzznewpagedouble{}\n");
                    &output ("    \\else\n");
                    &output ("        \\almlzznewpage{}\n");
                    &output ("    \\fi\n");
                    &output ("    \\addtocounter{pageoffset}{\\arabic{page}}\n");
                    &output ("    \\addtocounter{pageoffset}{-1}\n");
                    &output ("    \\almlzzstylepageempty{}\n");
                    &output ("    \\pagenumbering{arabic}\n");
                    &output ("    \\setcounter{page}{1}\n");
                    &output ("}");
                    &output ("\n");
                  }

                
                # Will define standard fonts dimentions.
                

                &output ("\n");
                
                
                # Normalfont, used inside normal text.
                

                if ($PRINTED_FONT_SIZE_NORMAL eq "")
                  {
                    &output ("\\renewcommand{\\normalsize}{\\fontsize{10}{12}\\selectfont}");
                    &output ("\n");
                  }
                else
                  {
                    &output ("\\renewcommand{\\normalsize}{\\fontsize{$PRINTED_FONT_SIZE_NORMAL}{$PRINTED_FONT_HEIGHT_NORMAL}\\selectfont}");
                    &output ("\n");
                  }
                #
                # Footnote size, used inside \footnote{...}
                #
                &output ("\\renewcommand{\\footnotesize}{\\normalsize\\fontsize{0.8em}{0.96em}\\selectfont}");
                &output ("\n");
                #
                # Table size, used inside tables
                #
                if ($PRINTED_FONT_SIZE_TABLE eq "")
                  {
                    &output ("\\newcommand\\almlaafontsizetable[1]{{\\normalsize\\fontsize{0.9em}{1.1em}\\selectfont{}#1}}");
                    &output ("\n");
                  }
                else
                  {
                    &output ("\\newcommand\\almlaafontsizetable[1]{{\\fontsize{$PRINTED_FONT_SIZE_TABLE}{$PRINTED_FONT_HEIGHT_TABLE}\\selectfont{}#1}}");
                    &output ("\n");
                  }
                #
                # Caption size, used after tables and pictures
                #
                &output ("\\newcommand\\almlaafontsizecaption[1]{{\\normalsize\\fontsize{0.8em}{1em}\\selectfont{}#1}}");
                &output ("\n");
                #
                # Title size, used for the big title of the document
                #
                if ($PRINTED_FONT_SIZE_TITLE eq "")
                  {
                    &output ("\\newcommand\\almlaafonttitle[1]{{\\normalsize\\fontsize{40}{50}\\selectfont\\sffamily{}#1}}");
                    &output ("\n");
                  }
                else
                  {
                    &output ("\\newcommand\\almlaafonttitle[1]{{\\normalsize\\fontsize{$PRINTED_FONT_SIZE_TITLE}{$PRINTED_FONT_HEIGHT_TITLE}\\selectfont\\sffamily{}#1}}");
                    &output ("\n");
                  }
                #
                # More traditional font sizes
                #
                &output ("\\renewcommand{\\Huge}{\\fontsize{25}{30}\\selectfont}");
                &output ("\n");
                &output ("\\renewcommand{\\huge}{\\fontsize{20}{25}\\selectfont}");
                &output ("\n");
                &output ("\\renewcommand{\\LARGE}{\\fontsize{17}{22}\\selectfont}");
                &output ("\n");
                &output ("\\renewcommand{\\Large}{\\fontsize{14}{18}\\selectfont}");
                &output ("\n");
                &output ("\\renewcommand{\\large}{\\fontsize{12}{14}\\selectfont}");
                &output ("\n");
                &output ("\\renewcommand{\\small}{\\fontsize{9}{10}\\selectfont}");
                &output ("\n");
                &output ("\\renewcommand{\\scriptsize}{\\fontsize{7}{8}\\selectfont}");
                &output ("\n");
                #
                # Activate the default size.
                #
                &output ("\n");
                &output ("\\normalsize");
                &output ("\n");
                #
                # Define some standard distances.
                #
                &output ("\n");
                &output ("\\setlength\\smallskipamount{2pt}");
                &output ("\n");
                &output ("\\setlength\\medskipamount{4pt}");
                &output ("\n");
                &output ("\\setlength\\bigskipamount{6pt}");
                &output ("\n");
                &output ("\\setlength\\headheight{4.5mm}");
                &output ("\n");
                &output ("\\setlength\\headsep{6.5mm}");
                &output ("\n");
                &output ("\\setlength\\topskip{1.75mm}");
                &output ("\n");
                &output ("\\setlength\\footskip{10mm}");
                &output ("\n");
		#
                # Define new TeX debug file for anything.
		#
                &output ("\\newwrite\\almlssauxdebug");
                &output ("\n");
		#
                # Open the file: jobname + .debug.
		#
                &output ("\\immediate\\openout\\almlssauxdebug\\jobname.debug");
                &output ("\n");
		#
                # Write something for debugging purposes.
		#
                &output ("\\immediate\\write\\almlssauxdebug{BOF}");
                &output ("\n");
		#
                # Define new TeX report file for page references.
		#
                &output ("\\newwrite\\almlssauxpageref");
                &output ("\n");
		#
                # Open the file: jobname + .pageref.
		#
                &output ("\\immediate\\openout\\almlssauxpageref\\jobname.pageref");
                &output ("\n");
		#
                # Write something for debugging purposes.
                &output ("\\immediate\\write\\almlssauxpageref{BOF}");
                &output ("\n");
		#
                # Define new TeX report file for page locations.
		#
                &output ("\\newwrite\\almlssauxpagelocation");
                &output ("\n");
		#
                # Open the file: jobname + .pageloc.
		#
                &output ("\\immediate\\openout\\almlssauxpagelocation\\jobname.pageloc\n");
		#
                # Write something for debugging purposes.
		#
                &output ("\\immediate\\write\\almlssauxpagelocation{BOF}\n");
		#!  #
                #!  # Define new TeX report file for titles.
		#!  #
                #!  &output ("\\newwrite\\almlssauxtitles");
                #!  &output ("\n");
		#!  #
                #!  # Open the file: jobname + .titles.
		#!  #
                #!  &output ("\\immediate\\openout\\almlssauxtitles\\jobname.titles\n");
		#!  #
                #!  # Write something for debugging purposes.
		#!  #
                #!  &output ("\\immediate\\write\\almlssauxtitles{BOF}\n");
		#
                # Page break conditionally.
		#
                &output ("\n");
                &output ("\\newdimen\\almlyybreakpagelevel\n");
                &output ("\\setlength{\\almlyybreakpagelevel}{\\textheight}\n");
		#
                &output ("\\newcommand{\\almlazbreakpageiflessthen}[1]{");
                &output ("\\vspace{0pt}");
                &output ("\n");
                &output ("\n");
                &output ("\\ifdim \\pagetotal <\\textheight");
                &output ("\n");
                &output ("\\addtolength{\\almlyybreakpagelevel}{-#1}");
                &output ("\n");
                &output ("\\ifdim \\pagetotal >\\almlyybreakpagelevel");
                &output ("\n");
                &output ("\\clearpage");
                &output ("\n");
                &output ("\\fi");
                &output ("\n");
                &output ("\\addtolength{\\almlyybreakpagelevel}{#1}");
                &output ("\n");
                &output ("\\fi");
                &output ("\n");
                &output ("}");
                &output ("\n");
                #
                # Define the label functions.
                #
                &output ("% It is important to have the following definition all in one line\n");
                #
		&output ("\\newcommand{\\almlazlabel}[1]{\\immediate\\write\\almlssauxpageref{\\string\\almlazlabel{#1}{\\thepage}}}\n");
		#
                &output ("\\newcommand{\\almlazvisiblelabel}[1]");
                &output ("{");
                &output ("{");
                &output ("\\raisebox{0.25ex}");
                &output ("{");
                &output ("\\fontsize{0.75em}{1em}");
                &output ("\\selectfont");
                &output ("{");
                &output ("\\color{green}");
                &output ("\\fboxsep=0.4mm");
                &output ("\\fboxrule=0.2mm");
                &output ("\\fbox");
                &output ("{");
                &output ("\\color{blue}");
                &output ("\\itshape{}");
                &output ("\\bfseries{}");
            	&output ("#1");
                &output ("}");
                &output ("}");
                &output ("}");
                &output ("}");
                &output ("}");
                &output ("\n");
                #
                # Define the special command that will be used to put
                # page numbers.
                # This command is parsed from the alml front-end
                # \almlczpageref{0}{000}{label}
                #
                &output ("\\newcommand{\\almlczpageref}[3]{#2}\n");
		#
                # Define the tome.
		#
                &output ("\n");
                &output ("\\newcommand{\\almlaastartoftome}[1]\n");
                &output ("{\n");
                &output ("    % Clear and new page if not already done.\n");
                &output ("    \\almlzznewpage{}\n");
                &output ("    % If the page is odd, we can stay here.\n");
                &output ("    \\ifodd \\arabic{page}\n");
                &output ("        % Ok, start from here.\n");
                &output ("    \\else\n");
                &output ("        % Need to print something to be able to jump to another page.\n");
                &output ("        ~\n");
                &output ("        \\almlzznewpage{}\n");
                &output ("    \\fi\n");
                #
                if ($page_numbering eq "tome")
                  {
                    &output ("    % Reset page numbering.\n");
                    &output ("    \\addtocounter{pageoffset}{\\arabic{page}}");
                    &output ("\n");
                    &output ("    \\addtocounter{pageoffset}{-1}");
                    &output ("\n");
                    &output ("    \\pagenumbering{arabic}");
                    &output ("\n");
                    &output ("    \\setcounter{page}{1}");
                    &output ("\n");
                  }
                &output ("    % Define the header also if unused.\n");
                &output ("    \\markboth{}{}\n");
                &output ("    % Starting and following tome pages must be plain.\n");
                &output ("    \\almlzzstylepagenormal{}\n");
                &output ("    \\stepcounter{tome}\n");
                &output ("    % Save page location.\n");
                &output ("    \\immediate\\write\\almlssauxpagelocation{tome{\\arabic{tome}}pageoffset{\\arabic{pageoffset}}relativepage{\\arabic{page}}}\n");
                &output ("    % Print the titles.\n");
                &output ("    \\par\n");
                &output ("    \\begin{flushright}\n");
                &output ("        \\normalfont\n");
                if ($PRINTED_FONT_SIZE_H2 eq "")
                  {
                    &output ("        \\LARGE");
                  }
                else
                  {
                    &output ("        \\fontsize{$PRINTED_FONT_SIZE_H2}{$PRINTED_FONT_HEIGHT_H2}\\selectfont\n");
                  }
                if ($edition eq "")
                  {
                    &output ("        \\sffamily\\almlaabooktitle ~~\n");
                  }
                else
                  {
                    &output ("        \\sffamily\\almlaabooktitle ~~\n");
                  }
                &output ("        {\\fontsize{0.8em}{1em}\\selectfont $version $edition}\n");
                &output ("        \\par\n");
                &output ("        ");
                &output (ucfirst (&tome_def ()));
                &output ("~~\\rmfamily\\Roman{tome}\n");
                &output ("        \\par\n");
                if ($PRINTED_FONT_SIZE_TOMEHEADING eq "")
                  {
                    &output ("        \\Huge\n");
                  }
                else
                  {
                    &output ("        \\fontsize{$PRINTED_FONT_SIZE_TOMEHEADING}{$PRINTED_FONT_HEIGHT_TOMEHEADING}\\selectfont\n");
                  }
                &output ("        \\sffamily #1\n");
                &output ("    \\end{flushright}\n");
                &output ("    \\par\n");
                &output ("}\n");
                #
                # Define the part
                #
                &output ("\n");
                &output ("\\newcommand{\\almlaastartofpart}[1]\n");
                &output ("{\n");
                &output ("    % Clear and new page if not already done.\n");
                &output ("    \\almlzznewpage{}\n");
                &output ("    % If the page is odd, we can stay here.\n");
                &output ("    \\ifodd \\arabic{page}\n");
                &output ("        % Ok, start from here.\n");
                &output ("    \\else\n");
                &output ("        % Need to print something to be able to jump to another page.\n");
                &output ("        ~\n");
                &output ("        \\almlzznewpage{}\n");
                &output ("    \\fi\n");
                &output ("    % Define the header also if unused.\n");
                &output ("    \\markboth{}{}\n");
                &output ("    % Starting and following tome pages must be plain.\n");
                &output ("    \\almlzzstylepagenormal{}\n");
                &output ("    \\stepcounter{part}\n");
                &output ("    % Save page location.\n");
                &output ("    \\immediate\\write\\almlssauxpagelocation{part{\\arabic{part}}pageoffset{\\arabic{pageoffset}}relativepage{\\arabic{page}}}\n");
                &output ("    % Print the titles.\n");
                &output ("    \\par\n");
                &output ("    \\begin{flushright}\n");
                &output ("        \\normalfont\n");
                if ($PRINTED_FONT_SIZE_H2 eq "")
                  {
                    &output ("        \\LARGE");
                  }
                else
                  {
                    &output ("        \\fontsize{$PRINTED_FONT_SIZE_H2}{$PRINTED_FONT_HEIGHT_H2}\\selectfont\n");
                  }
                #
                # The work title cannot be inserted inside parts,
		# because parts can be obtained incorporating
		# document of other authors.
                #
                &output ("        ");
                &output (ucfirst (&part_def ()));
                &output ("~~\\rmfamily\\roman{part}\n");
                &output ("        \\par\n");
                if ($PRINTED_FONT_SIZE_H0 eq "")
                  {
                    &output ("        \\Huge\n");
                  }
                else
                  {
                    &output ("        \\fontsize{$PRINTED_FONT_SIZE_H0}{$PRINTED_FONT_HEIGHT_H0}\\selectfont\n");
                  }
                &output ("        \\sffamily #1\n");
                &output ("    \\end{flushright}\n");
                &output ("    \\par\n");
                &output ("}\n");
		#
                # Define the introduction page to appendixes.
		#
                &output ("\n");
                &output ("\\newcommand{\\almlzzstartofappendix}\n");
                &output ("{\n");
                &output ("    % Clear and new page if not already done.\n");
                &output ("    \\almlzznewpage{}\n");
                &output ("    % If the page is odd, we can stay here.\n");
                &output ("    \\ifodd \\arabic{page}\n");
                &output ("        % Ok, start from here.\n");
                &output ("    \\else\n");
                &output ("        % Need to print something to be able to jump to another page.\n");
                &output ("        ~\n");
                &output ("        \\almlzznewpage{}\n");
                &output ("    \\fi\n");
                &output ("    % Reset page numbering.\n");
                &output ("    \\addtocounter{pageoffset}{\\arabic{page}}");
                &output ("\n");
                &output ("    \\addtocounter{pageoffset}{-1}");
                &output ("\n");
                &output ("    \\pagenumbering{arabic}");
                &output ("\n");
                &output ("    \\setcounter{page}{1}");
                &output ("\n");
                &output ("    % Define the header also if unused.\n");
                &output ("    \\markboth{}{}\n");
                &output ("    % Save page location.\n");
                &output ("    \\immediate\\write\\almlssauxpagelocation{appendix{}pageoffset{\\arabic{pageoffset}}relativepage{\\arabic{page}}}\n");
                &output ("    % This page must be plain.\n");
                &output ("    \\thispagestyle{plain}\n");
                &output ("    % Print the title.\n");
                &output ("    \\begin{flushright}\n");
                &output ("        \\normalfont\n");
                if ($PRINTED_FONT_SIZE_H0 eq "")
                  {
                    &output ("        \\Huge\n");
                  }
                else
                  {
                    &output ("        \\fontsize{$PRINTED_FONT_SIZE_H0}{$PRINTED_FONT_HEIGHT_H0}\\selectfont\n");
                  }
                &output ("        \\sffamily\n");
                &output ("        ");
                &output (ucfirst (&appendixes_def ()));
                &output ("\\par\n");
                &output ("    \\end{flushright}\n");
                &output ("    % Terminate the current page.\n");
                &output ("    \\almlzzendofpage{}\n");
                &output ("    % Start now the appendix.\n");
                &output ("    \\appendix\n");
                &output ("}\n");
		#
                # Define sections.
		#
                &output ("\n");
                &output ("\\newcommand{\\almlaastartofsection}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{section}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H2 eq "")
                  {
                    &output ("    \\LARGE");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H2}{$PRINTED_FONT_HEIGHT_H2}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("\\arabic{chapter}.\\arabic{section} #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
                &output ("\n");
                &output ("\\newcommand{\\almlaastartofsectionunnumbered}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H2 eq "")
                  {
                    &output ("    \\LARGE");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H2}{$PRINTED_FONT_HEIGHT_H2}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("#1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
                &output ("\n");
		#
                &output ("\\newcommand{\\almlaastartofsectionfaq}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{section}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H2 eq "")
                  {
                    &output ("    \\LARGE");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H2}{$PRINTED_FONT_HEIGHT_H2}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("\\arabic{chapter}.\\arabic{section} #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
		#
                &output ("\\newcommand{\\almlaastartofsectionfaqunnumbered}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{section}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H2 eq "")
                  {
                    &output ("    \\LARGE");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H2}{$PRINTED_FONT_HEIGHT_H2}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("\\arabic{section} #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");

                &output ("\n");
                &output ("\\newcommand{\\almlaastartofsectionappendix}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{section}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H2 eq "")
                  {
                    &output ("    \\LARGE");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H2}{$PRINTED_FONT_HEIGHT_H2}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("\\Alph{chapter}.\\arabic{section} #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
                &output ("\n");
                &output ("\\newcommand{\\almlaastartofsubsection}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{subsection}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H3 eq "")
                  {
                    &output ("    \\Large");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H3}{$PRINTED_FONT_HEIGHT_H3}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("\\arabic{chapter}.\\arabic{section}.\\arabic{subsection} #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
                &output ("\n");
                &output ("\\newcommand{\\almlaastartofsubsectionunnumbered}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H3 eq "")
                  {
                    &output ("    \\Large");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H3}{$PRINTED_FONT_HEIGHT_H3}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("#1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
                &output ("\n");

                &output ("\\newcommand{\\almlaastartofsubsectionfaq}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{subsection}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_NORMAL eq "")
                  {
                    &output ("    \\normalsize");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_NORMAL}{$PRINTED_FONT_HEIGHT_NORMAL}\\selectfont");
                  }
                &output ("    \\normalfont\\bfseries\n");
                &output ("    % Define space above.\n");
                &output ("    \\vspace{0.5em}\n");
                &output ("    \\begin{flushleft}\n");
                
                # FAQH3 is like this:
                #
                # 1.2.3) What is... ?
                
                &output ("\\arabic{chapter}.\\arabic{section}.\\arabic{subsection}) #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");

                &output ("\\newcommand{\\almlaastartofsubsectionfaqunnumbered}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{subsection}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_NORMAL eq "")
                  {
                    &output ("    \\normalsize");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_NORMAL}{$PRINTED_FONT_HEIGHT_NORMAL}\\selectfont");
                  }
                &output ("    \\normalfont\\bfseries\n");
                &output ("    % Define space above.\n");
                &output ("    \\vspace{0.5em}\n");
                &output ("    \\begin{flushleft}\n");
                &output ("\\arabic{section}.\\arabic{subsection} #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");

                &output ("\n");
                &output ("\\newcommand{\\almlaastartofsubsectionappendix}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{subsection}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H3 eq "")
                  {
                    &output ("    \\Large");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H3}{$PRINTED_FONT_HEIGHT_H3}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("\\Alph{chapter}.\\arabic{section}.\\arabic{subsection} #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
                &output ("\n");
                &output ("\\newcommand{\\almlaastartofsubsubsection}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{subsubsection}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H4 eq "")
                  {
                    &output ("    \\large");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H4}{$PRINTED_FONT_HEIGHT_H4}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("\\arabic{chapter}.\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection} #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
                &output ("\n");
                &output ("\\newcommand{\\almlaastartofsubsubsectionunnumbered}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H4 eq "")
                  {
                    &output ("    \\large");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H4}{$PRINTED_FONT_HEIGHT_H4}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("#1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
                &output ("\n");
                &output ("\\newcommand{\\almlaastartofsubsubsectionappendix}[1]\n");
                &output ("{\n");
                &output ("    % This paragraph is important, otherwise,\n");
                &output ("    % the other paragraphs will have strange spaceing.\n");
                &output ("    \\par\n");
                &output ("    % Increment section counter.\n");
                &output ("    \\stepcounter{subsubsection}\n");
                &output ("    % Change font.\n");
                if ($PRINTED_FONT_SIZE_H4 eq "")
                  {
                    &output ("    \\large");
                  }
                else
                  {
                    &output ("    \\fontsize{$PRINTED_FONT_SIZE_H4}{$PRINTED_FONT_HEIGHT_H4}\\selectfont");
                  }
                &output ("    \\normalfont\\sffamily\n");
                &output ("    \\begin{flushleft}\n");
                &output ("\\Alph{chapter}.\\arabic{section}.\\arabic{subsection}.\\arabic{subsubsection} #1\n");
                &output ("    \\end{flushleft}\n");
                &output ("    % Reset font.\n");
                &output ("    \\normalfont\\normalsize\n");
                &output ("}\n");
                &output ("\n");

                # Font selection.
                &output ("\n");
                # Use a better font.
                &output ("\\renewcommand{\\sfdefault}{pag} % newcent.sty\n");
                &output ("\\renewcommand{\\rmdefault}{ptm} % times.sty\n");
                &output ("\\renewcommand{\\ttdefault}{pcr} % times.sty\n");

                # Incorporate local configuration.

                if (-e ".alml-tex.sty")
                  {
                    &output ("\n");
                    open (TEXCONFIG, "<:utf8", ".alml-tex.sty");
                    while ($line = <TEXCONFIG>)
                      {
                        &output ("$line");
                      }
                    close (TEXCONFIG);
                  }

                # Use headings per default.

                &output ("\n");
                &output ("\\pagestyle{myheadings}\n");

                # print @frenchspacing only if supplied.

                if ($DOCUMENT_SPACING eq "french"
                    | $DOCUMENT_SPACING eq "uniform")
                  {
                    &output ("\n");
                    &output ("\\frenchspacing\n");
                  }
                
                # Start the document and then the title page.
                
                &output ("\n");
                &output ("\\begin{document}\n");
                
                # Select the language.
                
                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}\n");
                #&output ("\\hyphenation{"
                #         . &latex_language_name ($CURRENT_LANGUAGE)
                #        . "}\n");

                
                # Begin the front cover page.
                
                &output ("\n\\almlzzstylepagenormal{}");

                &output ("\n\\begin{titlepage}");
                &output ("\n");
                
                # Don't put a \null command, otherwise an empty
                # paragraph will be placed here.
                
                #&output ("\\null");
                &output ("\n\\vspace{1cm}");
                if ($front_cover_top ne "")
                  {
                    &output ("$front_cover_top");
                  }
                &output ("\n");
                &output ("\\rule{\\linewidth}{5pt}");
                &output ("\n");
                &output ("\n");
                &output ("\\almlaafonttitle{$title}");
                &output ("\n");
                &output ("\n");
                &output ("\\rule{\\linewidth}{5pt}");
                &output ("\n");
                if ($#subtitles > -1)
                  {
                    &output ("\n\\begin{center}");
                    &output ("\n\\large\\bfseries\\sffamily");
                    for ($n = 0 ; $n <= $#subtitles ; $n++)
                      { 
                        if ($n > 0)
                          {
                            &output ("\n\\par");
                          }
                        &output ("\n$subtitles[$n]");
                      }
                    &output ("\n\\end{center}\n");
                    &output ("\n\\rule{\\linewidth}{2pt}");
                  }
                &output ("\n\\begin{flushright}");
                &output ("\n\\large\\sffamily ");
                for ($n = 0 ; $n <= $#authors ; $n++)
                  { 
                    if ($n > 0)
                      {
                        &output ("\n\\par\n");
                      }
                    &output ("$authors[$n]");
                  }
                &output ("\n\\end{flushright}\n");
                &output ("\n\\vspace{0.5cm}");
                &output ("\n\\begin{flushright}");
                if ($edition eq "")
                  {
                    &output ("\n\\Huge\\sffamily $version $date");
                  }
                else
                  {
                    &output ("\n\\Huge\\sffamily $version $edition");
                  }
                &output ("\n\\end{flushright}\n");
                &output ("\n");
                if ($front_cover_bottom ne "")
                  {
                    &output ("$front_cover_bottom");
                  }
                &output ("\n\\end{titlepage}");
                #
                &output ("\n\\setcounter{footnote}{0}");
                &output ("\n\\almlzzendofpage{}");
                #
                &output ("\n\\almlzzstylepagenormal{}\n");
                #
                if ($extra_text_before_legal ne "")
                  {
                    &output ("$extra_text_before_legal");
                  }
                #
                if ($legal_text ne "")
                  {
                    &output ("\\almlzzvfill{}\n");
                    &output ("$legal_text");
                  }
                #
                if ($dedications ne "")
                  {
                    &output ("\\almlzzendofpage{}\n");
                    &output ("$dedications");
                  }
                #
                if ($extra_text_after_dedications ne "")
                  {
                    &output ("\\almlzzendofpage{}\n");
                    &output ("$extra_text_after_dedications");
                  }
                #
                # See if it is necessary to print footnotes.
                #
                &latex_standard_footnotes ();
                #
                &output ("\n");
                #
                # Main table of contents.
                #
                # $contents_list[x][0]  level                   -1..4
                # $contents_list[x][1]  tome number
                # $contents_list[x][2]  part number
                # $contents_list[x][3]  chapter number          
                # $contents_list[x][4]  level-description       1.2.3
                # $contents_list[x][5]  title
                # $contents_list[x][6]  html page number
                # $contents_list[x][7]  h1 section absolute counter
                # $contents_list[x][8]  document position: head,
                #                         intro, body, appendix,
                #                         index
                #
                if ($main_contents)
                  {
                    #
                    # The main table of contents is required,
                    # with a label "toc" for HTML and PDF
                    # external link.
                    #
                    &diag_output (sprintf (gettext ("%s:%s: inserting the main contents.\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME), $V_SUPER);
                    #
                    &output ("\n");
                    &output ("\\almlzzendofpage{}");
                    &output ("\n");
                    &output ("\\hypertarget{toc}{}");
                    &output ("{\\Huge\\sffamily $contents_title}");
                    &output ("\n");
                    #
                    # latex_table_of_contents (TOC_LEVEL,
                    #                          SECTION,
                    #                          CONTENTS_LEVELS,
                    #                          CONTENTS_NOPAGES,
                    #                          TOC_PAGE_NUMBERING)
                    #
                    &latex_table_of_contents (-9999,
                                              0,
                                              $contents_levels,
                                              $main_contents_nopages,
                                              $page_numbering)
                  }
              }
          }
        elsif ($element eq "ADMIN")
          {
            #
            # the ADMIN element is scanned at the very first pass,
            # identical for all backends.
            #
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Discard output.
                &pop_output ();
              }
          }
        elsif ($element eq "TITLE")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output (if any), considering that it should
                # be clean.
                #
                $title = &pop_output ();
              }
          }
        elsif ($element eq "SUBTITLE")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $subtitles[$#subtitles+1] = &pop_output ();
              }
          }
        elsif ($element eq "ABSTRACT")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $abstract = &pop_output ();
                #
                # With %block; elements, there is a line feed character
                # at the top of the string. I don't know why.
                # Anyway, we have to delete this extra line feed.
                #
                $abstract =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "AUTHOR")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $authors[$#authors+1] = &pop_output ();
              }
          }
        elsif ($element eq "DATE")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $date = &pop_output ();
              }
          }
        elsif ($element eq "EDITION")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $edition = &pop_output ();
              }
          }
        elsif ($element eq "VERSION")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $version = &pop_output ();
              }
          }
        elsif ($element eq "FRONTCOVERTOP")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $front_cover_top = &pop_output ();
                #
                # With %block; elements, there is a line feed character
                # at the top of the string. I don't know why.
                # Anyway, we have to delete this extra line feed.
                #
                $front_cover_top =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "FRONTCOVERBOTTOM")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $front_cover_bottom = &pop_output ();
                #
                # With %block; elements, there is a line feed character
                # at the top of the string. I don't know why.
                # Anyway, we have to delete this extra line feed.
                #
                $front_cover_bottom =~ s/^\n?(.*)$/$1/s;
                #
              }
          }
        elsif ($element eq "TEXTBEFORELEGAL")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $extra_text_before_legal = &pop_output ();
                #
                # With %block; elements, there is a line feed character
                # at the top of the string. I don't know why.
                # Anyway, we have to delete this extra line feed.
                #
                $extra_text_before_legal =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "LEGAL")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $legal_text = &pop_output ();
                #
                # With %block; elements, there is a line feed character
                # at the top of the string. I don't know why.
                # Anyway, we have to delete this extra line feed.
                #
                $legal_text =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "DEDICATIONS")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $dedications = &pop_output ();
                #
                ## With %block; elements, there is a line feed character
                ## at the top of the string. I don't know why.
                ## Anyway, we have to delete this extra line feed.
                #$dedications =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "TEXTAFTERDEDICATIONS")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $extra_text_after_dedications = &pop_output ();
                #
                # With %block; elements, there is a line feed character
                # at the top of the string. I don't know why.
                # Anyway, we have to delete this extra line feed.
                #
                $extra_text_after_dedications =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "MAINCONTENTS")
          {
            if ($type eq "start")
              {
                my ($nopages) = lc (${$attributes}{'NOPAGES'});
                #
                # Activate main table of contents.
                # This is used to know how to handle the html page counter.
                #
                $main_contents = 1;
                if ($nopages eq "true")
                  {
                    $main_contents_nopages = 1;
                  }
                else
                  {
                    $main_contents_nopages = 0;
                  }
                #
                # Save how many levels are required.
                #
                $contents_levels = ${$attributes}{'LEVELS'};
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $contents_title = &pop_output ();
              }
          }
        elsif ($element eq "INTRO")
          {
            if ($type eq "start")
              {
                #
                # Save the information.
                #
                $document_position = "intro";
              }
            else
              {
                #
                # Do nothing;
                #
                ;
              }
          }
        elsif ($element eq "BODY")
          {
            if ($type eq "start")
              {
                #
                # See if it is necessary to print footnotes.
                #
                &latex_standard_footnotes ();
                #
                # Save the information.
                #
                $document_position = "body";
                #
                # Start the body.
                #
                &output ("\n\\almlzzstartofbody{}");
              }
            else
              {
                #
                # Do nothing;
                #
                ;
              }
          }
        elsif ($element eq "APPENDIX")
          {
            if ($type eq "start")
              {
                #
                # See if it is necessary to print footnotes.
                #
                &latex_standard_footnotes ();
                #
                # Save the information.
                #
                $document_position = "appendix";
                #
                # Set appendix present.
                #
                $tome_present = 0;
                $part_present = 0;
                $appendix_present = 1;
                $index_present = 0;
                $intro_present = 0;
                #
                # Tell that the appendix starts.
                #
                &output ("\n\\almlzzstartofappendix{}\n");
              }
            else
              {
                #
                # Do nothing;
                #
                ;
              }
          }
        elsif ($element eq "INDEX")
          {
            if ($type eq "start")
              {
                #
                # See if it is necessary to print footnotes.
                #
                &latex_standard_footnotes ();
                #
                # Save the information.
                #
                $document_position = "index";
                #
                # Set index present.
                #
                $tome_present = 0;
                $part_present = 0;
                $index_present = 1;
                $appendix_present = 0;
                $intro_present = 0;
                #
                # Typeset.
                #
                &output ("% Clear and new page if not already done.");
                &output ("\n");
                &output ("\\almlzznewpage{}");
                &output ("\n");
                &output ("% If the page is odd, we can stay here.");
                &output ("\n");
                &output ("\\ifodd \\arabic{page}");
                &output ("\n");
                &output ("    % Ok, start from here.");
                &output ("\n");
                &output ("\\else");
                &output ("\n");
                &output ("    % Need to print something to be able to jump to another page.");
                &output ("\n");
                &output ("    ~");
                &output ("\n");
                &output ("    \\almlzznewpage{}");
                &output ("\n");
                &output ("\\fi");
                &output ("\n");
                #
                if ($page_numbering eq "plain")
                  {
                    #
                    # Nothing else to do;
                    #
                    ;
                  }
                else
                  {
                    &output ("\\addtocounter{pageoffset}{\\arabic{page}}");
                    &output ("\n");
                    &output ("\\addtocounter{pageoffset}{-1}");
                    &output ("\n");
                    &output ("\\almlzzstylepagenormal{}");
                    &output ("\n");
                    &output ("\\pagenumbering{roman}");
                    &output ("\n");
                    &output ("\\setcounter{page}{1}");
                    &output ("\n");
                  }
                #
                &output ("% Save page location.");
                &output ("\n");
                &output ("\\immediate\\write\\almlssauxpagelocation{index{}pageoffset{\\arabic{pageoffset}}relativepage{\\arabic{page}}}");
                &output ("\n");
              }
            else
              {
                #
                # Do nothing;
                #
                ;
              }
          }
        elsif ($element eq "NAVLINK")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                &pop_output ();
              }
          }
        elsif ($element eq "TOMEHEADING")
          {
            if ($type eq "start")
              {
                #
                # See if it is necessary to print footnotes.
                #
                &latex_standard_footnotes ();
                #
                # Increment some counters.
                #
                $contents_counter++;
                $cross_reference_counter++;
                #
                # Save anchor information.
                #
                $tome_heading_id = ${$attributes}{'ID'};
                $last_anchor_id = $tome_heading_id;
                $last_bookmark = ${$attributes}{'BOOKMARK'};
                #
                # Save and set language information.
                #
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $DOCUMENT_LANGUAGE;
                  }
                $TOME_LANGUAGE = $CURRENT_LANGUAGE;
                $PART_LANGUAGE = $CURRENT_LANGUAGE;
                $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                #
                # Here start a tome. Do some preparations.
                # Tome happens only inside a body.
                #
                $current_level = "tome";
                $current_level_by_number = -1;
                $tome++;
                $tome_present = 1;
                $part_present = 0;
                $appendix_present = 0;
                $index_present = 0;
                $intro_present = 0;
                #
                # tables and figures are reset.
                #
                $table = 0;
                $figure = 0;
                $listing = 0;
                $example = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
                #
                # part counter doesnt change.
                # chapter counter doesnt change.
                #
                $sect1 = 0;             
                $sect2 = 0;             
                $sect3 = 0;             
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
		#
		my ($human_readable_file_name) = "";
                #
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
                #
                $tome_heading_title = &pop_output ();
                $last_heading_title = &latex_header_clean ($tome_heading_title);
                #
                # Try to get the bookmark, also if it was't given.
		#
                if ($last_bookmark eq "")
                  {
                    $last_bookmark =
                      &latex_pdf_bookmark_safe_correction ($last_heading_title);
                  }
		#
		# Try to get a human readable file name from the title.
		# We get only the root file name, because extention is
		# not absolutely decided at this stage.
		#
		$human_readable_file_name = &human_readable_file_name_from_pdf_bookmark_header ("$last_bookmark");
                #
                # Print it.
		#
                &output ("\n");
                &output ("\n");
                &output ("% <". "$element" . ">");
                &output ("\n");
		#
		# Save the title inside the pagelocation file.
		#
                &output ("% Save title.");
                &output ("\n");
                &output ("\\immediate\\write\\almlssauxpagelocation{tometitle $tome $human_readable_file_name}");
                &output ("\n");
                #
                # Print the tome header and select the language.
		#
                &output ("\n");
                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}\n");
                &output ("\\almlaastartoftome{");
                &output ("\\almlazlabel{almltitle$contents_counter}");
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");
                &output ("$tome_heading_title");
                &output ("}\n");
                &output ("\\hypertarget{almltitle$contents_counter}{}");
                #
                # The following strange code is taken from the Dvipdfm
                # documentation.
                #
                &output ("\\almlbzpdfbookmark{"
                         . &latex_pdf_bookmark_level (-1)
                         . "}{"
                         . ucfirst (&tome_def ())
                         . " "
                         . &current_section_number ()
                         . " "
                         . $last_bookmark
                         . "}");
		#
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
                &output ("\n");
                &output ("% </". "$element" . ">\n");
		#
                &diag_output (sprintf (gettext ("%s:%s: %s\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       &current_section_number_complete ()), $V_NORMAL);
              }
          }
        elsif ($element eq "H0")
          {
            if ($type eq "start")
              {
                #
                # See if it is necessary to print footnotes.
                #
                &latex_standard_footnotes ();
                #
                # Increment some counters.
                #
                $contents_counter++;
                $cross_reference_counter++;
                #
                # Save anchor information.
                #
                $h0_id = ${$attributes}{'ID'};
                $last_anchor_id = $h0_id;
                $last_bookmark = ${$attributes}{'BOOKMARK'};
                #
                # Save and set language information.
                #
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $TOME_LANGUAGE;
                  }
                $PART_LANGUAGE = $CURRENT_LANGUAGE;
                $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                #
                # Here start a part. Do some preparations.
                # Tome happens only inside a body.
                #
                $current_level = "part";
                $current_level_by_number = 0;
                $part++;
                $part_present = 1;
                #
                # tables and figures are reset.
                #
                $table = 0;
                $figure = 0;
                $listing = 0;
                $example = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
                #
                # chapter counter doesnt change.
                #
                $sect1 = 0;             
                $sect2 = 0;             
                $sect3 = 0;             
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
		#
		my ($human_readable_file_name) = "";
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
                #
                $H0_title = &pop_output ();
                $last_heading_title = &latex_header_clean ($H0_title);
                #
                # Try to get the bookmark, also if it was't given.
                #
                if ($last_bookmark eq "")
                  {
                    $last_bookmark =
                      &latex_pdf_bookmark_safe_correction ($last_heading_title);
                  }
		#
		# Try to get a human readable file name from the title.
		# We get only the root file name, because extention is
		# not absolutely decided at this stage.
		#
		$human_readable_file_name = &human_readable_file_name_from_pdf_bookmark_header ("$last_bookmark");
		#
                # Start printing.
		#
                &output ("\n");
                &output ("\n");
                &output ("% <". "$element" . ">");
                &output ("\n");
		#
		# Save the title inside the pagelocation file.
		#
                &output ("% Save title.");
                &output ("\n");
                &output ("\\immediate\\write\\almlssauxpagelocation{parttitle $part $human_readable_file_name}");
                &output ("\n");
		#
                # Print the part header and select the language
		#
                &output ("\n");
                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}\n");
                &output ("\\almlaastartofpart{");
                &output ("\\almlazlabel{almltitle$contents_counter}");
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");
                &output ("$H0_title");
                &output ("}\n");
                &output ("\\hypertarget{almltitle$contents_counter}{}");
                #
                # The following strange code is taken from the Dvipdfm
                # documentation.
                #
                &output ("\\almlbzpdfbookmark{"
                         . &latex_pdf_bookmark_level (0)
                         . "}{"
                         . ucfirst (&part_def ())
                         . " "
                         . &current_section_number ()
                         . " "
                         . $last_bookmark
                         . "}");
		#
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
                &output ("\n");
                &output ("% </". "$element" . ">\n");
		#
                &diag_output (sprintf (gettext ("%s:%s: %s\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       &current_section_number_complete ()), $V_NORMAL);
              }
          }
        elsif ($element eq "H1"
               || $element eq "SLIDEH1"
               || $element eq "SHEETH1"
               || $element eq "UNNUMBEREDH1")
          {
            if ($type eq "start")
              {
                #
                # See if it is necessary to print footnotes.
                #
                &latex_standard_footnotes ();
                #
                # Increment some counters.
                #
                $contents_counter++;
                $cross_reference_counter++;
                #
                # Save anchor information.
                #
                $h1_id = ${$attributes}{'ID'};
                $last_anchor_id = $h1_id;
                $last_bookmark = ${$attributes}{'BOOKMARK'};
		#
                # Save and set language information.
		#
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $PART_LANGUAGE;
                  }
                $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                #
                # Here start a chapter. Do some preparations.
                #
                $current_level_by_number = 1;
                #
                # tables and figures are reset.
                #
                $table = 0;
                $figure = 0;
                $listing = 0;
                $example = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
		#
		#
		#
                if ($element eq "UNNUMBEREDH1")
                  {
                    $current_level = "unnumbered-h1";
                    $unnumbered_chapter++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;         
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "intro")
                  {
                    $current_level = "intro-h1";
                    $intro++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;         
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "body")
                  {
                    $current_level = "chapter-h1";
                    $chapter++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;         
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "appendix")
                  {
                    $current_level = "appendix-h1";
                    $appendix++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h1";
                    $index++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;
                    $sect2 = 0;
                    $sect3 = 0;
                  }

                
                # Send the output stream to a new stack level.        
                

                &push_output ();
              }
            else
              {
                #
                # Push inside also labels
		#
                &output ("\\almlazlabel{almltitle$contents_counter}");
                &output ("\\hypertarget{almltitle$contents_counter}{}");
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
                #
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $H1_title = &pop_output ();
                $last_heading_title = &latex_header_clean ($H1_title);
                #
                # Try to get the bookmark, also if it was't given.
                #
                if ($last_bookmark eq "")
                  {
                    $last_bookmark =
                      &latex_pdf_bookmark_safe_correction ($last_heading_title);
                  }

                
                # The label used to generate the PDF bookmark is
                # inserted inside the title variable.
                

                $H1_title = "\\almlbzpdfbookmark{"
                            . &latex_pdf_bookmark_level (1)
                            . "}{"
                            . &current_section_number ()
                            . " "
                            . $last_bookmark
                            . "}"
                            . $H1_title;

                
                # Start the section
                

                &output ("\n");
                &output ("\n");
                &output ("% <". "$element" . ">\n");

                
                # Print the chapter header.
                

                if ($element eq "UNNUMBEREDH1")
                  {
                    &output ("\n");
                    &output ("\\selectlanguage{"
                             . &latex_language_name ($CURRENT_LANGUAGE)
                             . "}\n");

                    &latex_chapter_unnumbered ($H1_title, $page_numbering);
                  }
                elsif ($document_position eq "intro")
                  {
                    &output ("\n");
                    &output ("\\selectlanguage{"
                             . &latex_language_name ($CURRENT_LANGUAGE)
                             . "}\n");

                    &latex_chapter_intro ($H1_title);
                  }
                elsif ($document_position eq "appendix")
                  {
                    &output ("\n");
                    &output ("\\selectlanguage{"
                             . &latex_language_name ($CURRENT_LANGUAGE)
                             . "}\n");

                    &latex_chapter_appendix ($H1_title, $page_numbering);
                  }
                elsif ($document_position eq "index")
                  {
                    &output ("\n");
                    &output ("\\selectlanguage{"
                             . &latex_language_name ($CURRENT_LANGUAGE)
                             . "}\n");

                    &latex_chapter_index ($H1_title);
                  }
                else
                  {
                    if ($element eq "SLIDEH1")
                      {
                        &output ("\n");
                        &output ("\\selectlanguage{"
                                 . &latex_language_name ($CURRENT_LANGUAGE)
                                 . "}\n");

                        # Presentation slide or overhead transparency
                        &latex_chapter_presentation_slide ($H1_title);
                      }
                    elsif ($element eq "SHEETH1")
                      {
                        &output ("\n");
                        &output ("\\selectlanguage{"
                             . &latex_language_name ($CURRENT_LANGUAGE)
                             . "}\n");

                        # Summary sheet
                        &latex_chapter_summary_sheet ($H1_title);
                      }
                    else
                      {
                        &output ("\n");
                        &output ("\\selectlanguage{"
                             . &latex_language_name ($CURRENT_LANGUAGE)
                             . "}\n");

                        # Usual chapter
                        &latex_chapter_numbered ($H1_title, $page_numbering);
                      }
                  }
                &output ("\n");
                &output ("% </". "$element" . ">\n");

                &diag_output (sprintf (gettext ("%s:%s: %s\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       &current_section_number_complete ()), $V_NORMAL);
              }
          }
        elsif ($element eq "H2"
               || $element eq "FAQH2")
          {
            if ($type eq "start")
              {

                
                # Increment some counters.
                

                $contents_counter++;
                $cross_reference_counter++;

                
                # Save anchor information.
                

                $h2_id = ${$attributes}{'ID'};
                $last_anchor_id = $h2_id;
                $last_bookmark = ${$attributes}{'BOOKMARK'};

                
                # Here start a chapter. Do some preparations.
                

                $current_level_by_number = 2;
                if ($document_position eq "intro")
                  {
                    $current_level = "intro-h2";
                    $sect1++;           
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "body")
                  {
                    # If previously was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h2";
                      }
                    else
                      {
                        $current_level = "chapter-h2";
                      }
                    $sect1++;           
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "appendix")
                  {
                    # If previously was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h2";
                      }
                    else
                      {
                        $current_level = "appendix-h2";
                      }
                    $sect1++;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h2";
                    $sect1++;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
                # Send the output stream to a new stack level.        
                &push_output ();
              }
            else
              {
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
                #
                $H2_title = &pop_output ();
                $last_heading_title = &latex_header_clean ($H2_title);
                #
                # Try to get the bookmark, also if it was't given.
                #
                if ($last_bookmark eq "")
                  {
                    $last_bookmark =
                      &latex_pdf_bookmark_safe_correction ($last_heading_title);
                  }

                &output ("\n");
                &output ("\n");
                &output ("% <". "$element" . ">");
                &output ("\n");
                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}");
                &output ("\n");
                &output ("\\almlazbreakpageiflessthen{4cm}");
                &output ("\n");
                #
                # Start a \samepage block.
                #
                &output ("{\\samepage\n");
                $header_to_be_closed = 1;
                $next_element_after_header_to_be_closed = "";
                #
                # Print the section header.
                #
                if ($element eq "FAQH2"
                    && ($document_position eq "intro"
                        || $document_position eq "index"
                        || $current_level eq "unnumbered-h2"))
                  {
                    # This is an "unnumbered" FAQ section.
                    &output ("\\almlaastartofsectionfaqunnumbered{");
                  }
                elsif ($element eq "FAQH2")
                  {
                    # This is a normal FAQ section.
                    &output ("\\almlaastartofsectionfaq{");
                  }
                elsif ($current_level eq "unnumbered-h2")
                  {
                    &output ("\\almlaastartofsectionunnumbered{");
                  }
                elsif ($document_position eq "intro")
                  {
                    &output ("\\almlaastartofsectionunnumbered{");
                  }
                elsif ($document_position eq "appendix")
                  {
                    &output ("\\almlaastartofsectionappendix{");
                  }
                else
                  {
                    &output ("\\almlaastartofsection{");
                  }
                &output ("\\almlazlabel{almltitle$contents_counter}");
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");

                &output ("\\almlbzpdfbookmark{"
                         . &latex_pdf_bookmark_level (2)
                         . "}{"
                         . &current_section_number ()
                         . " "
                         . $last_bookmark
                         . "}");

                &output ("$H2_title");
                &output ("}\n");
                &output ("\\hypertarget{almltitle$contents_counter}{}");
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
                &output ("\n");
                &output ("% </". "$element" . ">\n");
              }
          }
        elsif ($element eq "H3"
               || $element eq "FAQH3")
          {
            if ($type eq "start")
              {
		#
                # Increment some counters.
                #
                $contents_counter++;
                $cross_reference_counter++;
                #
                # Save anchor information.
                #
                $h3_id = ${$attributes}{'ID'};
                $last_anchor_id = $h3_id;
                $last_bookmark = ${$attributes}{'BOOKMARK'};
                #
                # Here start a chapter. Do some preparations.
                #
                $current_level_by_number = 3;
                if ($document_position eq "intro")
                  {
                    $current_level = "intro-h3";
                    $sect2++;           
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "body")
                  {
		    #
                    # If previously was unnumbered, remains unnumbered.
		    #
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h3";
                      }
                    else
                      {
                        $current_level = "chapter-h3";
                      }
                    $sect2++;           
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "appendix")
                  {
		    #
                    # If previously was unnumbered, remains unnumbered.
		    #
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h3";
                      }
                    else
                      {
                        $current_level = "appendix-h3";
                      }
                    $sect2++;
                    $sect3 = 0;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h3";
                    $sect2++;
                    $sect3 = 0;
                  }
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
                #
                $H3_title = &pop_output ();
                $last_heading_title = &latex_header_clean ($H3_title);
                #
                # Try to get the bookmark, also if it was't given.
                #
                if ($last_bookmark eq "")
                  {
                    $last_bookmark =
                      &latex_pdf_bookmark_safe_correction ($last_heading_title);
                  }
                #
                # FAQH3 is like this:
                #
                # 1.2.3) What is... ?
                #
                &output ("\n");
                &output ("\n");
                &output ("% <". "$element" . ">\n");
                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}");
                &output ("\n");
                &output ("\\almlazbreakpageiflessthen{4cm}");
                &output ("\n");
                #
                # Start a \samepage block.
                #
                &output ("{\\samepage\n");
                $header_to_be_closed = 1;
                $next_element_after_header_to_be_closed = "";
                #
                # Print the subsection header.
                #
                if ($element eq "FAQH3"
                    && ($document_position eq "intro"
                        || $document_position eq "index"
                        || $current_level eq "unnumbered-h3"))
                  {
		    #
                    # This is an "unnumbered" FAQ subsection.
		    #
                    &output ("\\almlaastartofsubsectionfaqunnumbered{");
                  }
                elsif ($element eq "FAQH3")
                  {
		    #
                    # This is a normal FAQ section.
		    #
                    &output ("\\almlaastartofsubsectionfaq{");
                  }
                elsif ($current_level eq "unnumbered-h3")
                  {
                    &output ("\\almlaastartofsubsectionunnumbered{");
                  }
                elsif ($document_position eq "intro")
                  {
                    &output ("\\almlaastartofsubsectionunnumbered{");
                  }
                elsif ($document_position eq "appendix")
                  {
                    &output ("\\almlaastartofsubsectionappendix{");
                  }
                else
                  {
                    &output ("\\almlaastartofsubsection{");
                  }
                &output ("\\almlazlabel{almltitle$contents_counter}");
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");
                &output ("\\almlbzpdfbookmark{"
                         . &latex_pdf_bookmark_level (3)
                         . "}{"
                         . &current_section_number ()
                         . " "
                         . $last_bookmark
                         . "}");
                &output ("$H3_title");
                &output ("}\n");
                &output ("\\hypertarget{almltitle$contents_counter}{}");
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
                &output ("\n");
                &output ("% </". "$element" . ">\n");
              }
          }
        elsif ($element eq "H4")
          {
            if ($type eq "start")
              {

                
                # Increment some counters.
                

                $contents_counter++;
                $cross_reference_counter++;

                
                # Save anchor information.
                

                $h4_id = ${$attributes}{'ID'};
                $last_anchor_id = $h4_id;
                $last_bookmark = ${$attributes}{'BOOKMARK'};

                
                # Here start a chapter. Do some preparations.
                

                $current_level_by_number = 4;
                if ($document_position eq "intro")
                  {
                    $current_level = "intro-h4";
                    $sect3++;           
                  }
                elsif ($document_position eq "body")
                  {
                    # If previously was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h4";
                      }
                    else
                      {
                        $current_level = "chapter-h4";
                      }
                    $sect3++;
                  }
                elsif ($document_position eq "appendix")
                  {
                    # If previously was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h4";
                      }
                    else
                      {
                        $current_level = "appendix-h4";
                      }
                    $sect3++;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h4";
                    $sect3++;
                  }

                
                # Send the output stream to a new stack level.        
                

                &push_output ();
              }
            else
              {
                #
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $H4_title = &pop_output ();
                $last_heading_title = &latex_header_clean ($H4_title);
                #
                # Try to get the bookmark, also if it was't given.
                #
                if ($last_bookmark eq "")
                  {
                    $last_bookmark =
                      &latex_pdf_bookmark_safe_correction ($last_heading_title);
                  }
		#
                &output ("\n");
                &output ("\n");
                &output ("% <". "$element" . ">\n");
                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}");
                &output ("\n");
                &output ("\\almlazbreakpageiflessthen{4cm}");
                &output ("\n");
                #
                # Start a \samepage block.
                #
                &output ("{\\samepage\n");
                $header_to_be_closed = 1;
                $next_element_after_header_to_be_closed = "";
                #
                # Print the chapter header.
                #
                if ($current_level eq "unnumbered-h4")
                  {
                    &output ("\\almlaastartofsubsubsectionunnumbered{");
                  }
                elsif ($document_position eq "intro")
                  {
                    &output ("\\almlaastartofsubsubsectionunnumbered{");
                  }
                elsif ($document_position eq "appendix")
                  {
                    &output ("\\almlaastartofsubsubsectionappendix{");
                  }
                else
                  {
                    &output ("\\almlaastartofsubsubsection{");
                  }
                &output ("\\almlazlabel{almltitle$contents_counter}");
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");
                &output ("\\almlbzpdfbookmark{"
                         . &latex_pdf_bookmark_level (4)
                         . "}{"
                         . &current_section_number ()
                         . " "
                         . $last_bookmark
                         . "}");
                &output ("$H4_title");
                &output ("}\n");
                &output ("\\hypertarget{almltitle$contents_counter}{}");
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
                &output ("\n");
                &output ("% </". "$element" . ">\n");
              }
          }
        elsif ($element eq "DIV")
          {
            if ($type eq "start")
              {
                #
                # Save and set language information.
		#
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $CHAPTER_LANGUAGE;
                  }
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                #
                # Insert LaTeX code.
		#
                &output ("\n");
                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}");
                &output ("\n");
    		#
              }
            else
              {
                #
                # Restore external language.
		#
                $CURRENT_LANGUAGE = $CHAPTER_LANGUAGE;
                #
                # Insert LaTeX code.
		#
                &output ("\n");
                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}");
                &output ("\n");
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;

              }
          }
        elsif ($element eq "SPAN")
          {
            if ($type eq "start")
              {
                
                # Save and set language information.

                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $DIV_LANGUAGE;
                  }
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;


                
                # Insert LaTeX code.
                

                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}");
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
        
              }
            else
              {

                
                # Restore external language.
                

                $CURRENT_LANGUAGE = $DIV_LANGUAGE;


                
                # Insert LaTeX code.
                

                &output ("\\selectlanguage{"
                         . &latex_language_name ($CURRENT_LANGUAGE)
                         . "}");
              }
          }
        elsif ($element eq "EXTRAMAINCONTENTS")
          {
            if ($type eq "start")
              {
                my ($nopages)           = lc (${$attributes}{'NOPAGES'});
                my ($contents_levels)   = ${$attributes}{'LEVELS'};

                if ($nopages eq "true")
                  {
                    $nopages = 1;
                  }
                else
                  {
                    $nopages = 0;
                  }

                
                # latex_table_of_contents (TOC_LEVEL,
                #                          SECTION,
                #                          CONTENTS_LEVELS,
                #                          CONTENTS_NOPAGES,
                #                          TOC_PAGE_NUMBERING)
                

                &latex_table_of_contents (-9999,
                                          0,
                                          $contents_levels,
                                          $nopages,
                                          $page_numbering)
              }
            else
              {
                # Do nothing.
                ;
              }
          }
        elsif ($element eq "TOMECONTENTS")
          {
            if ($type eq "start")
              {
                my ($nopages)           = lc (${$attributes}{'NOPAGES'});
                my ($contents_levels)   = ${$attributes}{'LEVELS'};

                if ($nopages eq "true")
                  {
                    $nopages = 1;
                  }
                else
                  {
                    $nopages = 0;
                  }


                
                # latex_table_of_contents (TOC_LEVEL,
                #                          SECTION,
                #                          CONTENTS_LEVELS,
                #                          CONTENTS_NOPAGES,
                #                          TOC_PAGE_NUMBERING)
                

                &latex_table_of_contents (-1,
                                          $tome,
                                          $contents_levels,
                                          $nopages,
                                          "")
              }
            else
              {
                # Do nothing.
                ;
              }
          }
        elsif ($element eq "PARTCONTENTS")
          {
            if ($type eq "start")
              {
                my ($nopages)           = lc (${$attributes}{'NOPAGES'});
                my ($contents_levels)   = ${$attributes}{'LEVELS'};

                if ($nopages eq "true")
                  {
                    $nopages = 1;
                  }
                else
                  {
                    $nopages = 0;
                  }


                
                # latex_table_of_contents (TOC_LEVEL,
                #                          SECTION,
                #                          CONTENTS_LEVELS,
                #                          CONTENTS_NOPAGES,
                #                          TOC_PAGE_NUMBERING)
                

                &latex_table_of_contents (0,
                                          $part,
                                          $contents_levels,
                                          $nopages,
                                          "")
              }
            else
              {

                
                # Do nothing.
                

                ;
              }
          }
        elsif ($element eq "CHAPTERCONTENTS")
          {
            if ($type eq "start")
              {
                my ($nopages)           = lc (${$attributes}{'NOPAGES'});
                my ($contents_levels)   = ${$attributes}{'LEVELS'};

                if ($nopages eq "true")
                  {
                    $nopages = 1;
                  }
                else
                  {
                    $nopages = 0;
                  }


                
                # latex_table_of_contents (TOC_LEVEL,
                #                          SECTION,
                #                          CONTENTS_LEVELS,
                #                          CONTENTS_NOPAGES,
                #                          TOC_PAGE_NUMBERING)
                

                &latex_table_of_contents (1,
                                          $h1section_absolute_counter,
                                          $contents_levels,
                                          $nopages,
                                          "")
              }
            else
              {

                
                # Do nothing.
                

                ;
              }
          }
        elsif ($element eq "INDEXENTRY")
          {
            if ($type eq "start")
              {
                #
                # Save index attributes.
                #
                $index_name = ${$attributes}{'INDEX'};
                #
                # increment the index entry counter.
                #
                $index_entry_counter++;
                #
                # Insert an index anchor.
                #
                &output ("\\almlazlabel{almlindex$index_entry_counter}");
                &output ("\\hypertarget{almlindex$index_entry_counter}{}");
                #
                # Eliminate the index entry.
                #
                &push_output ();
              }
            else
              {
                my ($entry) = "";
                #
                # Recall the index entry for draft typesetting.
                #
                $entry = &pop_output ();
                #
                if ($draft)
                  {
                    &output ("\\almlbzindexentrydraft{");
                    &output ($index_name);
                    &output ("}{");
                    &output ("$entry");
                    &output ("}");
                  }
              }
          }
        elsif ($element eq "PRINTINDEX")
          {
            if ($type eq "start")
              {
                my ($n) = 0;
                my ($m) = 0;
                my ($idxname) = "";
                my ($idxtype) = "";
                my ($idxcontext) = "";
                my ($index_file) = "";
                my ($output_stream);
                my ($input_stream);
                my ($line);
                my ($idxpagereference);


                
                # Save attributes.
                

                $idxname = ${$attributes}{'INDEX'};
                $idxtype = lc (${$attributes}{'INDEXREF'});
                $idxcontext = lc (${$attributes}{'INDEXCONTEXT'});
                $idxpagereference = lc (${$attributes}{'INDEXPAGEREFERENCE'});
                
                # Arrange pagenumbering.

                if ($idxpagereference eq "default"
                    && $idxcontext eq "all"
                    && $page_numbering eq "tome")
                  {
                    $idxpagereference = "tome";
                  }

                ########################################################
                # The sort is done at the beguinning, with ALML start
                # tag.
                ########################################################
                
                # Scan the index array.
                #
                # $index_list[x][0]        index name
                # $index_list[x][1]        NOT USED anymore
                # $index_list[x][2]        entry
                # $index_list[x][3]        array of links
                # $index_list[x][4]        array of html page numbers
                # $index_list[x][5]        array of level-descriptions
                # $index_list[x][6]        entry with formatting
                # $index_list[x][7]        array of tomes
                # $index_list[x][8]        array of parts
                # $index_list[x][9]        array of chapters (absolute)

                &output ("\n");
                for ($n = 0;
                     $n <= $#index_list;
                     $n++)
                  {
                    if ($index_list[$n][0] eq $idxname
                        && &valid_section_index_entry
                             ($n, $idxcontext, $tome, $part, $h1section_absolute_counter))
                      {
                        
                        # Write the index record.

                        &output ("$index_list[$n][6]");

                        &wait_message ($PROGRAM_EXECUTABLE   . ":"
                                       . $SOURCE_FILE_NAME . ":"
                                       . $CURRENT_FILE_NAME  . ":"
                                       . $INPUT_STREAM_LINE_COUNTER . ":"
                                       . "PRINTINDEX:"
                                       . $index_list[$n][0] . ":"
                                       . $index_list[$n][6]);
                        
                        # Scan the links.

                        for ($m = 0;
                             $m <= $#{$index_list[$n][3]};
                             $m++)
                          {
                            
                            # Check if this link is ok for the context
                            
                            if ($idxcontext eq "tome"
                                && $index_list[$n][7][$m] != $tome)
                              {
                                
                                # This link is not related to the tome.

                                next;
                              }
                            elsif ($idxcontext eq "part"
                                && $index_list[$n][8][$m] != $part)
                              {
                                
                                # This link is not related to the part.

                                next;
                              }
                            elsif ($idxcontext eq "chapter"
                                && $index_list[$n][9][$m] != $h1section_absolute_counter)
                              {
                                
                                # This link is not related to the chapter.

                                next;
                              }


                            
                            # Otherwise it is ok. :-)                             
                            

                            if ($idxtype eq "section")
                              {
                                &output
                                  (", "
                                   . $index_list[$n][5][$m]);
                              }
                            else
                              {
                                &output ("\\hyperlink{almlindex"
                                   . $index_list[$n][3][$m]
                                   . "}");
                                &output ("{");
                                &output (", ");
                                
                                if ($idxpagereference eq "tome")
                                  {
                                    if ($index_list[$n][5][$m] =~ m/^[i][0-9]/)
                                      {
                                        
                                        
                                        # This is an introduction that
                                        # has no prefix.
                                        

                                        ;
                                      }
                                    elsif ($index_list[$n][5][$m] =~ m/^[x][0-9]/)
                                      {

                                        
                                        # This is an index.
                                        

                                        ;
                                      }
                                    elsif ($index_list[$n][5][$m] =~ m/^[u][0-9]/)
                                      {

                                        
                                        # This is an unnumbered chapter.
                                        

                                        &output ($index_list[$n][7][$m]);
                                        &output ("-");
                                      }
                                    elsif ($index_list[$n][5][$m] =~ m/^[A-Z]/)
                                      {

                                        
                                        # This is an appendix.
                                        

                                        &output ("a-");
                                      }
                                    else
                                      {

                                        
                                        # This is a common chapter.
                                        

                                        &output ($index_list[$n][7][$m]);
                                        &output ("-");
                                      }
                                  }
                                &output ("\\almlczpageref{0}{000}{almlindex");
                                &output ($index_list[$n][3][$m]);
                                &output ("}");
                                &output ("}");
                              }
                          }
                        &output ("\\newline\n");
                      }
                  }
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "ANCHOR")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($anchor_type) = "";
                my ($visible_label) = "";
		#
                $id = ${$attributes}{'ID'};
                $anchor_type = uc (${$attributes}{'TYPE'});
		#
                # Use the counter to know the right number
                # inside the array.
		#
                $cross_reference_counter++;
		#
                # Print the reference anchor.
		#
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
		#
		if ($anchor_type eq "VISIBLE")
		  {
		    #
		    # Print a visible thing.
		    #
		    #
		    # Standard cross reference list.
		    #
		    # $cross_reference_list[x][0]        level                  -1..4
		    # $cross_reference_list[x][1]        tome number
		    # $cross_reference_list[x][2]        part number
		    # $cross_reference_list[x][3]        chapter number         
		    # $cross_reference_list[x][4]        table absolute number          
		    # $cross_reference_list[x][5]        figure absolute number         
		    # $cross_reference_list[x][6]        level-description      1.2.3
		    # $cross_reference_list[x][7]        title
		    # $cross_reference_list[x][8]        table level-description
		    # $cross_reference_list[x][9]        figure level-description
		    # $cross_reference_list[x][10]       original anchor id
		    # $cross_reference_list[x][11]       html page number
		    # $cross_reference_list[x][12]       listing absolute number         
		    # $cross_reference_list[x][13]       listing level-description
		    # $cross_reference_list[x][14]       text absolute number
		    # $cross_reference_list[x][15]       example absolute number         
		    # $cross_reference_list[x][16]       example level-description
		    #
		    $visible_label = $cross_reference_list[$cross_reference_counter][14];
		    $visible_label = &integer_to_alphabet ($visible_label);
		    $visible_label = lc ($visible_label);
		    #
            	    &output ("\\almlazvisiblelabel{$visible_label}");
		    #
            	    #!  &output ("\\almlazvisiblelabel{");
                    #!  &output ("{");
                    #!  &output ("\\raisebox{0.25ex}");
                    #!  &output ("{");
                    #!  &output ("\\fontsize{0.75em}{1em}");
                    #!  &output ("\\selectfont");
                    #!  &output ("{");
                    #!  &output ("\\color{green}");
                    #!  &output ("\\fboxsep=0.4mm");
                    #!  &output ("\\fboxrule=0.2mm");
                    #!  &output ("\\fbox");
                    #!  &output ("{");
                    #!  &output ("\\color{blue}");
                    #!  &output ("\\itshape{}");
                    #!  &output ("\\bfseries{}");
            	    #!  &output ("$visible_label");
                    #!  &output ("}");
                    #!  &output ("}");
                    #!  &output ("}");
                    #!  &output ("}");
                    #!  &output ("}");
		    #
		  }
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "EXTERNALANCHOR")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if (&external_anchor_check ($id))
                  {
                    &output ("\\hypertarget{$id}{}");
                  }
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "TABLE")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($pos) = "";


                
                # Initialize current table.
                

                $current_table_content = "";
                $current_table_splitable = 0;
                $current_table_status = "START";


                
                # Save attributes.
                

                $id = ${$attributes}{'ID'};
                $pos = lc ${$attributes}{'POS'};
                $table_position = $pos;
                $current_table_splitable = ${$attributes}{'SPLIT'};

 
                
                # Check attributes coherence and do necessary
                # corrections.
                

                if ($current_table_splitable)
                  {
                    if ($pos ne "fixed")
                      {


                        
                        # The table must be fixed
                        

                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: a splitable table must be fixed (cannot be floating).\n"),
                                     $PROGRAM_EXECUTABLE,
                                     $SOURCE_FILE_NAME,
                                     $CURRENT_FILE_NAME,
                                     $INPUT_STREAM_LINE_COUNTER), $V_WARNING);
                      }
                    $pos = "fixed";
                    $table_position = $pos;
                  }
                #
                # Increment some counters.
                #
                $table++;
                $absolute_table++;
                $cross_reference_counter++;
		#
                # Save table id.
                #
                if ($id eq "")
                  {
                    #
                    # Define a unique label.
                    #
                    $id = "table" . $absolute_table;
                  }
                $last_table_id = $id;
                #
                # Reset table caption.
                #
                $table_caption = "";
                #
                # Print the table border.
                #
                if ($pos eq "float")
                  {
                    #
                    # Floating block.
                    #
                    $floating_block++;
		    #
                    &output ("\n");
                    &output ("\\begin{table}[htbp]\n");
                  }
                else
                  {
                    &output ("\n");
                  }


                
                # Save the table body.
                

                &push_output ();
              }
            else
              {

                
                # Get table content.
                

                $current_table_content = &pop_output ();


                
                # If the table is splitable, cannot use minipage.
                

                if ($current_table_splitable)
                  {
                    ;
                  }
                else
                  {
                    &output ("\\begin{minipage}{\\linewidth}");
                    &output ("\n");
                  }
                #
                # Caption at the top of the table.
                # If the table is fixed and splitable, must see if there
                # is enough space at the bottom of the page.
                #
                if ($table_caption ne ""
                    && $table_position eq "fixed"
                    && $current_table_splitable)
                  {
                    #
                    # Must do something to avoid the caption on a page
                    # and the table starting on the next page.
                    #
                    &output ("\\almlazbreakpageiflessthen{4cm}");
                    &output ("\n");
                  }
                if ($table_caption ne "")
                  {
                    &output ("\n");
                    &output ("\\almlazlabel{almlanchor$cross_reference_counter}%");
                    &output ("\n");
                    &output ("\\hypertarget{almlanchor$cross_reference_counter}{}%");
                    &output ("\n");
                    &output ("\\hspace{0.075\\textwidth}%");
                    &output ("\n");
                    &output ("\\parbox{0.85\\textwidth}{");
                    &output ("\\noindent");
                    &output ("\\almlaafontsizecaption{");
                    &output ("\\textsf{");
                    &output ("$table_caption");
                    &output ("}");
                    &output ("}");
                    &output ("}");
                    &output ("\n");
                    &output ("\n");
                  }


                
                # Insert the table content.
                

                &output ("\n");
                &output ("$current_table_content");
                &output ("\n");


                
                # If the table is splitable, cannot use minipage.
                

                if ($current_table_splitable)
                  {
                    ;
                  }
                else
                  {
                    &output ("\\end{minipage}");
                    &output ("\n");
                  }


                
                # Close the table.
                

                if ($table_position eq "float")
                  {
                    &output ("\\end{table}\n");


                    
                    # Floating block.
                    

                    $floating_block--;
                  }


                
                # Reset current table status
                

                $current_table_status = "";

              }
          }
        elsif ($element eq "TCAPTION")
          {
            if ($type eq "start")
              {

                
                # Update status.
                

                $current_table_status = "CAPTION";


                
                # Send the output stream to a new stack level.        
                

                &push_output ();
              }
            else
              {

                
                # Recall output.
                

                $table_caption = &pop_output ();

                
                # Remove extra spaces before the caption text.
                #
                #!!!! In the near future, the space such as "{} " might
                #!!!! be changed into "\ ", that is more correct.
                #!!!! The DTD is arranged to delete duplicate spaces,
                #!!!! replacing also tabs into single space.
                #
                

                while ($table_caption =~ m/^\{\} (.*)$/s)
                  {
                    $table_caption = $1;
                  }
                
              }
          }
        elsif ($element eq "TABULAR")
          {
            if ($type eq "start")
              {
                my ($col) = 0;
                my ($font_size) = 0;
                my ($font_height) = 0;
                my ($columnfractions) = 0;
                my ($n) = 0;
                my ($caption_present) = 0;
                
                # Update status and see if the tabular must go back
                # a little vertically.

                $g_we_are_inside_a_tabular = 1;

                if ($current_table_status eq "CAPTION")
                  {
                    $current_table_status = "BODY";
                    $caption_present = 1;
                  }
                
                # Reset header status.

                $current_tabular_have_header = 0;
                
                # Save attributes.

                $current_tabular_columns = ${$attributes}{'COL'};
                $columnfractions = ${$attributes}{'COLUMNFRACTIONS'};
                $font_size = ${$attributes}{'PRINTEDFONTSIZE'};
                $current_tabular_border = ${$attributes}{'BORDER'};
                $current_tabular_splitable = $current_table_splitable;
                
                # Extract the font size.
                # Modify "," with ".".

                if ($font_size ne "")
                  {
                    $font_size =~ s/,/./;
                    $font_height = &font_size_resize ($font_size, 1.2);
                  }
                
                # Analyze column fractions.

                @current_tabular_columnfractions_list = ();
                if ($columnfractions eq "")
                  {
                    
                    # Set default columns width.

                    for ($n = 0; $n <= $current_tabular_columns; $n++)
                      {
                        $current_tabular_columnfractions_list[$n] = 0;
                      }
                  }
                else
                  {

                    # Take the column fractions from the string.

                    $n = 0;
                    while ($columnfractions =~ m/^\s*([0-9.,]+)\s*(.*)$/)
                      {
                        $current_tabular_columnfractions_list[$n] = $1;
                        $columnfractions = $2;

                        # Replace comma with point.

                        $current_tabular_columnfractions_list[$n] =~ s/\,/\./g;

                        $n++;
                      }
                  }

                # Calculate some column zoom.

                if ($current_tabular_columns > 15)
                  {
                    $current_tabular_columns_zoom =
                      1 - ($current_tabular_columns * 0.0353);
                  }
                elsif ($current_tabular_columns == 15)
                  {
                    $current_tabular_columns_zoom = 0.470;
                  }
                elsif ($current_tabular_columns == 14)
                  {
                    $current_tabular_columns_zoom = 0.505;
                  }
                elsif ($current_tabular_columns == 13)
                  {
                    $current_tabular_columns_zoom = 0.540;
                  }
                elsif ($current_tabular_columns == 12)
                  {
                    $current_tabular_columns_zoom = 0.575;
                  }
                elsif ($current_tabular_columns == 11)
                  {
                    $current_tabular_columns_zoom = 0.610;
                  }
                elsif ($current_tabular_columns == 10)
                  {
                    $current_tabular_columns_zoom = 0.645;
                  }
                elsif ($current_tabular_columns == 9)
                  {
                    $current_tabular_columns_zoom = 0.680;
                  }
                elsif ($current_tabular_columns == 8)
                  {
                    $current_tabular_columns_zoom = 0.715;
                  }
                elsif ($current_tabular_columns == 7)
                  {
                    $current_tabular_columns_zoom = 0.750;
                  }
                elsif ($current_tabular_columns == 6)
                  {
                    $current_tabular_columns_zoom = 0.785;
                  }
                elsif ($current_tabular_columns == 5)
                  {
                    $current_tabular_columns_zoom = 0.820;
                  }
                elsif ($current_tabular_columns == 4)
                  {
                    $current_tabular_columns_zoom = 0.855;
                  }
                elsif ($current_tabular_columns == 3)
                  {
                    $current_tabular_columns_zoom = 0.890;
                  }
                elsif ($current_tabular_columns == 2)
                  {
                    $current_tabular_columns_zoom = 0.925;
                  }
                else
                  {
                    $current_tabular_columns_zoom = 0.960;
                  }

                # Start the tabular.

                &output ("\n");
                &output ("\n");
                &output ("\\almlaafontsizetable{");
                &output ("\n");

                # Correct vertical spacing related to tabular.

                &output ("\n");
                &output ("\\vspace{-1ex}");
                &output ("\n");

                # Check font size.

                &output ("{");
                &output ("\n");
                if ($font_size ne "")
                  {
                    &output ("\\normalsize\\fontsize{$font_size}{$font_height}\\selectfont");
                  }
                &output ("\n");

                # Begin environment.

                &output ("\\begin{longtable}");
                &output ("{");

                # Columns definitions (external border are fixed).

                &output ("|");
                $n = 0;
                $col = $current_tabular_columns;
                while ($col > 0)
                  {
                    &output ("l");
                    $col--;
                    $n++;

                    # Column rules.

                    if ($current_tabular_border eq "1" && $col > 0)
                      {
                        &output ("|");
                      }

                  }
                &output ("|");

                &output ("}");
                &output ("\n");
                &output ("\\hline");
                &output ("\n");

              }
            else
              {

                # Closing tag.

                &output ("\\end{longtable}");
                &output ("\n");

                # Close font change

                &output ("} % end of font modification");
                &output ("\n");

                # Close almlaafontsizetable environment.

                &output ("} % end \\almlaafontsizetable");
                &output ("\n");
                
                # Reset tabular presence.

                $g_we_are_inside_a_tabular = 0;

              }
          }
        elsif ($element eq "THEAD")
          {
            my ($col) = $current_tabular_columns;
            my ($n) = 0;

            if ($type eq "start")
              {

                
                # Set header status.
                

                $current_tabular_have_header = 1;


                
                # There is no \line here because the TABULAR start
                # already inserts one.
                

                ;
              }
            else
              {

                
                # The end of header is at the beguinning of the
                # body.
                

                ;
              }
          }
        elsif ($element eq "TBODY")
          {
            if ($type eq "start")
              {

                
                # Close the header.
                

                if ($current_tabular_have_header)
                  {

                    
                    # We need a line here.
                    

                    &output ("\\hline");
                    &output ("\n");

                  }
                &output ("\\endhead");
                &output ("\n");

                if ($current_tabular_border ne "1")
                  {
                    &output ("\\hline");
                    &output ("\\endfoot");
                    &output ("\n");
                  }

              }
            else
              {

                
                # I am sorry, but I have to add this also if it may be
                # double.
                

                if ($current_tabular_border ne "1")
                  {
                    &output ("\\hline");
                    &output ("\n");
                  }
              }
          }
        elsif ($element eq "TROW")
          {
            my ($col) = $current_tabular_columns;
            my ($n) = 0;

            if ($type eq "start")
              {

                
                # This is the first column
                

                $current_tabular_column_index = 0;

                
                # Finally start the first cell.
                

                &output ("{");
                &output ("\\fboxrule=0mm");
                &output ("\\fboxsep=0.5mm");
                &output ("\\fbox");
                &output ("{");

                if ((! defined($current_tabular_columnfractions_list[$current_tabular_column_index]))
                    || ($current_tabular_columnfractions_list[$current_tabular_column_index] == 0))
                  {
                    &output ("\\mbox");
                    &output ("{");
                  }
                else
                  {
                    &output ("\\parbox{"
                             . $current_tabular_columnfractions_list[$current_tabular_column_index]*$current_tabular_columns_zoom
                             . "\\textwidth}");
                    &output ("{");

                    
                    # The following \hspace{0} is necessary to avoid
                    # empty cells, where the \parbox cannot work
                    # correctly.
                    

                    &output ("\\hspace{0mm}");

                  }
              }
            else
              {

                
                # Close the last cell.
                

                &output ("}");
                &output ("}");
                &output ("}");

                
                # Close the row.
                

                &output ("\\\\");
                &output ("\n");
                
                if ($current_tabular_border eq "1")
                  {
                    &output ("\n");
                    &output ("\\hline");
                    &output ("\n");
                  }
                
              }
          }
        elsif ($element eq "COLSEP")
          {
            if ($type eq "start")
              {
                # Close previous column.
                &output ("}");
                &output ("}");
                &output ("}");

                # Open next column.
                &output ("&\n");

                # This is the next column
                $current_tabular_column_index++;

                # Open next cell.
                &output ("{");
                &output ("\\fboxrule=0mm");
                &output ("\\fboxsep=0.5mm");
                &output ("\\fbox");
                &output ("{");

                if ((! defined($current_tabular_columnfractions_list[$current_tabular_column_index]))
                    || ($current_tabular_columnfractions_list[$current_tabular_column_index] == 0))
                  {
                    &output ("\\mbox");
                    &output ("{");
                  }
                else
                  {
                    &output ("\\parbox{"
                             . $current_tabular_columnfractions_list[$current_tabular_column_index]*$current_tabular_columns_zoom
                             . "\\textwidth}");
                    &output ("{");

                    
                    # The following \hspace{0} is necessary to avoid
                    # empty cells, where the \parbox cannot work
                    # correctly.
                    

                    &output ("\\hspace{0mm}");

                  }
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "FIGURE")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($pos) = "";
                my ($sep) = "";
		#
                # Save attributes.
		#
                $id = ${$attributes}{'ID'};
                $pos = lc ${$attributes}{'POS'};
                $sep = lc ${$attributes}{'SEP'};
                $figure_position = $pos;
                $figure_separation = $sep;
		#
		# Other elements need to know if there is a border.
		#
		$#IS_IT_A_FRAME++;
                if ($figure_separation eq "box"
                   || $figure_separation eq "border")
		  {
		    $IS_IT_A_FRAME[$#IS_IT_A_FRAME] = 1;
		  }
		else
		  {
		    $IS_IT_A_FRAME[$#IS_IT_A_FRAME] = 0;
		  }
		#
                # Increment some counters.
		#
                $figure++;
                $absolute_figure++;
                $cross_reference_counter++;
		#
                # Save picture id.
		#
                if ($id eq "")
                  {
    		    #
                    # Define a unique label.
    		    #
                    $id = "figure" . $absolute_figure;
                  }
                $last_figure_id = $id;
		#
                # Reset figure caption.
		#
                $figure_caption = "";
		#
                # Start figure containment.
		#
                if ($figure_position eq "float")
                  {
    		    #
                    # Floating block.
    		    #
                    $floating_block++;
    		    #
                    &output ("\n");
                    &output ("\\begin{figure}[htbp]\n");
                  }
                else
                  {
                    &output ("\n");
                    &output ("\\begin{minipage}{\\linewidth}\n");
                  }
	        #
                # Save the figure body.
	        #
                &push_output ();
              }
            else
              {
	        #
                # Get figure content.
	        #
                $current_figure_content = &pop_output ();
	        #
                # Put hypertextual targets.
	        #
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
                &output ("\n");
	        #
                # Caption.
	        #
                if ($figure_caption ne "")
                  {
    	    	    #
                    # Normal caption code.
    	    	    #
                    &output ("\n");
                    &output ("\\hspace{0.075\\textwidth}%");
                    &output ("\n");
                    &output ("\\parbox{0.85\\textwidth}{");
                    &output ("\\noindent");
                    &output ("\\almlaafontsizecaption{");
                    &output ("\\textsf{");
                    &output ("$figure_caption");
                    &output ("}");
                    &output ("}");
                    &output ("}");
                    &output ("\n");
                    &output ("\n");
    	    	    #
                    # Correct vertical space after the caption.
    	    	    #
                    if ($figure_separation eq "rule")
                      {
                        &output ("\\vspace{-1.0ex} % figure with rule");
                        &output ("\n");
                        &output ("\n");
                      }
                    elsif ($figure_separation eq "box"
                           || $figure_separation eq "border")
                      {
                        &output ("\\vspace{0.5ex} % figure with border");
                        &output ("\n");
                        &output ("\n");
                      }
                    else
                      {
    	    		#
                        # Nothing to do.
    	    		#
                        ;
                      }
                  }
		#
                # Start the figure border and put a little extra space
		# inside if necessary.
		#
                if ($figure_separation eq "rule")
                  {
                    &output ("{");
                    &output ("\\color{blue}");
                    &output ("\\rule{\\linewidth}{0.5pt}");
                    &output ("}");
                    &output ("\n");
                    &output ("\\vspace{-2ex}");
                  }
                elsif ($figure_separation eq "box"
                       || $figure_separation eq "border")
                  {
                    &output ("{");
                    &output ("\\color{blue}");
                    &output ("\\fboxrule=0.3mm");
	            &output ("\\fboxsep=0.4em");
                    &output ("\\fbox");
                    &output ("{");
                    &output ("\\color{black}");
                    &output ("\\noindent");
        	    &output ("\\begin{minipage}{0.97\\linewidth}");
                    &output ("\n");
                  }
		#
                # Insert the picture.
		#
                &output ($current_figure_content);
		#
                # Leave an empty line.
		#
                &output ("\n");
		#
                # Print the figure border.
		#
                if ($figure_separation eq "rule")
                  {
                    &output ("\\vspace{-1ex}\n");
                    &output ("{");
                    &output ("\\color{blue}");
                    &output ("\\rule{\\linewidth}{0.5pt}");
                    &output ("}");
                    &output ("\n");
                  }
                elsif ($figure_separation eq "box"
                       || $figure_separation eq "border")
                  {
                    &output ("\n");
                    &output ("\n");
                    &output ("\\end{minipage}");
                    &output ("}% End \\fbox");
                    &output ("\n");
                    &output ("}% End \\color");
                    &output ("\n");
                  }
		#
                # Close figure.
		#
                if ($figure_position eq "float")
                  {
                    &output ("\\end{figure}\n");
		    #
                    # Floating block.
		    #
                    $floating_block--;
                  }
                else
                  {
                    &output ("\\end{minipage}\n");
                  }
		#
                # Clear the figure content.
		#
                $current_figure_content = "";
		#
		# Other elements need to know if there is a border.
		# Now clear it (pop out).
		#
		$#IS_IT_A_FRAME--;
              }
          }
        elsif ($element eq "FCAPTION")
          {
            if ($type eq "start")
              {
		#
                # Send the output stream to a new stack level.        
		#
                &push_output ();
              }
            else
              {
		#
                # Recall output.
		#
                $figure_caption = &pop_output ();
		#
                # Remove extra spaces before the caption text.
                #
                #!!!! In the near future, the space such as "{} " might
                #!!!! be changed into "\ ", that is more correct.
                #!!!! The DTD is arranged to delete duplicate spaces,
                #!!!! replacing also tabs into single space.
                #
                while ($figure_caption =~ m/^\{\} (.*)$/s)
                  {
                    $figure_caption = $1;
                  }
              }
          }
        elsif ($element eq "LISTING")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($pos) = "";
                my ($sep) = "";
                my ($split) = 0;
		#
                # Save attributes.
		#
                $id = ${$attributes}{'ID'};
                $pos = lc ${$attributes}{'POS'};
                $sep = lc ${$attributes}{'SEP'};
                $split = lc ${$attributes}{'SPLIT'};
		#
                # Correct mistakes.
		#
                if (($sep eq "border"
                     || $sep eq "box")
                    && $split eq "1")
                  {
		    #
                    # There is a mistake.
		    #
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: cannot handle a splitable boxed listing.\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER), $V_WARNING);
                    $split = 0;
                  }
                if ($pos eq "float" && $split eq "1")
                  {
		    #
                    # There is a mistake.
		    #
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: cannot handle a splitable floating listing.\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER), $V_WARNING);
                    $pos = "fixed";
                  }
		#
                $listing_position = $pos;
                $listing_separation = $sep;
                $listing_split = $split;
		#
		# Other elements need to know if there is a border.
		#
		$#IS_IT_A_FRAME++;
                if ($listing_separation eq "box"
                   || $listing_separation eq "border")
		  {
		    $IS_IT_A_FRAME[$#IS_IT_A_FRAME] = 1;
		  }
		else
		  {
		    $IS_IT_A_FRAME[$#IS_IT_A_FRAME] = 0;
		  }
		#
                # Increment some counters.
		#
                $listing++;
                $absolute_listing++;
                $cross_reference_counter++;
		#
                # Save listing id.
		#
                if ($id eq "")
                  {
		    #
                    # Define a unique label.
		    #
                    $id = "listing" . $absolute_listing;
                  }
                $last_listing_id = $id;
		#
                # Reset table caption.
		#
                $listing_caption = "";
		#
                # Begin the listing.
		#
                if ($listing_position eq "float")
                  {
		    #
                    # Floating block.
		    #
                    $floating_block++;
                    &output ("\n");
                    #
                    #
                    #
                    &output ("\\begin{figure}[htbp]    % Listing start");
                    &output ("\n");
                  }
                elsif ($listing_split eq "0")
                  {
                    &output ("\n");
                    &output ("\\begin{minipage}{\\linewidth}    % Listing start");
                    &output ("\n");
                  }
                else
                  {
                    &output ("\n");
                    &output ("% Listing start");
                    &output ("\n");
                    #
                    # The following conditional page break is important
                    # when the listing has no caption and has a border,
                    # because there is a little back vertical space
                    # and otherwise it may happen that a horizontal
                    # rule start at the bottom of the page and the
                    # listing starts really at the next page.
                    #
                    &output ("\\almlazbreakpageiflessthen{1cm}");
                    &output ("\n");
                  }
                #
                # Here should go the caption.
                #
                #
                # Must save output because of caption.
                #
                &push_output ();
                #
                # Border required?
                #
                if ($listing_separation eq "rule")
                  {
                    #
                    &output ("\\almlazbreakpageiflessthen{4cm}");
                    &output ("\n");
                    #
                    &output ("\\rule{\\linewidth}{0.5pt}");
                    &output ("\n");
                    &output ("\n");
                    &output ("\\vspace{0pt}");
                    &output ("\n");
                    &output ("\\vspace{-0.5ex}");
                    &output ("\\nopagebreak");
                    &output ("\n");
                  }
                elsif ($listing_separation eq "box"
                       || $listing_separation eq "border")
                  {
                    &output ("\\fboxsep=1mm");
                    &output ("\n");
                    &output ("\\fbox");
                    &output ("{");
                    &output ("\\noindent");
                    &output ("\\begin{minipage}{0.99\\linewidth}    % minipage inside \\fbox");
                    &output ("\n");
                  }
                #
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
                &output ("\n");
              }
            else
              {
                my ($listing_body) = "";
                #
                # restore the listing body
                #
                $listing_body = &pop_output ();
                #
                # If the listing is fixed and can be splited, do
                # something to avoid to have the caption on a page
                # and the listing starting non the next one.
                #
                if ($listing_caption ne ""
                    && $listing_position eq "fixed"
                    && $listing_split)
                  {
                    &output ("\\almlazbreakpageiflessthen{4cm}");
                    &output ("\n");
                  }
                #
                # Caption.
                #
                if ($listing_caption ne "")
                  {
                    #
                    # Normal caption code.
                    #
                    &output ("\n");
                    &output ("\\hspace{0.075\\textwidth}%");
                    &output ("\n");
                    &output ("\\parbox{0.85\\textwidth}{");
                    &output ("\\noindent");
                    &output ("\\almlaafontsizecaption{");
                    &output ("\\textsf{");
                    &output ("$listing_caption");
                    &output ("}");
                    &output ("}");
                    &output ("}");
                    &output ("\n");
                    &output ("\n");
                    #
                    # Correct vertical space after the caption.
                    #
                    if ($listing_split eq "0")
                      {
                        if ($listing_separation eq "rule")
                          {
	                    #
                            # Nothing to do.
	                    #
                            ;
                          }
                        else
                          {
	                    #
                            # Correct the vertical space.
	                    #
                            &output ("\\vspace{1ex} % unspiltable listing");
                            &output ("\n");
                            &output ("\n");
                          }
                      }
                    else
                      {
                        if ($listing_separation eq "rule")
                          {
	                    #
                            # Correct the vertical space.
	                    #
                            &output ("\\vspace{-1ex} % spiltable listing with rule");
                            &output ("\n");
                            &output ("\n");
                          }
                        else
                          {
	                    #
                            # Nothing to do.
	                    #
                            ;
                          }
                      }
                  }
                #
                # Put the body of the listing.
                #
                &output ("$listing_body");
                #
                # Leave an empty line.
                #
                &output ("\n");
                #
                # Print the listing border.
                #
                if ($listing_separation eq "rule")
                  {
                    &output ("\\vspace{-1.5ex}");
                    &output ("\\nopagebreak");
                    &output ("\n");
                    &output ("\\rule{\\linewidth}{0.5pt}");
                    &output ("\n");
                  }
                elsif ($listing_separation eq "box"
                       || $listing_separation eq "border")
                  {
                    &output ("\n");
                    &output ("\\end{minipage}    % minipage inside \\fbox");
                    &output ("\n");
                    &output ("} % End \\fbox");
                    &output ("\n");
                  }
                #
                # Close the listing box.
                #
                if ($listing_position eq "float")
                  {
                    &output ("\\end{figure}    % Listing start");
                    &output ("\n");
                    #
                    # Floating block.
                    #
                    $floating_block--;
                  }
                elsif ($listing_split eq "0")
                  {
                    &output ("\\end{minipage}    % Listing end");
                    &output ("\n");
                  }
                else
                  {
                    &output ("% Listing end");
                    &output ("\n");
                  }
              }
	    #
	    # Other elements need to know if there is a border.
	    # Now clear it (pop out).
	    #
	    $#IS_IT_A_FRAME--;
          }
        elsif ($element eq "LCAPTION")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $listing_caption = &pop_output ();
                #
                # Remove extra spaces before the caption text.
                #
                ## In the near future, the space such as "{} " might
                ## be changed into "\ ", that is more correct.
                ## The DTD is arranged to delete duplicate spaces,
                ## replacing also tabs into single space.
                #
                while ($listing_caption =~ m/^\{\} (.*)$/s)
                  {
                    $listing_caption = $1;
                  }
              }
          }
        elsif ($element eq "EXAMPLE")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($pos) = "";
                my ($sep) = "";
                my ($split) = 0;
		#
                # Save attributes.
		#
                $id = ${$attributes}{'ID'};
                $pos = lc ${$attributes}{'POS'};
                $sep = lc ${$attributes}{'SEP'};
                $split = lc ${$attributes}{'SPLIT'};
		#
                # Correct mistakes.
		#
                if (($sep eq "border"
                     || $sep eq "box")
                    && $split eq "1")
                  {
		    #
                    # There is a mistake.
		    #
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: cannot handle a splitable boxed example.\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER), $V_WARNING);
                    $split = 0;
                  }
                if ($pos eq "float" && $split eq "1")
                  {
		    #
                    # There is a mistake.
		    #
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: cannot handle a splitable floating example.\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER), $V_WARNING);
                    $pos = "fixed";
                  }
		#
                $example_position = $pos;
                $example_separation = $sep;
                $example_split = $split;
		#
		# Other elements need to know if there is a border.
		#
		$#IS_IT_A_FRAME++;
                if ($example_separation eq "box"
                   || $example_separation eq "border")
		  {
		    $IS_IT_A_FRAME[$#IS_IT_A_FRAME] = 1;
		  }
		else
		  {
		    $IS_IT_A_FRAME[$#IS_IT_A_FRAME] = 0;
		  }
		#
                # Increment some counters.
		#
                $example++;
                $absolute_example++;
                $cross_reference_counter++;
		#
                # Save listing id.
		#
                if ($id eq "")
                  {
		    #
                    # Define a unique label.
		    #
                    $id = "example" . $absolute_example;
                  }
                $last_example_id = $id;
		#
                # Reset example caption.
		#
                $example_caption = "";
		#
                # Begin the example.
		#
                if ($example_position eq "float")
                  {
		    #
                    # Floating block.
		    #
                    $floating_block++;
                    &output ("\n");
                    #
                    #
                    #
                    &output ("\\begin{figure}[htbp]    % Example start");
                    &output ("\n");
                  }
                elsif ($example_split eq "0")
                  {
                    &output ("\n");
                    &output ("\\begin{minipage}{\\linewidth}    % Example start");
                    &output ("\n");
                  }
                else
                  {
                    &output ("\n");
                    &output ("% Example start");
                    &output ("\n");
                    #
                    # The following conditional page break is important
                    # when the example has no caption and has a border,
                    # because there is a little back vertical space
                    # and otherwise it may happen that a horizontal
                    # rule start at the bottom of the page and the
                    # listing starts really at the next page.
                    #
                    &output ("\\almlazbreakpageiflessthen{1cm}");
                    &output ("\n");
                  }
                #
                # Here should go the caption.
                #
                #
                # Must save output because of caption.
                #
                &push_output ();
                #
                # Border required?
                #
                if ($example_separation eq "rule")
                  {
                    #
                    &output ("\\almlazbreakpageiflessthen{4cm}");
                    &output ("\n");
                    #
                    &output ("\\rule{\\linewidth}{0.5pt}");
                    &output ("\n");
                    &output ("\n");
                    &output ("\\vspace{0pt}");
                    &output ("\n");
                    &output ("\\vspace{-0.5ex}");
                    &output ("\\nopagebreak");
                    &output ("\n");
                  }
                elsif ($example_separation eq "box"
                       || $example_separation eq "border")
                  {
                    &output ("\\fboxsep=1mm");
                    &output ("\n");
                    &output ("\\fbox");
                    &output ("{");
                    &output ("\\noindent");
                    &output ("\\begin{minipage}{0.99\\linewidth}    % minipage inside \\fbox");
                    &output ("\n");
                  }
                #
                &output ("\\almlazlabel{almlanchor$cross_reference_counter}");
                &output ("\\hypertarget{almlanchor$cross_reference_counter}{}");
                &output ("\n");
              }
            else
              {
                my ($example_body) = "";
                #
                # Restore the example body.
                #
                $example_body = &pop_output ();
                #
                # If the example is fixed and can be splited, do
                # something to avoid to have the caption on a page
                # and the listing starting non the next one.
                #
                if ($example_caption ne ""
                    && $example_position eq "fixed"
                    && $example_split)
                  {
                    &output ("\\almlazbreakpageiflessthen{4cm}");
                    &output ("\n");
                  }
                #
                # Caption.
                #
                if ($example_caption ne "")
                  {
                    #
                    # Normal caption code.
                    #
                    &output ("\n");
                    &output ("\\hspace{0.075\\textwidth}%");
                    &output ("\n");
                    &output ("\\parbox{0.85\\textwidth}{");
                    &output ("\\noindent");
                    &output ("\\almlaafontsizecaption{");
                    &output ("\\textsf{");
                    &output ("$example_caption");
                    &output ("}");
                    &output ("}");
                    &output ("}");
                    &output ("\n");
                    &output ("\n");
                    #
                    # Correct vertical space after the caption.
                    #
                    if ($example_split eq "0")
                      {
                        if ($example_separation eq "rule")
                          {
	                    #
                            # Nothing to do.
	                    #
                            ;
                          }
                        else
                          {
	                    #
                            # Correct the vertical space.
	                    #
                            &output ("\\vspace{1ex} % unspiltable example");
                            &output ("\n");
                            &output ("\n");
                          }
                      }
                    else
                      {
                        if ($example_separation eq "rule")
                          {
	                    #
                            # Correct the vertical space.
	                    #
                            &output ("\\vspace{-1ex} % spiltable example with rule");
                            &output ("\n");
                            &output ("\n");
                          }
                        else
                          {
	                    #
                            # Nothing to do.
	                    #
                            ;
                          }
                      }
                  }
                #
                # Change the body font.
                #
                if ($PRINTED_FONT_SIZE_EXAMPLE eq "")
                  {
                    &output ("{\\fontsize{0.85em}{1.05em}\\selectfont%");
                    &output ("\n");
                  }
                else
                  {
                    &output ("{\\fontsize{$PRINTED_FONT_SIZE_EXAMPLE}{$PRINTED_FONT_HEIGHT_EXAMPLE}\\selectfont%");
                    &output ("\n");
                  }
                #
                # Put the body of the example.
                #
                &output ("$example_body");
                #
                # Leave an empty line.
                #
                &output ("\n");
                #
                # Print the example border.
                #
                if ($example_separation eq "rule")
                  {
                    &output ("\\vspace{-1.5ex}");
                    &output ("\\nopagebreak");
                    &output ("\n");
                    &output ("\\rule{\\linewidth}{0.5pt}");
                    &output ("\n");
                  }
                elsif ($example_separation eq "box"
                       || $example_separation eq "border")
                  {
                    &output ("\n");
                    &output ("\\end{minipage}    % minipage inside \\fbox");
                    &output ("\n");
                    &output ("} % End \\fbox");
                    &output ("\n");
                  }
                #
                # Close the font change.
                #
                &output ("}%");
                &output ("\n");
                #
                # Close the example box.
                #
                if ($example_position eq "float")
                  {
                    &output ("\\end{figure}    % Example start");
                    &output ("\n");
                    #
                    # Floating block.
                    #
                    $floating_block--;
                  }
                elsif ($example_split eq "0")
                  {
                    &output ("\\end{minipage}    % Example end");
                    &output ("\n");
                  }
                else
                  {
                    &output ("% Example end");
                    &output ("\n");
                  }
              }
	    #
	    # Other elements need to know if there is a border.
	    # Now clear it (pop out).
	    #
	    $#IS_IT_A_FRAME--;
          }
        elsif ($element eq "ECAPTION")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output.
                #
                $example_caption = &pop_output ();
                #
                # Remove extra spaces before the caption text.
                #
                ## In the near future, the space such as "{} " might
                ## be changed into "\ ", that is more correct.
                ## The DTD is arranged to delete duplicate spaces,
                ## replacing also tabs into single space.
                #
                while ($example_caption =~ m/^\{\} (.*)$/s)
                  {
                    $example_caption = $1;
                  }
              }
          }
        elsif ($element eq "IFREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($n) = "";
                $id = ${$attributes}{'ID'};

                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number             
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
                    # Do nothing, just scan.
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
                    # The reference was found at $n-th position.
                    $cross_reference_present = 1;
                  }
                else
                  {
                    # There is no reference.
                    $cross_reference_present = 0;
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: conditional link \"%s\" is not present\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           $id), $V_WARNING);
                  }

                
                # Save output.
                
                &push_output ();
              }
            else
              {
                my ($conditional_output) = "";


                
                # If the conditional reference was found, typeset it;
                # otherwise, discard it.
                

                $conditional_output = &pop_output ();

                if ($cross_reference_present)
                  {
                    &output ($conditional_output);
                  }
                elsif ($draft)
                  {
                    &output ("\\almlaaifref{");
                    &output ($conditional_output);
                    &output ("}");
                  }
                else
                  {
                    # Nothing to output
                    ;
                  }


                
                # Must restore a valid cross reference status.
                
                $cross_reference_present = 1;
              }
          }
        elsif ($element eq "SECTIONREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($visible_label) = "";
		#
                $id = ${$attributes}{'ID'};
                $id_latex = $id;
                $id_latex =~ s/[^a-zA-Z0-9]/ /g;
		#
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number             
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
		    #
                    # Do nothing, just scan.
		    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
		    #
                    # The reference was found at $n-th position.
            	    #
                    &output ("\\hyperlink{almlanchor$n}");
                    &output ("{");
                    &output ($cross_reference_list[$n][6]);
		    #
		    # Check if it is a visible anchor.
		    #
		    if ($cross_reference_list[$n][14] > 0)
		      {
		        #
			# Add the anchor letter to the end of the
			# section number: "1.2.3:a".
			#
			$visible_label = $cross_reference_list[$n][14];
			$visible_label = &integer_to_alphabet ($visible_label);
			$visible_label = lc ($visible_label);
			#
            		&output (":");
                	&output ("{");
                	&output ("\\color{blue}");
                	&output ("\\itshape{}");
                	&output ("\\bfseries{}");
            		&output ("$visible_label");
                	&output ("}");
		      }
		    #
                    &output ("}");
		    #
                  }
                else
                  {
		    #
                    # There is no reference.
		    #
                    &output ("??$id_latex??");
		    #
                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
		    #
                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "TABLEREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
                    # Replace with last.
                    $id = $last_table_id;
                  }
                $id_latex = $id;
                $id_latex =~ s/[^a-zA-Z0-9]/ /g;

                
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number             
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
                    #
                    # Do nothing, just scan.
                    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
                    #
                    # The reference was found at $n-th position.
                    #
                    &output ("\\hyperlink{almlanchor$n}");
                    &output ("{");
                    &output ($cross_reference_list[$n][8]);
                    &output ("}");
                  }
                else
                  {

                    
                    # There is no reference.
                    

                    &output ("??$id_latex??");

                    
                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
                    

                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "FIGUREREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
                    # Replace with last.
                    $id = $last_figure_id;
                  }
                $id_latex = $id;
                $id_latex =~ s/[^a-zA-Z0-9]/ /g;
                #
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
            	#
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
		    #
                    # Do nothing, just scan.
		    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
            	    #
                    # The reference was found.
                    #
                    &output ("\\hyperlink{almlanchor$n}");
                    &output ("{");
                    &output ($cross_reference_list[$n][9]);
                    &output ("}");

                  }
                else
                  {
                    # There is no reference.
                    &output ("??$id_latex??");

                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "LISTINGREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
		    #
                    # Replace with last.
		    #
                    $id = $last_listing_id;
                  }
                $id_latex = $id;
                $id_latex =~ s/[^a-zA-Z0-9]/ /g;
		#
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
		    #
                    # Do nothing, just scan.
		    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
		    #
                    # The reference was found at $n-th position.
		    #
                    &output ("\\hyperlink{almlanchor$n}");
                    &output ("{");
                    &output ($cross_reference_list[$n][13]);
                    &output ("}");
                  }
                else
                  {
		    #
                    # There is no reference.
		    #
                    &output ("??$id_latex??");
		    #
                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
		    #
                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "EXAMPLEREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
		    #
                    # Replace with last.
		    #
                    $id = $last_example_id;
                  }
                $id_latex = $id;
                $id_latex =~ s/[^a-zA-Z0-9]/ /g;
		#
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
		    #
                    # Do nothing, just scan.
		    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
		    #
                    # The reference was found at $n-th position.
		    #
                    &output ("\\hyperlink{almlanchor$n}");
                    &output ("{");
                    &output ($cross_reference_list[$n][16]);
                    &output ("}");
                  }
                else
                  {
		    #
                    # There is no reference.
		    #
                    &output ("??$id_latex??");
		    #
                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
		    #
                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "SPECIAL")
          {
            if ($type eq "start")
              {
                # Increment the index entry counter.
                $index_entry_counter++;
                # Typeset properly.
                &output ("\\almlazlabel{almlindex$index_entry_counter}");
                &output ("\\hypertarget{almlindex$index_entry_counter}{}");
                &output ("\\almlbaspecialname{");
              }
            else
              {
                my ($special) = "";
                $special = ${$attributes}{'SPECIAL'};
                &output ("}{$special}");
              }
          }
        elsif ($element eq "DFN")
          {
            if ($type eq "start")
              {
                
                # Typeset properly.
                
                &output ("{\\bfseries\\itshape{}");
              }
            else
              {
                &output ("\\/}");
              }
          }
        elsif ($element eq "WORKINFO")
          {
            if ($type eq "start")
              {
                #
                # Reset global variables.
                #
                $workinfo_name         = "";
                $workinfo_license      = "";
                $workinfo_license_text = "";
                $workinfo_notes        = "";
              }
            else
              {
                #
                # increment the workinfo counter.
                #
                $workinfo_counter++;
                #
                # Insert a workinfo anchor.
                #
                &output ("\\almlazlabel{almlwork$workinfo_counter}");
                &output ("\\hypertarget{almlwork$workinfo_counter}{}");
                #
                # Print a footnote.
                #
                my ($n) = 0;
                #
                # Prepare footnote data.
                #
                $latex_footnote = "\\hyperlink{almlworkinfo:$workinfo_name}"
                                . "{"
                                . "\\textbf{$workinfo_name}"
                                . "}"
                                . " ~ "
                                . "$workinfo_license";
                #
                # Prepare a new element inside the footnote array.
                #
                $#latex_footnote_list++;
                $n = $#latex_footnote_list +1;
                #
                # Insert the footnote link.
                #
                &output ("\\almlaafootnotemark{\\hypertarget{almlfootnote-ref:$h1section_absolute_counter:$n}{}\\hyperlink{almlfootnote:$h1section_absolute_counter:$n}{$n}}");
                #
                # Insert the footnote inside the array.
                #
                $latex_footnote_list[$#latex_footnote_list] = $latex_footnote;
              }
          }
        elsif ($element eq "WORKNAME")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_name = &pop_output ();
              }
          }
        elsif ($element eq "WORKLICENSE")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_license = &pop_output ();
              }
          }
        elsif ($element eq "WORKLICENSETEXT")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_license_text = &pop_output ();
              }
          }
        elsif ($element eq "WORKNOTES")
          {
            if ($type eq "start")
              {
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Recall output (if any).
                #
                $workinfo_notes = &pop_output ();
              }
          }
        elsif ($element eq "PRINTWORKINFO")
          {
            if ($type eq "start")
              {
                my ($n) = 0;
                my ($i) = 0;
                my ($reftype) = "";
                $reftype = lc (${$attributes}{'WORKINFOREF'});
                #
                # Sort workinfo array, based on the work name.
                #
                # $workinfo_list[x][0]   work name
                # $workinfo_list[x][1]   work license
                # $workinfo_list[x][2]   work license text
                # $workinfo_list[x][3]   work notes
                # $workinfo_list[x][4]   section number
                # $workinfo_list[x][5]   HTML page counter
                # $workinfo_list[x][6]   array of section numbers
                # $workinfo_list[x][7]   array of HTML page numbers
                # $workinfo_list[x][8]   work info serial number
                # $workinfo_list[x][9]   array of work info serial numbers
                #
                &sort_generic_array (\@workinfo_list, 0, 0, $#workinfo_list);
                #
                # Scan and join duplicate records.
                #
                &scan_and_join_doubles_workinfo_list ();
                #
                # Insert workinfo array.
                #
                &output ("\n");
                &output ("\\begin{list}{}{}\n");
                #
                # Workinfo list.
                #
                # $workinfo_list[x][0]        work name
                # $workinfo_list[x][1]        work license
                # $workinfo_list[x][2]        work license text
                # $workinfo_list[x][3]        work notes
                # $workinfo_list[x][4]        section number
                # $workinfo_list[x][5]        HTML page counter
                # $workinfo_list[x][6]        array of section numbers
                # $workinfo_list[x][7]        array of HTML page numbers
                # $workinfo_list[x][8]        work info serial number
                # $workinfo_list[x][9]        array of work info serial numbers
                #
                for ($n = 0; $n <= $#workinfo_list; $n++)
                  {
                    &output ("\n\\item\\hspace{-0,25in}");
                    #
                    # Put a label so that it can be reached
                    # from the origin.
                    #
                    &output ("\\almlazlabel{almlworkinfo:");
                    &output ($workinfo_list[$n][0]);
                    &output ("}");
                    #
                    &output ("\\hypertarget{almlworkinfo:");
                    &output ($workinfo_list[$n][0]);
                    &output ("}{}");
                    #
                    # Write the name of the work.
                    #
                    &output ("\\begin{large}");
                    &output ($workinfo_list[$n][0]);
                    &output ("\\end{large}");
                    #
                    # Append references.
                    #
                    if ($reftype eq "section")
                      {
                        for ($i = 0; $i <= $#{$workinfo_list[$n][6]}; $i++)
                          {
                            &output (", ");
                            &output ("\\hyperlink{almlwork"
                                   . $workinfo_list[$n][9][$i]
                                   . "}");
                            &output ("{");
                            &output ($workinfo_list[$n][6][$i]);
                            &output ("}");
                          }
                      }
                    else
                      {
                        for ($i = 0; $i <= $#{$workinfo_list[$n][9]}; $i++)
                          {

                            &output (", ");
                            &output ("\\hyperlink{almlwork"
                                   . $workinfo_list[$n][9][$i]
                                   . "}");
                            &output ("{");
                            &output ("\\almlczpageref{0}{000}{almlwork"
                                    . $workinfo_list[$n][9][$i]
                                    . "}");
                            &output ("}");
                          }
                      }
                    #
                    # Insert informations about the work.
                    #
                    &output ("\n");
                    #
                    if ($workinfo_list[$n][2] =~ m/^[^a-z0-9]*$/is)
                      {
                        #
                        # There is no license text. So, print just
                        # the license name or definition.
                        #
                        &output ("\n");
                        &output ($workinfo_list[$n][1]);
                        &output ("\n");
                       }
                    else
                      {
                        #
                        # There is the license text. Print it!
                        #
                        &output ($workinfo_list[$n][2]);
                       }
                    if ($workinfo_list[$n][3] =~ m/^[^a-z0-9]*$/is)
                      {
                        #
                        # There are some notes. Print them.
                        #
                        &output ($workinfo_list[$n][3]);
                       }
                  }
                &output ("\\end{list}\n");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "NOMOD")
          {
            if ($type eq "start")
              {
                #
                # Increment the counter.
                #
                $nomod_sections_counter++;
                #
                # Insert an anchor.
                #
                &output ("\\almlazlabel{almlnomod$nomod_sections_counter}");
                &output ("\\hypertarget{almlnomod$nomod_sections_counter}{}");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "PRINTNOMOD")
          {
            if ($type eq "start")
              {
                my ($n) = 0;
                #
                # Insert nomod array.
                #
                &output ("\n");
                &output ("\\begin{list}{}{}\n");
                #
                # $nomod_sections_list[x][0]    level     -1..4
                # $nomod_sections_list[x][1]    description   section 1.2
                # $nomod_sections_list[x][2]    title
                # $nomod_sections_list[x][3]    html page
                #
                for ($n = 0; $n <= $#nomod_sections_list; $n++)
                  {
                    &output ("\\item");
                    &output (" ");
                    &output ($nomod_sections_list[$n][1]);
                    &output (", ");
                    &output ("\\textit{");
                    &output ($nomod_sections_list[$n][2]);
                    &output ("}");
                    &output (", ");
                    &output (&short_page_def ());
                    &output (" ");
                    #&output ("\\pageref{almlnomod$n}\n");
                    &output ("\\hyperlink{almlnomod$n}");
                    &output ("{");
                    &output ("\\almlczpageref{0}{000}{almlnomod$n}\n");
                    &output ("}");
                  }
                &output ("\\end{list}\n");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "SPECIALCONDITION")
          {
            if ($type eq "start")
              {
                &output ("\n\\begin{flushright}\\textsf{");
              }
            else
              {
                &output ("}\\end{flushright}\n");
              }
          }
        elsif ($element eq "DOCINFO")
          {
            if ($type eq "start")
              {
                #
                # Increment the docinfo counter.
                #
                $docinfo_counter++;
                #
                # Print an anchor.
                #
                &output ("\\almlazlabel{almldocinfo$docinfo_counter}");
                &output ("\\hypertarget{almldocinfo$docinfo_counter}{}");
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Discard output.
                #
                &pop_output ();
              }
          }
        elsif ($element eq "PRINTDOCINFO")
          {
            if ($type eq "start")
              {
                my ($n) = 0;
                my ($m) = 0;
                #
                # Insert docinfo array.
                #
                &output ("\n");
                &output ("\\begin{list}{}{}\n");
                #
                # $docinfo_list[x][0]       level               -1..4
                # $docinfo_list[x][1]       description     section 1.2
                # $docinfo_list[x][2]       title
                # $docinfo_list[x][3]       notes and history
                # $docinfo_list[x][4]       html page number
                #
                for ($n = 0; $n <= $#docinfo_list; $n++)
                  {
                    if ($docinfo_list[$n][1] ne "##unknown-section##")
                      {
                        #
                        # This is a usual section
                        #
                        &output ("\\item\\hspace{-0,25in}");
                        &output ($docinfo_list[$n][1]);
                        &output (", ");
                        &output ("\\textit{");
                        &output ($docinfo_list[$n][2]);
                        &output ("}");
                        &output (", ");
                        &output (&short_page_def ());
                        &output (" ");
                        &output ("\\hyperlink{almldocinfo$n}");
                        &output ("{");
                        &output ("\\almlczpageref{0}{000}{almldocinfo$n}\n");
                        &output ("}");

                        if ($docinfo_list[$n][3] ne "")
                          {
                            &output ($docinfo_list[$n][3]);
                          }
                      }
                    else
                      {
                        #
                        # This is external of usual sections
                        #
                        &output ("\\item\\hspace{-0,25in}");
                        &output (&short_page_def ());
                        &output (" ");
                        &output ("\\hyperlink{almldocinfo$n}");
                        &output ("{");
                        &output ("\\almlczpageref{0}{000}{almldocinfo$n}\n");
                        &output ("}");
                        #
                        if ($docinfo_list[$n][3] ne "")
                          {
                            &output ($docinfo_list[$n][3]);
                          }
                      }
                  }
                &output ("\\end{list}\n");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "COPY")
          {
            if ($type eq "start")
              {
                #
                $COPY_NAME = ${$attributes}{'COPY'};
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                my ($string) = "";
                #
                # Recall output (if any).
                #
                $string = &pop_output ();
                #
                # Print it.
                #
                &output ("$string");
                #
                # Save it to the copy list.
                #
                &add_copy_list ("$COPY_NAME", "$string");
                #
              }
          }
        elsif ($element eq "PASTE")
          {
            if ($type eq "start")
              {
                my ($paste) = 0;
                my ($string) = "";
                #
                $paste = ${$attributes}{'PASTE'};
                #
                $string = &get_copy_list ("$paste");
                #
                &output ("$string");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "IFHTML")
          {
            if ($type eq "start")
              {
                #
                # Put a mark inside the diagnostic output.
                #
                &diag_output (sprintf (gettext ("%s: <IFHTML> if you read errors below, these are irrelevant for the final typesetting.\n"),
                                               $PROGRAM_EXECUTABLE),
                              $V_NORMAL);
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
                #
              }
            else
              {
                #
                # Loose HTML content.
                #
                &pop_output ();
                #
                # Put a mark inside the diagnostic output.
                #
                &diag_output (sprintf (gettext ("%s: </IFHTML> if you read errors above, these are irrelevant for the final typesetting.\n"),
                                               $PROGRAM_EXECUTABLE),
                              $V_NORMAL);
              }
          }
        elsif ($element eq "HTML")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Please note that this elaboration will take place
                # anyway. If you are using this HTML element inside
                # an IFHTML, there might be a reason, for example
                # because there is no good typesetting for the
                # HTML code (think to a FORM for example).
                #
                # If this is the case, inside the diag file it might
                # appear some errors, that are irrelevant to the real
                # final typesetting:
                #
                # alml: html2ps -f:/tmp/alml_a2_TF210662tmp.css -D -o /tmp/alml_a2_TF253345tmp.ps /tmp/alml_a2_TF253345tmp.html 
                # alml: Error opening resource file: /home/a2/sorgente/.html2psrc
                # alml: GNU Ghostscript 7.07: Unrecoverable error, exit code 1
                # alml: Error: /typecheck in --length--
                # alml: Operand stack:
                # alml:    --nostringval--   --nostringval--
                # alml: Execution stack:
                # alml:    %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   1   1   1   --nostringval--   %for_pos_int_continue   1   1   2   --nostringval--   %for_pos_int_continue   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
                # alml: Dictionary stack:
                # alml:    --dict:1061/1123(ro)(G)--   --dict:0/20(G)--   --dict:68/200(L)--   --dict:491/2000(L)--
                # alml: Current allocation mode is local
                # alml: Last OS error: 2
                # alml: Current file position is 41547
                # alml: cp /tmp/alml_a2_TF253345tmp.ps 1.ps 
                # 
                # Such errors are real errors only if you want the
                # result inside the final typesetting.
                #
                my ($html_code) = "";
                my ($html_temp_file) = "";
                my ($html_css_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the HTML back-end code.
                #
                #! $html_code = $html_code . &pop_output ();
                $html_code = &pop_output ();
                #
                # Replace UTF-8 with &#NNNN;
                #
                $html_code =  &sp_html_unicode_clean ($html_code);
                #
                # Prepare the HTML temporary file.
                #
                $html_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit.
                #
                open (HTML_TEMP_FILE, "> ${html_temp_file}.html ");
                print HTML_TEMP_FILE ("<html>\n");
                print HTML_TEMP_FILE ("<body>\n");
                print HTML_TEMP_FILE ($html_code);
                print HTML_TEMP_FILE ("\n");
                print HTML_TEMP_FILE ("</body>\n");
                print HTML_TEMP_FILE ("</html>\n");
                close (HTML_TEMP_FILE);
                #
                # Prepare the CSS temporary file.
                #
                $html_css_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Must be opened as usual 8 bit file, otherwise,
                # Perl will not create the file!
                #
                open (HTML_CSS_TEMP_FILE, "> ${html_css_temp_file}.css ");
                print HTML_CSS_TEMP_FILE ("\@page {\n");
                print HTML_CSS_TEMP_FILE ("size 21cm 100cm; ");
                print HTML_CSS_TEMP_FILE ("margin-top: 0cm; ");
                print HTML_CSS_TEMP_FILE ("margin-bottom: 0cm; ");
                print HTML_CSS_TEMP_FILE ("margin-right: 0cm; ");
                print HTML_CSS_TEMP_FILE ("margin-left: 0cm;");
                print HTML_CSS_TEMP_FILE ("}\n");
                close (HTML_CSS_TEMP_FILE);
                #
                # Use HTML2ps to get the HTML code converted into
                # PostScript.
                #
                # It is better to create an empty file ./.html2psrc,
                # otherwise an error will be shown.
                #
                system ("touch .html2psrc");
                &system_diag_output ("$PROGRAM_EXECUTABLE", "html2ps -f:${html_css_temp_file}.css -D -o ${html_temp_file}.ps ${html_temp_file}.html ", $V_NORMAL);
                #
                # Print picture file.
                #
                $ps_picture_counter++;
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cp ${html_temp_file}.ps ${ps_picture_counter}.ps ", $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${html_temp_file}*");
                system ("rm -f ${html_css_temp_file}*");
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
              }
          }
        elsif ($element eq "IMG")
          {
            if ($type eq "start")
              {
                my ($imgfile) = "";
                my ($ext) = "";
                my ($alt) = "";
                my ($width) = "";
                my ($heght) = "";
                #
                # Save picture information.
                #
                $imgfile = ${$attributes}{'IMGFILE'};
                $alt = ${$attributes}{'ALT'};
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                ## About pictures.
                ##
                ## Pictures are converted into EPS for PostScript
                ## typesetting. But there is a problem: when
                ## converting to PDF with Dvipdfm, pictures are
                ## converted to PDF with a bad resolution. To resolve
                ## this problem, the EPS convertion might be made
                ## with a bigger size, but only if the width or height
                ## information is given.
                #
                # New picture.
                #
                # Prepare also PDF conversion: it might be usefull.
                #
                $ps_picture_counter++;
		#
                if (-r "$imgfile.pnm")
		  {
		    $ext = "pnm"
		  }
                elsif (-r "$imgfile.png")
		  {
		    $ext = "png"
		  }
		else
		  {
		    #
		    # The file is not there or it is not readable.
		    #
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot read picture file %s or %s!\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           "$imgfile.pnm",
                                           "$imgfile.png"), $V_ERROR);
		  }
		#
                if (-r "$imgfile.$ext")
                  {
                    #
                    # If width and/or height are available, enlarge
                    # the image.
                    #
                    if ($height ne ""
                        || $width ne "")
                      {
			&latex_png_to_eps_enlarged ("$imgfile.$ext", "$ps_picture_counter.ps");
                      }
		    else
                      {
			&latex_png_to_eps_normal ("$imgfile.$ext", "$ps_picture_counter.ps");
                      }
		    #
		    # Extra PDF picture (not currently necessary).
		    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "convert -antialias -quality 100 $imgfile.$ext PDF:$ps_picture_counter.pdf ",
                                         $V_NORMAL);
		    #
		    #
		    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s and to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "$imgfile.$ext",
                                           "$ps_picture_counter.ps",
                                           "$ps_picture_counter.pdf"), $V_NORMAL);
                  }
                else
                  {
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot convert %s to %s and to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           "$imgfile.$ext",
                                           "$ps_picture_counter.ps",
                                           "$ps_picture_counter.pdf"), $V_ERROR);
                  }
		#
		#
		#
                &output ("\\epsfig{file=$ps_picture_counter");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "EMBIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($img_code) = "";
                my ($img_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                #
                # Save picture information.
                #
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the base64 code.
                #
                $img_code = $img_code . &pop_output ();
                #
                # Prepare the temporary file.
                #
                $img_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit file.
                #
                open (IMG_TEMP_FILE, "> ${img_temp_file}.uuencode ");
                print IMG_TEMP_FILE ("begin-base64 664 dummy\n");
                print IMG_TEMP_FILE ($img_code);
                print IMG_TEMP_FILE ("\n");
                print IMG_TEMP_FILE ("====\n");
                close (IMG_TEMP_FILE);
                #
                # Get the picture with uudecode.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "uudecode -o ${img_temp_file}.uudecode ${img_temp_file}.uuencode ", $V_NORMAL);
                #
                ## About pictures.
                ##
                ## Pictures are converted into EPS for PostScript
                ## typesetting. But there is a problem: when
                ## converting to PDF with Dvipdfm, pictures are
                ## converted to PDF with a bad resolution. To resolve
                ## this problem, the EPS convertion might be made
                ## with a bigger size, but only if the width or height
                ## information is given.
                #
                $ps_picture_counter++;
                #
                # If width and/or height are available, enlarge
                # the image.
                #
                if ($height ne ""
                    || $width ne "")
                  {
		    &latex_png_to_eps_enlarged ("${img_temp_file}.uudecode", "$ps_picture_counter.ps");
                  }
		else
                  {
		    &latex_png_to_eps_normal ("${img_temp_file}.uudecode", "$ps_picture_counter.ps");
                  }
		#
		# Convert to PDF (not really necessary).
		#
		&system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "convert -antialias -quality 100 ${img_temp_file}.uudecode PDF:${ps_picture_counter}.pdf ", $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${img_temp_file}*");
                #
                # Print picture file.
                #
                &output ("\\epsfig{file=${ps_picture_counter}");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
              }
          }
        elsif ($element eq "HTMLIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Please note that this elaboration will take place
                # anyway. If you are using this HTMLIMG element inside
                # an IFHTML, there might be a reason, for example
                # because there is no good typesetting for the
                # HTML code (think to a FORM for example).
                #
                # If this is the case, inside the diag file it might
                # appear some errors, that are irrelevant to the real
                # final typesetting:
                #
                # alml: html2ps -f:/tmp/alml_a2_TF210662tmp.css -D -o /tmp/alml_a2_TF253345tmp.ps /tmp/alml_a2_TF253345tmp.html 
                # alml: Error opening resource file: /home/a2/sorgente/.html2psrc
                # alml: GNU Ghostscript 7.07: Unrecoverable error, exit code 1
                # alml: Error: /typecheck in --length--
                # alml: Operand stack:
                # alml:    --nostringval--   --nostringval--
                # alml: Execution stack:
                # alml:    %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   1   1   1   --nostringval--   %for_pos_int_continue   1   1   2   --nostringval--   %for_pos_int_continue   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
                # alml: Dictionary stack:
                # alml:    --dict:1061/1123(ro)(G)--   --dict:0/20(G)--   --dict:68/200(L)--   --dict:491/2000(L)--
                # alml: Current allocation mode is local
                # alml: Last OS error: 2
                # alml: Current file position is 41547
                # alml: cp /tmp/alml_a2_TF253345tmp.ps 1.ps 
                # 
                # Such errors are real errors only if you want the
                # result inside the final typesetting.
                #
                my ($html_code) = "";
                my ($html_temp_file) = "";
                my ($html_css_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                #
                $width  = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt    = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the HTML back-end code.
                #
                $html_code = &pop_output ();
                #
                # Replace UTF-8 with &#NNNN;
                #
                $html_code =  &sp_html_unicode_clean ($html_code);
                #
                # Prepare the HTML temporary file.
                #
                $html_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit.
                # Please note that the HTML code must be complete.
                #
                open (HTML_TEMP_FILE, "> ${html_temp_file}.html ");
                print HTML_TEMP_FILE ($html_code);
                print HTML_TEMP_FILE ("\n");
                close (HTML_TEMP_FILE);
                #
                # Use HTML2ps to get the HTML code converted into
                # PostScript.
                #
                # It is better to create an empty file ./.html2psrc,
                # otherwise an error will be shown.
                #
                system ("touch .html2psrc");
                #!  &system_diag_output ("$PROGRAM_EXECUTABLE", "html2ps -f:${html_css_temp_file}.css -D -o ${html_temp_file}.ps ${html_temp_file}.html ", $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE", "html2ps -D -o ${html_temp_file}.ps ${html_temp_file}.html ", $V_NORMAL);
                #
                # Print picture file.
                #
                $ps_picture_counter++;
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cp ${html_temp_file}.ps ${ps_picture_counter}.ps ", $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${html_temp_file}*");
                #
                # Print picture file.
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
              }
          }
        elsif ($element eq "EPSIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($eps_code) = "";
                my ($eps_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                my ($alt) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the EPS back-end code.
                #
                $eps_code = $eps_code . &pop_output ();
                #
                # Prepare the EPS temporary file.
                #
                $eps_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit file.
                #
                open (EPS_TEMP_FILE, "> ${eps_temp_file}.eps ");
                print EPS_TEMP_FILE ($eps_code);
                print EPS_TEMP_FILE ("\n");
                close (EPS_TEMP_FILE);
                #
                # Prepare picture.
                #
                $ps_picture_counter++;
                &system_diag_output ("$PROGRAM_EXECUTABLE", "eps2eps ${eps_temp_file}.eps ${ps_picture_counter}.ps ", $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${eps_temp_file}*");
                #
                # Print picture file.
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
              }
          }
        elsif ($element eq "FIGIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
                #
              }
            else
              {
                my ($fig_code) = "";
                my ($fig_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                my ($alt) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                my ($new_eps_file_name) = "";
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the Fig back-end code.
                #
                $fig_code = $fig_code . &pop_output ();
                #
                # Prepare the Fig temporary file.
                #
                $fig_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Must be opened as usual 8 bit file, otherwise,
                # Perl will not create the file!
                #
                open (FIG_TEMP_FILE, "> ${fig_temp_file}.fig");
                print FIG_TEMP_FILE ($fig_code);
                print FIG_TEMP_FILE ("\n");
                close (FIG_TEMP_FILE);
                #
                # Increment the picture counter.
                #
                $ps_picture_counter++;
                #
                # Convert the XFig draw into a EPS picture.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "fig2dev -L eps ${fig_temp_file}.fig ${fig_temp_file}.eps", $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${fig_temp_file}.eps");
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${fig_temp_file}*");
                #
                # Print.
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
              }
          }
        elsif ($element eq "GNUPLOTIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
                #
              }
            else
              {
                my ($gnuplot_code) = "";
                my ($gnuplot_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                my ($alt) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                my ($new_eps_file_name) = "";
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the Fig back-end code.
                #
                $gnuplot_code = $gnuplot_code . &pop_output ();
                #
                # Prepare the Gnuplot temporary file.
                #
                $gnuplot_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Must be opened as usual 8 bit file, otherwise,
                # Perl will not create the file!
                #
                open (GNUPLOT_TEMP_FILE, "> ${gnuplot_temp_file}.gnuplot");
                print GNUPLOT_TEMP_FILE ("set terminal postscript eps color\n");
                print GNUPLOT_TEMP_FILE ($gnuplot_code);
                print GNUPLOT_TEMP_FILE ("\n");
                close (GNUPLOT_TEMP_FILE);
                #
                # Increment the picture counter.
                #
                $ps_picture_counter++;
                #
                # Convert the Gnuplot draw into a EPS picture.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "gnuplot ${gnuplot_temp_file}.gnuplot > ${gnuplot_temp_file}.eps", $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${gnuplot_temp_file}.eps");
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${gnuplot_temp_file}*");
                #
                # Print.
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
              }
          }
        elsif ($element eq "LYIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($ly_code) = "";
                my ($ly_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                my ($alt) = "";
                my ($new_eps_file_name) = "";
                #
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the Lilypond back-end code.
                $ly_code = $ly_code . &pop_output ();
                #
                # Prepare the Lilypond temporary file.
                #
                $ly_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit file.
                #
                open (LY_TEMP_FILE, "> ${ly_temp_file}.ly ");
                print LY_TEMP_FILE ($ly_code);
                print LY_TEMP_FILE ("\n");
                print LY_TEMP_FILE ("\n");
                close (LY_TEMP_FILE);
                #
                # Increment the picture counter.
                #
                $ps_picture_counter++;
                #
                # Convert LilyPond to EPS.
                # Please note that *must* be converted "in place" (-e)
                # because otherwise it might generate an empty file.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "convert-ly -e ${ly_temp_file}.ly",
                                     $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "lilypond-bin -o ${ly_temp_file}.tex ${ly_temp_file}.ly",
                                     $V_NORMAL);
                #
                # Add extra code, so that, if no LaTeX file was
                # generated, LaTeX will not stop waiting for
                # input.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "( echo \\\\nonstopmode ; cat ${ly_temp_file}.tex 2> /dev/null ; echo \\\\end{document} ) > ${ly_temp_file}2.tex",
                                     $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "mv -f ${ly_temp_file}2.tex ${ly_temp_file}.tex",
                                     $V_NORMAL);
                #
                # Typeset with LaTeX.
                # Consider that tex can accept a file name with path,
                # but will generate a file DVI on current directory.
                # That's why I am doing this cd and basename.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cd " . &temporary_dir () . " ; latex `basename ${ly_temp_file}.tex` ",
                                     $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "dvips -E -V -o ${ly_temp_file}.eps ${ly_temp_file}.dvi ",
                                     $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${ly_temp_file}.eps");
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${ly_temp_file}*");
                #
                # Now put the picture inside the TeX source.
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
              }
          }
        elsif ($element eq "TEXIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($tex_code) = "";
                my ($tex_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                my ($alt) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                my ($new_eps_file_name) = "";
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the TeX back-end code.
                #
                $tex_code = $tex_code . &pop_output ();
                #
                # Prepare the TeX temporary file.
                $tex_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit file.
                #
                open (TEX_TEMP_FILE, "> ${tex_temp_file}.tex");
                print TEX_TEMP_FILE ("\\nonstopmode\n");
                print TEX_TEMP_FILE ("\\nopagenumbers\n");
                print TEX_TEMP_FILE ($tex_code);
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\bye\n");
                close (TEX_TEMP_FILE);
                #
                # Typeset.
                # Consider that tex can accept a file name with path,
                # but will generate a file DVI on current directory.
                # That's why I am doing this cd and basename.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cd " . &temporary_dir () . " ; tex `basename ${tex_temp_file}.tex` ",
                                     $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "dvips -E -V -o ${tex_temp_file}.eps ${tex_temp_file}.dvi ",
                                     $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${tex_temp_file}.eps");
                #
                # Prepare picture.
                #
                $ps_picture_counter++;
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps ",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${tex_temp_file}*");
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
              }
          }
        elsif ($element eq "LATEXIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($tex_code) = "";
                my ($tex_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                my ($alt) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                my ($new_eps_file_name) = "";
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the TeX back-end code.
                #
                $tex_code = $tex_code . &pop_output ();
                #
                # Prepare the TeX temporary file.
                #
                $tex_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit file.
                #
                open (TEX_TEMP_FILE, "> ${tex_temp_file}.tex");
                print TEX_TEMP_FILE ("\\nonstopmode\n");
                print TEX_TEMP_FILE ($tex_code);
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\end{document}\n");
                close (TEX_TEMP_FILE);
                #
                # Typeset.
                # Consider that tex can accept a file name with path,
                # but will generate a file DVI on current directory.
                # That's why I am doing this cd and basename.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE", "dvips -E -V -o ${tex_temp_file}.eps ${tex_temp_file}.dvi ", $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${tex_temp_file}.eps");
                #
                # Prepare picture.
                #
                $ps_picture_counter++;
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps ",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${tex_temp_file}*");
                #
                # Print picture file.
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
              }
          }
        elsif ($element eq "ASCIIART")
          {
            if ($type eq "start")
              {
                #
                # Save column width.
                #
                $g_preformatted_column_width = ${$attributes}{'WIDTH'};
                #
                # Correct min and max.
                #
                if ($g_preformatted_column_width eq "")
                  {
                    $g_preformatted_column_width = 80;
                  }
                elsif ($g_preformatted_column_width le 0)
                  {
                    #
                    # There isn't an environment here
                    #
                    $g_preformatted_column_width = 80;
                  }
                elsif ($g_preformatted_column_width < 30)
                  {
                    $g_preformatted_column_width = 30;
                  }
                elsif ($g_preformatted_column_width > 200)
                  {
                    $g_preformatted_column_width = 200;
                  }
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
		my ($new_eps_file_name) = "";
                my ($tex_temp_file) = "";
                my (@dim) = ();
                my ($height) = "";
                my ($width) = "";
                my ($pre) = "";
                my ($font_size) =
                    (int ((46.3 * &convert_to_mm_as_number ($PRINTED_BODY_WIDTH))
                          / $g_preformatted_column_width)) / 10;
                my ($font_spacing) = $font_size*1.2;
                #
                # The normal mode for output() function is re-established.
                #
                $pre = &pop_output ();
                #
                # Do some transformations for good printing.
                #
                $pre = &latex_literal_verbatim ($pre);
                $pre = &latex_literal_step_2 ($pre);
                #!  $pre = &latex_literal_step_3 ($pre);
                #
                # Prepare the TeX temporary file.
                #
                $tex_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                open (TEX_TEMP_FILE, ">:utf8", "${tex_temp_file}.tex");
                print TEX_TEMP_FILE ("\\nonstopmode");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\documentclass{article}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\setlength{\\textwidth}{$paper_width}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\setlength{\\textheight}{$paper_height}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage\[autogenerated,warnunknown,postscript\]{ucs}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage\[utf8\]{inputenc}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage\[T1\]{fontenc}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage{amssymb} % for some math symbols");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage{amsfonts} % for some math symbols");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage{amsbsy} % for some math symbols");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage{pifont} % for some ding symbols");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage{textcomp}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage{color}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage{wasysym} % for some ding symbols");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\usepackage{mathrsfs} % for some math");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\renewcommand{\\ttdefault}{pcr} % times.sty");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\begin{document}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\pagestyle{empty}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\parindent 0.0 in");
                print TEX_TEMP_FILE ("\n");
                #
                # The \par at the beguinning and at the end, is
                # necessary because the font change is inside {...},
                # and without the last one the base line skip does not
                # take affect. So, the first \par is there for simmetry.
                #
                print TEX_TEMP_FILE ("{");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\par");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\fontsize{$font_size}{$font_spacing}\\selectfont");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("{");
                print TEX_TEMP_FILE ("\\begin{ttfamily}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("$pre");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\end{ttfamily}");
                print TEX_TEMP_FILE ("}");
                print TEX_TEMP_FILE ("\\par");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("}");
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\end{document}");
                print TEX_TEMP_FILE ("\n");
                close (TEX_TEMP_FILE);
                #
                # Typeset.
                # Consider that tex can accept a file name with path,
                # but will generate a file DVI on current directory.
                # That's why I am doing this cd and basename.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ",
                                     $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE", "dvips -E -V -o ${tex_temp_file}.ps ${tex_temp_file}.dvi ", $V_NORMAL);
                #
                # Prepare picture.
                #
                $ps_picture_counter++;
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${tex_temp_file}.ps");
		#
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${tex_temp_file}*");
                #
                # Print picture file.
                #
                &output ("\n");
                &output ("\\begin{center}\n");
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                &output ("\n\\end{center}\n");
              }
          }
        elsif ($element eq "IMAGE")
          {
            if ($type eq "start")
              {
                my ($imgfile) = "";
                my ($ext) = "";
                my ($width) = "";
                my ($heght) = "";
                #
                # Save picture information.
                #
                $imgfile = ${$attributes}{'IMGFILE'};
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                ## About pictures.
                ##
                ## Pictures are converted into EPS for PostScript
                ## typesetting. But there is a problem: when
                ## converting to PDF with Dvipdfm, pictures are
                ## converted to PDF with a bad resolution. To resolve
                ## this problem, the EPS convertion might be made
                ## with a bigger size, but only if the width or height
                ## information is given.
                #
                # New picture.
                #
                # Prepare also PDF conversion: it might be usefull.
                #
                $ps_picture_counter++;
		#
                if (-r "$imgfile.pnm")
		  {
		    $ext = "pnm"
		  }
                elsif (-r "$imgfile.png")
		  {
		    $ext = "png"
		  }
		else
		  {
		    #
		    # The file is not there or it is not readable.
		    #
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot read picture file %s or %s!\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           "$imgfile.pnm",
                                           "$imgfile.png"), $V_ERROR);
		  }
		#
                if (-r "$imgfile.$ext")
                  {
        	    #
            	    # If width and/or height are available, enlarge
                    # the image.
	            #
    	            if ($height ne ""
        	        || $width ne "")
            	      {
			&latex_png_to_eps_enlarged ("$imgfile.$ext", "$ps_picture_counter.ps");
            	      }
		    else
            	      {
		        &latex_png_to_eps_normal ("$imgfile.$ext", "$ps_picture_counter.ps");
            	      }
		    #
		    # PDF picture.
		    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "convert -antialias -quality 100 $imgfile.$ext PDF:$ps_picture_counter.pdf ", $V_NORMAL);
                    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s and %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "$imgfile.$ext",
                                           "$ps_picture_counter.ps",
                                           "$ps_picture_counter.pdf"), $V_NORMAL);
                  }
                else
                  {
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot convert %s to %s and %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           "$imgfile.$ext",
                                           "$ps_picture_counter.ps",
                                           "$ps_picture_counter.pdf"), $V_ERROR);
                  }
                &output ("\n");
                &output ("\\begin{center}\n");
                &output ("\\epsfig{file=$ps_picture_counter");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}\n");
                &output ("\\end{center}\n");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "EMBIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($img_code) = "";
                my ($img_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                #
                # Save picture information.
                #
                $width  = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt    = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the base64 code.
                #
                $img_code = $img_code . &pop_output ();
                #
                # Prepare the temporary file.
                #
                $img_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit file.
                #
                open (IMG_TEMP_FILE, "> ${img_temp_file}.uuencode ");
                print IMG_TEMP_FILE ("begin-base64 664 dummy\n");
                print IMG_TEMP_FILE ($img_code);
                print IMG_TEMP_FILE ("\n");
                print IMG_TEMP_FILE ("====\n");
                close (IMG_TEMP_FILE);
                #
                # Get the picture with uudecode.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "uudecode -o ${img_temp_file}.uudecode ${img_temp_file}.uuencode ", $V_NORMAL);
                #
                ##
                ## About pictures.
                ##
                ## Pictures are converted into EPS for PostScript
                ## typesetting. But there is a problem: when
                ## converting to PDF with Dvipdfm, pictures are
                ## converted to PDF with a bad resolution. To resolve
                ## this problem, the EPS convertion might be made
                ## with a bigger size, but only if the width or height
                ## information is given.
                ##
                #
                $ps_picture_counter++;
                #
                # If width and/or height are available, enlarge
                # the image.
                #
                if ($height ne ""
                    || $width ne "")
                  {
		    &latex_png_to_eps_enlarged ("${img_temp_file}.uudecode", "$ps_picture_counter.ps");
                  }
		else
                  {
		    &latex_png_to_eps_normal ("${img_temp_file}.uudecode", "$ps_picture_counter.ps");
                  }
		#
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "convert -antialias -quality 100 ${img_temp_file}.uudecode PDF:${ps_picture_counter}.pdf ", $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${img_temp_file}*");
                #
                # Print picture file.
                #
                &output ("\n");
                &output ("\\begin{center}\n");
                &output ("\\epsfig{file=${ps_picture_counter}");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
                &output ("\n");
                &output ("\\end{center}");
                &output ("\n");
              }
          }
        elsif ($element eq "HTMLIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Please note that this elaboration will take place
                # anyway. If you are using this HTMLIMAGE element inside
                # an IFHTML, there might be a reason, for example
                # because there is no good typesetting for the
                # HTML code (think to a FORM for example).
                #
                # If this is the case, inside the diag file it might
                # appear some errors, that are irrelevant to the real
                # final typesetting:
                #
                # alml: html2ps -f:/tmp/alml_a2_TF210662tmp.css -D -o /tmp/alml_a2_TF253345tmp.ps /tmp/alml_a2_TF253345tmp.html 
                # alml: Error opening resource file: /home/a2/sorgente/.html2psrc
                # alml: GNU Ghostscript 7.07: Unrecoverable error, exit code 1
                # alml: Error: /typecheck in --length--
                # alml: Operand stack:
                # alml:    --nostringval--   --nostringval--
                # alml: Execution stack:
                # alml:    %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   1   1   1   --nostringval--   %for_pos_int_continue   1   1   2   --nostringval--   %for_pos_int_continue   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
                # alml: Dictionary stack:
                # alml:    --dict:1061/1123(ro)(G)--   --dict:0/20(G)--   --dict:68/200(L)--   --dict:491/2000(L)--
                # alml: Current allocation mode is local
                # alml: Last OS error: 2
                # alml: Current file position is 41547
                # alml: cp /tmp/alml_a2_TF253345tmp.ps 1.ps 
                # 
                # Such errors are real errors only if you want the
                # result inside the final typesetting.
                #
                my ($html_code) = "";
                my ($html_temp_file) = "";
                my ($html_css_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                #
                $width  = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt    = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the HTML back-end code.
                #
                $html_code = &pop_output ();
                #
                # Replace UTF-8 with &#NNNN;
                #
                $html_code =  &sp_html_unicode_clean ($html_code);
                #
                # Prepare the HTML temporary file.
                #
                $html_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit.
                # Please note that the HTML code must be complete.
                #
                open (HTML_TEMP_FILE, "> ${html_temp_file}.html ");
                print HTML_TEMP_FILE ($html_code);
                print HTML_TEMP_FILE ("\n");
                close (HTML_TEMP_FILE);
                #
                # Use HTML2ps to get the HTML code converted into
                # PostScript.
                #
                # It is better to create an empty file ./.html2psrc,
                # otherwise an error will be shown.
                #
                system ("touch .html2psrc");
                &system_diag_output ("$PROGRAM_EXECUTABLE", "html2ps -D -o ${html_temp_file}.ps ${html_temp_file}.html ", $V_NORMAL);
                #
                # Print picture file.
                #
                &output ("\n");
                &output ("\\begin{center}");
                &output ("\n");
                #
                $ps_picture_counter++;
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cp ${html_temp_file}.ps ${ps_picture_counter}.ps ", $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${html_temp_file}*");
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                #
                &output ("\n");
                &output ("\\end{center}");
                &output ("\n");
                #
              }
          }
        elsif ($element eq "EPSIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($eps_code) = "";
                my ($eps_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the EPS back-end code.
                #
                $eps_code = $eps_code . &pop_output ();
                #
                # Prepare the EPS temporary file.
                #
                $eps_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit file.
                #
                open (EPS_TEMP_FILE, "> ${eps_temp_file}.eps ");
                print EPS_TEMP_FILE ($eps_code);
                print EPS_TEMP_FILE ("\n");
                close (EPS_TEMP_FILE);
                #
                # Print picture file.
                #
                &output ("\n");
                &output ("\\begin{center}\n");
                #
                $ps_picture_counter++;
                #
                # Include the PostScript picture.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "eps2eps ${eps_temp_file}.eps ${ps_picture_counter}.ps ", $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${eps_temp_file}*");
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                &output ("\n");
                #
                &output ("\\end{center}");
                &output ("\n");
              }
          }
        elsif ($element eq "FIGIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($fig_code) = "";
                my ($fig_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the FIG back-end code.
                #
                $fig_code = $fig_code . &pop_output ();
                #
                # Prepare the FIG temporary file.
                #
                $fig_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit file.
                #
                open (FIG_TEMP_FILE, "> ${fig_temp_file}.fig ");
                print FIG_TEMP_FILE ("$fig_code");
                #
                print FIG_TEMP_FILE ("\n");
                close (FIG_TEMP_FILE);
                #
                # Increment the picture counter.
                #
                $ps_picture_counter++;
                #
                # Convert the pictrure properly.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "fig2dev -L eps ${fig_temp_file}.fig ${fig_temp_file}.eps", $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${fig_temp_file}.eps");
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${fig_temp_file}*");
                #
                # Print picture file.
                #
                &output ("\n");
                &output ("\\begin{center}\n");
                #
                # Include the EPS picture.
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                &output ("\n\\end{center}\n");
              }
          }
        elsif ($element eq "GNUPLOTIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($gnuplot_code) = "";
                my ($gnuplot_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the Gnuplot back-end code.
                #
                $gnuplot_code = $gnuplot_code . &pop_output ();
                #
                # Prepare the Gnuplot temporary file.
                #
                $gnuplot_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open as usual 8 bit file.
                #
                open (GNUPLOT_TEMP_FILE, "> ${gnuplot_temp_file}.gnuplot ");
                print GNUPLOT_TEMP_FILE ("set terminal postscript eps color\n");
                print GNUPLOT_TEMP_FILE ("$gnuplot_code");
                #
                print GNUPLOT_TEMP_FILE ("\n");
                close (GNUPLOT_TEMP_FILE);
                #
                # Increment the picture counter.
                #
                $ps_picture_counter++;
                #
                # Convert the pictrure properly.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "gnuplot ${gnuplot_temp_file}.gnuplot > ${gnuplot_temp_file}.eps", $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${gnuplot_temp_file}.eps");
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${gnuplot_temp_file}*");
                #
                # Print picture file.
                #
                &output ("\n");
                &output ("\\begin{center}\n");
                #
                # Include the EPS picture.
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                &output ("\n\\end{center}\n");
              }
          }
        elsif ($element eq "LYIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
                #
              }
            else
              {
                my ($ly_code) = "";
                my ($ly_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                my ($new_eps_file_name) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the LY back-end code.
                #
                $ly_code = $ly_code . &pop_output ();
                #
                # Prepare the LY temporary file.
                #
                $ly_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # At the moment it is opened as usual 8 bit file.
                #
                open (LY_TEMP_FILE, "> ${ly_temp_file}.ly ");
                print LY_TEMP_FILE ($ly_code);
                print LY_TEMP_FILE ("\n");
                print LY_TEMP_FILE ("\n");
                close (LY_TEMP_FILE);
                #
                # Increment the picture counter.
                #
                $ps_picture_counter++;
                #
                # Convert LilyPond to EPS.
                # Please note that *must* be converted "in place" (-e)
                # because otherwise it might generate an empty file.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "convert-ly -e ${ly_temp_file}.ly",
                                     $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "lilypond-bin -o ${ly_temp_file}.tex ${ly_temp_file}.ly",
                                     $V_NORMAL);
                #
                # Add extra code, so that, if no LaTeX file was
                # generated, LaTeX will not stop waiting for
                # input.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "( echo \\\\nonstopmode ; cat ${ly_temp_file}.tex 2> /dev/null ; echo \\\\end{document} ) > ${ly_temp_file}2.tex",
                                     $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "mv -f ${ly_temp_file}2.tex ${ly_temp_file}.tex",
                                     $V_NORMAL);
                #
                # Typeset with LaTeX.
                # Consider that tex can accept a file name with path,
                # but will generate a file DVI on current directory.
                # That's why I am doing this cd and basename.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cd " . &temporary_dir () . " ; latex `basename ${ly_temp_file}.tex` ",
                                     $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "dvips -E -V -o ${ly_temp_file}.eps ${ly_temp_file}.dvi ",
                                     $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${ly_temp_file}.eps");
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${ly_temp_file}*");
                #
                # Print picture file.
                #
                &output ("\n");
                &output ("\\begin{center}\n");
                #
                # Include the EPS picture.
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                &output ("\n\\end{center}\n");
              }
          }
        elsif ($element eq "TEXIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($tex_code) = "";
                my ($tex_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the TeX back-end code.
                $tex_code = $tex_code . &pop_output ();
                #
                # Prepare the TeX temporary file.
                $tex_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Must be opened as usual 8 bit file, otherwise,
                # Perl will not create the file!
                #
                open (TEX_TEMP_FILE, "> ${tex_temp_file}.tex");
                print TEX_TEMP_FILE ("\\nonstopmode\n");
                print TEX_TEMP_FILE ("\\nopagenumbers\n");
                print TEX_TEMP_FILE ($tex_code);
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\bye\n");
                close (TEX_TEMP_FILE);
                #
                # Typeset.
                # Consider that tex can accept a file name with path,
                # but will generate a file DVI on current directory.
                # That's why I am doing this cd and basename.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; tex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE", "dvips -E -V -o ${tex_temp_file}.eps ${tex_temp_file}.dvi ", $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                #
                $new_eps_file_name = &filter_eps ("${tex_temp_file}.eps");
                #
                # Print picture file.
                #
                &output ("\n");
                &output ("\\begin{center}\n");
                $ps_picture_counter++;
                #
                # Include the PostScript picture.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cp $new_eps_file_name ${ps_picture_counter}.ps ", $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${tex_temp_file}*");
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                &output ("\n\\end{center}\n");
              }
          }
        elsif ($element eq "LATEXIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($tex_code) = "";
                my ($tex_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my (@dim) = ();
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Restore the TeX back-end code.
                #
                $tex_code = $tex_code . &pop_output ();
                #
                # Prepare the TeX temporary file.
                #
                $tex_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Opened as usual 8 bit file.
                #
                open (TEX_TEMP_FILE, "> ${tex_temp_file}.tex");
                print TEX_TEMP_FILE ("\\nonstopmode\n");
                print TEX_TEMP_FILE ($tex_code);
                print TEX_TEMP_FILE ("\n");
                print TEX_TEMP_FILE ("\\end{document}\n");
                close (TEX_TEMP_FILE);
                #
                # Typeset.
                # Consider that tex can accept a file name with path,
                # but will generate a file DVI on current directory.
                # That's why I am doing this cd and basename.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                &system_diag_output ("$PROGRAM_EXECUTABLE", "dvips -E -V -o ${tex_temp_file}.eps ${tex_temp_file}.dvi ", $V_NORMAL);
                #
                # Filter the EPS file to get a better one, with
                # fonts.
                $new_eps_file_name = &filter_eps ("${tex_temp_file}.eps");
                #
                # Print picture file.
                #
                &output ("\n");
                &output ("\\begin{center}\n");
                $ps_picture_counter++;
                #
                # Include the PostScript picture.
                #
                &system_diag_output ("$PROGRAM_EXECUTABLE",
                                     "cp $new_eps_file_name ${ps_picture_counter}.ps ",
                                     $V_NORMAL);
                #
                # Remove temporary files now.
                #
                system ("rm -f ${tex_temp_file}*");
                #
                &output ("\\epsfig{file=${ps_picture_counter}.ps");
                if ($height ne "")
                  {
                    &output (",height=$height");
                  }
                if ($width ne "")
                  {
                    &output (",width=$width");
                  }
                &output (",angle=0}");
                &output ("\n\\end{center}\n");
                #
              }
          }
        else
          {
            #
            # Call the basic %block; and %inline; sub process.
            #
            &sgml_tag_elab_latex_basic
                ($type,
                 $element,
                 $attributes,
                 $typesetting,
                 $target,
                 $draft,
                 $page_numbering,
                 "", #! $compact,
                 "", #! $long,
                 "", #! $original_file_name,
                 "", #! $current_file_name,
                 "", #! $root_file_name,
                 $paper_width,
                 $paper_height);
          }
        #
        # Aftere the true analisys, we have to check if there
        # is a block of "{\samepage", made by a section header,
        # that must be closed with a "}"
        # Another block like this is before all the if/elsif block
        #
        if ($type ne "start"
            && $element eq $next_element_after_header_to_be_closed)
          {
            if ($next_element_after_header_to_be_closed_nest_level <= 0)
              {
                # It is right to close the header "same page" block.
                &output ("}% samepage-end from an H* element\n");
                # Reset the element name.
                $next_element_after_header_to_be_closed = "";
              }
            else
              {
                $next_element_after_header_to_be_closed_nest_level--;
              }
          }
    } # sgml_tag_elab_latex
    #
    # This is the sub elaboration process specific, for basic %block;
    # and %inline; elements, for the HTML back-end.
    #
    # &sgml_tag_elab_html_basic (TYPE, ELEMENT, %ATTRIBUTES,
    #                            TYPESETTING,
    #                            TARGET,
    #                            DRAFT,
    #                            PAGE-NUMBERING,
    #                            COMPACT,
    #                            LONG,
    #                            ORIGINAL_NAME,
    #                            ROOT_FILE_NAME)
    #
    sub sgml_tag_elab_html_basic
    {
        #
        # Function arguments.
        #
        my ($type)               = $_[0];
        my ($element)            = $_[1];
        my ($attributes)         = $_[2];
        my ($typesetting)        = $_[3];
        my ($target)             = $_[4];
        my ($draft)              = $_[5];
        my ($page_numbering)     = $_[6];
        #! my ($compact)            = $_[7];
        #! my ($long)               = $_[8];
        #! my ($original_file_name) = $_[9];
        #! my ($current_file_name)  = $_[10];
        #! my ($root_file_name)     = $_[11];
        my ($paper_width)        = $_[12];
        my ($paper_height)       = $_[13];
        #
        # Element handlers.
        # Element names and attribute names are uppercase.
        #
        if ($element eq "P")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<P>");
              }
            else
              {
                &output ("</P>\n");
              }
          }
        elsif ($element eq "BR")
          {
            if ($type eq "start")
              {
                &output ("<BR>\n");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "URI")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($uri_literal) = "";
                my ($uri_print)   = "";
                #
                $uri_literal = &pop_output ();
                $uri_print   = &html_literal_verbatim ($uri_literal);
                chomp($uri_print);
		#
                $uri_literal = &literal_uri_adaptation ($uri_literal);
		#
		# Must replace "%26" with "&amp;".
		#
	        $uri_literal =~ s/\%26/\&amp;/mg;
                #
		#
		#
                &output ("&lt;<EM><A HREF=\""
                         . $uri_literal
                         . "\">"
                         . $uri_print
                         . "</A></EM>&gt;");
              }
          }
        elsif ($element eq "EMAIL")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($email_literal) = "";
                my ($email_print)   = "";
                #
                $email_literal = &pop_output ();
                $email_print   = &html_literal_verbatim ($email_literal);
                chomp($email_print);
		#
		# Must replace "@" and ".".
		#
	        $email_print =~ s/\./&middot;/mg;
	        $email_print =~ s/\@/&thinsp;(ad)&thinsp;/mg;
                #
		#
		#
                &output ("&lt;<EM>$email_print</EM>&gt;");
              }
          }
        elsif ($element eq "MAN")
          {
            if ($type eq "start")
              {
                &output ("<EM>");
              }
            else
              {
                &output ("");
              }
          }
        elsif ($element eq "MANSECT")
          {
            if ($type eq "start")
              {
                &output ("</EM>(");
              }
            else
              {
                &output (")");
              }
          }
        elsif ($element eq "BIBREF")
          {
            if ($type eq "start")
              {
                &output ("<EM>");
              }
            else
              {
                &output ("</EM>");
              }
          }
        elsif ($element eq "EM")
          {
            if ($type eq "start")
              {
                &output ("<EM>");
              }
            else
              {
                &output ("</EM>");
              }
          }
        elsif ($element eq "BIG")
          {
            if ($type eq "start")
              {
		#
                # <BIG> is not available with HTML ISO 15445.
		#
                &output ("<SPAN CLASS=\"big\">");
              }
            else
              {
                #
                # </BIG> is not available with HTML ISO 15445.
                #
                &output ("</SPAN>");
              }
          }
        elsif ($element eq "SMALL")
          {
            if ($type eq "start")
              {
                #
                # <SMALL> is not available with HTML ISO 15445.
                #
                &output ("<SPAN CLASS=\"small\">");
              }
            else
              {
                #
                # </SMALL> is not available with HTML ISO 15445.
                #
                &output ("</SPAN>");
              }
          }
        elsif ($element eq "STRONG")
          {
            if ($type eq "start")
              {
                &output ("<STRONG>");
              }
            else
              {
                &output ("</STRONG>");
              }
          }
        elsif ($element eq "ACRONYM")
          {
            if ($type eq "start")
              {
                &output ("<ACRONYM>");
              }
            else
              {
                &output ("</ACRONYM>");
              }
          }
        elsif ($element eq "DACRONYM")
          {
            if ($type eq "start")
              {
                &output ("<EM>");
              }
            else
              {
                &output ("</EM>");
              }
          }
        elsif ($element eq "KBD")
          {
            if ($type eq "start")
              {
                &output ("[<KBD>");
              }
            else
              {
                &output ("</KBD>]");
              }
          }
        elsif ($element eq "KP")
          {
            if ($type eq "start")
              {
                if ($target eq "HTML-TEXT")
                  {
            	    &output ("num(");
                  }
                else
                  {
            	    &output ("<SUP>");
		  }
              }
            else
              {
                if ($target eq "HTML-TEXT")
                  {
            	    &output (")");
                  }
                else
                  {
            	    &output ("</SUP>");
		  }
              }
          }
        elsif ($element eq "VKBD")
          {
            if ($type eq "start")
              {
                &output ("&lt;<KBD>");
              }
            else
              {
                &output ("</KBD>&gt;");
              }
          }
        elsif ($element eq "REVISION")
          {
            if ($type eq "start")
              {
                &output ("[<EM>");
              }
            else
              {
                &output ("</EM>]");
              }
          }
        elsif ($element eq "BUTTON")
          {
            if ($type eq "start")
              {
                &output ("&lt;<CODE>");
              }
            else
              {
                &output ("</CODE>&gt;");
              }
          }
        elsif ($element eq "MENUITEM")
          {
            if ($type eq "start")
              {
                &output ("{<CODE>");
              }
            else
              {
                &output ("</CODE>}");
              }
          }
        elsif ($element eq "ASCIICODE")
          {
            if ($type eq "start")
              {
                &output ("&lt;<EM>");
              }
            else
              {
                &output ("</EM>&gt;");
              }
          }
        elsif ($element eq "CODE")
          {
            if ($type eq "start")
              {
                &output ("<CODE>");
              }
            else
              {
                &output ("</CODE>");
              }
          }
        elsif ($element eq "SAMP")
          {
            if ($type eq "start")
              {
                &output ("<SAMP>");
              }
            else
              {
                &output ("</SAMP>");
              }
          }
        elsif ($element eq "STRDFN")
          {
            if ($type eq "start")
              {
                &output ("<EM>");
              }
            else
              {
                &output ("</EM>");
              }
          }
        elsif ($element eq "KERNELOPTION")
          {
            if ($type eq "start")
              {
                &output ("<EM>");
		#
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: the element \"kerneloption\" is obsolete; you might use \"menuitem\" instead.\n"),
                             $PROGRAM_EXECUTABLE,
                             $SOURCE_FILE_NAME,
                             $CURRENT_FILE_NAME,
                             $INPUT_STREAM_LINE_COUNTER), $V_WARNING);
              }
            else
              {
                &output ("</EM>");
              }
          }
        elsif ($element eq "FILE")
          {
            if ($type eq "start")
              {
                &output ("<CODE CLASS=\"file\">");
              }
            else
              {
                &output ("</CODE>");
              }
          }
        elsif ($element eq "URISTR")
          {
            if ($type eq "start")
              {
                &output ("<CODE>");
              }
            else
              {
                &output ("</CODE>");
              }
          }
        elsif ($element eq "SUP")
          {
            if ($type eq "start")
              {
                &output ("<SUP>");
              }
            else
              {
                &output ("</SUP>");
              }
          }
        elsif ($element eq "SUB")
          {
            if ($type eq "start")
              {
                &output ("<SUB>");
              }
            else
              {
                &output ("</SUB>");
              }
          }
        elsif ($element eq "PWR")
          {
            if ($type eq "start")
              {
                if ($target eq "HTML-TEXT")
                  {
                    &output ("^");
                  }
                else
                  {
                    &output ("<SUP>");
                  }
              }
            else
              {
                if ($target eq "HTML-TEXT")
                  {
                    &output ("");
                  }
                else
                  {
                    &output ("</SUP>");
                  }
              }
          }
        elsif ($element eq "EXA")
          {
            if ($type eq "start")
              {
                if ($target eq "HTML-TEXT")
                  {
                    #&output ("0x");
                    &output ("(");
                  }
                else
                  {
                    #
                    # Nothing to do;
                    #
                    ;
                  }
              }
            else
              {
                if ($target eq "HTML-TEXT")
                  {
                    &output (")_16");
                  }
                else
                  {
                    &output ("<SUB>16</SUB>");
                  }
              }
          }
        elsif ($element eq "DEC")
          {
            if ($type eq "start")
              {
                if ($target eq "HTML-TEXT")
                  {
                    &output ("(");
                  }
                else
                  {
                    #
                    # Nothing to do;
                    #
                    ;
                  }
              }
            else
              {
                if ($target eq "HTML-TEXT")
                  {
                    &output (")_10");
                  }
                else
                  {
                    &output ("<SUB>10</SUB>");
                  }
              }
          }
        elsif ($element eq "OCT")
          {
            if ($type eq "start")
              {
                if ($target eq "HTML-TEXT")
                  {
                    &output ("(");
                  }
                else
                  {
                    #
                    # Nothing to do;
                    #
                    ;
                  }
              }
            else
              {
                if ($target eq "HTML-TEXT")
                  {
                    &output (")_8");
                  }
                else
                  {
                    &output ("<SUB>8</SUB>");
                  }
              }
          }
        elsif ($element eq "BIN")
          {
            if ($type eq "start")
              {
                if ($target eq "HTML-TEXT")
                  {
                    &output ("(");
                  }
                else
                  {
                    #
                    # Nothing to do;
                    #
                    ;
                  }
              }
            else
              {
                if ($target eq "HTML-TEXT")
                  {
                    &output (")_2");
                  }
                else
                  {
                    &output ("<SUB>2</SUB>");
                  }
              }
          }
        elsif ($element eq "NUM")
          {
            if ($type eq "start")
              {
                #
                # Save data here.
                #
                push_output ();
              }
            else
              {
                my ($num) = "";
                my ($int) = "";
                my ($dec) = "";
                my ($point) = "";
                my ($sep) = "";
                my ($plus) = "";
                my ($minus) = "";
                #
                # Recall output.
                #
                $num = &pop_output ();
                #
                # The separator is a &nbsp;.
                #
                $sep = "&nbsp;";
                $plus = "+";
                $minus = "-";
                #
                # Now, start elaboration, to separate each three digits.
                #
                if ($num =~ m/^([+-]?)([0-9]*)([.,]?)([0-9]*)$/)
                  {
                    $sign  = $1;
                    $int   = $2;
                    $point = $3;
                    $dec   = $4;
                    $int   = &integer_to_string ($int, $sep);
                    $dec   = &decimal_to_string ($dec, $sep);
                    #
                    # Correct integer side if necessary.
                    #
                    if ($int eq "")
                      {
                        $int = "0";
                      }
                    #
                    # Set the sign prefix.
                    #
                    if ($sign eq "+")
                      {
                        $sign = $plus;
                      }
                    elsif ($sign eq "-")
                      {
                        $sign = $minus;
                      }
                    else
                      {
                        $sign = "";
                      }

                    if ($dec eq "")
                      {
                        #
                        # Nothing after the decimal marker.
                        #
                        &output ($sign . $int);
                      }
                    else
                      {
                        &output ($sign . $int . $point . $dec);
                      }
                  }
                else
                  {
                    #
                    # This is not a valid number.
                    #
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: wrong number %s\n"),
                                  $PROGRAM_EXECUTABLE,
                                  $SOURCE_FILE_NAME,
                                  $CURRENT_FILE_NAME,
                                  $INPUT_STREAM_LINE_COUNTER,
                                  $num), $V_ERROR);
                    #
                    # Anyway, print it out.
                    #
                    &output ($num);
                  }
              }
          }
        elsif ($element eq "TEX")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Loose the TeX back-end code.
                #
                &pop_output ();
              }
          }
        elsif ($element eq "IFTEX")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Loose the TeX back-end code.
                #
                &pop_output ();
              }
          }
        elsif ($element eq "HTML")
          {
            if ($type eq "start")
              {
		#
		# As any HTML code can be inserted, it cannot be
		# ensured the ISO 15445 compatibility for current
		# page. Sorry.
		#
		$STANDARD_ISO_15445 = 0;
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($line)      = "";
                #
                # Prepare HTML temporary file.
                #
                my ($temp_file) = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                #
                # Open the temporary file.
                # The pop output is saved inside the file, because it
                # might be very big and must be elaborated line per
                # line.
                #
                open (TEMP_FILE, ">:utf8", "${temp_file}.html");
                print TEMP_FILE (&pop_output ());
                close (TEMP_FILE);
                #
                # Reopen the file and scan it.
                #
                open (TEMP_FILE, "<:utf8", "${temp_file}.html");
                while ($line = <TEMP_FILE>)
                  {
                    #
                    # Output modified HTML line.
                    # Replace UTF-8 with &#NNNN;
                    #
                    &output (&sp_html_unicode_clean ($line));
                    #
                    &wait_message ("$PROGRAM_EXECUTABLE:$SOURCE_FILE_NAME:$CURRENT_FILE_NAME:$line");
                  }                
                close (TEMP_FILE);
                #
                # Delete temporary files.
                #
                system ("rm -f ${temp_file}*");
              }
          }
        elsif ($element eq "IFHTML")
          {
            if ($type eq "start")
              {
                #
                # Nothing to do here;
                #
                ;
              }
            else
              {
                #
                # Nothing to do here;
                #
                ;
              }
          }
        elsif ($element eq "BLOCKQUOTE")
          {
            if ($type eq "start")
              {
                &output ("<BLOCKQUOTE>\n");
                #
                # Save the URI.
                #
                $last_quote_uri = ${$attributes}{'URI'};
              }
            else
              {
                if (defined ($last_quote_uri)
                    && $last_quote_uri ne "")
                  {
                    my ($n) = 0;
                    #
                    # Put the URI at a footnote.
                    #
                    # Prepare a new element inside the footnote array.
                    #
                    $#html_footnote_list++;
                    $n = $#html_footnote_list +1;
                    #
                    # Insert the footnote link.
                    #
                    &output ("<P><SUP><A HREF=\"#almlfootnote$n\" NAME=\"almlfootnote-ref$n\">($n)</A></SUP></P>");
                    #
                    # Insert the footnote inside the array.
                    #
                    $html_footnote_list[$#html_footnote_list]
                      = "<A HREF=\"$last_quote_uri\">$last_quote_uri</A>";
                  }
                &output ("\n");
                &output ("</BLOCKQUOTE>\n");
              }
          }
        elsif ($element eq "FRAME")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<TABLE CLASS=\"frame\" SUMMARY=\"\">");
                &output ("\n");
                &output ("<TBODY>");
                &output ("<TR>");
                &output ("<TD>");
                &output ("\n");
              }
            else
              {
                &output ("\n");
                &output ("</TD>");
                &output ("</TR>");
                &output ("</TBODY>");
                &output ("\n");
                &output ("</TABLE>");
                &output ("\n");
              }
          }
        elsif ($element eq "PRE")
          {
            if ($type eq "start")
              {
                #
                # Save attributes.
                #
                $g_preformatted_column_width = ${$attributes}{'WIDTH'};
                $g_preformatted_border       = ${$attributes}{'BORDER'};
                $g_preformatted_numbering    = ${$attributes}{'NUMBERING'};
                #
                if ($g_preformatted_border)
                  {
                    &output ("\n");
                    &output ("<TABLE CLASS=\"pre\" SUMMARY=\"\">\n");
                    &output ("<TBODY>");
                    &output ("<TR>");
                    &output ("<TD>");
                    &output ("\n");
                  }
                #
                &output ("\n");
                &output ("<PRE>");
                #
                &push_output ();
              }
            else
              {
                my ($pre);
                $pre = &pop_output ();
                #
                $pre = &html_block ($pre, $g_preformatted_numbering);
                #
                &output ("$pre");
                &output ("</PRE>\n");
                #
                if ($g_preformatted_border)
                  {
                    &output ("\n");
                    &output ("</TD>");
                    &output ("</TR>");
                    &output ("</TBODY>");
                    &output ("\n");
                    &output ("</TABLE>");
                    &output ("\n");
                  }
              }
          }
        elsif ($element eq "PNEWLINE")
          {
            if ($type eq "start")
              {
                #
                # No sub or sup are supported.
                #
                &output ("<STRONG CLASS=\"newline\">\\</STRONG><BR>");
                &output ("&nbsp;&nbsp;<STRONG CLASS=\"newline\">\\</STRONG>");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "ASCIIART")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<PRE>");
                &push_output ();
              }
            else
              {
                my ($pre);
                $pre = &pop_output ();
                $pre = &html_literal_verbatim ($pre);
                &output ("$pre");
                &output ("</PRE>\n");
              }
          }
        elsif ($element eq "VERBATIMPRE")
          {
            if ($type eq "start")
              {
                #
                # Save attributes.
                #
                $g_preformatted_column_width = ${$attributes}{'WIDTH'};
                $g_preformatted_border       = ${$attributes}{'BORDER'};
                $g_preformatted_numbering    = ${$attributes}{'NUMBERING'};
                #
                if ($g_preformatted_border)
                  {
                    &output ("\n");
                    &output ("<TABLE CLASS=\"pre\" SUMMARY=\"\">\n");
                    &output ("<TBODY>");
                    &output ("<TR>");
                    &output ("<TD>");
                    &output ("\n");
                  }
                #
                &output ("\n");
                &output ("<PRE>");
                #
                &push_output ();
              }
            else
              {
                my ($pre);
                $pre = &pop_output ();
                $pre = &html_literal_verbatim ($pre);
                
                $pre = &html_block ($pre, $g_preformatted_numbering);
                
                &output ("$pre");
                &output ("</PRE>\n");

                if ($g_preformatted_border)
                  {
                    &output ("\n");
                    &output ("</TD>");
                    &output ("</TR>");
                    &output ("</TBODY>");
                    &output ("\n");
                    &output ("</TABLE>");
                    &output ("\n");
                  }
              }
          }
        elsif ($element eq "SYNTAX")
          {
            if ($type eq "start")
              {
                my ($sep) = "";
		#
                # Save attributes.
		#
                $sep = lc ${$attributes}{'SEP'};
		#
                # It is supposed that the value is valid.
		#
                $syntax_separation = $sep;
		#
                # Send the output stream to a new stack level.        
		#
                &push_output ();
		#
              }
            else
              {
                my ($syntax) = "";
                my ($string) = "";
                my ($string_up) = "";
                my ($string_down) = "";
                my ($string_next) = "";
		#
                # The normal mode for output() function is re-established.
		#
                $syntax = &pop_output ();
		#
                # Change space into "&nbsp;".
                # But don't change it inside HTML elements.
		#
                $string      = "";
                $string_next = $syntax;
		#
                while ($string_next ne "")
                  {
                    if ($string_next =~ m/^(<[^<>]*>)(.*)$/s)
                      {
                        $string_up   = $1;
                        $string_down = $2;
                        $string      = $string . $string_up;
                        $string_next = $string_down;
                      }
		    #
                    if ($string_next =~ m/^([^<>]*)(.*)$/s)
                      {
                        $string_up   = $1;
                        $string_down = $2;
                        $string_up   =~ s/ /&nbsp;/g;
                        $string      = $string . $string_up;
                        $string_next = $string_down;
                      }
                    else
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:%s:ERROR: regexp should always match.\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           $element), $V_ERROR);
			#
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:%s:ERROR: %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           $element,
                                           $string_next), $V_ERROR);
			#
                        $string      = $string . $string_next;
                        last
                      }
		    #
                  }
		#
                $syntax = $string;
		#
                # Change new line code into <BR>.
		#
                $syntax =~ s/$/\n<BR>/mg;
		#
                # Change last <BR> into nothing.
		#
                $syntax =~ s/<BR>$//;
		#
                # Start drawing the syntax element.
		#
                &output ("\n");
		#
                if ($syntax_separation eq "box"
                    || $syntax_separation eq "border")
                  {
                    &output ("<TABLE CLASS=\"syntax\" SUMMARY=\"\">");
                    &output ("\n");
                    &output ("<TBODY>");
                    &output ("<TR>");
                    &output ("<TD>");
                    &output ("\n");
                  }
		#
                &output ("<P CLASS=\"syntax\">");
                &output ("<CODE>");
                &output ("$syntax");
                &output ("</CODE>");
                &output ("</P>");
                &output ("\n");
		#
                if ($syntax_separation eq "box"
                    || $syntax_separation eq "border")
                  {
                    &output ("</TD>");
                    &output ("</TR>");
                    &output ("</TBODY>");
                    &output ("\n");
                    &output ("</TABLE>");
                    &output ("\n");
                  }
              }
          }
        elsif ($element eq "SNEWLINE")
          {
            if ($type eq "start")
              {
                &output ("</CODE><STRONG CLASS=\"newline\">\\</STRONG><BR>");
                &output ("&nbsp;&nbsp;<STRONG CLASS=\"newline\">\\</STRONG><CODE>");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "DL")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<DL>\n");
              }
            else
              {
                &output ("</DL>\n");
              }
          }
        elsif ($element eq "DT")
          {
            if ($type eq "start")
              {
                &output ("<DT>");
              }
            else
              {
                &output ("</DT>\n");
              }
          }
        elsif ($element eq "DD")
          {
            if ($type eq "start")
              {
                &output ("<DD>\n");
              }
            else
              {
                &output ("</DD>\n");
              }
          }
        elsif ($element eq "OL")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<OL>\n");
              }
            else
              {
                &output ("</OL>\n");
              }
          }
        elsif ($element eq "UL")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<UL>\n");
              }
            else
              {
                &output ("</UL>\n");
              }
          }
        elsif ($element eq "LI")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<LI>\n");
              }
            else
              {
                &output ("</LI>\n");
              }
          }
        elsif ($element eq "SEGMENT")
          {
            if ($type eq "start")
              {
		#
		# This is obsolete; warn the user.
		#
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: element \"segment\" is obsolete; please use \"dl\" instead.\n"),
                             $PROGRAM_EXECUTABLE,
                             $SOURCE_FILE_NAME,
                             $CURRENT_FILE_NAME,
                             $INPUT_STREAM_LINE_COUNTER), $V_WARNING);
		#
                &output ("\n");
                &output ("<DL>\n");
              }
            else
              {
                &output ("</DD>\n");
                &output ("</DL>\n");
              }
          }
        elsif ($element eq "SEGMENTHEAD")
          {
            if ($type eq "start")
              {
                &output ("<DT><STRONG>");
              }
            else
              {
                &output ("</STRONG></DT>\n");
                &output ("<DD>\n");
              }
          }
        elsif ($element eq "VAR")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                my ($var) = "";
                $var = &pop_output ();

                if ($target eq "HTML-TEXT")
                  {
                    # It would be fine to put it under upper case, but
                    # it isn't possibile: sub element names will be translated
                    # into upper case too, with attributes; but the worse
                    # thing is that also entities would be changed,
                    # and this is not possibile!
                    $var = "&lt;$var&gt;";
                    &output ("<VAR>$var</VAR>");
                  }
                else
                  {
                    # &output ("&thinsp;<VAR>$var</VAR>&thinsp;");
                    # &thinsp; does not work because it requires Unicode!
                    # The problem of <var>...</var><var>...</var> remains,
                    # so that the two variables might seem one different
                    # bigger variable.
                    &output ("<VAR>$var</VAR>");
                  }
              }
          }
        elsif ($element eq "SYNSQB")
          {
            if ($type eq "start")
              {
                &output ("<STRONG CLASS=\"syn\">[</STRONG>");
              }
            else
              {
                &output ("<STRONG CLASS=\"syn\">]</STRONG>");
              }
          }
        elsif ($element eq "SYNCUB")
          {
            if ($type eq "start")
              {
                &output ("<STRONG CLASS=\"syn\">{</STRONG>");
              }
            else
              {
                &output ("<STRONG CLASS=\"syn\">}</STRONG>");
              }
          }
        elsif ($element eq "SYNVERBAR")
          {
            if ($type eq "start")
              {
                &output ("<STRONG CLASS=\"syn\">|</STRONG>");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "SYNELLIPSIS")
          {
            if ($type eq "start")
              {
                &output ("...");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "SYNSTAR")
          {
            if ($type eq "start")
              {
                &output ("<STRONG CLASS=\"syn\">*</STRONG>");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "RESULT")
          {
            if ($type eq "start")
              {
                &output ("<STRONG CLASS=\"syn\">=&gt;</STRONG>");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "HR")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<HR>\n");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "NEWPAGE")
          {
            if ($type eq "start")
              {
                # Nothing to do.
                ;
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "HEIGHTREQUIRED")
          {
            if ($type eq "start")
              {
                # Nothing to do.
                ;
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "BOTTOMPAGE")
          {
            if ($type eq "start")
              {
                # Nothing to do.
                ;
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "COMMAND")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<P CLASS=\"command\">");
              }
            else
              {
                &output ("</P>\n");
              }
          }
        elsif ($element eq "PROMPT")
          {
            if ($type eq "start")
              {
                &output ("<CODE>");
              }
            else
              {
                &output ("</CODE>");
              }
          }
        elsif ($element eq "TYPE")
          {
            if ($type eq "start")
              {
                &output ("<STRONG><CODE>");
              }
            else
              {
                &output ("</CODE></STRONG>");
              }
          }
        elsif ($element eq "CNEWLINE")
          {
            if ($type eq "start")
              {
                &output ("</CODE><STRONG CLASS=\"newline\">\\</STRONG><BR>");
                &output ("&nbsp;&nbsp;<STRONG CLASS=\"newline\">\\</STRONG><CODE>");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "ENDOFCHAPTER")
          {
            if ($type eq "start")
              {

                
                # Just start a paragraph.
                

                &output ("<P>");

              }
            else
              {

                
                # Just end a paragraph.
                

                &output ("</P>");

              }
          }
        elsif ($element eq "BACKCOVER")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $back_cover = &pop_output ();

                ## With %block; elements, there is a line feed character
                ## at the top of the string. I don't know why.
                ## Anyway, we have to delete this extra line feed.
                #$front_cover_bottom =~ s/^\n?(.*)$/$1/s;

                # Fix HTML page counter.
                $html_back_cover_page = 1;
              }
          }

    } # sgml_tag_elab_html_basic
    #
    # This is the elaboration process specific for the HTML back-end.
    #
    # &sgml_tag_elab_html (TYPE, ELEMENT, %ATTRIBUTES,
    #                      TYPESETTING,
    #                      TARGET,
    #                      DRAFT,
    #                      PAGE-NUMBERING,
    #                      COMPACT,
    #                      LONG,
    #                      ORIGINAL_NAME,
    #                      ROOT_FILE_NAME)
    #
    sub sgml_tag_elab_html
    {
        #
        # Function arguments.
        #
        my ($type)               = $_[0];
        my ($element)            = $_[1];
        my ($attributes)         = $_[2];
        my ($typesetting)        = $_[3];
        my ($target)             = $_[4];
        my ($draft)              = $_[5];
        my ($page_numbering)     = $_[6];
        #! my ($compact)            = $_[7];
        #! my ($long)               = $_[8];
        #! my ($original_file_name) = $_[9];
        #! my ($current_file_name)  = $_[10];
        #! my ($root_file_name)     = $_[11];
        my ($paper_width)        = $_[12];
        my ($paper_height)       = $_[13];
        #
        # Prepare the HTML header.
        #
        # &html_standard_page_top (ROOT_FILE_NAME,
        #                          CURRENT_PAGE_NUMBER,
        #                          MAX_PAGE,
        #                          HTML_EXT,
        #                          HTML_LANGUAGE,
        #                          META_HTTP_EQUIV,
        #                          META_DESCRIPTION,
        #                          META_KEYWORDS,
        #                          META_AUTHOR,
        #                          META_DATE,
        #                          TITLE)
        #
        sub html_standard_page_top
        {
            #! my ($name)        = $_[0];
            my ($page)        = $_[1];
            my ($max_page)    = $_[2];
            my ($html_ext)    = $_[3];
            my ($lang)        = $_[4];
            my ($http_equiv)  = $_[5];
            my ($description) = $_[6];
            my ($keywords)    = $_[7];
            my ($author)      = $_[8];
            my ($date)        = $_[9];
            my ($title)       = $_[10];
	    #
            my ($current)     = "";
            my ($previous)    = "";
            my ($next)        = "";
            my ($up)          = "";
            my ($last)        = "";
            my ($next_page)     = $page + 1;
            my ($previous_page) = $page - 1;
	    #
            my ($n)         = 0;
            my ($m)         = 0;
	    #
            my ($tome_up)       = "";
            my ($part_up)       = "";
            my ($navigation_up) = "";
	    #
            my ($line)          = "";
            my ($link_description)      = "";
	    #
            # Calculate link pages.
	    #
            if ($page == 0)
              {
                $current = $ROOT_FILE_NAME . $html_ext;
              }
            else
              {
                $current = $ROOT_FILE_NAME . $page . $html_ext;
              }
	    #
            if ($page > 1)
              {
                $previous = $ROOT_FILE_NAME . $previous_page . $html_ext;
              }
            else
              {
                $previous = $ROOT_FILE_NAME . $html_ext;
              }
	    #
            if ($page < $max_page)
              {
                $next = $ROOT_FILE_NAME . $next_page . $html_ext;
              }
            else
              {
                $next = $ROOT_FILE_NAME . $page . $html_ext;
              }
	    #
            $up = $ROOT_FILE_NAME . $html_ext;
            $last = $ROOT_FILE_NAME . $max_page . $html_ext;
	    #
            # Print Header.
	    #
            &output ("<!DOCTYPE HTML PUBLIC \"ISO/IEC 15445:2000//DTD HTML//EN\">\n");
            &output ("<HTML LANG=\"$lang\">\n");
            &output ("<HEAD>\n");
            &output ("    <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"$http_equiv\">\n");
            &output ("    <META NAME=\"Generator\" CONTENT=\"Alml\">\n");
	    #
            if ($description ne "")
              {
                &output ("    <META NAME=\"Description\" CONTENT=\"$description\">\n");
              }
	    #
            if ($keywords ne "")
              {
                &output ("    <META NAME=\"Keywords\" CONTENT=\"$keywords\">\n");
              }
	    #
            &output ("    <META NAME=\"Author\" CONTENT=\"$author\">\n");
            &output ("    <META NAME=\"Date\" CONTENT=\"$date\">\n");
	    #
            # HTML meta tags.
            #
            # $html_meta_tag[x][0]        name
            # $html_meta_tag[x][1]        lang
            # $html_meta_tag[x][2]        content
	    #
            for ($n = 0 ; $n <= $#html_meta_tag ; $n++)
              { 
                &output ("    <META NAME=\""
                         . $html_meta_tag[$n][0]
                         . "\" ");
                if ($html_meta_tag[$n][1] ne "")
                  {
                    &output ("LANG=\""
                             . $html_meta_tag[$n][1]
                             . "\" ");
                  }
                if ($html_meta_tag[$n][2] ne "")
                  {
                    &output ("CONTENT=\""
                             . $html_meta_tag[$n][2]
                             . "\" ");
                  }
                &output (">\n");
              }
            &output ("    <TITLE>$title</TITLE>");
            &output ("\n");
            &output ("    <STYLE TYPE=\"text/css\">");
            &output ("\n");
            &output ("        <!--");
            &output ("\n");
            if (-e "$ROOT_FILE_NAME.css")
	      {
	        #
		# Read the user specified CSS style.
		#
	        open (HTML_CSS_FILE, "<:utf8", "$ROOT_FILE_NAME.css");
        	while ($line = <HTML_CSS_FILE>)
            	  {
            	    &output ("$line");
        	  }
        	close (HTML_CSS_FILE);
	      }
	    else
	      {
	        #
		# Give a default CSS style.
		#
		&output ("BODY {\n");
		&output ("    background-color: rgb(255, 255, 255)\n");
		&output ("}\n");
		&output ("H1 {\n");
		&output ("    text-align: right\n");
		&output ("    color: rgb(230, 100, 180)\n");
		&output ("}\n");
		&output ("SAMP {\n");
		&output ("    quotes:           \"'\" \"'\";\n");
		&output ("    font-style:       bold;\n");
		&output ("}\n");
		&output ("SAMP:before {\n");
		&output ("    content:          open-quote;\n");
		&output ("}\n");
		&output ("SAMP:after {\n");
		&output ("    content:          close-quote;\n");
		&output ("}\n");
		&output ("CODE.file {\n");
		&output ("    quotes:           \"'\" \"'\";\n");
		&output ("}\n");
		&output ("CODE.file:before {\n");
		&output ("    content:          open-quote;\n");
		&output ("}\n");
		&output ("CODE.file:after {\n");
		&output ("    content:          close-quote;\n");
		&output ("}\n");
		&output ("\n");
		&output ("P.syntax {\n");
		&output ("    width:            auto;\n");
		&output ("    text-align:       left\n");
		&output ("}\n");
		&output ("P.caption {\n");
		&output ("    text-align:       left;\n");
		&output ("    font-style:       italic;\n");
		&output ("    width:            100%;\n");
		&output ("    background-color: lightgray;\n");
		&output ("}\n");
		&output ("P.command {\n");
		&output ("    text-align:       left;\n");
		&output ("    width:            auto;\n");
		&output ("#   width:            100%;\n");
		&output ("    border-style:     none;\n");
		&output ("    background-color: cyan;\n");
		&output ("}\n");
		&output ("P.fullpagepicture {\n");
		&output ("    text-align:       center;\n");
		&output ("}\n");
		&output ("P {\n");
		&output ("    /* text-align: justify */\n");
		&output ("    text-align: left\n");
		&output ("}\n");
		&output ("P.validator {\n");
		&output ("    border-style:     none;\n");
		&output ("}\n");
		&output ("DIV.listing {\n");
		&output ("    width:            auto;\n");
		&output ("    background-color: lightblue;\n");
		&output ("}\n");
		&output ("DIV.example {\n");
		&output ("    width:            auto;\n");
		&output ("    background-color: lightyellow;\n");
		&output ("}\n");
		&output ("TABLE.frame {\n");
		&output ("    width:            100%;\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    background-color: yellow;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("TABLE.pre {\n");
		&output ("#   width:            100%;\n");
		&output ("    width:            auto;\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    background-color: lightgray;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("TABLE.syntax {\n");
		&output ("#   width:            100%;\n");
		&output ("    width:            auto;\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    background-color: cyan;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("TABLE.figurewrapper {\n");
		&output ("    width:            100%;\n");
		&output ("    border-style:     none;\n");
		&output ("}\n");
		&output ("TABLE.figure {\n");
		&output ("    width:            100%;\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    background-color: lightgray;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("TABLE.listing {\n");
		&output ("#   width:            100%;\n");
		&output ("    width:            auto;\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("TABLE.example {\n");
		&output ("#   width:            100%;\n");
		&output ("    width:            auto;\n");
		&output ("    border-color:     blue;\n");
		&output ("    border-style:     solid;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("TABLE.table {\n");
		&output ("    width:            100%;\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    border-width:     thin;\n");
		&output ("    background-color: lightgreen;\n");
		&output ("}\n");
		&output ("THEAD.border {\n");
		&output ("    background-color: lightcyan;\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("THEAD.noborder {\n");
		&output ("    background-color: lightcyan;\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("TBODY.border {\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("TBODY.noborder {\n");
		&output ("    border-style:     none;\n");
		&output ("}\n");
		&output ("\n");
		&output ("TD.border {\n");
		&output ("    border-color:     black;\n");
		&output ("    border-style:     solid;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
		&output ("TR.noborder {\n");
		&output ("    border-style:     none;\n");
		&output ("}\n");
		&output ("STRONG.syn {\n");
		&output ("    font-size:        120%;\n");
		&output ("}\n");
		&output ("STRONG.newline {\n");
		&output ("    font-size:        162%;\n");
		&output ("}\n");
		&output ("SPAN.big {\n");
		&output ("    font-size:        120%;\n");
		&output ("}\n");
		&output ("SPAN.small {\n");
		&output ("    font-size:        80%;\n");
		&output ("}\n");
		&output ("SPAN.visible_label {\n");
		&output ("    font-size:        75%;\n");
		&output ("    font-style:       italic;\n");
		&output ("    font-weight:      bold;\n");
		&output ("    color:	        blue;\n");
		&output ("    border-color:     green;\n");
		&output ("    border-style:     solid;\n");
		&output ("    border-width:     thin;\n");
		&output ("}\n");
	      }
            &output ("        -->");
            &output ("\n");
            &output ("    </STYLE>");
            &output ("\n");
            &output ("    <LINK REL=\"Start\" TITLE=\"Start\" HREF=\"$up\">");
            &output ("\n");
            &output ("    <LINK REL=\"Prev\" TITLE=\"Previous\" HREF=\"$previous\">");
            &output ("\n");
            &output ("    <LINK REL=\"Next\" TITLE=\"Next\" HREF=\"$next\">");
            &output ("\n");
            &output ("</HEAD>");
            &output ("\n");
            &output ("<BODY>");
            &output ("\n");
            &output ("<P>");
            &output ("\n");
            &output ("<A HREF=\"$next\">[" . &next_page_def () . "]</A>");
            &output ("\n");
            &output ("<A HREF=\"$previous\">[" . &previous_page_def () . "]</A>");
            &output ("\n");
            &output ("<A HREF=\"$up\">[" . &top_page_def () . "]</A>");
            &output ("\n");
            &output ("<A HREF=\"$last\">[" . &last_page_def () . "]</A>");
            &output ("\n");
            #
            # Insert fixed navigation links.
            #
            # $html_page_fixed_link_list[x][0]        html page number
            # $html_page_fixed_link_list[x][1]        link description
            #
            for ($n = 0; $n <= $#html_page_fixed_link_list; $n++)
              {
                #
                $link_description = $html_page_fixed_link_list[$n][1];
                if ($link_description =~ m/^\&(.*)$/)
                  {
                    $link_description = &{$1} ();
                  }
                #
                $navigation_up = $ROOT_FILE_NAME
                                 . $html_page_fixed_link_list[$n][0]
                                 . $html_ext;
                #
                &output ("<A HREF=\"$navigation_up\">["
                         . $link_description
                         . "]</A>\n");
              }
            #
            if ($document_position eq "body"
                && $tome > 0)
              {
                #
                # Need to extract tome page number.
                # Remember that arrays have starting index 0.
                #
                $tome_up = $ROOT_FILE_NAME
                           . $html_page_tome_link_list[$tome-1]
                           . $html_ext;
                #
                &output ("<A HREF=\"$tome_up\">[" . &tome_def () . "]</A>\n");
              }
            if ($document_position eq "body"
                && $part > 0
                && $part_present)
              {
                #
                # Need to extract part page number.
                # Remember that arrays have starting index 0.
                #
                $part_up = $ROOT_FILE_NAME
                           . $html_page_part_link_list[$part-1]
                           . $html_ext;

                &output ("<A HREF=\"$part_up\">[" . &part_def () . "]</A>\n");
              }
            &output ("</P>\n");
            &output ("<HR>\n");
            #
            # With HTML ISO 15445, the element DIV cannot contain
            # H1, H2, ... H6 elements. It was:
	    # &output ("<DIV>\n");
	    #
        }
        #
        # Prepare the HTML footer.
        #
        # &html_standard_page_bottom (ROOT_FILE_NAME,
        #                             CURRENT_PAGE_NUMBER,
        #                             MAX_PAGE,
        #                             HTML_EXT)
        #
        sub html_standard_page_bottom
        {
            #! my ($name)       = $_[0];
            my ($page)       = $_[1];
            my ($max_page)   = $_[2];
            my ($html_ext)   = $_[3];
            #
            my ($current)    = "";
            my ($previous)   = "";
            my ($next)       = "";
            my ($up)         = "";
            my ($last)       = "";
            my ($next_page)     = $page + 1;
            my ($previous_page) = $page - 1;
            #
            my ($n)         = 0;
            my ($m)         = 0;
            #
            my ($tome_up)       = "";
            my ($part_up)       = "";
            #
            my ($human_readable_file_name) = "";
            my ($link_description) = "";
            #
            # Calculate link pages.
            #
            if ($page == 0)
              {
                $current = $ROOT_FILE_NAME . $html_ext;
              }
            else
              {
                $current = $ROOT_FILE_NAME . $page . $html_ext;
              }
            #
            if ($page > 1)
              {
                $previous = $ROOT_FILE_NAME . $previous_page . $html_ext;
              }
            else
              {
                $previous = $ROOT_FILE_NAME . $html_ext;
              }
            if ($page < $max_page)
              {
                $next = $ROOT_FILE_NAME . $next_page . $html_ext;
              }
            else
              {
                $next = $ROOT_FILE_NAME . $page . $html_ext;
              }
            $up = $ROOT_FILE_NAME . $html_ext;
            $last = $ROOT_FILE_NAME . $max_page . $html_ext;
            #
            # Print footnotes.
            #
            &html_standard_footnotes ();
            #
            # Print Footer.
            #
            # With HTML ISO 15445, the element DIV cannot contain
            # H1, H2, ... H6 elements. It was:
            # &output ("<DIV>\n");
            #
            &output ("<HR>\n");
            #
            # Fix human readable file name.
            #
            $human_readable_file_name
              = &human_readable_file_name ($last_html_page_title, $html_ext);
            #
            system ("ln -s $current $human_readable_file_name");
            #
            &output ("<P>"
                     . &may_link_to_human_readable_name_def ()
                     . " <A HREF=\"$human_readable_file_name\">"
                     . $human_readable_file_name
                     . "</A></P>\n");
            #
            &output ("<P>\n");
            &output ("<A HREF=\"$next\">[" . &next_page_def () . "]</A>\n");
            &output ("<A HREF=\"$previous\">[" . &previous_page_def () . "]</A>\n");
            &output ("<A HREF=\"$up\">[" . &top_page_def () . "]</A>\n");
            &output ("<A HREF=\"$last\">[" . &last_page_def () . "]</A>\n");
            #
            # Insert fixed navigation links.
            #
            # $html_page_fixed_link_list[x][0]        html page number
            # $html_page_fixed_link_list[x][1]        link description
            #
            for ($n = 0; $n <= $#html_page_fixed_link_list; $n++)
              {
                #
                $link_description = $html_page_fixed_link_list[$n][1];
                if ($link_description =~ m/^\&(.*)$/)
                  {
                    $link_description = &{$1} ();
                  }
                #
                $navigation_up = $ROOT_FILE_NAME
                                 . $html_page_fixed_link_list[$n][0]
                                 . $html_ext;
                &output ("<A HREF=\"$navigation_up\">["
                         . $link_description
                         . "]</A>\n");
                #
              }
            #
            # The bottom page links about tome and part is difficult
            # to fix, because the tome and the part might be changed.
            # So, there is no tome and no part link at the bottom.
            #
            &output ("</P>\n");
            #
            # Add ISO-HTML validation icon, if it is possible.
            #
	    if ($STANDARD_ISO_15445)
	      {
		#
		#
		#
        	&output ("<P CLASS=\"validator\">");
        	&output ("<A HREF=\"http://validator.w3.org/check/referer\">");
        	&output ("<IMG SRC=\"http://validator.w3.org/images/v15445\" ");
        	&output ("ALT=\"Valid ISO-HTML!\"></A></P>");
        	&output ("\n");
		#
	      }
	    #
	    # Reset to standard for next page.
	    #
	    $STANDARD_ISO_15445 = 1;
            #
            &output ("</BODY>\n");
            &output ("</HTML>\n");
	    #
        }
        #
        # Print HTML footnotes and clear footnote list
        #
        # &html_standard_footnotes ()
        #
        sub html_standard_footnotes
        {
            #
            # Print footnotes.
            #
            if ($#html_footnote_list >= 0)
              {
                &output ("<HR>\n");
                for ($n = 0; $n <= $#html_footnote_list; $n++)
                  {
                    $m = $n +1;
                    &output ("\n");
                    &output ("<P>");
                    &output ("<A HREF=\"#almlfootnote-ref$m\" NAME=\"almlfootnote$m\">$m)</A> ");
                    &output ($html_footnote_list[$n]);
                    &output ("</P>\n");
                  }
              }
            #
            # Reset footnote list.
            #
            @html_footnote_list = ();
        }
        #
        # Prepare a new HTML page: close the previous and start the next.
        # It is better not to use this function, because it is difficult
        # to have complete data to build the bottom of the previous
        # HTML page.
        #
        # &html_new_page (ROOT_FILE_NAME,
        #                 MAX_PAGE,
        #                 HTML_EXT,
        #                 HTML_LANGUAGE,
        #                 META_HTTP_EQUIV,
        #                 META_DESCRIPTION,
        #                 META_KEYWORDS,
        #                 META_AUTHOR,
        #                 META_DATE,
        #                 TITLE)
        #
        sub html_new_page
        {
            #! my ($name)         = $_[0];
            my ($max_page)     = $_[1]; # True or false
            my ($html_ext)     = $_[2];
            my ($lang)         = $_[3];
            my ($http_equiv)   = $_[4];
            my ($description)  = $_[5];
            my ($keywords)     = $_[6];
            my ($author)       = $_[7];
            my ($date)         = $_[8];
            my ($title)        = $_[9];
            #
            # Print bottom HTML page.
            #
            &html_standard_page_bottom ("", #! $name,
                                        $html_page_counter,
                                        $max_page,
                                        $html_ext);
            #
            # Close output stream.
            #
            close ($CURRENT_OUTPUT_STREAM);
            #
            # Increment the HTML page counter (global variable).
            #
            $html_page_counter++;
            #
            # Reopen.
            #
            $CURRENT_OUTPUT_STREAM = $ROOT_FILE_NAME . $html_page_counter . $html_ext;
            open ($CURRENT_OUTPUT_STREAM, ">:utf8", $ROOT_FILE_NAME . $html_page_counter . $html_ext);
            #
            # Print top HTML page.
            #
            &html_standard_page_top ("". #! $name,
                                     $html_page_counter,
                                     $max_page,
                                     $html_ext,
                                     $CURRENT_LANGUAGE,
                                     "text/html",
                                     $description,
                                     $keywords,
                                     $author,
                                     $date,
                                     $title);
        }
        #
        # Determinate the right string to generate for a text table
        # element.
        #
        # The problem is that we know the final number of columns
        # that we want, but actually the cell has also HTML
        # markup. Some calculation is neaded.
        #
        # &html_table_cell_string (CELL, WIDTH)
        #
        sub html_table_cell_string
        {
            my ($cell)  = $_[0];
            my ($width) = $_[1];
            my ($elab_cell)    = "";
            my ($gross_length) = 0;
            my ($net_length)   = 0;
            my ($diff_length)  = 0;

            $elab_cell = $cell;
            #
            # Calculate the actual gross length.
            #
            $gross_length = length ($elab_cell);
            #
            # Reduce the string, eliminating HTML elements and
            # extra HTML entities, just like it was done
            # when calculating originally the length.
            #
            # Remember that at the first scan, some element are
            # just absent: SPECIAL, DFN, ANCHOR and INDEXENTRY.
            # At this moments, these elements are translated
            # into A elements. These A elements must be
            # just discarded.
            #
            $elab_cell =~ s/<A .*?>//ig;
            $elab_cell =~ s/<\/A>//ig;
            #
            # VAR elements have an additional "<" and ">" added.
            # This addition must be considered while counting
            # the net string length.
            #
            $elab_cell =~ s/<VAR>&lt;/_/ig;
            $elab_cell =~ s/&gt;<\/VAR>/_/ig;
            #
            # Other elements are treated as a single character
            #
            $elab_cell =~ s/<.*?>/_/ig;
            #
            # Entities are meant to be single letters.
            #
            $elab_cell =~ s/&[a-z]+;/\?/ig;
            #
            # Calculate net length.
            #
            $net_length = length ($elab_cell);
            #
            # Calculate the difference.
            #
            $diff_length = $gross_length - $net_length;
            #
            $cell = $cell . &spaces (200);
            $cell = substr ($cell, 0, $width + $diff_length);
            #
            return $cell;
            #
        }
        #
        # Element handlers.
        # Element names and attribute names are uppercase.
        #
        if ($element eq "ALML")
          {
            if ($type eq "start")
              {
		#
                # Reset counters, flags and arrays.
		#
                $intro = 0;
                $tome = 0;
                $part = 0;
                $tome_present = 0;
                $part_present = 0;
                $appendix_present = 0;
                $index_present = 0;
                $intro_present = 0;
                $chapter = 0;
                $h1section_absolute_counter = 0;
                $appendix = 0;
                $sect1 = 0;         
                $sect2 = 0;         
                $sect3 = 0;         
                $index = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
                $table = 0;
                $absolute_table = 0;
                $picture =  0;
                $absolute_figure = 0;
                $absolute_listing = 0;
                $absolute_example = 0;
                $unnumbered = 0;
                $current_level = "";
                $document_position = "";
                $index_entry_counter = 0;
                $workinfo_counter = 0;
                $html_max_page          = $html_page_counter + $html_back_cover_page;
                $html_page_counter      = 0;
                $html_picture_counter   = 0;
                @html_footnote_list     = ();
		$STANDARD_ISO_15445 = 1;
                #
                # Save administrative information.
                #
                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                $DOCUMENT_LANGUAGE = $CURRENT_LANGUAGE;
                $TOME_LANGUAGE = $CURRENT_LANGUAGE;
                $PART_LANGUAGE = $CURRENT_LANGUAGE;
                $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                $DOCUMENT_SPACING = lc ${$attributes}{'SPACING'};
                #!  #
                #!  # Reset the human readable file name list.
                #!  #
                #!  $html_human_readable_file_name_list = ();
              }
            else
              {
                #
                # If back cover page...
                #
                if ($back_cover ne "")
                  {
                    #
                    # There is another final page.
                    #
                    # New HTML page now.
                    #
                    if ($target eq "HTML-TEXT")
                      {
                        #
                        # Nothing to do here; footnotes are
                        # printed at the very last as the counter
                        # cannot be reset befor the end of this
                        # big HTML page.
                        #
                        ;
                      }
                    else
                      {
                        #
                        # Close the previous HTML page
                        #
                        # &html_standard_page_bottom (ROOT_FILE_NAME,
                        #                             CURRENT_PAGE_NUMBER,
                        #                             MAX_PAGE,
                        #                             HTML_EXT)
                        #
                        &html_standard_page_bottom
                          ("", #! $root_file_name,
                           $html_page_counter,
                           $html_max_page,
                           $html_ext);
                        #
                        # Close output stream.
                        #
                        close ($CURRENT_OUTPUT_STREAM);
                        #
                        # Increment the HTML page counter (global variable)
                        #
                        $html_page_counter++;
                        #
                        # Set language information to document language.
                        #
                        $CURRENT_LANGUAGE = $DOCUMENT_LANGUAGE;
                        #
                        # Set the page title
                        #
                        $last_html_page_title = &last_page_def ();
                        #
                        # Reopen.
                        #
                        $CURRENT_OUTPUT_STREAM = $ROOT_FILE_NAME
                                                 . $html_page_counter
                                                 . $html_ext;
                        open ($CURRENT_OUTPUT_STREAM,
                              ">:utf8",
                              $ROOT_FILE_NAME
                              . $html_page_counter
                              . $html_ext);
                        #
                        # Print top HTML page.
                        #
                        # &html_standard_page_top (ROOT_FILE_NAME,
                        #                          CURRENT_PAGE_NUMBER,
                        #                          MAX_PAGE,
                        #                          HTML_EXT,
                        #                          HTML_LANGUAGE,
                        #                          META_HTTP_EQUIV,
                        #                          META_DESCRIPTION,
                        #                          META_KEYWORDS,
                        #                          META_AUTHOR,
                        #                          META_DATE,
                        #                          TITLE)
                        #
                        &html_standard_page_top ("", #! $root_file_name,
                                                 $html_page_counter,
                                                 $html_max_page,
                                                 $html_ext,
                                                 $CURRENT_LANGUAGE,
                                                 "text/html",
                                                 $DOCUMENT_DESCRIPTION,
                                                 $DOCUMENT_KEYWORDS,
                                                 "@authors",
                                                 $date,
                                                 $title);
                      }
                  }
                #
                &output ("\n");
                #
                if ($back_cover ne "")
                  {
                    &output ("$back_cover");
                  }
                #
                # Close the HTML source
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # This is the end of the file. It is time
                    # to print footnotes.
                    #
                    &html_standard_footnotes ();
                    &output ("</BODY>\n");
                    &output ("</HTML>\n");
                  }
                else
                  {
                    #
                    # &html_standard_page_bottom (ROOT_FILE_NAME,
                    #                             CURRENT_PAGE_NUMBER,
                    #                             MAX_PAGE,
                    #                             HTML_EXT)
                    #
                    &html_standard_page_bottom ("", #! $root_file_name,
                                                $html_page_counter,
                                                $html_max_page,
                                                $html_ext);
                  }
              }
          }
        elsif ($element eq "HEAD")
          {
            if ($type eq "start")
              {
                #
                # Save the document position.
                #
                $document_position = "head";
              }
            else
              {
                #
                # End of header: compose into HTML.
                #
                my ($n) = 0;
                my ($line) = "";
                #
                if ($target eq "HTML-TEXT")
                  {
                    &output ("<!DOCTYPE HTML PUBLIC \"ISO/IEC 15445:2000//DTD HTML//EN\">\n");
                    &output ("<HTML LANG=\"$CURRENT_LANGUAGE\">\n");
                    &output ("<HEAD>\n");
                    &output ("    <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html\">\n");
                    &output ("    <META NAME=\"Generator\" CONTENT=\"Alml\">\n");
                    if ($DOCUMENT_DESCRIPTION ne "")
                      {
                        &output ("    <META NAME=\"Description\" CONTENT=\"$DOCUMENT_DESCRIPTION\">\n");
                      }
                    if ($DOCUMENT_KEYWORDS ne "")
                      {
                        &output ("    <META NAME=\"Keywords\" CONTENT=\"$DOCUMENT_KEYWORDS\">\n");
                      }
                    &output ("    <META NAME=\"Author\" CONTENT=\"@authors\">\n");
                    &output ("    <META NAME=\"Date\" CONTENT=\"$date\">\n");
                    #
                    # HTML meta tags.
                    #
                    # $html_meta_tag[x][0]        name
                    # $html_meta_tag[x][1]        lang
                    # $html_meta_tag[x][2]        content
                    #
                    for ($n = 0 ; $n <= $#html_meta_tag ; $n++)
                      { 
                        &output ("    <META NAME=\""
                                 . $html_meta_tag[$n][0]
                                 . "\" ");
                        if ($html_meta_tag[$n][1] ne "")
                          {
                            &output ("LANG=\""
                                     . $html_meta_tag[$n][1]
                                     . "\" ");
                          }
                        if ($html_meta_tag[$n][2] ne "")
                          {
                            &output ("CONTENT=\""
                                     . $html_meta_tag[$n][2]
                                     . "\" ");
                          }
                        &output (">\n");
                      }
                    &output ("    <TITLE>$title</TITLE>\n");
                    &output ("</HEAD>\n");
                    &output ("<BODY>\n");
                  }
                else
                  {
                    #
                    # &html_standard_page_top (ROOT_FILE_NAME,
                    #                          CURRENT_PAGE_NUMBER,
                    #                          MAX_PAGE,
                    #                          HTML_EXT,
                    #                          HTML_LANGUAGE,
                    #                          META_HTTP_EQUIV,
                    #                          META_DESCRIPTION,
                    #                          META_KEYWORDS,
                    #                          META_AUTHOR,
                    #                          META_DATE,
                    #                          TITLE)
                    #
                    &html_standard_page_top ("", #! $root_file_name,
                                             $html_page_counter,
                                             $html_max_page,
                                             $html_ext,
                                             $CURRENT_LANGUAGE,
                                             "text/html",
                                             $DOCUMENT_DESCRIPTION,
                                             $DOCUMENT_KEYWORDS,
                                             "@authors",
                                             $date,
                                             $title);
                  }
                #
                # Front cover top.
                #
                if ($front_cover_top ne "")
                  {
                    &output ("$front_cover_top");
                  }
                #
                &output ("\n");
                &output ("<HR>\n");
                &output ("<H1>$title</H1>\n");
                &output ("<HR>\n");
                if ($#subtitles > -1)
                  {
                    for ($n = 0 ; $n <= $#subtitles ; $n++)
                      { 
                        &output ("<H2>$subtitles[$n]</H2>\n");
                      }
                    &output ("<HR>\n");
                  }
                for ($n = 0 ; $n <= $#authors ; $n++)
                  { 
                    &output ("<P>$authors[$n]</P>\n");
                  }
                if ($edition eq "")
                  {
                    &output ("<P>$version $date</P>\n");
                  }
                else
                  {
                    &output ("<P>$version $edition</P>\n");
                  }
                &output ("\n");
                if ($front_cover_bottom ne "")
                  {
                    &output ("$front_cover_bottom");
                  }
                #
                # Pseudo new page.
                #
                &output ("\n");
                #
                # Print footnotes.
                #
                &html_standard_footnotes ();
                &output ("<HR>\n");
                &output ("<HR>\n");
                #
                if ($extra_text_before_legal ne "")
                  {
                    &output ("$extra_text_before_legal");
                  }
                #
                if ($legal_text ne "")
                  {
                    &output ("\n");
                    &output ("<HR>\n");
                    &output ("$legal_text");
                  }
                #
                if ($dedications ne "")
                  {
                    # Pseudo new page.
                    &output ("\n");
                    # Print footnotes.
                    &html_standard_footnotes ();
                    &output ("<HR>\n");
                    &output ("<HR>\n");
                    &output ("$dedications");
                  }
                  
                if ($extra_text_after_dedications ne "")
                  {
                    # Pseudo new page.
                    &output ("\n");
                    # Print footnotes.
                    &html_standard_footnotes ();
                    &output ("<HR>\n");
                    &output ("<HR>\n");
                    &output ("$extra_text_after_dedications");
                  }

                &output ("\n");

                # Main table of contents.
                #
                # $contents_list[x][0]  level                   -1..4
                # $contents_list[x][1]  tome number
                # $contents_list[x][2]  part number
                # $contents_list[x][3]  chapter number          
                # $contents_list[x][4]  level-description       1.2.3
                # $contents_list[x][5]  title
                # $contents_list[x][6]  html page number
                # $contents_list[x][7]  h1 section absolute counter
                # $contents_list[x][8]  document position: head,
                #                         intro, body, appendix,
                #                         index
                #
                if ($main_contents)
                  {
                    # The main table of contents is required.
                    &diag_output (sprintf (gettext ("%s:%s: inserting the main contents.\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME), $V_NORMAL);

                    # New HTML page now.
                    if ($target eq "HTML-TEXT")
                      {
                        # Nothing to do here; footnotes are
                        # printed at the very last as the counter
                        # cannot be reset befor the end of this
                        # big HTML page.
                        ;
                      }
                    else
                      {
                        # Close the previous HTML page
                        #
                        # &html_standard_page_bottom (ROOT_FILE_NAME,
                        #                             CURRENT_PAGE_NUMBER,
                        #                             MAX_PAGE,
                        #                             HTML_EXT)
                        #
                        &html_standard_page_bottom
                          ("", #! $root_file_name,
                           $html_page_counter,
                           $html_max_page,
                           $html_ext);

                        # Close output stream.
                        close ($CURRENT_OUTPUT_STREAM);

                        # Increment the HTML page counter (global variable)
                        $html_page_counter++;

                        # Set language information to document language.
                        $CURRENT_LANGUAGE = $DOCUMENT_LANGUAGE;

                        # Reopen
                        $CURRENT_OUTPUT_STREAM = $ROOT_FILE_NAME
                                                 . $html_page_counter
                                                 . $html_ext;
                        open ($CURRENT_OUTPUT_STREAM,
                              ">:utf8",
                              $ROOT_FILE_NAME
                              . $html_page_counter
                              . $html_ext);

                        # Print top HTML page.
                        #
                        # &html_standard_page_top (ROOT_FILE_NAME,
                        #                          CURRENT_PAGE_NUMBER,
                        #                          MAX_PAGE,
                        #                          HTML_EXT,
                        #                          HTML_LANGUAGE,
                        #                          META_HTTP_EQUIV,
                        #                          META_DESCRIPTION,
                        #                          META_KEYWORDS,
                        #                          META_AUTHOR,
                        #                          META_DATE,
                        #                          TITLE)
                        #
                        &html_standard_page_top ("", #! $root_file_name,
                                                 $html_page_counter,
                                                 $html_max_page,
                                                 $html_ext,
                                                 $CURRENT_LANGUAGE,
                                                 "text/html",
                                                 $DOCUMENT_DESCRIPTION,
                                                 $DOCUMENT_KEYWORDS,
                                                 "@authors",
                                                 $date,
                                                 $title);
                      }
		    #
                    # Save the page title
		    #
                    $last_html_page_title = $contents_title;
		    #
                    # Now the table of contents,
                    # with a special label for external link.
                    # This "toc" label might be unnecessary
                    # if the toc is inside a single HTML page,
                    # but it is done for coherence with PDF typesetting.
		    #
                    &output ("\n");
                    &output ("<H1><A NAME=\"toc\"></A>$contents_title</H1>\n");
                    &output ("\n");
                    &output ("<UL>\n");
                    $last_contents_level = 1;
                    for ($n = 0 ; $n <= $#contents_list ; $n++)
                      { 
                        if ($contents_list[$n][0] == -1)
                          {
                            # Tome
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
			    #
            		    # <BIG> is not available with HTML
			    # ISO 15445.
			    #
            		    &output ("<SPAN CLASS=\"big\">");
                            &output ("<STRONG>");
                            &output (ucfirst (&tome_def ()));
                            &output (" ");
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                            &output ($contents_list[$n][5]);
                            &output ("</STRONG>");
                            &output ("</SPAN>");
                            &output ("</A>");
                            &output ("</P>\n");
                            $last_contents_level = 1;
                          }
                        elsif ($contents_list[$n][0] == 0)
                          {
                            # part
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            &output ("<STRONG>");
                            &output (ucfirst (&part_def ()));
                            &output (" ");
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                            &output ($contents_list[$n][5]);
                            &output ("</STRONG>");
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 1;
                          }
                        elsif ($contents_list[$n][0] == 1
                               && ($contents_levels >= 1
                                   || $contents_list[$n][4] =~ m/^[ixu][0-9]/
                                   || $contents_list[$n][4] =~ m/^[A-Z]/))
                          {
                            # chapter
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            elsif ($contents_list[$n][4] =~ m/^[A-Z]/)
                              {
                                # This is an appendix.
                                &output (ucfirst (&appendix_def ()));
                                &output (" ");
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            else
                              {
                                # This is a standard chapter.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 1;
                          }
                        elsif ($contents_list[$n][0] == 2
                               && $contents_levels >= 2)
                          {
                            # section
                            if ($last_contents_level == 1)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            if ($last_contents_level > 2)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 2)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            else
                              {
                                # This is a standard section.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 2;
                          }
                        elsif ($contents_list[$n][0] == 3
                               && $contents_levels >= 3)
                          {
                            # subsection
                            if ($last_contents_level == 2)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            if ($last_contents_level > 3)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 3;
                          }
                        elsif ($contents_list[$n][0] == 4
                               && $contents_levels >= 4)
                          {
                            # sub-subsection
                            if ($last_contents_level == 3)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # So, don't add the number.
                                ;
                              }
                            else
                              {
                                # This is a standard section.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 4;
                          }
                      }
                    # Close levels.
                    if ($last_contents_level > 1)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    if ($last_contents_level > 1)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    if ($last_contents_level > 1)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    # Close the very last level.
                    &output ("</UL>\n");
                  }
              }
          }
        elsif ($element eq "ADMIN")
          {
            # the ADMIN element is scanned at the very first pass,
            # identical for all backends.
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Discard output.
                &pop_output ();
              }
          }
        elsif ($element eq "TITLE")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $title = &pop_output ();
                $last_html_page_title = $title;

              }
          }
        elsif ($element eq "SUBTITLE")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $subtitles[$#subtitles+1] = &pop_output ();
              }
          }
        elsif ($element eq "ABSTRACT")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $abstract = &pop_output ();

                ## With %block; elements, there is a line feed character
                ## at the top of the string. I don't know why.
                ## Anyway, we have to delete this extra line feed.
                #$abstract =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "AUTHOR")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $authors[$#authors+1] = &pop_output ();
              }
          }
        elsif ($element eq "DATE")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $date = &pop_output ();
              }
          }
        elsif ($element eq "EDITION")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $edition = &pop_output ();
              }
          }
        elsif ($element eq "VERSION")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $version = &pop_output ();
              }
          }
#       elsif ($element eq "FRONTCOVERPICTURE")
#         {
#           if ($type eq "start")
#             {
#               # Save picture information.
#               $front_cover_picture_file = ${$attributes}{'IMGFILE'};
#               $front_cover_picture_width = ${$attributes}{'WIDTH'};
#               $front_cover_picture_height = ${$attributes}{'HEIGHT'};
#             }
#           else
#             {
#               # Nothing to do.
#               ;
#             }
#         }
        elsif ($element eq "FRONTCOVERTOP")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $front_cover_top = &pop_output ();

                ## With %block; elements, there is a line feed character
                ## at the top of the string. I don't know why.
                ## Anyway, we have to delete this extra line feed.
                #$front_cover_bottom =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "FRONTCOVERBOTTOM")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $front_cover_bottom = &pop_output ();

                ## With %block; elements, there is a line feed character
                ## at the top of the string. I don't know why.
                ## Anyway, we have to delete this extra line feed.
                #$front_cover_bottom =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "TEXTBEFORELEGAL")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $extra_text_before_legal = &pop_output ();

                ## With %block; elements, there is a line feed character
                ## at the top of the string. I don't know why.
                ## Anyway, we have to delete this extra line feed.
                #$extra_text_before_legal =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "LEGAL")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $legal_text = &pop_output ();

                ## With %block; elements, there is a line feed character
                ## at the top of the string. I don't know why.
                ## Anyway, we have to delete this extra line feed.
                #$legal_text =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "DEDICATIONS")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $dedications = &pop_output ();

                ## With %block; elements, there is a line feed character
                ## at the top of the string. I don't know why.
                ## Anyway, we have to delete this extra line feed.
                #$dedications =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "TEXTAFTERDEDICATIONS")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output.
                $extra_text_after_dedications = &pop_output ();

                ## With %block; elements, there is a line feed character
                ## at the top of the string. I don't know why.
                ## Anyway, we have to delete this extra line feed.
                #$extra_text_after_dedications =~ s/^\n?(.*)$/$1/s;
              }
          }
        elsif ($element eq "MAINCONTENTS")
          {
            if ($type eq "start")
              {
                # Activate main table of contents.

                $main_contents = 1;

                # Save how many levels are required.

                $contents_levels = ${$attributes}{'LEVELS'};

                # Send the output stream to a new stack level.        

                &push_output ();
              }
            else
              {
                # Recall output.
                $contents_title = &pop_output ();
              }
          }
        elsif ($element eq "INTRO")
          {
            if ($type eq "start")
              {
                # Save the information.
                $document_position = "intro";
              }
            else
              {
                # Do nothing;
                ;
              }
          }
        elsif ($element eq "BODY")
          {
            if ($type eq "start")
              {

                
                # Save the information.
                

                $document_position = "body";
              }
            else
              {

                
                # Do nothing;
                

                ;
              }
          }
        elsif ($element eq "APPENDIX")
          {
            if ($type eq "start")
              {
                # Save the information.
                $document_position = "appendix";
              }
            else
              {

                
                # Do nothing;
                

                ;
              }
          }
        elsif ($element eq "INDEX")
          {
            if ($type eq "start")
              {
                # Save the information.
                $document_position = "index";
              }
            else
              {
                # Do nothing;
                ;
              }
          }
        elsif ($element eq "NAVLINK")
          {
            if ($type eq "start")
              {
                &push_output ();
              }
            else
              {
                &pop_output ();
              }
          }
        elsif ($element eq "TOMEHEADING")
          {
            if ($type eq "start")
              {
		#
                # Increment some counters.
		#
                $contents_counter++;
                $cross_reference_counter++;
		#
                # Save anchor information.
		#
                $tome_heading_id = ${$attributes}{'ID'};
                $last_anchor_id = $tome_heading_id;
		#
                # Here start a tome. Do some preparations.
                # Tome happens only inside a body.
		#
                $current_level = "tome";
                $current_level_by_number = -1;
                $tome++;
                $tome_present = 1;
                $part_present = 0;
                $appendix_present = 0;
                $index_present = 0;
                $intro_present = 0;
		#
                # tables and figures are reset.
		#
                $table = 0;
                $figure = 0;
                $listing = 0;
                $example = 0;
		$textpoint = 0;
	        $textpoint_current = 0;
		#
                # Part counter doesn't change.
                # Chapter counter doesn't change.
		#
                $sect1 = 0;             
                $sect2 = 0;             
                $sect3 = 0;             
		#
                # New HTML page now.
		#
                if ($target eq "HTML-TEXT")
                  {
		    #
                    # Nothing to do here; footnotes are
                    # printed at the very last as the counter
                    # cannot be reset befor the end of this
                    # big HTML page.
		    #
                    ;
                  }
                else
                  {
		    #
                    # Close the previous HTML page
                    #
                    # &html_standard_page_bottom (ROOT_FILE_NAME,
                    #                             CURRENT_PAGE_NUMBER,
                    #                             MAX_PAGE,
                    #                             HTML_EXT)
                    #
                    &html_standard_page_bottom
                      ("", #! $root_file_name,
                       $html_page_counter,
                       $html_max_page,
                       $html_ext);
		    #
                    # Close output stream.
		    #
                    close ($CURRENT_OUTPUT_STREAM);
		    #
                    # Increment the HTML page counter (global variable)
		    #
                    $html_page_counter++;
		    #
                    # Save and set language information.
		    #
                    $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
		    #
                    if ($CURRENT_LANGUAGE eq "")
                      {
                        $CURRENT_LANGUAGE = $DOCUMENT_LANGUAGE;
                      }
		    #
                    $TOME_LANGUAGE = $CURRENT_LANGUAGE;
                    $PART_LANGUAGE = $CURRENT_LANGUAGE;
                    $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                    $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                    $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
		    #
                    # Reopen
		    #
                    $CURRENT_OUTPUT_STREAM = $ROOT_FILE_NAME
                                             . $html_page_counter
                                             . $html_ext;
		    #
                    open ($CURRENT_OUTPUT_STREAM,
                          ">:utf8",
                          $ROOT_FILE_NAME
                          . $html_page_counter
                          . $html_ext);
                  }
		#
                # Send the output stream to a new stack level.        
		#
                &push_output ();
              }
            else
              {
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $tome_heading_title   = &pop_output ();
                $last_heading_title   = &html_header_clean ($tome_heading_title);
                $last_html_page_title = &html_header_clean ($tome_heading_title);
		#
                #
		#
                if ($target eq "HTML-TEXT")
                  {
		    #
                    # Nothing to do here; footnotes are
                    # printed at the very last as the counter
                    # cannot be reset befor the end of this
                    # big HTML page.
		    #
                    ;
                  }
                else
                  {
		    #
                    # Print top HTML page.
                    #
                    # &html_standard_page_top (ROOT_FILE_NAME,
                    #                          CURRENT_PAGE_NUMBER,
                    #                          MAX_PAGE,
                    #                          HTML_EXT,
                    #                          HTML_LANGUAGE,
                    #                          META_HTTP_EQUIV,
                    #                          META_DESCRIPTION,
                    #                          META_KEYWORDS,
                    #                          META_AUTHOR,
                    #                          META_DATE,
                    #                          TITLE)
                    #
                    &html_standard_page_top ("", #! $root_file_name,
                                             $html_page_counter,
                                             $html_max_page,
                                             $html_ext,
                                             $CURRENT_LANGUAGE,
                                             "text/html",
                                             $DOCUMENT_DESCRIPTION,
                                             $DOCUMENT_KEYWORDS,
                                             "@authors",
                                             $date,
                                             $last_heading_title);
		  }
		#
                # Print the tome header.
		#
                &output ("<H1>");
                &output ("<A NAME=\"almltitle$contents_counter\"></A>");
                &output ("<A NAME=\"almlanchor$cross_reference_counter\"></A>\n");
                &output (ucfirst (&tome_def ()));
                &output (" ");
                &output (&current_section_number ());
                &output (". &nbsp; ");
                &output ("$tome_heading_title");
                &output ("</H1>\n");
		#
                &diag_output (sprintf (gettext ("%s:%s: %s\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       &current_section_number_complete ()), $V_NORMAL);
              }
          }
        elsif ($element eq "H0")
          {
            if ($type eq "start")
              {
		#
                # Increment some counters.
		#
                $contents_counter++;
                $cross_reference_counter++;
		#
                # Save anchor information.
		#
                $h0_id = ${$attributes}{'ID'};
                $last_anchor_id = $h0_id;
		#
                # Here start a part. Do some preparations.
                # Tome happens only inside a body.
		#
                $current_level = "part";
                $current_level_by_number = 0;
                $part++;
                $part_present = 1;
		#
                # tables and figures are reset.
		#
                $table = 0;
                $figure = 0;
                $listing = 0;
                $example = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
		#
                # chapter counter doesnt change.
		#
                $sect1 = 0;             
                $sect2 = 0;             
                $sect3 = 0;             
		#
                # New HTML page now.
		#
                if ($target eq "HTML-TEXT")
                  {
		    #
                    # Nothing to do here; footnotes are
                    # printed at the very last as the counter
                    # cannot be reset befor the end of this
                    # big HTML page.
		    #
                    ;
                  }
                else
                  {
		    #
                    # Close the previous HTML page
                    #
                    # &html_standard_page_bottom (ROOT_FILE_NAME,
                    #                             CURRENT_PAGE_NUMBER,
                    #                             MAX_PAGE,
                    #                             HTML_EXT)
                    #
		    #
                    &html_standard_page_bottom
                      ("", #! $root_file_name,
                       $html_page_counter,
                       $html_max_page,
                       $html_ext);
		    #
                    # Close output stream.
		    #
                    close ($CURRENT_OUTPUT_STREAM);
		    #
                    # Increment the HTML page counter (global variable)
		    #
                    $html_page_counter++;
		    #
                    # Save and set language information.
		    #
                    $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                    if ($CURRENT_LANGUAGE eq "")
                      {
                        $CURRENT_LANGUAGE = $TOME_LANGUAGE;
                      }
                    $PART_LANGUAGE = $CURRENT_LANGUAGE;
                    $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                    $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                    $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
		    #
                    # Reopen
		    #
                    $CURRENT_OUTPUT_STREAM = $ROOT_FILE_NAME
                                             . $html_page_counter
                                             . $html_ext;
                    open ($CURRENT_OUTPUT_STREAM,
                          ">:utf8",
                          $ROOT_FILE_NAME
                          . $html_page_counter
                          . $html_ext);
		  }
		#
                # Send the output stream to a new stack level.
		#
                &push_output ();
              }
            else
              {
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $H0_title = &pop_output ();
                $last_heading_title = &html_header_clean ($H0_title);
                $last_html_page_title = &html_header_clean ($H0_title);
		#
                #
		#
                if ($target eq "HTML-TEXT")
                  {
		    #
                    # Nothing to do here; footnotes are
                    # printed at the very last as the counter
                    # cannot be reset befor the end of this
                    # big HTML page.
		    #
                    ;
                  }
                else
                  {
                    # Print top HTML page.
                    #
                    # &html_standard_page_top (ROOT_FILE_NAME,
                    #                          CURRENT_PAGE_NUMBER,
                    #                          MAX_PAGE,
                    #                          HTML_EXT,
                    #                          HTML_LANGUAGE,
                    #                          META_HTTP_EQUIV,
                    #                          META_DESCRIPTION,
                    #                          META_KEYWORDS,
                    #                          META_AUTHOR,
                    #                          META_DATE,
                    #                          TITLE)
                    #
                    &html_standard_page_top ("", #! $root_file_name,
                                             $html_page_counter,
                                             $html_max_page,
                                             $html_ext,
                                             $CURRENT_LANGUAGE,
                                             "text/html",
                                             $DOCUMENT_DESCRIPTION,
                                             $DOCUMENT_KEYWORDS,
                                             "@authors",
                                             $date,
                                             #$title
					     $last_heading_title);
                  }
		#
                # Print the part header.
		#
                &output ("<H1>");
                &output ("<A NAME=\"almltitle$contents_counter\"></A>");
                &output ("<A NAME=\"almlanchor$cross_reference_counter\"></A>\n");
                &output (ucfirst (&part_def ()));
                &output (" ");
                &output (&current_section_number ());
                &output (". &nbsp; ");
                &output ("$H0_title");
                &output ("</H1>\n");
		#
                &diag_output (sprintf (gettext ("%s:%s: %s\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       &current_section_number_complete ()), $V_NORMAL);
              }
          }
        elsif ($element eq "H1"
               || $element eq "SLIDEH1"
               || $element eq "SHEETH1"
               || $element eq "UNNUMBEREDH1")
          {
            if ($type eq "start")
              {
		#
                # New HTML page now.
		#
                if ($target eq "HTML-TEXT")
                  {
		    #
                    # Nothing to do here; footnotes are
                    # printed at the very last as the counter
                    # cannot be reset befor the end of this
                    # big HTML page.
		    #
                    ;
                  }
                else
                  {
		    #
                    # Close the previous HTML page
                    #
                    # &html_standard_page_bottom (ROOT_FILE_NAME,
                    #                             CURRENT_PAGE_NUMBER,
                    #                             MAX_PAGE,
                    #                             HTML_EXT)
                    #
                    &html_standard_page_bottom
                      ("", #! $root_file_name,
                       $html_page_counter,
                       $html_max_page,
                       $html_ext);
		    #
                    # Close output stream.
		    #
                    close ($CURRENT_OUTPUT_STREAM);
		    #
                    # Increment the HTML page counter (global variable)
		    #
                    $html_page_counter++;
		    #
                    # Save and set language information.
		    #
                    $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                    if ($CURRENT_LANGUAGE eq "")
                      {
                        $CURRENT_LANGUAGE = $PART_LANGUAGE;
                      }
                    $CHAPTER_LANGUAGE = $CURRENT_LANGUAGE;
                    $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                    $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
		    #
                    # Reopen.
		    #
                    $CURRENT_OUTPUT_STREAM = $ROOT_FILE_NAME
                                             . $html_page_counter
                                             . $html_ext;
                    open ($CURRENT_OUTPUT_STREAM,
                          ">:utf8",
                          $ROOT_FILE_NAME
                          . $html_page_counter
                          . $html_ext);
		  }
		#
                # Send the output stream to a new stack level.
		#
                &push_output ();
              }
            else
              {
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $H1_title = &pop_output ();
                $last_heading_title   = &html_header_clean ($H1_title);
                $last_html_page_title = &html_header_clean ($H1_title);
		#
                #
		#
                if ($target eq "HTML-TEXT")
                  {
		    #
                    # Nothing to do here; footnotes are
                    # printed at the very last as the counter
                    # cannot be reset befor the end of this
                    # big HTML page.
		    #
                    ;
                  }
                else
                  {
		    #
                    # Print top HTML page.
                    #
                    # &html_standard_page_top (ROOT_FILE_NAME,
                    #                          CURRENT_PAGE_NUMBER,
                    #                          MAX_PAGE,
                    #                          HTML_EXT,
                    #                          HTML_LANGUAGE,
                    #                          META_HTTP_EQUIV,
                    #                          META_DESCRIPTION,
                    #                          META_KEYWORDS,
                    #                          META_AUTHOR,
                    #                          META_DATE,
                    #                          TITLE)
                    #
                    &html_standard_page_top ("", #! $root_file_name,
                                             $html_page_counter,
                                             $html_max_page,
                                             $html_ext,
                                             $CURRENT_LANGUAGE,
                                             "text/html",
                                             $DOCUMENT_DESCRIPTION,
                                             $DOCUMENT_KEYWORDS,
                                             "@authors",
                                             $date,
                                             # $title
					     $last_heading_title);
                  }
		#
                # Increment some counters.
		#
                $contents_counter++;
                $cross_reference_counter++;
		#
                # Save anchor information.
		#
                $h1_id = ${$attributes}{'ID'};
                $last_anchor_id = $h1_id;
		#
                # Here start a chapter. Do some preparations.
		#
                $current_level_by_number = 1;
		#
                # tables and figures are reset.
		#
                $table = 0;
                $figure = 0;
                $listing = 0;
                $example = 0;
	        $textpoint = 0;
	        $textpoint_current = 0;
		#
                if ($element eq "UNNUMBEREDH1")
                  {
                    $current_level = "unnumbered-h1";
                    $unnumbered_chapter++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;         
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "intro")
                  {
                    $current_level = "intro-h1";
                    $intro++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;         
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "body")
                  {
                    $current_level = "chapter-h1";
                    $chapter++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;         
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "appendix")
                  {
                    $current_level = "appendix-h1";
                    $appendix++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h1";
                    $index++;
                    $h1section_absolute_counter++;
                    $sect1 = 0;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
		#
                # Print the chapter header.
		#
                if ($element eq "UNNUMBEREDH1")
                  {
                    &output ("<H1>");
                  }
                elsif ($document_position eq "intro")
                  {
                    &output ("<H1>");
                  }
                elsif ($document_position eq "appendix")
                  {
                    &output ("<H1>");
                    &output (ucfirst (&appendix_def ()));
                    &output (" ");
                    &output (&current_section_number ());
                    &output (". &nbsp; ");
                  }
                elsif ($document_position eq "index")
                  {
                    &output ("<H1>");
                  }
                else
                  {
                    &output ("<H1>");
                    &output (ucfirst (&chapter_def ()));
                    &output (" ");
                    &output (&current_section_number ());
                    if ($element eq "SLIDEH1")
                      {
                        &output (", ");
                        &output (lc (&presentation_slide_def ()));
                        &output ("<BR>");
                      }
                    elsif ($element eq "SHEETH1")
                      {
                        &output (", ");
                        &output (lc (&summary_sheet_def ()));
                        &output ("<BR>");
                      }
                    else
                      {
                        &output (". &nbsp; ");
                      }
                  }
                &output ("<A NAME=\"almltitle$contents_counter\"></A>");
                &output ("<A NAME=\"almlanchor$cross_reference_counter\"></A>");
                &output ("$H1_title");
                &output ("</H1>\n");

                &diag_output (sprintf (gettext ("%s:%s: %s\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       &current_section_number_complete ()), $V_NORMAL);
              }
          }
        elsif ($element eq "H2"
               || $element eq "FAQH2")
          {
            if ($type eq "start")
              {
                # Increment some counters.
                $contents_counter++;
                $cross_reference_counter++;
                # Save anchor information.
                $h2_id = ${$attributes}{'ID'};
                $last_anchor_id = $h2_id;
                # Here start a chapter. Do some preparations.
                $current_level_by_number = 2;
                if ($document_position eq "intro")
                  {
                    $current_level = "intro-h2";
                    $sect1++;           
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "body")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h2";
                      }
                    else
                      {
                        $current_level = "chapter-h2";
                      }
                    $sect1++;           
                    $sect2 = 0;         
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "appendix")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h2";
                      }
                    else
                      {
                        $current_level = "appendix-h2";
                      }
                    $sect1++;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h2";
                    $sect1++;
                    $sect2 = 0;
                    $sect3 = 0;
                  }
                # Send the output stream to a new stack level.        
                &push_output ();
              }
            else
              {
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
                $H2_title = &pop_output ();
                $last_heading_title = &html_header_clean ($H2_title);
		#
                # Print the section header.
		#
                if ($element eq "FAQH2"
                       && ($current_level eq "unnumbered-h2"
                           || $document_position eq "intro"))
                  {
                    &output ("\n");
                    &output ("<H2>$sect1");
                    &output (" &nbsp; ");
                  }
                elsif ($element eq "FAQH2")
                  {
                    &output ("\n");
                    &output ("<H2>");
                    &output (&current_section_number ());
                    &output (" &nbsp; ");
                  }
                elsif ($document_position eq "intro")
                  {
                    &output ("\n");
                    &output ("<H2>");
                  }
                elsif ($current_level eq "unnumbered-h2")
                  {
                    &output ("\n");
                    &output ("<H2>");
                  }
                elsif ($current_level eq "chapter-h2"
                       || $current_level eq "appendix-h2")
                  {
                    &output ("\n");
                    &output ("<H2>");
                    &output (&current_section_number ());
                    &output (" &nbsp; ");
                  }
                else
                  {
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:%s:ERROR: anomalous current section string: \"%s\"\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           $element,
                                           $current_level), $V_ERROR);
                    &output ("\n");
                    &output ("<H2>");
                    &output (&current_section_number ());
                    &output (" &nbsp; ");
                  }
                &output ("<A NAME=\"almltitle$contents_counter\"></A>");
                &output ("<A NAME=\"almlanchor$cross_reference_counter\"></A>\n");
                &output ("$H2_title");
                &output ("</H2>\n");
              }
          }
        elsif ($element eq "H3"
               || $element eq "FAQH3")
          {
            if ($type eq "start")
              {
                # Increment some counters.
                $contents_counter++;
                $cross_reference_counter++;
                # Save anchor information.
                $h3_id = ${$attributes}{'ID'};
                $last_anchor_id = $h3_id;
                # Here start a chapter. Do some preparations.
                $current_level_by_number = 3;
                if ($document_position eq "intro")
                  {
                    $current_level = "intro-h3";
                    $sect2++;           
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "body")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h3";
                      }
                    else
                      {
                        $current_level = "chapter-h3";
                      }
                    $sect2++;           
                    $sect3 = 0;         
                  }
                elsif ($document_position eq "appendix")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h3";
                      }
                    else
                      {
                        $current_level = "appendix-h3";
                      }
                    $sect2++;
                    $sect3 = 0;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h3";
                    $sect2++;
                    $sect3 = 0;
                  }
                # Send the output stream to a new stack level.        
                &push_output ();
              }
            else
              {
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
                $H3_title = &pop_output ();
                $last_heading_title = &html_header_clean ($H3_title);
		#
                # Print the subsection header.
		#
                if ($element eq "FAQH3"
                       && ($current_level eq "unnumbered-h3"
                           || $document_position eq "intro"))
                  {
                    &output ("\n");
                    &output ("<P><STRONG>$sect1.$sect2");
                    &output (")&nbsp;&nbsp;");
                  }
                elsif ($element eq "FAQH3")
                  {
                    &output ("\n");
                    &output ("<P><STRONG>");
                    &output (&current_section_number ());
                    &output (")&nbsp;&nbsp;");
                  }
                elsif ($document_position eq "intro")
                  {
                    &output ("\n");
                    &output ("<H3>");
                  }
                elsif ($current_level eq "unnumbered-h3")
                  {
                    &output ("\n");
                    &output ("<H3>");
                  }
                else
                  {
                    &output ("\n");
                    &output ("<H3>");
                    &output (&current_section_number ());
                    &output (" &nbsp; ");
                  }
                &output ("<A NAME=\"almltitle$contents_counter\"></A>");
                &output ("<A NAME=\"almlanchor$cross_reference_counter\"></A>\n");
                &output ("$H3_title");
                if ($element eq "FAQH3")
                  {
                    &output ("</STRONG></P>\n");
                  }
                else
                  {
                    &output ("</H3>\n");
                  }
              }
          }
        elsif ($element eq "H4")
          {
            if ($type eq "start")
              {
                # Increment some counters.
                $contents_counter++;
                $cross_reference_counter++;
                # Save anchor information.
                $h4_id = ${$attributes}{'ID'};
                $last_anchor_id = $h4_id;
                # Here start a chapter. Do some preparations.
                $current_level_by_number = 4;
                if ($document_position eq "intro")
                  {
                    $current_level = "intro-h4";
                    $sect3++;           
                  }
                elsif ($document_position eq "body")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h4";
                      }
                    else
                      {
                        $current_level = "chapter-h4";
                      }
                    $sect3++;
                  }
                elsif ($document_position eq "appendix")
                  {
                    # If previous level was unnumbered, remains unnumbered.
                    if ($current_level =~ m/unnumbered-h[1-9]/)
                      {
                        $current_level = "unnumbered-h4";
                      }
                    else
                      {
                        $current_level = "appendix-h4";
                      }
                    $sect3++;
                  }
                elsif ($document_position eq "index")
                  {
                    $current_level = "index-h4";
                    $sect3++;
                  }
                # Send the output stream to a new stack level.        
                &push_output ();
              }
            else
              {
		#
                # The header information is recalled and saved.
                # The normal mode for output() function is re-established.
		#
                $H4_title = &pop_output ();
                $last_heading_title = &html_header_clean ($H4_title);
		#
                # Print the subsubsection header.
                if ($document_position eq "intro")
                  {
                    &output ("\n");
                    &output ("<H4>");
                  }
                elsif ($current_level eq "unnumbered-h4")
                  {
                    &output ("\n");
                    &output ("<H4>");
                  }
                else
                  {
                    &output ("\n");
                    &output ("<H4>");
                    &output (&current_section_number ());
                    &output (" &nbsp; ");
                  }
                &output ("<A NAME=\"almltitle$contents_counter\"></A>");
                &output ("<A NAME=\"almlanchor$cross_reference_counter\"></A>");
                &output ("$H4_title");
                &output ("</H4>\n");
              }
          }
        elsif ($element eq "DIV")
          {
            if ($type eq "start")
              {
                
                # Save and set language information.

                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $CHAPTER_LANGUAGE;
                  }
                $DIV_LANGUAGE = $CURRENT_LANGUAGE;
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                
                # Insert HTML code.

                &output ("\n");
                &output ("<DIV LANG=\"$CURRENT_LANGUAGE\">");
                &output ("\n");
        
              }
            else
              {
                
                # Restore external language.

                $CURRENT_LANGUAGE = $CHAPTER_LANGUAGE;
                
                # Insert HTML code.

                &output ("\n");
                &output ("</DIV>");
                &output ("\n");

              }
          }
        elsif ($element eq "SPAN")
          {
            if ($type eq "start")
              {
                
                
                # Save and set language information.
                

                $CURRENT_LANGUAGE = ${$attributes}{'LANG'};
                if ($CURRENT_LANGUAGE eq "")
                  {
                    $CURRENT_LANGUAGE = $DIV_LANGUAGE;
                  }
                $SPAN_LANGUAGE = $CURRENT_LANGUAGE;
                #
                # Insert HTML code.
                #
                #&output ("\n");
                &output ("<SPAN LANG=\"$CURRENT_LANGUAGE\">");
                #&output ("\n");
              }
            else
              {
                #
                # Restore external language.
		#
                $CURRENT_LANGUAGE = $DIV_LANGUAGE;
                #
                # Insert HTML code.
		#
                #&output ("\n");
                &output ("</SPAN>");
                #&output ("\n");
              }
          }
        elsif ($element eq "EXTRAMAINCONTENTS")
          {
            if ($type eq "start")
              {
                my $contents_levels = ${$attributes}{'LEVELS'};
                my $last_contents_level = 0;
		#
                # Main table of contents.
                #
                # $contents_list[x][0]  level                   -1..4
                # $contents_list[x][1]  tome number
                # $contents_list[x][2]  part number
                # $contents_list[x][3]  chapter number          
                # $contents_list[x][4]  level-description       1.2.3
                # $contents_list[x][5]  title
                # $contents_list[x][6]  html page number
                # $contents_list[x][7]  h1 section absolute counter
                # $contents_list[x][8]  document position: head,
                #                         intro, body, appendix,
                #                         index
                #

                # An extra main table of contents is required.
                &diag_output (sprintf (gettext ("%s:%s: inserting an extra main contents of level %s.\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME, $contents_levels), $V_NORMAL);

                &output ("\n");
                &output ("<UL>\n");
                $last_contents_level = 1;
                for ($n = 0 ; $n <= $#contents_list ; $n++)
                  { 
                    if ($contents_list[$n][0] == -1)
                      {
                        # Tome
                        if ($last_contents_level > 1)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        if ($last_contents_level > 1)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        if ($last_contents_level > 1)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        &output ("<LI><P>");
                        if ($target eq "HTML-TEXT")
                          {
                            &output ("<A HREF=\"#almltitle$n\">");
                          }
                        else
                          {
                            &output ("<A HREF=\"$ROOT_FILE_NAME");
                            &output ($contents_list[$n][6]);
                            &output ("$html_ext#almltitle$n\">");
                          }
			#
            		# <BIG> is not available with HTML
			# ISO 15445.
			#
            		&output ("<SPAN CLASS=\"big\">");
                        &output ("<STRONG>");
                        &output (ucfirst (&tome_def ()));
                        &output (" ");
                        &output ($contents_list[$n][4]);
                        &output (" &nbsp; ");
                        &output ($contents_list[$n][5]);
                        &output ("</STRONG>");
                        &output ("</SPAN>");
                        &output ("</A>");
                        &output ("</P>\n");
                        $last_contents_level = 1;
                      }
                    elsif ($contents_list[$n][0] == 0
                           && $contents_levels >= 0)
                      {
                        # part
                        if ($last_contents_level > 1)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        if ($last_contents_level > 1)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        if ($last_contents_level > 1)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        &output ("<LI><P>");
                        if ($target eq "HTML-TEXT")
                          {
                            &output ("<A HREF=\"#almltitle$n\">");
                          }
                        else
                          {
                            &output ("<A HREF=\"$ROOT_FILE_NAME");
                            &output ($contents_list[$n][6]);
                            &output ("$html_ext#almltitle$n\">");
                          }
                        &output ("<STRONG>");
                        &output (ucfirst (&part_def ()));
                        &output (" ");
                        &output ($contents_list[$n][4]);
                        &output (" &nbsp; ");
                        &output ($contents_list[$n][5]);
                        &output ("</STRONG>");
                        &output ("</A>\n");
                        &output ("</P>\n");
                        $last_contents_level = 1;
                      }
                    elsif ($contents_list[$n][0] == 1
                           && $contents_levels >= 1)
                      {
                        # chapter
                        if ($last_contents_level > 1)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        if ($last_contents_level > 1)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        if ($last_contents_level > 1)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        &output ("<LI><P>");
                        if ($target eq "HTML-TEXT")
                          {
                            &output ("<A HREF=\"#almltitle$n\">");
                          }
                        else
                          {
                            &output ("<A HREF=\"$ROOT_FILE_NAME");
                            &output ($contents_list[$n][6]);
                            &output ("$html_ext#almltitle$n\">");
                          }
                        if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                          {
                            # This is an introduction, an index or an unnumbered.
                            # So, don't add the number.
                            ;
                          }
                        elsif ($contents_list[$n][4] =~ m/^[A-Z]/)
                          {
                            # This is an appendix.
                            &output (ucfirst (&appendix_def ()));
                            &output (" ");
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                          }
                        else
                          {
                            # This is a standard chapter.
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                          }
                        &output ($contents_list[$n][5]);
                        &output ("</A>\n");
                        &output ("</P>\n");
                        $last_contents_level = 1;
                      }
                    elsif ($contents_list[$n][0] == 2
                           && $contents_levels >= 2)
                      {
                        # section
                        if ($last_contents_level == 1)
                          {
                            # We have to add an indent level.
                            &output ("<UL>\n");
                          }
                        if ($last_contents_level > 2)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        if ($last_contents_level > 2)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        &output ("<LI><P>");
                        if ($target eq "HTML-TEXT")
                          {
                            &output ("<A HREF=\"#almltitle$n\">");
                          }
                        else
                          {
                            &output ("<A HREF=\"$ROOT_FILE_NAME");
                            &output ($contents_list[$n][6]);
                            &output ("$html_ext#almltitle$n\">");
                          }
                        if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                          {
                            # This is an introduction, an index or an unnumbered.
                            # So, don't add the number.
                            ;
                          }
                        else
                          {
                            # This is a standard section.
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                          }
                        &output ($contents_list[$n][5]);
                        &output ("</A>\n");
                        &output ("</P>\n");
                        $last_contents_level = 2;
                      }
                    elsif ($contents_list[$n][0] == 3
                           && $contents_levels >= 3)
                      {
                        # subsection
                        if ($last_contents_level == 2)
                          {
                            # We have to add an indent level.
                            &output ("<UL>\n");
                          }
                        if ($last_contents_level > 3)
                          {
                            # We have to subtract an indent level.
                            &output ("</UL>\n");
                            $last_contents_level--;
                          }
                        &output ("<LI><P>");
                        if ($target eq "HTML-TEXT")
                          {
                            &output ("<A HREF=\"#almltitle$n\">");
                          }
                        else
                          {
                            &output ("<A HREF=\"$ROOT_FILE_NAME");
                            &output ($contents_list[$n][6]);
                            &output ("$html_ext#almltitle$n\">");
                          }
                        &output ($contents_list[$n][4]);
                        &output (" &nbsp; ");
                        &output ($contents_list[$n][5]);
                        &output ("</A>\n");
                        &output ("</P>\n");
                        $last_contents_level = 3;
                      }
                    elsif ($contents_list[$n][0] == 4
                           && $contents_levels >= 4)
                      {
                        # sub-subsection
                        if ($last_contents_level == 3)
                          {
                            # We have to add an indent level.
                            &output ("<UL>\n");
                          }
                        &output ("<LI><P>");
                        if ($target eq "HTML-TEXT")
                          {
                            &output ("<A HREF=\"#almltitle$n\">");
                          }
                        else
                          {
                            &output ("<A HREF=\"$ROOT_FILE_NAME");
                            &output ($contents_list[$n][6]);
                            &output ("$html_ext#almltitle$n\">");
                          }
                        if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                          {
                            # This is an introduction, an index or an unnumbered.
                            # So, don't add the number.
                            ;
                          }
                        else
                          {
                            # This is a standard section.
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                          }
                        &output ($contents_list[$n][5]);
                        &output ("</A>\n");
                        &output ("</P>\n");
                        $last_contents_level = 4;
                      }
                  }
                # Close levels.
                if ($last_contents_level > 1)
                  {
                    # We have to subtract an indent level.
                    &output ("</UL>\n");
                    $last_contents_level--;
                  }
                if ($last_contents_level > 1)
                  {
                    # We have to subtract an indent level.
                    &output ("</UL>\n");
                    $last_contents_level--;
                  }
                if ($last_contents_level > 1)
                  {
                    # We have to subtract an indent level.
                    &output ("</UL>\n");
                    $last_contents_level--;
                  }
                # Close the very last level.
                &output ("</UL>\n");
              }
            else
              {
                # Do nothing.
                ;
              }
          }
        elsif ($element eq "TOMECONTENTS")
          {
            if ($type eq "start")
              {
                &diag_output (sprintf (gettext ("%s:%s: inserting a tome contents.\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME), $V_NORMAL);

                # Save how many levels are required.
                $contents_levels = ${$attributes}{'LEVELS'};

                # Insert a tome contents.
                #
                # $contents_list[x][0]  level                   -1..4
                # $contents_list[x][1]  tome number
                # $contents_list[x][2]  part number
                # $contents_list[x][3]  chapter number          
                # $contents_list[x][4]  level-description       1.2.3
                # $contents_list[x][5]  title
                # $contents_list[x][6]  html page number
                # $contents_list[x][7]  h1 section absolute counter
                # $contents_list[x][8]  document position: head,
                #                         intro, body, appendix,
                #                         index
                #

                # Scan the @contents_list to find the right tome.
                for ($n = 0 ;
                     $n <= $#contents_list && $contents_list[$n][1] < $tome ;
                     $n++)
                  { 
                    # Do nothing; just jump it.
                    ;
                  }

                # Now $n is on the first tome entry, or after the end of
                # the array.
                if($n > $#contents_list)
                  {
                    # The array is finished, and there is no tome.
                    ;
                  }
                elsif ($contents_list[$n][1] == $tome)
                  {
                    # OK, just jump this entry, that is obvious.
                    $n++;

                    &output ("\n");
                    &output ("<UL>\n");
                    $last_contents_level = 1;
                    for ($n = $n ;
                         $n <= $#contents_list && $contents_list[$n][1] == $tome;
                         $n++)
                      { 
                        if ($contents_list[$n][0] == 0)
                          {
                            # part
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            &output (ucfirst (&part_def ()));
                            &output (" ");
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 1;
                          }
                        elsif ($contents_list[$n][0] == 1)
                          {
                            # chapter
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            elsif ($contents_list[$n][4] =~ m/^[A-Z]/)
                              {
                                # This is an appendix.
                                &output (ucfirst (&appendix_def ()));
                                &output (" ");
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            else
                              {
                                # This is a standard chapter.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 1;
                          }
                        elsif ($contents_list[$n][0] == 2
                               && $contents_levels >= 2)
                          {
                            # section
                            if ($last_contents_level == 1)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            if ($last_contents_level > 2)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 2)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            else
                              {
                                # This is a standard section.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 2;
                          }
                        elsif ($contents_list[$n][0] == 3
                               && $contents_levels >= 3)
                          {
                            # subsection
                            if ($last_contents_level == 2)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            if ($last_contents_level > 3)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 3;
                          }
                        elsif ($contents_list[$n][0] == 4
                               && $contents_levels >= 4)
                          {
                            # sub-subsection
                            if ($last_contents_level == 3)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            else
                              {
                                # This is a standard section.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 4;
                          }
                      }
                    # Close levels.
                    if ($last_contents_level > 1)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    if ($last_contents_level > 1)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    if ($last_contents_level > 1)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    # Close the very last level.
                    &output ("</UL>\n");
                  }
              }
            else
              {
                # Do nothing.
                ;
              }
          }
        elsif ($element eq "PARTCONTENTS")
          {
            if ($type eq "start")
              {
                &diag_output (sprintf (gettext ("%s:%s: inserting a part contents.\n"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME), $V_NORMAL);

                # Save how many levels are required.
                $contents_levels = ${$attributes}{'LEVELS'};

                # Insert a part contents.
                #
                # $contents_list[x][0]  level                   -1..4
                # $contents_list[x][1]  tome number
                # $contents_list[x][2]  part number
                # $contents_list[x][3]  chapter number          
                # $contents_list[x][4]  level-description       1.2.3
                # $contents_list[x][5]  title
                # $contents_list[x][6]  html page number
                # $contents_list[x][7]  h1 section absolute counter
                # $contents_list[x][8]  document position: head,
                #                         intro, body, appendix,
                #                         index
                #

                # Scan the @contents_list to find the right tome.
                for ($n = 0 ;
                     $n <= $#contents_list && $contents_list[$n][2] < $part ;
                     $n++)
                  { 
                    # Do nothing; just jump it.
                    ;
                  }
                # Now $n is on the first part entry, or after the end of
                # the array.
                if($n > $#contents_list)
                  {
                    # The array is finished, and there is no part.
                    ;
                  }
                elsif ($contents_list[$n][2] == $part)
                  {
                    # OK, just jump this entry, that is obvious.
                    $n++;

                    &output ("\n");
                    &output ("<UL>\n");
                    $last_contents_level = 1;
                    for ($n = $n ;
                         $n <= $#contents_list && $contents_list[$n][2] == $part;
                         $n++)
                      { 
                        if ($contents_list[$n][0] == 1)
                          {
                            # chapter
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 1)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            elsif ($contents_list[$n][4] =~ m/^[A-Z]/)
                              {
                                # This is an appendix.
                                &output (ucfirst (&appendix_def ()));
                                &output (" ");
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            else
                              {
                                # This is a standard chapter.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 1;
                          }
                        elsif ($contents_list[$n][0] == 2
                               && $contents_levels >= 2)
                          {
                            # section
                            if ($last_contents_level == 1)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            if ($last_contents_level > 2)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 2)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            else
                              {
                                # This is a standard section.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 2;
                          }
                        elsif ($contents_list[$n][0] == 3
                               && $contents_levels >= 3)
                          {
                            # subsection
                            if ($last_contents_level == 2)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            if ($last_contents_level > 3)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 3;
                          }
                        elsif ($contents_list[$n][0] == 4
                               && $contents_levels >= 4)
                          {
                            # sub-subsection
                            if ($last_contents_level == 3)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            else
                              {
                                # This is a standard section.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 4;
                          }
                      }
                    # Close levels.
                    if ($last_contents_level > 1)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    if ($last_contents_level > 1)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    if ($last_contents_level > 1)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    # Close the very last level.
                    &output ("</UL>\n");
                  }
              }
            else
              {
                # Do nothing.
                ;
              }
          }
        elsif ($element eq "CHAPTERCONTENTS")
          {
            if ($type eq "start")
              {
                &diag_output (sprintf (gettext ("%s:%s: inserting a chapter contents.\n"),
                                       $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME), $V_NORMAL);

                # Save how many levels are required.
                $contents_levels = ${$attributes}{'LEVELS'};

                # Insert a part contents.
                #
                # $contents_list[x][0]  level                   -1..4
                # $contents_list[x][1]  tome number
                # $contents_list[x][2]  part number
                # $contents_list[x][3]  chapter number          
                # $contents_list[x][4]  level-description       1.2.3
                # $contents_list[x][5]  title
                # $contents_list[x][6]  html page number
                # $contents_list[x][7]  h1 section absolute counter
                # $contents_list[x][8]  document position: head,
                #                         intro, body, appendix,
                #                         index
                #

                # Scan the @contents_list to find the right chapter.
                for ($n = 0 ;
                     $n <= $#contents_list && $contents_list[$n][7] < $h1section_absolute_counter ;
                     $n++)
                  { 
                    # Do nothing; just jump it.
                    ;
                  }

                # Now $n is on the first chapter entry, or after the end of
                # the array.
                if($n > $#contents_list)
                  {
                    # The array is finished, and there is no part.
                    ;
                  }
                elsif ($contents_list[$n][7] == $h1section_absolute_counter)
                  {
                    # OK, just jump this entry, that is obvious.
                    $n++;

                    &output ("\n");
                    &output ("<UL>\n");
                    $last_contents_level = 2;
                    for ($n = $n ;
                         $n <= $#contents_list && $contents_list[$n][7] == $h1section_absolute_counter ;
                         $n++)
                      { 
                        if ($contents_list[$n][0] == 2
                               && $contents_levels >= 2)
                          {
                            # section
                            if ($last_contents_level == 1)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            if ($last_contents_level > 2)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            if ($last_contents_level > 2)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            else
                              {
                                # This is a standard section.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 2;
                          }
                        elsif ($contents_list[$n][0] == 3
                               && $contents_levels >= 3)
                          {
                            # subsection
                            if ($last_contents_level == 2)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            if ($last_contents_level > 3)
                              {
                                # We have to subtract an indent level.
                                &output ("</UL>\n");
                                $last_contents_level--;
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            &output ($contents_list[$n][4]);
                            &output (" &nbsp; ");
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 3;
                          }
                        elsif ($contents_list[$n][0] == 4
                               && $contents_levels >= 4)
                          {
                            # sub-subsection
                            if ($last_contents_level == 3)
                              {
                                # We have to add an indent level.
                                &output ("<UL>\n");
                              }
                            &output ("<LI><P>");
                            if ($target eq "HTML-TEXT")
                              {
                                &output ("<A HREF=\"#almltitle$n\">");
                              }
                            else
                              {
                                &output ("<A HREF=\"$ROOT_FILE_NAME");
                                &output ($contents_list[$n][6]);
                                &output ("$html_ext#almltitle$n\">");
                              }
                            if ($contents_list[$n][4] =~ m/^[ixu][0-9]/)
                              {
                                # This is an introduction, an index or an unnumbered.
                                # So, don't add the number.
                                ;
                              }
                            else
                              {
                                # This is a standard section.
                                &output ($contents_list[$n][4]);
                                &output (" &nbsp; ");
                              }
                            &output ($contents_list[$n][5]);
                            &output ("</A>\n");
                            &output ("</P>\n");
                            $last_contents_level = 4;
                          }
                      }
                    # Close levels.
                    if ($last_contents_level > 2)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    if ($last_contents_level > 2)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    if ($last_contents_level > 2)
                      {
                        # We have to subtract an indent level.
                        &output ("</UL>\n");
                        $last_contents_level--;
                      }
                    # Close the very last level.
                    &output ("</UL>\n");
                  }
              }
            else
              {
                # Do nothing.
                ;
              }
          }
        elsif ($element eq "INDEXENTRY")
          {
            if ($type eq "start")
              {
                # Save index attributes.
                $index_name = ${$attributes}{'INDEX'};

                # increment the index entry counter.
                $index_entry_counter++;
                
                # Insert an index anchor.
                &output ("<A NAME=\"almlindex$index_entry_counter\"></A>");

                # Eliminate the index entry.
                &push_output ()
              }
            else
              {
                # Eliminate the index entry.
                &pop_output ()
              }
          }
        elsif ($element eq "PRINTINDEX")
          {
            if ($type eq "start")
              {
                my ($n) = 0;
                my ($m) = 0;
                my ($idxname) = "";
                my ($idxtype) = "";
                my ($idxcontext) = "";
                my ($index_file) = "";
                my ($output_stream);
                my ($input_stream);
                my ($line);

                # Save the index type name.

                $idxname = ${$attributes}{'INDEX'};
                $idxtype = lc (${$attributes}{'INDEXREF'});
                $idxcontext = lc (${$attributes}{'INDEXCONTEXT'});

                # $index_list[x][0]        index name
                # $index_list[x][1]        NOT USED anymore
                # $index_list[x][2]        entry
                # $index_list[x][3]        array of links
                # $index_list[x][4]        array of html page numbers
                # $index_list[x][5]        array of level-descriptions
                # $index_list[x][6]        entry with formatting
                # $index_list[x][7]        array of tomes
                # $index_list[x][8]        array of parts
                # $index_list[x][9]        array of chapters (absolute)

                &output ("\n");
                &output ("<UL>\n");

                # Scan the index array.

                for ($n = 0;
                     $n <= $#index_list;
                     $n++)
                  {
                    if ($index_list[$n][0] eq $idxname
                        && &valid_section_index_entry
                             ($n, $idxcontext, $tome, $part, $h1section_absolute_counter))
                      {
                        
                        # Write the index record.

                        &output ("<LI><P>$index_list[$n][6]");
                    
                        # Scan the links.

                        for ($m = 0;
                             $m <= $#{$index_list[$n][3]};
                             $m++)
                          {
                            # Check if this link is ok for the context
                            if ($idxcontext eq "tome"
                                && $index_list[$n][7][$m] != $tome)
                              {
                                # This link is not related to the tome.
                                next;
                              }
                            elsif ($idxcontext eq "part"
                                && $index_list[$n][8][$m] != $part)
                              {
                                # This link is not related to the part.
                                next;
                              }
                            elsif ($idxcontext eq "chapter"
                                && $index_list[$n][9][$m] != $h1section_absolute_counter)
                              {
                                # This link is not related to the chapter.
                                next;
                              }

                            # Otherwise it is ok. :-)                             

                            if ($target eq "HTML-TEXT")
                              {
                                &output
                                  (", <A HREF=\"#almlindex"
                                   . $index_list[$n][3][$m]
                                   . "\">"
                                   . $index_list[$n][5][$m]
                                   . "</A>");
                              }
                            else
                              {
                                &output
                                  (", <A HREF=\"$ROOT_FILE_NAME"
                                   . $index_list[$n][4][$m]
                                   . $html_ext
                                   . "#almlindex"
                                   . $index_list[$n][3][$m]
                                   . "\">"
                                   . $index_list[$n][5][$m]
                                   . "</A>");
                              }
                          }
                        &output ("</P></LI>\n");
                      }
                    else
                      {
                        # Nothing to do here.
                        ;
                      }
                  }
                &output ("</UL>\n");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "ANCHOR")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($anchor_type) = "";
                my ($visible_label) = "";
		#
                $id = ${$attributes}{'ID'};
                $anchor_type = uc (${$attributes}{'TYPE'});
		#
                # Use the counter to know the right number
                # inside the array.
		#
                $cross_reference_counter++;
		#
                # Print the reference anchor.
		#
                &output ("<A NAME=\"almlanchor$cross_reference_counter\"></A>");
		#
		#
		#
		if ($anchor_type eq "VISIBLE")
		  {
		    #
		    # Print a visible thing.
		    #
		    #
		    # Standard cross reference list.
		    #
		    # $cross_reference_list[x][0]        level                  -1..4
		    # $cross_reference_list[x][1]        tome number
		    # $cross_reference_list[x][2]        part number
		    # $cross_reference_list[x][3]        chapter number         
		    # $cross_reference_list[x][4]        table absolute number          
		    # $cross_reference_list[x][5]        figure absolute number         
		    # $cross_reference_list[x][6]        level-description      1.2.3
		    # $cross_reference_list[x][7]        title
		    # $cross_reference_list[x][8]        table level-description
		    # $cross_reference_list[x][9]        figure level-description
		    # $cross_reference_list[x][10]       original anchor id
		    # $cross_reference_list[x][11]       html page number
		    # $cross_reference_list[x][12]       listing absolute number         
		    # $cross_reference_list[x][13]       listing level-description
		    # $cross_reference_list[x][14]       text absolute number
		    # $cross_reference_list[x][15]       example absolute number         
		    # $cross_reference_list[x][16]       example level-description
		    #
		    $visible_label = $cross_reference_list[$cross_reference_counter][14];
		    $visible_label = &integer_to_alphabet ($visible_label);
		    $visible_label = lc ($visible_label);
		    #
            	    &output ("<SUP><SPAN CLASS=\"visible_label\">");
            	    &output ("{$visible_label}");
            	    &output ("</SPAN></SUP>");
		    #
		  }
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "EXTERNALANCHOR")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if (&external_anchor_check ($id))
                  {
                    &output ("<A NAME=\"$id\"></A>");
                  }
              }
            else
              {

                # Nothing to do.

                ;
              }
          }
        elsif ($element eq "TABLE")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($pos) = "";
                # Save attributes.
                $id = ${$attributes}{'ID'};
                $pos = lc ${$attributes}{'POS'};
                $table_position = $pos;
		#
                # Initialize current table.
		#
                $current_table_content = "";
		#
                # Increment some counters.
		#
                $table++;
                $absolute_table++;
                $cross_reference_counter++;
                $table_columns_width_counter = $absolute_table -1;
		#
                # Save table id.
		#
                if ($id eq "")
                  {
		    #
                    # Define a unique label.
		    #
                    $id = "table" . $absolute_table;
                  }
                $last_table_id = $id;

                # Reset table caption.
                $table_caption = "";

                # Print the table anchor.
                &output ("\n");
                &output ("<P ID=\"almlanchor$cross_reference_counter\"><!--\n");
                &output ("    This is just an anchor for the next table.\n");
                &output ("--></P>\n");

                # Save output.
                &push_output ();

              }
            else
              {

                # Restore table
                $current_table_content = &pop_output ();

                
                # The caption is outside the table, although it is not
                # so nice, but there might be table not made of
                # columns and elements.
                

                # Caption.
                if ($table_caption ne "")
                  {
                    &output ("\n");
                    &output ("<P CLASS=\"caption\"><EM>$table_caption</EM></P>\n");
                  }

                # Insert the rest of the table.
                &output ("$current_table_content");

              }
          }
        elsif ($element eq "TCAPTION")
          {
            if ($type eq "start")
              {
                # Send the output stream to a new stack level.        
                &push_output ();
              }
            else
              {
                # Recall output.
                $table_caption = &pop_output ();
              }
          }
        elsif ($element eq "TABULAR")
          {
            if ($type eq "start")
              {
                my ($col) = "";
                my ($columnfractions) = "";
                my (@columnfractions_list) = ();
                my ($n) = "";

                
                # Save attributes.
                

                $col = ${$attributes}{'COL'};
                $columnfractions = ${$attributes}{'COLUMNFRACTIONS'};
                $current_tabular_border = ${$attributes}{'BORDER'};


                
                # Analyze column fractions.
                

                if ($columnfractions eq "")
                  {
                    # Default columns width.
                    for ($n = 0; $n <= $col; $n++)
                      {
                        $columnfractions_list[$n] = 0;
                      }
                  }
                else
                  {
                    # Take the column fractions from the string.
                    $n = 0;
                    while ($columnfractions =~ m/^\s*([0-9.,]+)\s*(.*)$/)
                      {
                        $columnfractions_list[$n] = $1;
                        $columnfractions = $2;
                        
                        # Replace comma with point.
                        $columnfractions_list[$n] =~ s/\,/\./g;

                        $n++;
                      }
                  }


                
                # Start only here the true table definition.
                # The anchor was already defined before.
                

                &output ("<TABLE CLASS=\"table\" SUMMARY=\"\">");
                &output ("\n");


                
                # Use a colgroup to describe column width.
                

                &output ("\n");
                &output ("<COLGROUP>");
                $n = 0;
                while ($col > 0)
                  {
                    if ((! defined ($columnfractions_list[$n]))
                        || ($columnfractions_list[$n] == 0))
                      {
                        &output ("<COL>");
                      }
                    else
                      {

                        
                        # the WIDTH attribute is incompatible with
                        # ISO 15445
                        #
                        # &output ("<COL WIDTH=\"");
                        # &output ($columnfractions_list[$n] * &convert_to_pixel ($PRINTED_BODY_WIDTH));
                        # &output ("\">");
                        

                        &output ("<COL>");

                      }
                    $col--;
                    $n++;
                  }
                &output ("</COLGROUP>\n");
              }
            else
              {

                
                # Close the table. The caption is outside the table,
                # but it must be remembered that there might be also
                # strange kind of tables.
                

                &output ("</TABLE>\n");
              }
          }
        elsif ($element eq "THEAD")
          {
            if ($type eq "start")
              {
                &output ("\n");

                if ($current_tabular_border eq "1")
                  {
                    &output ("<THEAD CLASS=\"border\">");
                  }
                else
                  {
                    &output ("<THEAD CLASS=\"noborder\">");
                  }
                &output ("\n");
              }
            else
              {
                &output ("</THEAD>\n");
              }
          }
        elsif ($element eq "TBODY")
          {
            if ($type eq "start")
              {
                if ($current_tabular_border eq "1")
                  {
                    &output ("<TBODY CLASS=\"border\">");
                  }
                else
                  {
                    &output ("<TBODY CLASS=\"noborder\">");
                  }
                &output ("\n");
              }
            else
              {
                &output ("</TBODY>");
                &output ("\n");
              }
          }
        elsif ($element eq "TROW")
          {
            if ($type eq "start")
              {
                $table_column_counter = -1; # Before the first element
                &output ("<TR>");

                if ($current_tabular_border eq "1")
                  {
                    &output ("<TD CLASS=\"border\">");
                  }
                else
                  {
                    &output ("<TD CLASS=\"noborder\">");
                  }

                push_output ();
              }
            else
              {
                my ($cell) = "";
                $cell = pop_output ();
                $table_column_counter++; # Next element
                #if ($target eq "HTML-TEXT")
                #  {
                #    $cell = &html_table_cell_string
                #              ($cell,
                #               $table_columns_width[$table_columns_width_counter][$table_column_counter]);
                #    &output ("$cell\n");
                #  }
                #else
                #  {
                    &output ("$cell</TD></TR>\n");
                #  }
              }
          }
        elsif ($element eq "COLSEP")
          {
            if ($type eq "start")
              {
                my ($cell) = "";
                $cell = pop_output ();
                $table_column_counter++; # Next element
                &output ("$cell</TD>");
                if ($current_tabular_border eq "1")
                  {
                    &output ("<TD CLASS=\"border\">");
                  }
                else
                  {
                    &output ("<TD CLASS=\"noborder\">");
                  }
                push_output ();
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "FIGURE")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($pos) = "";
                my ($sep) = "";
		#
                # Save attributes.
		#
                $id = ${$attributes}{'ID'};
                $pos = lc ${$attributes}{'POS'};
                $sep = lc ${$attributes}{'SEP'};
                $figure_position = $pos;
                $figure_separation = $sep;

                
                # Increment some counters.
                

                $figure++;
                $absolute_figure++;
                $cross_reference_counter++;

                
                # Define and save the figure identity label.
                

                if ($id eq "")
                  {
                    $id = "figure" . $absolute_figure;
                  }
                $last_figure_id = $id;

                
                # Reset figure caption.
                

                $figure_caption = "";

                
                # Put it inside an invisible table with anchor.
                

                &output ("\n");
                &output ("<TABLE ID=\"almlanchor$cross_reference_counter\" ");
                &output ("CLASS=\"figurewrapper\" ");
                &output ("SUMMARY=\"\">");
                &output ("\n");
                &output ("<TBODY>");
                &output ("<TR>");
                &output ("<TD>");
                &output ("\n");

                
                # Save the figure body.
                

                &push_output ();
              }
            else
              {

                
                # Get figure content.
                

                $current_figure_content = &pop_output ();

                
                # Caption at the top of the figure.
                

                if ($figure_caption ne "")
                  {
                    &output ("\n");
                    &output ("<P CLASS=\"caption\">$figure_caption</P>");
                    &output ("\n");
                    &output ("\n");
                  }

                
                # Put border or rule.
                

                if ($figure_separation eq "box"
                    || $figure_separation eq "border")
                  {
                    &output ("<TABLE CLASS=\"figure\" SUMMARY=\"\">");
                    &output ("\n");
                    &output ("<TBODY>");
                    &output ("<TR>");
                    &output ("<TD>");
                    &output ("\n");
                  }
                elsif ($figure_separation eq "rule")
                  {
                    &output ("<HR>");
                    &output ("\n");
                  }

                
                # Print the figure content.
                
                &output ($current_figure_content);


                
                # Close border or rule.
                

                if ($figure_separation eq "box"
                    || $figure_separation eq "border")
                  {
                    &output ("\n");
                    &output ("</TD>");
                    &output ("</TR>");
                    &output ("</TBODY>");
                    &output ("\n");
                    &output ("</TABLE>");
                    &output ("\n");
                  }
                elsif ($figure_separation eq "rule")
                  {
                    &output ("\n");
                    &output ("<HR>");
                    &output ("\n");
                  }

                
                # Close the other external invisible area.
                

                &output ("\n");
                &output ("</TD>");
                &output ("</TR>");
                &output ("</TBODY>");
                &output ("\n");
                &output ("</TABLE>");
                &output ("\n");

                
                # Clear the figure content.
                

                $current_figure_content = "";

              }
          }
        elsif ($element eq "FCAPTION")
          {
            if ($type eq "start")
              {

                
                # Send the output stream to a new stack level.        
                

                &push_output ();
              }
            else
              {

                
                # Recall output.
                

                $figure_caption = &pop_output ();
              }
          }
        elsif ($element eq "LISTING")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($pos) = "";
                my ($sep) = "";
		#
                # Save attributes.
		#
                $id = ${$attributes}{'ID'};
                $pos = lc ${$attributes}{'POS'};
                $sep = lc ${$attributes}{'SEP'};
                $listing_position = $pos;
                $listing_separation = $sep;
		#
                # Increment some counters.
		#
                $listing++;
                $absolute_listing++;
                $cross_reference_counter++;
		#
                # Save table id.
		#
                if ($id eq "")
                  {
		    #
                    # Define a unique label.
		    #
                    $id = "listing" . $absolute_listing;
                  }
                $last_listing_id = $id;
    	        #
                # Reset table caption.
    	        #
                $listing_caption = "";
    	        #
                # Put the listing inside an invisible table with anchor.
    	        #
                &output ("\n");
                &output ("<TABLE SUMMARY=\"\" ID=\"almlanchor$cross_reference_counter\">");
                &output ("\n");
                &output ("<TBODY>");
                &output ("<TR>");
                &output ("<TD>");
                &output ("\n");
    	        #
                # The caption should go here.
    	        #
                &push_output ();
    	        #
                # Put a DIV here to get the background color.
    	        #
                &output ("<DIV CLASS=\"listing\">");
                &output ("\n");
    	        #
                # Put borders if required.
    	        #
                if ($listing_separation eq "box"
                    || $listing_separation eq "border")
                  {
                    &output ("<TABLE CLASS=\"listing\" SUMMARY=\"\">");
                    &output ("\n");
                    &output ("<TBODY>");
                    &output ("<TR>");
                    &output ("<TD>");
                    &output ("\n");
                  }
                elsif ($listing_separation eq "rule")
                  {
                    &output ("<HR>");
                    &output ("\n");
                  }
              }
            else
              {
                my ($listing_body) = "";
    	        #
                # Restore the listing body.
    	        #
                $listing_body = &pop_output ();
    	        #
                # Put at the top the caption.
    	        #
                if ($listing_caption ne "")
                  {
                    &output ("\n");
                    &output ("<P CLASS=\"caption\">$listing_caption</P>");
                    &output ("\n");
                  }
    	        #
                # Put the body of the listing.
		#
                &output ("$listing_body");
		#
                # Put borders if required.
		#
                if ($listing_separation eq "box"
                    || $listing_separation eq "border")
                  {
                    &output ("</TD>");
                    &output ("</TR>");
                    &output ("</TBODY>");
                    &output ("\n");
                    &output ("</TABLE>");
                    &output ("\n");
                  }
                elsif ($listing_separation eq "rule")
                  {
                    &output ("<HR>");
                    &output ("\n");
                  }
    	        #
                # Close the DIV.
    	        #
                &output ("</DIV>");
                &output ("\n");
		#
                # Close the invisible table area.
		#
                &output ("\n");
                &output ("</TD>");
                &output ("</TR>");
                &output ("</TBODY>");
                &output ("\n");
                &output ("</TABLE>");
                &output ("\n");
              }
          }
        elsif ($element eq "LCAPTION")
          {
            if ($type eq "start")
              {
		#
                # Send the output stream to a new stack level.        
		#
                &push_output ();
              }
            else
              {
		#
                # Recall output.
		#
                $listing_caption = &pop_output ();
              }
          }
        elsif ($element eq "EXAMPLE")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($pos) = "";
                my ($sep) = "";
		#
                # Save attributes.
		#
                $id = ${$attributes}{'ID'};
                $pos = lc ${$attributes}{'POS'};
                $sep = lc ${$attributes}{'SEP'};
                $example_position = $pos;
                $example_separation = $sep;
		#
                # Increment some counters.
		#
                $example++;
                $absolute_example++;
                $cross_reference_counter++;
		#
                # Save table id.
		#
                if ($id eq "")
                  {
		    #
                    # Define a unique label.
		    #
                    $id = "example" . $absolute_example;
                  }
                $last_example_id = $id;
    	        #
                # Reset example caption.
    	        #
                $example_caption = "";
    	        #
                # Put the example inside an invisible table with anchor.
    	        #
                &output ("\n");
                &output ("<TABLE SUMMARY=\"\" ID=\"almlanchor$cross_reference_counter\">");
                &output ("\n");
                &output ("<TBODY>");
                &output ("<TR>");
                &output ("<TD>");
                &output ("\n");
    	        #
                # The caption should go here.
    	        #
                &push_output ();
    	        #
                # Put a DIV here to get the background color.
    	        #
                &output ("<DIV CLASS=\"example\">");
                &output ("\n");
    	        #
                # Put borders if required.
    	        #
                if ($example_separation eq "box"
                    || $example_separation eq "border")
                  {
                    &output ("<TABLE CLASS=\"example\" SUMMARY=\"\">");
                    &output ("\n");
                    &output ("<TBODY>");
                    &output ("<TR>");
                    &output ("<TD>");
                    &output ("\n");
                  }
                elsif ($example_separation eq "rule")
                  {
                    &output ("<HR>");
                    &output ("\n");
                  }
              }
            else
              {
                my ($example_body) = "";
    	        #
                # Restore the example body.
    	        #
                $example_body = &pop_output ();
    	        #
                # Put at the top the caption.
    	        #
                if ($example_caption ne "")
                  {
                    &output ("\n");
                    &output ("<P CLASS=\"caption\">$example_caption</P>");
                    &output ("\n");
                  }
    	        #
                # Put the body of the listing.
		#
                &output ("$example_body");
		#
                # Put borders if required.
		#
                if ($example_separation eq "box"
                    || $example_separation eq "border")
                  {
                    &output ("</TD>");
                    &output ("</TR>");
                    &output ("</TBODY>");
                    &output ("\n");
                    &output ("</TABLE>");
                    &output ("\n");
                  }
                elsif ($example_separation eq "rule")
                  {
                    &output ("<HR>");
                    &output ("\n");
                  }
    	        #
                # Close the DIV.
    	        #
                &output ("</DIV>");
                &output ("\n");
		#
                # Close the invisible table area.
		#
                &output ("\n");
                &output ("</TD>");
                &output ("</TR>");
                &output ("</TBODY>");
                &output ("\n");
                &output ("</TABLE>");
                &output ("\n");
              }
          }
        elsif ($element eq "ECAPTION")
          {
            if ($type eq "start")
              {
		#
                # Send the output stream to a new stack level.        
		#
                &push_output ();
              }
            else
              {
		#
                # Recall output.
		#
                $example_caption = &pop_output ();
              }
          }
        elsif ($element eq "IMAGE")
          {
            if ($type eq "start")
              {
                my ($alt) = "";
                my ($imgfile) = "";
                my ($ext) = "";
                my ($width) = "";
                my ($heght) = "";
                my ($human_readable_file_name) = "";
                #
                # Save picture information.
                #
                $alt     = ${$attributes}{'ALT'};
                $imgfile = ${$attributes}{'IMGFILE'};
                $width   = ${$attributes}{'WIDTH'};
                $height  = ${$attributes}{'HEIGHT'};
                #
                # Set default alternate description.
                #
                if ($alt eq "")
                  {
                    $alt = $imgfile;
                  }
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                # Print picture file.
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    $html_picture_counter++;
		    #
        	    if (-r "$imgfile.pnm")
		      {
			$ext = "pnm"
		      }
            	    elsif (-r "$imgfile.png")
		      {
		        $ext = "png"
		      }
		    else
		      {
			#
			# The file is not there or it is not readable.
			#
                	&diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot read picture file %s or %s!\n"),
                    	    	               $PROGRAM_EXECUTABLE,
	                                       $SOURCE_FILE_NAME,
    	                                       $CURRENT_FILE_NAME,
    		                               $INPUT_STREAM_LINE_COUNTER,
                	                       "$imgfile.pnm",
                    	                       "$imgfile.png"), $V_ERROR);
		      }
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width}x$height! $imgfile.$ext $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width} $imgfile.$ext $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry x${height} $imgfile.$ext $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry 200% $imgfile.$ext $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "$imgfile.$ext",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    &output ("\n");
                    &output ("<P CLASS=\"fullpagepicture\">");
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    &output ("</P>\n");
                  }
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "EMBIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($img_code) = "";
                my ($img_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                #
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the base64 code.
                #
                $img_code = $img_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the temporary file.
                    #
                    $img_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (IMG_TEMP_FILE, "> ${img_temp_file}.uuencode ");
                    print IMG_TEMP_FILE ("begin-base64 664 dummy\n");
                    print IMG_TEMP_FILE ($img_code);
                    print IMG_TEMP_FILE ("\n");
                    print IMG_TEMP_FILE ("====\n");
                    close (IMG_TEMP_FILE);
                    #
                    # Get the picture with uudecode.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "uudecode -o ${img_temp_file}.uudecode ${img_temp_file}.uuencode ", $V_NORMAL);
                    #
                    # New HTML picture
                    $html_picture_counter++;
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width}x$height! ${img_temp_file}.uudecode $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width} ${img_temp_file}.uudecode $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry x${height} ${img_temp_file}.uudecode $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry 200% ${img_temp_file}.uudecode $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${img_temp_file}.uudecode",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    &output ("\n");
                    &output ("<P CLASS=\"fullpagepicture\">");
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    &output ("\n");
                    &output ("</P>");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${img_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "HTMLIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Please note that this elaboration will take place
                # anyway. If you are using this HTMLIMAGE element inside
                # an IFHTML, there might be a reason, for example
                # because there is no good typesetting for the
                # HTML code (think to a FORM for example).
                #
                # If this is the case, inside the diag file it might
                # appear some errors, that are irrelevant to the real
                # final typesetting:
                #
                # alml: html2ps -f:/tmp/alml_a2_TF210662tmp.css -D -o /tmp/alml_a2_TF253345tmp.ps /tmp/alml_a2_TF253345tmp.html 
                # alml: Error opening resource file: /home/a2/sorgente/.html2psrc
                # alml: GNU Ghostscript 7.07: Unrecoverable error, exit code 1
                # alml: Error: /typecheck in --length--
                # alml: Operand stack:
                # alml:    --nostringval--   --nostringval--
                # alml: Execution stack:
                # alml:    %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   1   1   1   --nostringval--   %for_pos_int_continue   1   1   2   --nostringval--   %for_pos_int_continue   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
                # alml: Dictionary stack:
                # alml:    --dict:1061/1123(ro)(G)--   --dict:0/20(G)--   --dict:68/200(L)--   --dict:491/2000(L)--
                # alml: Current allocation mode is local
                # alml: Last OS error: 2
                # alml: Current file position is 41547
                # alml: cp /tmp/alml_a2_TF253345tmp.ps 1.ps 
                # 
                # Such errors are real errors only if you want the
                # result inside the final typesetting.
                #
                my ($html_code) = "";
                my ($html_temp_file) = "";
                my ($html_css_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($human_readable_file_name) = "";
                #
                $width  = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt    = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the HTML back-end code.
                #
                $html_code = &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                # Replace UTF-8 with &#NNNN;
                #
                $html_code =  &sp_html_unicode_clean ($html_code);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the HTML temporary file.
                    #
                    $html_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit.
                    # Please note that the HTML code must be complete.
                    #
                    open (HTML_TEMP_FILE, "> ${html_temp_file}.html ");
                    print HTML_TEMP_FILE ($html_code);
                    print HTML_TEMP_FILE ("\n");
                    close (HTML_TEMP_FILE);
                    #
                    # Use HTML2ps to get the HTML code converted into
                    # PostScript.
                    #
                    # It is better to create an empty file ./.html2psrc,
                    # otherwise an error will be shown.
                    #
                    system ("touch .html2psrc");
                    #!  &system_diag_output ("$PROGRAM_EXECUTABLE", "html2ps -f:${html_css_temp_file}.css -D -o ${html_temp_file}.ps ${html_temp_file}.html ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "html2ps -D -o ${html_temp_file}.ps ${html_temp_file}.html ", $V_NORMAL);
                    #
                    # Print picture file.
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 || $height > 0)
                      {
                        #
                        # Prepare a temporary enlarged PNG file.
                        #
                        &eps_to_10_times_png ("${html_temp_file}.ps", "${html_temp_file}.png");
                      }
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width}x$height! ${html_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width} ${html_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry x${height} ${html_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry 200% ${html_temp_file}.ps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${html_temp_file}.ps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    &output ("\n");
                    &output ("<P CLASS=\"fullpagepicture\">");
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    &output ("\n");
                    &output ("</P>");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${html_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "EPSIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($eps_code) = "";
                my ($eps_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                #
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the EPS back-end code.
                #
                $eps_code = $eps_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the EPS temporary file.
                    $eps_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (EPS_TEMP_FILE, "> ${eps_temp_file}.eps ");
                    print EPS_TEMP_FILE ($eps_code);
                    print EPS_TEMP_FILE ("\n");
                    close (EPS_TEMP_FILE);
                    #
                    # It is better to filter with eps2eps, otherwise
                    # the convert program might have difficulties.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "eps2eps ${eps_temp_file}.eps ${eps_temp_file}2.eps ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "mv -f   ${eps_temp_file}2.eps ${eps_temp_file}.eps ", $V_NORMAL);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 || $height > 0)
                      {
                        #
                        # Prepare a temporary enlarged PNG file.
                        #
                        &eps_to_10_times_png ("${eps_temp_file}.eps", "${eps_temp_file}.png");
                      }
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${eps_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${eps_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${eps_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 140x140 ${eps_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${eps_temp_file}.eps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Save the temporary file name inside the list.
                    #
                    $TEMP_FILES_LIST = $TEMP_FILES_LIST
                                       . " ${eps_temp_file}.eps";
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    &output ("\n");
                    &output ("<P CLASS=\"fullpagepicture\">");
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    &output ("\n");
                    &output ("</P>");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${eps_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "FIGIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($fig_code) = "";
                my ($fig_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                #
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the Fig back-end code.
                #
                $fig_code = $fig_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the Fig temporary file.
                    #
                    $fig_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (FIG_TEMP_FILE, "> ${fig_temp_file}.fig ");
                    print FIG_TEMP_FILE ($fig_code);
                    print FIG_TEMP_FILE ("\n");
                    close (FIG_TEMP_FILE);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture to a double EPS.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "fig2dev -L eps ${fig_temp_file}.fig ${fig_temp_file}.eps ", $V_NORMAL);
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 || $height > 0)
                      {
                        #
                        # Prepare a temporary enlarged PNG file.
                        #
                        &eps_to_10_times_png ("${fig_temp_file}.eps", "${fig_temp_file}.png");
                      }
                    #
                    if ($width > 0 && $height > 0)
                      {
                         &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${fig_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${fig_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${fig_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension:
                        #
                        #   convert -antialias -quality 100 \
                        #     -density 140x140 ${fig_temp_file}.png \
                        #     $html_picture_counter.jpg ", $V_NORMAL);
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 140x140 ${fig_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${fig_temp_file}.fig",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    #
                    &output ("\n");
                    &output ("<P CLASS=\"fullpagepicture\">");
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    &output ("\n");
                    &output ("</P>");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${fig_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "GNUPLOTIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($gnuplot_code) = "";
                my ($gnuplot_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                #
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the Gnuplot back-end code.
                #
                $gnuplot_code = $gnuplot_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the Gnuplot temporary file.
                    #
                    $gnuplot_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (GNUPLOT_TEMP_FILE, "> ${gnuplot_temp_file}.gnuplot ");
                    print GNUPLOT_TEMP_FILE ("set terminal postscript eps color\n");
                    print GNUPLOT_TEMP_FILE ($gnuplot_code);
                    print GNUPLOT_TEMP_FILE ("\n");
                    close (GNUPLOT_TEMP_FILE);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture to a double EPS.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "gnuplot ${gnuplot_temp_file}.gnuplot > ${gnuplot_temp_file}.eps ", $V_NORMAL);
                    #
                    # Convert picture geometry
                    #
                    #!  if ($width > 0 || $height > 0)
                    #!    {
                    #!      #
                    #!      # Prepare a temporary enlarged PNG file.
                    #!      #
                    #!      &eps_to_10_times_png ("${gnuplot_temp_file}.eps", "${gnuplot_temp_file}.png");
                    #!    }
                    #
                    if ($width > 0 && $height > 0)
                      {
                         &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${gnuplot_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${gnuplot_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${gnuplot_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is usually x2 as it happens with
			# the &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension:
                        #
                        #   convert -antialias -quality 100 \
                        #     -density 140x140 ${fig_temp_file}.png \
                        #     $html_picture_counter.jpg ", $V_NORMAL);
			#
			# But Gnuplot makes already big pictures (landscape),
			# so, no enlargement is done.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 ${gnuplot_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${gnuplot_temp_file}.gnuplot",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    #
                    &output ("\n");
                    &output ("<P CLASS=\"fullpagepicture\">");
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    &output ("\n");
                    &output ("</P>");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${gnuplot_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "LYIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($ly_code) = "";
                my ($ly_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                #
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the Lilypond back-end code.
                #
                $ly_code = $ly_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the Lilypond temporary file.
                    #
                    $ly_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Must be opened as usual 8 bit file, otherwise,
                    # Perl will not create the file!
                    #
                    open (LY_TEMP_FILE, "> ${ly_temp_file}.ly ");
                    print LY_TEMP_FILE ($ly_code);
                    print LY_TEMP_FILE ("\n");
                    print LY_TEMP_FILE ("\n");
                    close (LY_TEMP_FILE);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert LilyPond to EPS.
                    # Please note that *must* be converted "in place" (-e)
                    # because otherwise it might generate an empty file.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "convert-ly -e ${ly_temp_file}.ly",
                                         $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "lilypond-bin -o ${ly_temp_file}.tex ${ly_temp_file}.ly",
                                         $V_NORMAL);
                    #
                    # Add extra code, so that, if no LaTeX file was
                    # generated, LaTeX will not stop waiting for
                    # input.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "( echo \\\\nonstopmode ; cat ${ly_temp_file}.tex 2> /dev/null ; echo \\\\end{document} ) > ${ly_temp_file}2.tex",
                                         $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "mv -f ${ly_temp_file}2.tex ${ly_temp_file}.tex",
                                         $V_NORMAL);
                    #
                    # Typeset with LaTeX.
                    # Consider that tex can accept a file name with path,
                    # but will generate a file DVI on current directory.
                    # That's why I am doing this cd and basename.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "cd " . &temporary_dir () . " ; latex `basename ${ly_temp_file}.tex` ",
                                         $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "dvips -E -V -o ${ly_temp_file}.ps ${ly_temp_file}.dvi ",
                                         $V_NORMAL);
                    #
                    # Convert picture geometry
                    # Must tell the first scene number as [0]
                    # after the file name.
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${ly_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${ly_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${ly_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 140x140 ${ly_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${ly_temp_file}.ps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    # The picture is inserted with the MIDI link.
                    #
                    &output ("\n");
                    &output ("<P CLASS=\"fullpagepicture\">");
                    #
                    # If the file MIDI is available, open a hyperlink.
                    #
                    if (-e "${ly_temp_file}.midi")
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "cp -f ${ly_temp_file}.midi ${html_picture_counter}.midi", $V_NORMAL);
                        &output ("<A HREF=\"${html_picture_counter}.midi\">");
                        #
                        # Make a human readable symlink to the MIDI
                        # file name.
                        #
                        $human_readable_file_name
                          = &human_readable_file_name ($alt, ".midi");
                        #
                        system ("ln -s $html_picture_counter.midi $human_readable_file_name");
                        #
                      }                 
                    #
                    # Insert the IMG code.
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    #
                    # If the file MIDI is available, close the
                    # hyperlink.
                    #
                    if ("-e ${html_picture_counter}.midi")
                      {
                        &output ("</A>");
                      }                 
                    #
                    &output ("\n");
                    &output ("</P>");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${ly_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "TEXIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($tex_code) = "";
                my ($tex_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                #
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the TeX back-end code.
                #
                $tex_code = $tex_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the TeX temporary file.
                    #
                    $tex_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (TEX_TEMP_FILE, "> ${tex_temp_file}.tex");
                    print TEX_TEMP_FILE ("\\nonstopmode\n");
                    print TEX_TEMP_FILE ("\\nopagenumbers\n");
                    print TEX_TEMP_FILE ($tex_code);
                    print TEX_TEMP_FILE ("\n");
                    print TEX_TEMP_FILE ("\\bye\n");
                    close (TEX_TEMP_FILE);
                    #
                    # Typeset.
                    # Consider that tex can accept a file name with path,
                    # but will generate a file DVI on current directory.
                    # That's why I am doing this cd and basename.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; tex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "dvips -E -V -o ${tex_temp_file}.ps ${tex_temp_file}.dvi ", $V_NORMAL);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture geometry.
                    # Must tell the first scene number as [0] after the file name.
                    #
		    # Please note that we cannot enlarge the
		    # picture with function &eps_to_10_times_png
		    # because TeX and LaTeX do not start at the
		    # bottom-left of the space, so the result
		    # has a lot of space below and on the left.
		    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 140x140 ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${tex_temp_file}.ps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    #
                    &output ("\n");
                    &output ("<P CLASS=\"fullpagepicture\">");
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    &output ("\n");
                    &output ("</P>");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${tex_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "LATEXIMAGE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($tex_code) = "";
                my ($tex_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                #
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the TeX back-end code.
                #
                $tex_code = $tex_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the TeX temporary file.
                    #
                    $tex_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open a as usual 8 bit file.
                    #
                    open (TEX_TEMP_FILE, "> ${tex_temp_file}.tex");
                    print TEX_TEMP_FILE ("\\nonstopmode\n");
                    print TEX_TEMP_FILE ($tex_code);
                    print TEX_TEMP_FILE ("\n");
                    print TEX_TEMP_FILE ("\\end{document}\n");
                    close (TEX_TEMP_FILE);
                    #
                    # Typeset.
                    # Consider that tex can accept a file name with path,
                    # but will generate a file DVI on current directory.
                    # That's why I am doing this cd and basename.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "dvips -E -V -o ${tex_temp_file}.ps ${tex_temp_file}.dvi ", $V_NORMAL);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture geometry.
                    # Must tell the first scene number as [0] after the file name.
                    #
		    # Please note that we cannot enlarge the
		    # picture with function &eps_to_10_times_png
		    # because TeX and LaTeX do not start at the
		    # bottom-left of the space, so the result
		    # has a lot of space below and on the left.
		    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 140x140 ${tex_temp_file}.ps[0] $html_picture_counter.jpg", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${tex_temp_file}.ps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    #
                    &output ("\n");
                    &output ("<P CLASS=\"fullpagepicture\">");
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    &output ("\n");
                    &output ("</P>");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${tex_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "IFREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                my ($n) = "";
                $id = ${$attributes}{'ID'};
                #
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number             
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
                    #
                    # Do nothing, just scan.
                    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
                    #
                    # The reference was found at $n-th position.
                    #
                    $cross_reference_present = 1;
                  }
                else
                  {
                    #
                    # There is no reference.
                    #
                    $cross_reference_present = 0;
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:WARNING: conditional link \"%s\" is not present\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           $CURRENT_FILE_NAME,
                                           $INPUT_STREAM_LINE_COUNTER,
                                           $id), $V_WARNING);
                  }
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                my ($conditional_output) = "";
                #
                # If the conditional reference was found, typeset it;
                # otherwise, discard it.
                #
                if ($cross_reference_present)
                  {
                    $conditional_output = &pop_output ();
                    &output ($conditional_output);
                  }
                else
                  {
                    &pop_output ();
                  }
                #
                # Must restore a valid cross reference status.
                #
                $cross_reference_present = 1;
              }
          }
        elsif ($element eq "SECTIONREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                #
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number             
                # $cross_reference_list[x][13]       listing level-description
		# $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
                    #
                    # Do nothing, just scan.
                    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
                    if ($target eq "HTML-TEXT")
                      {
                        # The reference was found at $n-th position.
                        &output ("<A HREF=\"#almlanchor$n\">");
                      }
                    else
                      {
                        # The reference was found at $n-th position.
                        &output ("<A HREF=\"");
                        &output ($ROOT_FILE_NAME);
                        &output ($cross_reference_list[$n][11]);
                        &output ($html_ext);
                        &output ("#almlanchor$n");
                        &output ("\">");
                      }
                    &output ($cross_reference_list[$n][6]);
		    #
		    # Check if it is a visible anchor.
		    #
		    if ($cross_reference_list[$n][14] > 0)
		      {
		        #
			# Add the anchor letter to the end of the
			# section number: "1.2.3:a".
			#
			$visible_label = $cross_reference_list[$n][14];
			$visible_label = &integer_to_alphabet ($visible_label);
			$visible_label = lc ($visible_label);
			#
            		&output (":<EM>$visible_label</EM>");
		      }
		    #
                    &output ("</A>");
		    #
                  }
                else
                  {
                    #
                    # There is no reference.
                    #
                    &output ("##$id##");
                    #
                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
                    #
                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "TABLEREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
                    # Replace with last.
                    $id = $last_table_id;
                  }
                #
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number             
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
                    #
                    # Do nothing, just scan.
                    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
                    if ($target eq "HTML-TEXT")
                      {
                        # The reference was found at $n-th position.
                        &output ("<A HREF=\"#almlanchor$n\">");
                        &output ($cross_reference_list[$n][8]);
                        &output ("</A>");
                      }
                    else
                      {
                        # The reference was found at $n-th position.
                        &output ("<A HREF=\"");
                        &output ($ROOT_FILE_NAME);
                        &output ($cross_reference_list[$n][11]);
                        &output ($html_ext);
                        &output ("#almlanchor$n");
                        &output ("\">");
                        &output ($cross_reference_list[$n][8]);
                        &output ("</A>");
                      }
                  }
                else
                  {
                    # There is no reference.
                    &output ("##$id##");

                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "FIGUREREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
                    # Replace with last.
                    $id = $last_figure_id;
                  }

                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
                    # Do nothing, just scan.
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
                    if ($target eq "HTML-TEXT")
                      {
                        # The reference was found.
                        &output ("<A HREF=\"#almlanchor$n\">");
                        &output ($cross_reference_list[$n][9]);
                        &output ("</A>");
                      }
                    else
                      {
                        # The reference was found.
                        &output ("<A HREF=\"");
                        &output ($ROOT_FILE_NAME);
                        &output ($cross_reference_list[$n][11]);
                        &output ($html_ext);
                        &output ("#almlanchor$n");
                        &output ("\">");
                        &output ($cross_reference_list[$n][9]);
                        &output ("</A>");
                      }
                  }
                else
                  {
                    # There is no reference.
                    &output ("##$id##");

                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "LISTINGREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
		    #
                    # Replace with last.
		    #
                    $id = $last_listing_id;
                  }
		#
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
		    #
                    # Do nothing, just scan.
		    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
                    if ($target eq "HTML-TEXT")
                      {
			#
                        # The reference was found.
			#
                        &output ("<A HREF=\"#almlanchor$n\">");
                        &output ($cross_reference_list[$n][13]);
                        &output ("</A>");
                      }
                    else
                      {
			#
                        # The reference was found.
			#
                        &output ("<A HREF=\"");
                        &output ($ROOT_FILE_NAME);
                        &output ($cross_reference_list[$n][11]);
                        &output ($html_ext);
                        &output ("#almlanchor$n");
                        &output ("\">");
                        &output ($cross_reference_list[$n][13]);
                        &output ("</A>");
                      }
                  }
                else
                  {
		    #
                    # There is no reference.
		    #
                    &output ("##$id##");
		    #
                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
		    #
                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "EXAMPLEREF")
          {
            if ($type eq "start")
              {
                my ($id) = "";
                $id = ${$attributes}{'ID'};
                if ($id eq "")
                  {
		    #
                    # Replace with last.
		    #
                    $id = $last_example_id;
                  }
		#
                # Find the anchor inside the array
                #
                # $cross_reference_list[x][0]        level                      -1..4
                # $cross_reference_list[x][1]        tome number
                # $cross_reference_list[x][2]        part number
                # $cross_reference_list[x][3]        chapter number             
                # $cross_reference_list[x][4]        table absolute number              
                # $cross_reference_list[x][5]        figure absolute number             
                # $cross_reference_list[x][6]        level-description  1.2.3
                # $cross_reference_list[x][7]        title
                # $cross_reference_list[x][8]        table level-description
                # $cross_reference_list[x][9]        figure level-description
                # $cross_reference_list[x][10]       original anchor id
                # $cross_reference_list[x][11]       html page number
                # $cross_reference_list[x][12]       listing absolute number
                # $cross_reference_list[x][13]       listing level-description
	        # $cross_reference_list[x][14]       text absolute number
		# $cross_reference_list[x][15]       example absolute number         
		# $cross_reference_list[x][16]       example level-description
                #
                for ($n = 0;
                     $n <= $#cross_reference_list
                       && $cross_reference_list[$n][10] ne $id;
                     $n++)
                  {
		    #
                    # Do nothing, just scan.
		    #
                    ;
                  }
                if ($n <= $#cross_reference_list)
                  {
                    if ($target eq "HTML-TEXT")
                      {
			#
                        # The reference was found.
			#
                        &output ("<A HREF=\"#almlanchor$n\">");
                        &output ($cross_reference_list[$n][16]);
                        &output ("</A>");
                      }
                    else
                      {
			#
                        # The reference was found.
			#
                        &output ("<A HREF=\"");
                        &output ($ROOT_FILE_NAME);
                        &output ($cross_reference_list[$n][11]);
                        &output ($html_ext);
                        &output ("#almlanchor$n");
                        &output ("\">");
                        &output ($cross_reference_list[$n][16]);
                        &output ("</A>");
                      }
                  }
                else
                  {
		    #
                    # There is no reference.
		    #
                    &output ("##$id##");
		    #
                    # Warn the user only if the cross reference is not
                    # already catched from an ifref.
		    #
                    if ($cross_reference_present)
                      {
                        &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: broken link to %s\n"),
                                               $PROGRAM_EXECUTABLE,
                                               $SOURCE_FILE_NAME,
                                               $CURRENT_FILE_NAME,
                                               $INPUT_STREAM_LINE_COUNTER,
                                               $id), $V_ERROR);
                      }
                  }
              }
            else
              {
		#
                # Nothing to do.
		#
                ;
              }
          }
        elsif ($element eq "SPECIAL")
          {
            if ($type eq "start")
              {
                #
                # Increment the index entry counter.
                #
                $index_entry_counter++;
                #
                # Typeset properly.
                # Notice that it is better to let it empty, because
                # we want avoid recursive A element, wich are not
                # allowed.
                #
                &output ("<A NAME=\"almlindex$index_entry_counter\"></A>");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "DFN")
          {
            if ($type eq "start")
              {
#                # Increment the index entry counter.
#                $index_entry_counter++;
                # Typeset properly.
                &output ("<STRONG><EM>");
                # Notice that it is better to let the A element empty,
                # because we want avoid recursive A element, wich are
                # not allowed.
#                &output ("<A NAME=\"almlindex$index_entry_counter\"></A>");
              }
            else
              {
                &output ("</EM></STRONG>");
              }
          }
        elsif ($element eq "WORKINFO")
          {
            if ($type eq "start")
              {
                # Reset global variables.
                $workinfo_name         = "";
                $workinfo_license      = "";
                $workinfo_license_text = "";
                $workinfo_notes        = "";
              }
            else
              {
                my ($n) = 0;

                
                # increment the workinfo counter.
                

                $workinfo_counter++;

                
                # Insert a workinfo anchor.
                

                &output ("<A NAME=\"almlwork" . $workinfo_counter . "\"></A>");

                
                # Prepare a new element inside the footnote array.
                

                $#html_footnote_list++;
                $n = $#html_footnote_list +1;

                
                # Insert the footnote link.
                

                &output ("<SUP><A HREF=\"#almlfootnote$n\" NAME=\"almlfootnote-ref$n\">($n)</A></SUP>");

                
                # Insert the footnote inside the array.
                

                if ($target eq "HTML-TEXT")
                  {
                    $html_footnote_list[$#html_footnote_list]
                      = "<A HREF=\"#almlworkinfo:$workinfo_name\">"
                        . "<STRONG>$workinfo_name</STRONG>"
                        . "</A>"
                        . " &nbsp; "
                        . $workinfo_license;
                  }
                else
                  {
                    $html_footnote_list[$#html_footnote_list]
                      = "<A HREF=\""
                        . $ROOT_FILE_NAME
                        . $workinfo_html_page
                        . $html_ext
                        . "#almlworkinfo:$workinfo_name\">"
                        . "<STRONG>$workinfo_name</STRONG>"
                        . "</A>"
                        . " &nbsp; "
                        . $workinfo_license;
                  }
              }
          }
        elsif ($element eq "WORKNAME")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_name = &pop_output ();
              }
          }
        elsif ($element eq "WORKLICENSE")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_license = &pop_output ();
              }
          }
        elsif ($element eq "WORKLICENSETEXT")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_license_text = &pop_output ();
              }
          }
        elsif ($element eq "WORKNOTES")
          {
            if ($type eq "start")
              {
                # Save output.
                &push_output ();
              }
            else
              {
                # Recall output (if any).
                $workinfo_notes = &pop_output ();
              }
          }
        elsif ($element eq "PRINTWORKINFO")
          {
            if ($type eq "start")
              {
                my ($n) = 0;
                my ($i) = 0;
                my ($reftype) = "";
                $reftype = lc (${$attributes}{'WORKINFOREF'});
                
                # Save HTML page location.

                $workinfo_html_page = $html_page_counter;
                
                # Sort workinfo array, based on the work name.
                #
                # $workinfo_list[x][0]   work name
                # $workinfo_list[x][1]   work license
                # $workinfo_list[x][2]   work license text
                # $workinfo_list[x][3]   work notes
                # $workinfo_list[x][4]   section number
                # $workinfo_list[x][5]   HTML page counter
                # $workinfo_list[x][6]   array of section numbers
                # $workinfo_list[x][7]   array of HTML page numbers
                # $workinfo_list[x][8]   work info serial number
                # $workinfo_list[x][9]   array of work info serial numbers

                &sort_generic_array (\@workinfo_list, 0, 0, $#workinfo_list);
                
                # Scan and join duplicate records.
        
                &scan_and_join_doubles_workinfo_list ();
                
                # Insert workinfo array.

                &output ("\n");
                &output ("<DL>\n");

                
                # Workinfo list.
                #
                # $workinfo_list[x][0]        work name
                # $workinfo_list[x][1]        work license
                # $workinfo_list[x][2]        work license text
                # $workinfo_list[x][3]        work notes
                # $workinfo_list[x][4]        section number
                # $workinfo_list[x][5]        HTML page counter
                # $workinfo_list[x][6]        array of section numbers
                # $workinfo_list[x][7]        array of HTML page numbers
                # $workinfo_list[x][8]        work info serial number
                # $workinfo_list[x][9]        array of work info serial numbers
                

                for ($n = 0; $n <= $#workinfo_list; $n++)
                  {
                    &output ("<DT>");

                    
                    # Put a label so that it can be reached
                    # from the origin.
                    

                    &output ("<A NAME=\"almlworkinfo:");
                    &output ($workinfo_list[$n][0]);
                    &output ("\"></A>");

                    
                    # Write the name of the work.
                    

                    &output ("<STRONG>");
                    &output ($workinfo_list[$n][0]);
                    &output ("</STRONG>");

                    
                    # Append references.
                    

                    for ($i = 0; $i <= $#{$workinfo_list[$n][6]}; $i++)
                      {
                        &output (", ");
                        
                        if ($target eq "HTML-TEXT")
                          {
                            &output
                              ("<A HREF=\"#almlwork"
                               . $workinfo_list[$n][9][$i]
                               . "\">"
                               . $workinfo_list[$n][6][$i]
                               . "</A>");
                          }
                        else
                          {
                            &output
                              ("<A HREF=\"$ROOT_FILE_NAME"
                               . $workinfo_list[$n][7][$i]
                               . $html_ext
                               . "#almlwork"
                               . $workinfo_list[$n][9][$i]
                               . "\">"
                               . $workinfo_list[$n][6][$i]
                               . "</A>");
                          }
                      }

                    &output ("</DT>\n");

                    
                    # Insert informations about the work.
                    

                    &output ("<DD>\n");
                    if ($workinfo_list[$n][2] =~ m/^[^a-z0-9]*$/is)
                      {

                        
                        # There is no license text. So, print just
                        # the license name or definition.
                        

                        &output ($workinfo_list[$n][1]);
                       }
                    else
                      {

                        
                        # There is the license text. Print it!
                        

                        &output ($workinfo_list[$n][2]);
                       }
                    if ($workinfo_list[$n][3] =~ m/^[^a-z0-9]*$/is)
                      {

                        
                        # There are some notes. Print them.
                        

                        &output ($workinfo_list[$n][3]);
                       }
                    &output ("</DD>\n");
                  }
                &output ("</DL>\n");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "NOMOD")
          {
            if ($type eq "start")
              {
                # Increment the counter.
                $nomod_sections_counter++;
                # Insert an anchor.
                &output ("<A NAME=\"almlnomod$nomod_sections_counter\"></A>");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "PRINTNOMOD")
          {
            if ($type eq "start")
              {
                my ($n) = 0;

                # Insert nomod array.
                &output ("\n");
                &output ("<UL>\n");

                # $nomod_sections_list[x][0]    level     -1..4
                # $nomod_sections_list[x][1]    description   section 1.2
                # $nomod_sections_list[x][2]    title
                # $nomod_sections_list[x][3]    html page
                #
                for ($n = 0; $n <= $#nomod_sections_list; $n++)
                  {
                    if ($target eq "HTML-TEXT")
                      {
                        &output ("<LI><P><A HREF=\"#almlnomod$n\">"
                                 . $nomod_sections_list[$n][1]
                                 . ", "
                                 . "<EM>"
                                 . $nomod_sections_list[$n][2]
                                 . "</EM></A></P>\n");
                      }
                    else
                      {
                        &output ("<LI><P><A HREF=\"$ROOT_FILE_NAME"
                                 . $nomod_sections_list[$n][3]
                                 . $html_ext
                                 . "#almlnomod$n\">"
                                 . $nomod_sections_list[$n][1]
                                 . ", "
                                 . "<EM>"
                                 . $nomod_sections_list[$n][2]
                                 . "</EM></A></P>\n");
                      }
                  }
                &output ("</UL>\n");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "SPECIALCONDITION")
          {
            if ($type eq "start")
              {
                &output ("\n");
                &output ("<P><EM>");
              }
            else
              {
                &output ("</EM></P>\n");
              }
          }
        elsif ($element eq "DOCINFO")
          {
            if ($type eq "start")
              {
                #
                # Increment the docinfo counter.
                #
                $docinfo_counter++;
                #
                # Print an anchor.
                #
                &output ("<P><A NAME=\"almldocinfo$docinfo_counter\"></A>");
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                #
                # Discard output.
                #
                &pop_output ();
              }
          }
        elsif ($element eq "PRINTDOCINFO")
          {
            if ($type eq "start")
              {
                my ($n) = 0;
                my ($m) = 0;
                #
                # Insert docinfo array.
                #
                &output ("\n");
                &output ("<UL>\n");
                #
                # $docinfo_list[x][0]       level               -1..4
                # $docinfo_list[x][1]       description     section 1.2
                # $docinfo_list[x][2]       title
                # $docinfo_list[x][3]       notes and history
                # $docinfo_list[x][4]       html page number
                #
                for ($n = 0; $n <= $#docinfo_list; $n++)
                  {
                    if ($docinfo_list[$n][1] ne "##unknown-section##")
                      {

                        
                        # This is a usual section
                        

                        if ($target eq "HTML-TEXT")
                          {
                            &output ("<LI><P><A HREF=\"#almldocinfo$n\">"
                                     . $docinfo_list[$n][1]
                                     . ", "
                                     . "<EM>"
                                     . $docinfo_list[$n][2]
                                     . "</EM>"
                                     . "</A></P>");
                          }
                        else
                          {
                            &output ("<LI><P><A HREF=\""
                                     . $ROOT_FILE_NAME
                                     . $docinfo_list[$n][4]
                                     . $html_ext
                                     . "#almldocinfo$n\">"
                                     . $docinfo_list[$n][1]
                                     . ", "
                                     . "<EM>"
                                     . $docinfo_list[$n][2]
                                     . "</EM>"
                                     . "</A></P>");
                          }
                        if ($docinfo_list[$n][3] ne "")
                          {
                            &output ($docinfo_list[$n][3]);
                          }
                      }
                    else
                      {
                        
                        # This is outside usual sections

                        if ($target eq "HTML-TEXT")
                          {
                            &output ("<LI><P><A HREF=\"#almldocinfo$n\">"
                                     . "#$n"
                                     . "</A></P>");
                          }
                        else
                          {
                            &output ("<LI><P><A HREF=\""
                                     . $ROOT_FILE_NAME
                                     . $docinfo_list[$n][4]
                                     . $html_ext
                                     . "#almldocinfo$n\">"
                                     . "#$n"
                                     . "</A></P>");
                          }
                        if ($docinfo_list[$n][3] ne "")
                          {
                            &output ($docinfo_list[$n][3]);
                          }
                      }
                  }
                &output ("</UL>\n");
              }
            else
              {
                # Nothing to do.
                ;
              }
          }
        elsif ($element eq "COPY")
          {
            if ($type eq "start")
              {
                #
                $COPY_NAME = ${$attributes}{'COPY'};
                #
                # Save output.
                #
                &push_output ();
              }
            else
              {
                my ($string) = "";
                #
                # Recall output (if any).
                #
                $string = &pop_output ();
                #
                # Print it.
                #
                &output ("$string");
                #
                # Save it to the copy list.
                #
                &add_copy_list ("$COPY_NAME", "$string");
              }
          }
        elsif ($element eq "PASTE")
          {
            if ($type eq "start")
              {
                my ($paste) = 0;
                my ($string) = "";
                #
                $paste = ${$attributes}{'PASTE'};
                #
                $string = &get_copy_list ("$paste");
                #
                &output ("$string");
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "FOOTNOTE")
          {
            if ($type eq "start")
              {
		#
                # Send the output stream to a new stack level.
		#
                &push_output ();
              }
            else
              {
                my ($n) = 0;
                #
                # Recall output (if any).
                #
                $html_footnote = &pop_output ();
                #
                # Prepare a new element inside the footnote array.
                #
                $#html_footnote_list++;
                $n = $#html_footnote_list +1;
                #
                # Insert the footnote link.
                #
                &output ("<!--ALML FOOTNOTE-->");
                &output ("<SUP><A HREF=\"#almlfootnote$n\" NAME=\"almlfootnote-ref$n\">($n)</A></SUP>");
                &output ("<!/--ALML FOOTNOTE-->");
                #
                # Insert the footnote inside the array.
                #
                $html_footnote_list[$#html_footnote_list] = $html_footnote;
              }
          }
        elsif ($element eq "BLOCKFOOTNOTE")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($n) = 0;
                #
                # Recall output (if any).
                #
                $html_footnote = &pop_output ();
                #
                # Prepare a new element inside the footnote array.
                #
                $#html_footnote_list++;
                $n = $#html_footnote_list +1;
                #
                # Insert the footnote link.
                #
                &output ("<P><SUP><A HREF=\"#almlfootnote$n\" NAME=\"almlfootnote-ref$n\">($n)</A></SUP>");
                #
                # Insert the footnote inside the array.
                #
                $html_footnote_list[$#html_footnote_list] = $html_footnote;
                #
                # Close footnote block.
                #
                &output ("</P>\n");
              }
          }
        elsif ($element eq "QUOTEINFO")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($n) = 0;
                #
                # Recall output (if any).
                #
                $html_footnote = &pop_output ();
                #
                # Prepare a new element inside the footnote array.
                #
                $#html_footnote_list++;
                $n = $#html_footnote_list +1;
                #
                # Insert the footnote link.
                #
                &output ("<P><SUP><A HREF=\"#almlfootnote$n\" NAME=\"almlfootnote-ref$n\">($n)</A></SUP>");
                #
                # Insert the footnote inside the array.
                #
                $html_footnote_list[$#html_footnote_list] = $html_footnote;
                #
                # Close footnote block.
                #
                &output ("</P>\n");
              }
          }
        elsif ($element eq "EPSIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($eps_code)                 = "";
                my ($eps_temp_file)            = "";
                my ($height)                   = "";
                my ($width)                    = "";
                my ($alt)                      = "";
                my ($human_readable_file_name) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the EPS back-end code.
                #
                $eps_code = $eps_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the EPS temporary file.
                    #
                    $eps_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (EPS_TEMP_FILE, "> ${eps_temp_file}.eps");
                    print EPS_TEMP_FILE ($eps_code);
                    print EPS_TEMP_FILE ("\n");
                    close (EPS_TEMP_FILE);
                    #
                    # It is better to filter with eps2eps, otherwise
                    # the convert program might have difficulties.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "eps2eps ${eps_temp_file}.eps ${eps_temp_file}2.eps ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "mv -f   ${eps_temp_file}2.eps ${eps_temp_file}.eps ", $V_NORMAL);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 || $height > 0)
                      {
                        #
                        # Prepare a temporary enlarged PNG file.
                        #
                        &eps_to_10_times_png ("${eps_temp_file}.eps", "${eps_temp_file}.png");
                      }
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${eps_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${eps_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${eps_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 140x140 ${eps_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${eps_temp_file}.eps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${eps_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "FIGIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($fig_code) = "";
                my ($fig_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the Fig back-end code.
                #
                $fig_code = $fig_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the Fig temporary file.
                    #
                    $fig_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (FIG_TEMP_FILE, "> ${fig_temp_file}.fig ");
                    print FIG_TEMP_FILE ($fig_code);
                    print FIG_TEMP_FILE ("\n");
                    close (FIG_TEMP_FILE);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture to a double EPS.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "fig2dev -L eps ${fig_temp_file}.fig ${fig_temp_file}.eps ", $V_NORMAL);
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 || $height > 0)
                      {
                        #
                        # Prepare a temporary enlarged PNG file.
                        #
                        &eps_to_10_times_png ("${fig_temp_file}.eps", "${fig_temp_file}.png");
                      }
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${fig_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${fig_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${fig_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension:
                        #
                        #   convert -antialias -quality 100 \
                        #     -density 140x140 ${fig_temp_file}.png \
                        #     $html_picture_counter.jpg ", $V_NORMAL);
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 140x140 ${fig_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                        #
                      }
                    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${fig_temp_file}.fig",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${fig_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "GNUPLOTIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($gnuplot_code) = "";
                my ($gnuplot_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the Gnuplot back-end code.
                #
                $gnuplot_code = $gnuplot_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the Fig temporary file.
                    #
                    $gnuplot_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (GNUPLOT_TEMP_FILE, "> ${gnuplot_temp_file}.gnuplot ");
                    print GNUPLOT_TEMP_FILE ("set terminal postscript eps color\n");
                    print GNUPLOT_TEMP_FILE ($gnuplot_code);
                    print GNUPLOT_TEMP_FILE ("\n");
                    close (GNUPLOT_TEMP_FILE);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture to EPS.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "gnuplot ${gnuplot_temp_file}.gnuplot > ${gnuplot_temp_file}.eps ", $V_NORMAL);
                    #
                    # Convert picture geometry
                    #
                    #!  if ($width > 0 || $height > 0)
                    #!    {
                    #!      #
                    #!      # Prepare a temporary enlarged PNG file.
                    #!      #
                    #!      &eps_to_10_times_png ("${fig_temp_file}.eps", "${fig_temp_file}.png");
                    #!    }
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${gnuplot_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${gnuplot_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${gnuplot_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension:
                        #
                        #   convert -antialias -quality 100 \
                        #     -density 140x140 ${fig_temp_file}.png \
                        #     $html_picture_counter.jpg ", $V_NORMAL);
			#
			# But with Gnuplot, picture are already big
			# enough.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE",
                                             "convert -antialias -quality 100 ${gnuplot_temp_file}.eps $html_picture_counter.jpg ", $V_NORMAL);
                        #
                      }
                    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${gnuplot_temp_file}.eps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${gnuplot_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "LYIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($ly_code) = "";
                my ($ly_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the Lilypond back-end code.
                #
                $ly_code = $ly_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the Lilypond temporary file.
                    #
                    $ly_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # At the moment, open as usual 8 bit file.
                    #
                    open (LY_TEMP_FILE, "> ${ly_temp_file}.ly");
                    print LY_TEMP_FILE ($ly_code);
                    print LY_TEMP_FILE ("\n");
                    print LY_TEMP_FILE ("\n");
                    close (LY_TEMP_FILE);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert LilyPond to EPS.
                    # Please note that *must* be converted "in place" (-e)
                    # because otherwise it might generate an empty file.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "convert-ly -e ${ly_temp_file}.ly",
                                         $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "lilypond-bin -o ${ly_temp_file}.tex ${ly_temp_file}.ly",
                                         $V_NORMAL);
                    #
                    # Add extra code, so that, if no LaTeX file was
                    # generated, LaTeX will not stop waiting for
                    # input.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "( echo \\\\nonstopmode ; cat ${ly_temp_file}.tex 2> /dev/null ; echo \\\\end{document} ) > ${ly_temp_file}2.tex",
                                         $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "mv -f ${ly_temp_file}2.tex ${ly_temp_file}.tex",
                                         $V_NORMAL);
                    #
                    # Typeset with LaTeX.
                    # Consider that tex can accept a file name with path,
                    # but will generate a file DVI on current directory.
                    # That's why I am doing this cd and basename.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "cd " . &temporary_dir () . " ; latex `basename ${ly_temp_file}.tex` ",
                                         $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE",
                                         "dvips -E -V -o ${ly_temp_file}.ps ${ly_temp_file}.dvi ",
                                         $V_NORMAL);
                    #
                    # Convert picture geometry
                    # Must tell the first scene number as [0]
                    # after the file name.
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${ly_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${ly_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${ly_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 140x140 ${ly_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    #
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${ly_temp_file}.ps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    # If the file MIDI is available, open a hyperlink.
                    #                    
                    if (-e "${ly_temp_file}.midi")
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "cp -f ${ly_temp_file}.midi ${html_picture_counter}.midi", $V_NORMAL);
                        &output ("<A HREF=\"${html_picture_counter}.midi\">");
                        #
                        # Make a human readable symlink to the MIDI
                        # file name.
                        #
                        $human_readable_file_name
                            = &human_readable_file_name ($alt, ".midi");
                        #
                        system ("ln -s $html_picture_counter.midi $human_readable_file_name");
                        #
                      }                 
                    #
                    # Insert the IMG code.
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    #
                    # If the file MIDI is available, close the hyperlink.
                    #
                    if (-e "${html_picture_counter}.midi")
                      {
                        &output ("</A>");
                      }
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${ly_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "TEXIMG")
          {
            if ($type eq "start")
              {
                # Send the output stream to a new stack level.        
                &push_output ();
              }
            else
              {
                my ($tex_code) = "";
                my ($tex_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the TeX back-end code.
                #
                $tex_code = $tex_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the TeX temporary file.
                    #
                    $tex_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as 8 bit file
                    #
                    open (TEX_TEMP_FILE, "> ${tex_temp_file}.tex");
                    print TEX_TEMP_FILE ("\\nonstopmode\n");
                    print TEX_TEMP_FILE ("\\nopagenumbers\n");
                    print TEX_TEMP_FILE ($tex_code);
                    print TEX_TEMP_FILE ("\n");
                    print TEX_TEMP_FILE ("\\bye\n");
                    close (TEX_TEMP_FILE);
                    #
                    # Typeset.
                    # Consider that tex can accept a file name with path,
                    # but will generate a file DVI on current directory.
                    # That's why I am doing this cd and basename.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; tex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "dvips -E -V -o ${tex_temp_file}.ps ${tex_temp_file}.dvi ", $V_NORMAL);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture geometry
                    # Must tell the first scene number as [0] after the file name.
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 140x140 ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${tex_temp_file}.ps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${tex_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "LATEXIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($tex_code) = "";
                my ($tex_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the TeX back-end code.
                #
                $tex_code = $tex_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the TeX temporary file.
                    #
                    $tex_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (TEX_TEMP_FILE, "> ${tex_temp_file}.tex");
                    print TEX_TEMP_FILE ("\\nonstopmode\n");
                    print TEX_TEMP_FILE ($tex_code);
                    print TEX_TEMP_FILE ("\n");
                    print TEX_TEMP_FILE ("\\end{document}\n");
                    close (TEX_TEMP_FILE);
                    #
                    # Typeset.
                    # Consider that tex can accept a file name with path,
                    # but will generate a file DVI on current directory.
                    # That's why I am doing this cd and basename.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "cd " . &temporary_dir () . " ; latex `basename ${tex_temp_file}.tex` ", $V_NORMAL);
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "dvips -E -V -o ${tex_temp_file}.ps ${tex_temp_file}.dvi ", $V_NORMAL);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture geometry
                    # Must tell the first scene number as [0] after the file name.
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width}x$height! ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry ${width} ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 300x300 -geometry x${height} ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        # It is obtained with the -density option.
                        # The 140x140 gives the double of the original
                        # dimension.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -antialias -quality 100 -density 140x140 ${tex_temp_file}.ps[0] $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${tex_temp_file}.ps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #                    
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${tex_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "IMG")
          {
            if ($type eq "start")
              {
                my ($imgfile) = "";
                my ($ext) = "";
                my ($alt) = "";
                my ($width) = "";
                my ($heght) = "";
                my ($human_readable_file_name) = "";
                #
                # Save picture information.
                #
                $imgfile = ${$attributes}{'IMGFILE'};
                $alt = ${$attributes}{'ALT'};
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = $imgfile;
                  }
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # HTML picture number counter.
                    #
                    $html_picture_counter++;
		    #
        	    if (-r "$imgfile.pnm")
		      {
			$ext = "pnm"
		      }
            	    elsif (-r "$imgfile.png")
		      {
		        $ext = "png"
		      }
		    else
		      {
			#
			# The file is not there or it is not readable.
			#
                	&diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot read picture file %s or %s!\n"),
                    	    	               $PROGRAM_EXECUTABLE,
	                                       $SOURCE_FILE_NAME,
    	                                       $CURRENT_FILE_NAME,
    		                               $INPUT_STREAM_LINE_COUNTER,
                	                       "$imgfile.pnm",
                    	                       "$imgfile.png"), $V_ERROR);
		      }
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width}x$height! $imgfile.$ext $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width} $imgfile.$ext $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry x${height} $imgfile.$ext $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry 200% $imgfile.$ext $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "$imgfile.$ext",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                  }
              }
            else
              {
                #
                # Nothing to do.
                #
                ;
              }
          }
        elsif ($element eq "EMBIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                my ($img_code) = "";
                my ($img_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($alt) = "";
                my ($human_readable_file_name) = "";
                $width = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt = ${$attributes}{'ALT'};
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the base64 code.
                #
                $img_code = $img_code . &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the temporary file.
                    #
                    $img_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit file.
                    #
                    open (IMG_TEMP_FILE, "> ${img_temp_file}.uuencode ");
                    print IMG_TEMP_FILE ("begin-base64 664 dummy\n");
                    print IMG_TEMP_FILE ($img_code);
                    print IMG_TEMP_FILE ("\n");
                    print IMG_TEMP_FILE ("====\n");
                    close (IMG_TEMP_FILE);
                    #
                    # Get the picture with uudecode.
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "uudecode -o ${img_temp_file}.uudecode ${img_temp_file}.uuencode ", $V_NORMAL);
                    #
                    # New HTML picture
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width}x$height! ${img_temp_file}.uudecode $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width} ${img_temp_file}.uudecode $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry x${height} ${img_temp_file}.uudecode $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry 200% ${img_temp_file}.uudecode $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${img_temp_file}.uudecode",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Save the temporary file name inside the list.
                    #
                    $TEMP_FILES_LIST = $TEMP_FILES_LIST
                                       . " ${img_temp_file}.uudecode";
                    $TEMP_FILES_LIST = $TEMP_FILES_LIST
                                       . " ${img_temp_file}.uuencode";
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${img_temp_file}*");
                    #
                  }
              }
          }
        elsif ($element eq "HTMLIMG")
          {
            if ($type eq "start")
              {
                #
                # Send the output stream to a new stack level.        
                #
                &push_output ();
              }
            else
              {
                #
                # Please note that this elaboration will take place
                # anyway. If you are using this HTMLIMAGE element inside
                # an IFHTML, there might be a reason, for example
                # because there is no good typesetting for the
                # HTML code (think to a FORM for example).
                #
                # If this is the case, inside the diag file it might
                # appear some errors, that are irrelevant to the real
                # final typesetting:
                #
                # alml: html2ps -f:/tmp/alml_a2_TF210662tmp.css -D -o /tmp/alml_a2_TF253345tmp.ps /tmp/alml_a2_TF253345tmp.html 
                # alml: Error opening resource file: /home/a2/sorgente/.html2psrc
                # alml: GNU Ghostscript 7.07: Unrecoverable error, exit code 1
                # alml: Error: /typecheck in --length--
                # alml: Operand stack:
                # alml:    --nostringval--   --nostringval--
                # alml: Execution stack:
                # alml:    %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   1   3   %oparray_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   1   1   1   --nostringval--   %for_pos_int_continue   1   1   2   --nostringval--   %for_pos_int_continue   1   1   0   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
                # alml: Dictionary stack:
                # alml:    --dict:1061/1123(ro)(G)--   --dict:0/20(G)--   --dict:68/200(L)--   --dict:491/2000(L)--
                # alml: Current allocation mode is local
                # alml: Last OS error: 2
                # alml: Current file position is 41547
                # alml: cp /tmp/alml_a2_TF253345tmp.ps 1.ps 
                # 
                # Such errors are real errors only if you want the
                # result inside the final typesetting.
                #
                my ($html_code) = "";
                my ($html_temp_file) = "";
                my ($html_css_temp_file) = "";
                my ($height) = "";
                my ($width) = "";
                my ($human_readable_file_name) = "";
                #
                $width  = ${$attributes}{'WIDTH'};
                $height = ${$attributes}{'HEIGHT'};
                $alt    = ${$attributes}{'ALT'};
                #
                # Convert decimal comma to decimal point for security.
                #
                $width  =~ s/,/./;
                $height =~ s/,/./;
                #
                # If width is relative to the body, calculate width.
                #
                $width = &convert_width_to_absolute ($width);
                #
                if ($alt eq "")
                  {
                    $alt = &picture_def ();
                  }
                #
                # Restore the HTML back-end code.
                #
                $html_code = &pop_output ();
                #
                # Convert to pixel somehow.
                #
                $width = &convert_to_pixel ($width);
                $height = &convert_to_pixel ($height);
                #
                # Replace UTF-8 with &#NNNN;
                #
                $html_code =  &sp_html_unicode_clean ($html_code);
                #
                if ($target eq "HTML-TEXT")
                  {
                    #
                    # No pictures here. Nothing to do.
                    #
                    ;
                  }
                else
                  {
                    #
                    # Prepare the HTML temporary file.
                    #
                    $html_temp_file = &temporary_file ($TEMP_FILE_NAME_PREFIX);
                    #
                    # Open as usual 8 bit.
                    # Please note that the HTML code must be complete.
                    #
                    open (HTML_TEMP_FILE, "> ${html_temp_file}.html ");
                    print HTML_TEMP_FILE ($html_code);
                    print HTML_TEMP_FILE ("\n");
                    close (HTML_TEMP_FILE);
                    #
                    # Use HTML2ps to get the HTML code converted into
                    # PostScript.
                    #
                    # It is better to create an empty file ./.html2psrc,
                    # otherwise an error will be shown.
                    #
                    system ("touch .html2psrc");
                    #
                    &system_diag_output ("$PROGRAM_EXECUTABLE", "html2ps -D -o ${html_temp_file}.ps ${html_temp_file}.html ", $V_NORMAL);
                    #
                    # Print picture file.
                    #
                    $html_picture_counter++;
                    #
                    # Convert picture geometry
                    #
                    if ($width > 0 || $height > 0)
                      {
                        #
                        # Prepare a temporary enlarged PNG file.
                        #
                        &eps_to_10_times_png ("${html_temp_file}.ps", "${html_temp_file}.png");
                      }
                    #
                    if ($width > 0 && $height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width}x$height! ${html_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($width > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry ${width} ${html_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    elsif ($height > 0)
                      {
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry x${height} ${html_temp_file}.png $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    else
                      {
                        #
                        # Default dimension is x2 as it happens with the
                        # &convert_to_pixel () function.
                        #
                        &system_diag_output ("$PROGRAM_EXECUTABLE", "convert -geometry 200% ${html_temp_file}.ps $html_picture_counter.jpg ", $V_NORMAL);
                      }
                    &diag_output (sprintf (gettext ("%s:%s: picture %s converted to %s\n"),
                                           $PROGRAM_EXECUTABLE,
                                           $SOURCE_FILE_NAME,
                                           "${html_temp_file}.ps",
                                           "$html_picture_counter.jpg"), $V_NORMAL);
                    #
                    # Make a human readable symlink to the picture
                    # file name.
                    #
                    $human_readable_file_name
                      = &human_readable_file_name ($alt, ".jpg");
                    #
                    system ("ln -s $html_picture_counter.jpg $human_readable_file_name");
                    #
                    &output ("<IMG SRC=\"$html_picture_counter.jpg\" ALT=\"$alt\" TITLE=\"$human_readable_file_name\">");
                    #
                    # Remove temporary files now.
                    #
                    system ("rm -f ${html_temp_file}*");
                    #
                  }
              }
          }
        else
          {
            #
            # Call the basic %block; and %inline; sub process.
            #
            &sgml_tag_elab_html_basic
                ($type,
                 $element,
                 $attributes,
                 $typesetting,
                 $target,
                 $draft,
                 $page_numbering,
                 "", #! $compact,
                 "", #! $long,
                 "", #! $original_file_name,
                 "", #! $current_file_name,
                 "", #! $root_file_name,
                 $paper_width,
                 $paper_height);
          }

    } # sgml_tag_elab_html
    ##
    ##
    ##
    ## Start.
    ##
    ##
    ##
    #
    # Set current file name.
    #
    $CURRENT_FILE_NAME = "$input_file";
    #
    # First, start the scan for cross references.
    #
    # Output from output() is sent to /dev/null
    #
    $CURRENT_OUTPUT_STREAM = "/dev/null";
    open ($CURRENT_OUTPUT_STREAM, ">:utf8", "/dev/null");
    #
    # Open input file.
    #
    open ($input_stream, "<:utf8", "$input_file");
    $INPUT_STREAM_LINE_COUNTER = 0;
    #
    &diag_output (sprintf (gettext ("%s:%s: scanning post-SP searching for cross references.\n"),
                           $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME), $V_SUPER);
    #
    # Scan the post-SP output.
    #
    while ($line = <$input_stream>)
      {
        #
        $INPUT_STREAM_LINE_COUNTER++;
        #
        # Determinate what kind of SP record is.
        #
        if ($line =~ m/^A([a-z]*) ([a-z]*) ?(.*)$/i)
          {
            #
            # This is an attribute record: $1 is the attribute name;
            # $2 is the attrybute type; $3 is the attribute value.
            # We save the name and the value.
            #
            %element_attribute = (%element_attribute, "$1", "$3");
            #
          }
        elsif ($line =~ m/^\((.*)$/i)
          {
            #
            # This is an element start: $1.
            #
            &sgml_tag_elab_first_pass
                ("start", $1, \%element_attribute,
                $typesetting,
                $target,
                $draft,
                $page_numbering,
                "", #! $compact,
                "", #! $long,
                "", #! $original_file_name,
                "", #! $current_file_name,
                "", #! $root_file_name,
                $paper_width,
                $paper_height);
          }
        elsif ($line =~ m/^\)(.*)$/i)
          {
            #
            # This is an element end: $1.
            #
            &sgml_tag_elab_first_pass
                ("end", $1, \%element_attribute,
                $typesetting,
                $target,
                $draft,
                $page_numbering,
                "", #! $compact,
                "", #! $long,
                "", #! $original_file_name,
                "", #! $current_file_name,
                "", #! $root_file_name,
                $paper_width,
                $paper_height);
            #
            # Reset %element_attribute associative array.
            #
            %element_attribute = ();
            #
          }
        elsif ($line =~ m/^\-(.*)$/i)
          {
            #
            # This is parsed character text: $1.
            #
            $pcdata = $1;
            #
            # This text must be transformed if necessary.
            #
            # Notice that the \\ to \bsol translation and back is just
            # an hack to resolve this problem inside SP records.
            #
            # Suppose we have:
            #   bla bla bla \\no bla bla bla.
            # If we tranlsate the two \\ into a single \, we will have
            #   bla bla bla \no bla bla bla.
            # and then we will have a new line there. If the check
            # the new line before, we will have
            #   bla bla bla \
            #   o bla bla bla.
            # with a resitual \.
            # But we wanted exacty.
            #   bla bla bla \no bla bla bla.
            # 
            if ($pcdata =~ s/\\\|(\[[a-zA-Z0-9 ]+\])\\\|/$1/g)        # \\|[hiphen]\\|       --> [hiphen]
              {
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot handle SGML entity %s.\n"),
                              $PROGRAM_EXECUTABLE,
                              $SOURCE_FILE_NAME,
                              $CURRENT_FILE_NAME,
                              $INPUT_STREAM_LINE_COUNTER,
                              $1), $V_ERROR);
              }
            $pcdata =~ s/\\\\\|/\\bsol|/g;        # \\|           --> A true "\|" sequence
            if ($pcdata =~ s/\\\|//g)             # \|            --> "" (SDATA residual delimiters)
              {
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: there is a residual \"\\|\" here and it should not happen.\n"),
                              $PROGRAM_EXECUTABLE,
                              $SOURCE_FILE_NAME,
                              $CURRENT_FILE_NAME,
                              $INPUT_STREAM_LINE_COUNTER), $V_ERROR);
                &diag_output (sprintf ("$pcdata\n"), $V_ERROR);
              }
            $pcdata =~ s/\\\\/\\bsol/g;           # \\            --> \bsol
            $pcdata =~ s/\\n/\n/g;                # \n            --> new line
            $pcdata =~ s/\\bsol/\\/g;             # \bsol         --> \
            #
            # The text is released.
            #
            &output ($pcdata);
          }
        elsif ($line =~ m/^\C$/i)
          {
            #
            # The file is OK.
            # Nothing to do.
            #
            ;
          }
        else
          {
            #
            # This is an unknown rercord type.
            #
            printf STDERR (gettext ("%s: unknown post-SP record: %s\n"),
                           $PROGRAM_EXECUTABLE, $line);
          }
        #
        &wait_message ("$PROGRAM_EXECUTABLE:$SOURCE_FILE_NAME:$CURRENT_FILE_NAME:$INPUT_STREAM_LINE_COUNTER");
        #
      } # while
    #
    # Close input file.
    #
    close ($input_stream);
    #
    # Close output stream and reset @output_stack.
    #
    close ($CURRENT_OUTPUT_STREAM);
    @output_stack = ();
    #
    # Second, another scan depending on the back-end target.
    #
    # Sort index entries.
    #
    &diag_output (sprintf (gettext ("%s:%s: sorting %s index entries.\n"),
                           $PROGRAM_EXECUTABLE,
                           $SOURCE_FILE_NAME,
                           $#index_list), $V_NORMAL);
    #
    &sort_index_list_completely (\@index_list, 0, $#index_list);
    #
    &diag_output (sprintf (gettext ("%s:%s: scanning post-SP again searching for typesetting.\n"),
                           $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME), $V_SUPER);
    #
    if ($typesetting eq "LATEX")
      {
        #
        # Output from output() is sent to a LaTeX source file.
        #
        $CURRENT_OUTPUT_STREAM = $ROOT_FILE_NAME . ".tex";
        open ($CURRENT_OUTPUT_STREAM, ">:utf8", "$ROOT_FILE_NAME.tex");
        #
        # Open input file.
        #
        open ($input_stream, "<:utf8", "$input_file");
        $INPUT_STREAM_LINE_COUNTER = 0;
        #
        # Scan the post-SP output.
        #
        while ($line = <$input_stream>)
          {
            #
            $INPUT_STREAM_LINE_COUNTER++;
            #
            # Determinate what kind of SP record is.
            #
            if ($line =~ m/^A([a-z]*) ([a-z]*) ?(.*)$/i)
              {
                #
                # This is an attribute record: $1 is the attribute name;
                # $2 is the attrybute type; $3 is the attribute value.
                # We save the name and the value.
                #
                %element_attribute = (%element_attribute, "$1", "$3");
                #
              }
            elsif ($line =~ m/^\((.*)$/i)
              {
                #
                # This is an element start: $1.
                #
                &sgml_tag_elab_latex
                  ("start", $1, \%element_attribute,
                    $typesetting,
                    $target,
                    $draft,
                    $page_numbering,
                    "", #! $compact,
                    "", #! $long,
                    "", #! $original_file_name,
                    "", #! $current_file_name,
                    "", #! $root_file_name,
                    $paper_width,
                    $paper_height);
              }
            elsif ( $line =~ m/^\)(.*)$/i )
              {
                #
                # This is an element end: $1.
                #
                &sgml_tag_elab_latex
                  ("end", $1, \%element_attribute,
                    $typesetting,
                    $target,
                    $draft,
                    $page_numbering,
                    "", #! $compact,
                    "", #! $long,
                    "", #! $original_file_name,
                    "", #! $current_file_name,
                    "", #! $root_file_name,
                    $paper_width,
                    $paper_height);
                #
                # Reset %element_attribute associative array.
                #
                %element_attribute = ();
              }
            elsif ($line =~ m/^\-(.*)$/i)
              {
                #
                # This is parsed character text: $1.
                #
                $pcdata = $1;
                #
                # This text must be transformed if necessary.
                #
                # Notice that the \\ to \bsol translation and back is just
                # an hack to resolve this problem inside SP records.
                #
                # Suppose we have:
                #       bla bla bla \\no bla bla bla.
                # If we tranlsate the two \\ into a single \, we will have
                #       bla bla bla \no bla bla bla.
                # and then we will have a new line there. If the check
                # the new line before, we will have
                #       bla bla bla \
                #   o bla bla bla.
                # with a resitual \.
                # But we wanted exacty.
                #       bla bla bla \no bla bla bla.
                # 
                if ($pcdata =~ s/\\\|(\[[a-zA-Z0-9 ]+\])\\\|/$1/g)        # \\|[hiphen]\\|       --> [hiphen]
                  {
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot handle SGML entity %s.\n"),
                                  $PROGRAM_EXECUTABLE,
                                  $SOURCE_FILE_NAME,
                                  $CURRENT_FILE_NAME,
                                  $INPUT_STREAM_LINE_COUNTER,
                                  $1), $V_ERROR);
                  }
                $pcdata =~ s/\\\\\|/\\bsol|/g;        # \\|           --> A true "\|" sequence
                if ($pcdata =~ s/\\\|//g)             # \|            --> "" (SDATA residual delimiters)
                  {
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: there is a residual \"\\|\" here and it should not happen.\n"),
                                  $PROGRAM_EXECUTABLE,
                                  $SOURCE_FILE_NAME,
                                  $CURRENT_FILE_NAME,
                                  $INPUT_STREAM_LINE_COUNTER), $V_ERROR);
                    &diag_output (sprintf ("$pcdata\n"), $V_ERROR);
                  }
                $pcdata =~ s/\\\\/\\bsol/g;           # \\            --> \bsol
                $pcdata =~ s/\\n/\n/g;                # \n            --> new line
                $pcdata =~ s/\\bsol/\\/g;             # \bsol         --> \
                #
                # The text is released.
                #
                &output ($pcdata);
              }
            elsif ($line =~ m/^\C$/i)
              {
                #
                # The file is OK.
                # Nothing to do.
                #
                ;
              }
            else
              {
                #
                # This is an unknown record type.
                #
                &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: unknown post-SP record: %s"),
                                       $PROGRAM_EXECUTABLE,
                                       $SOURCE_FILE_NAME,
                                       $CURRENT_FILE_NAME,
                                       $INPUT_STREAM_LINE_COUNTER,
                                       $line), $V_ERROR);
              }
            #
            &wait_message ("$PROGRAM_EXECUTABLE:$SOURCE_FILE_NAME:$CURRENT_FILE_NAME:$INPUT_STREAM_LINE_COUNTER");
            #
          } # while
        #
        # Close input file.
        close ($input_stream);
        #
        # Close output stream and reset @output_stack.
        #
        close ($CURRENT_OUTPUT_STREAM);
        @output_stack = ();
      }
    elsif ($typesetting eq "HTML")
      {
        #
        # Output from output() is sent to a starting HTML file.
        #
        $CURRENT_OUTPUT_STREAM = $ROOT_FILE_NAME . $html_ext;
        open ($CURRENT_OUTPUT_STREAM, ">:utf8", $ROOT_FILE_NAME . $html_ext);
        #
        # Open input file.
        #
        open ($input_stream, "<:utf8", "$input_file");
        $INPUT_STREAM_LINE_COUNTER = 0;
        #
        # Scan the post-SP output.
        #
        while ($line = <$input_stream>)
          {
            #
            $INPUT_STREAM_LINE_COUNTER++;
            #
            # Determinate what kind of SP record is.
            #
            if ($line =~ m/^A([a-z]*) ([a-z]*) ?(.*)$/i)
              {
                # This is an attribute record: $1 is the attribute name;
                # $2 is the attrybute type; $3 is the attribute value.
                # We save the name and the value.
                %element_attribute = (%element_attribute, "$1", "$3");
              }
            elsif ($line =~ m/^\((.*)$/i)
              {
                #
                # This is an element start: $1.
                #
                &sgml_tag_elab_html
                  ("start", $1, \%element_attribute,
                    $typesetting,
                    $target,
                    $draft,
                    $page_numbering,
                    "", #! $compact,
                    "", #! $long,
                    "", #! $original_file_name,
                    "", #! $current_file_name,
                    "", #! $root_file_name,
                    $paper_width,
                    $paper_height);
              }
            elsif ( $line =~ m/^\)(.*)$/i )
              {
                #
                # This is an element end: $1.
                #
                &sgml_tag_elab_html
                  ("end", $1, \%element_attribute,
                    $typesetting,
                    $target,
                    $draft,
                    $page_numbering,
                    "", #! $compact,
                    "", #! $long,
                    "", #! $original_file_name,
                    "", #! $current_file_name,
                    "", #! $root_file_name,
                    $paper_width,
                    $paper_height);
                #
                # Reset %element_attribute associative array.
                #
                %element_attribute = ();
              }
            elsif ($line =~ m/^\-(.*)$/i)
              {
                #
                # This is parsed character text: $1.
                #
                $pcdata = $1;
                #
                # This text must be transformed if necessary.
                #
                # Notice that the \\ to \bsol translation and back is just
                # an hack to resolve this problem inside SP records.
                #
                # Suppose we have:
                #       bla bla bla \\no bla bla bla.
                # If we tranlsate the two \\ into a single \, we will have
                #       bla bla bla \no bla bla bla.
                # and then we will have a new line there. If the check
                # the new line before, we will have
                #       bla bla bla \
                #   o bla bla bla.
                # with a resitual \.
                # But we wanted exacty.
                #       bla bla bla \no bla bla bla.
                # 
                if ($pcdata =~ s/\\\|(\[[a-zA-Z0-9 ]+\])\\\|/$1/g)        # \\|[hiphen]\\|       --> [hiphen]
                  {
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: cannot handle SGML entity %s.\n"),
                                  $PROGRAM_EXECUTABLE,
                                  $SOURCE_FILE_NAME,
                                  $CURRENT_FILE_NAME,
                                  $INPUT_STREAM_LINE_COUNTER,
                                  $1), $V_ERROR);
                  }
                $pcdata =~ s/\\\\\|/\\bsol|/g;        # \\|           --> A true "\|" sequence
                if ($pcdata =~ s/\\\|//g)             # \|            --> "" (SDATA residual delimiters)
                  {
                    &diag_output (sprintf (gettext ("%s:%s:%s:%s:ERROR: there is a residual \"\\|\" here and it should not happen.\n"),
                                  $PROGRAM_EXECUTABLE,
                                  $SOURCE_FILE_NAME,
                                  $CURRENT_FILE_NAME,
                                  $INPUT_STREAM_LINE_COUNTER), $V_ERROR);
                    &diag_output (sprintf ("$pcdata\n"), $V_ERROR);
                  }
                $pcdata =~ s/\\\\/\\bsol/g;           # \\            --> \bsol
                $pcdata =~ s/\\n/\n/g;                # \n            --> new line
                $pcdata =~ s/\\bsol/\\/g;             # \bsol         --> \
                #
                # The text is released.
                #
                &output ($pcdata);
              }
            elsif ($line =~ m/^\C$/i)
              {
                #
                # The file is OK.
                # Nothing to do.
                #
                ;
              }
            else
              {
                #
                # This is an unknown rercord type.
                #
                printf STDERR (gettext ("%s: unknown post-SP record: %s\n"),
                               $PROGRAM_EXECUTABLE, $line);
              }
          } # while
        #
        # Close input file.
        #
        close ($input_stream);
        #
        # Close output stream and reset @output_stack.
        #
        close ($CURRENT_OUTPUT_STREAM);
        @output_stack = ();

      }
    else
      {
        #
        # This is an unknown typesetting type.
        #
        printf STDERR (gettext ("%s: unknown typesetting: %s\n"),
                       $PROGRAM_EXECUTABLE, $typesetting);
      }
    #
    # Free up memory
    #
    @cross_reference_list       = ();
    undef (@cross_reference_list);
    @index_list = ();
    undef (@index_list);
    @table_columns_width        = ();
    undef (@table_columns_width);
    @output_stack       = ();
    undef (@output_stack);
    @workinfo_list      = ();
    undef (@workinfo_list);
    @nomod_sections_list        = ();
    undef (@nomod_sections_list);
    @current_tabular_columnfractions_list       = ();
    undef (@current_tabular_columnfractions_list);
    @language_list      = ();
    undef (@language_list);
    @html_footnote_list = ();
    undef (@html_footnote_list);
    @html_page_tome_link_list   = ();
    undef (@html_page_tome_link_list);
    @html_page_part_link_list   = ();
    undef (@html_page_part_link_list);
    @html_page_fixed_link_list  = ();
    undef (@html_page_fixed_link_list);

} # sgml_post_sp_elab
###
###
###
### Start of program.
###
###
###
#
# See if it was called with a different name.
#
if ($PROGRAM_EXECUTABLE eq "alml-sp2sp")
  {
    my ($file_name)          = $ARGV[0];
    my ($typesetting)        = $ARGV[1];
    $SOURCE_FILE_NAME        = $ARGV[2];
    $VERBOSE                 = $ARGV[3];
    #
    # Tell it.
    #
    &diag_output (sprintf (gettext ("%s:%s: INFO: %s \"%s\" \"%s\" \"%s\" \"%s\"\n"),
                           $PROGRAM_EXECUTABLE,
                           $file_name,
                           $PROGRAM_EXECUTABLE,
                           $file_name,
                           $typesetting,
                           $SOURCE_FILE_NAME,
                           $VERBOSE), $V_INFO);
    #
    # Now modify the SP output
    #
    &sp_to_sp_filter ($file_name, $typesetting);
    #
    # Don't have to continue with the program.
    #
    exit;
  }
#
my ($working_source_file_name)  = "";
my ($action)                    = "";
my ($draft)                     = 0;
my ($paper)                     = "a4";       # default to A4 portrait
my ($paper_width)               = "210mm";    # default to A4 portrait
my ($paper_height)              = "297mm";    # default to A4 portrait
my ($paper_orientation)         = "portrait"; # default to A4 portrait
my ($page_numbering)            = "";
my ($input_encoding)            = "";         # default to UTF-8
my ($sgml_include)              = ();
my ($nsgmls_include_options)    = "";
my ($end_of_options)            = 0;
my ($typesetting)               = "";
my ($n)                         = 0;
#
# used to tell what kind of target is the post-SP elaboration for.
#
my ($sgml_target) = $typesetting;
#
# Scan arguments.
#
for ($n = 0; $n <= $#ARGV; $n++)
  {
    #
    # Analyze argument $n.
    #
    if ($ARGV[$n] !~ m/^-/)
     {
        #
        # Options are terminated as this argument has no minus at the
        # beguinning. This must be a file name.
        #
        if ($end_of_options)
          {
            #
            # As options are already terminated, this is an extra
            # argument: a mistake.
            #
            printf STDERR (gettext ("%s: no more arguments allowed after the file name: %s\n"),
                                     $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
        else
          {
            #
            # This is the first time that we encounter an argument
            # without "-". Must be the source file.
            #
            $end_of_options = 1;
            $SOURCE_FILE_NAME = $ARGV[$n];
          }
      }
    elsif ($ARGV[$n] eq "--help")
      {
        #
        # The user is asking for help.
        #
        &help_syntax;
        exit 0;
      }
    elsif ($ARGV[$n] eq "--version")
      {
        #
        # The user wants to know the program version.
        #
        &version_info;
        exit 0;
      }
    elsif ($ARGV[$n] eq "--draft")
      {
        #
        # The user wants to get draft typesetting.
        #
        $draft = 1;
      }
    elsif ($ARGV[$n] eq "--sgml-syntax"
           || $ARGV[$n] eq "--sgml-check")
      {
        #
        # The user wants to check the SGML source.
        # We need to verify that the action wasnt already definied.
        #
        if ($action eq "")
          {
            $action = "sgml-check";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                                     $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--html-check")
      {
        
        # The user wants to check the HTML source.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "html-check";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                                     $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--htmliso-check")
      {
        
        # The user wants to check the HTML source.
        # We need to verify that the action was not already definied.

        if ($action eq "")
          {
            $action = "htmliso-check";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                                     $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--html401-check")
      {
        
        # The user wants to check the HTML source.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "html401-check";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                                     $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--html320-check")
      {
        
        # The user wants to check the HTML source.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "html320-check";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                                     $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--xml-check")
      {
        
        # The user wants to check the XML source.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "xml-check";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                                     $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--sgml-syntax-hard"
           || $ARGV[$n] eq "--sgml-check-hard")
      {
        
        # The user wants to check all SGML aspects.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "sgml-check-hard";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                                     $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ( $ARGV[$n] =~ m/^--input-encoding=(.+)$/ )
      {

        # The user tells what input encoding is used for the SGML
        # source file.

        $input_encoding = $1;

      }
    elsif ($ARGV[$n] =~ m/^--sgml-include=(.*)$/)
      {
        
        # The user tells the name of an SGML parameter entity
        # that should be assigned with the word "INCLUDE". That
        # is, we want:
        #
        # <!ENTITY % name "INCLUDE">
        #
        # This option is cumulative; this way, we add to an array.

        $sgml_include[$#sgml_include+1] = $1;
      }
    elsif ( $ARGV[$n] =~ m/^--paper=(.+)$/ )
      {
        
        # The user tells what page size.
        # We need to verify that the dimentions werent already definied.

        $paper = lc $1;
        ($paper_width, $paper_height) = &paper_size ($paper, $paper_orientation);

        # The function &paper_size has defaults, so there is no
        # point to check the result.

      }
    elsif ( $ARGV[$n] =~ m/^--paper-orientation=(.+)$/ )
      {
        
        # The user tells the paper orientation.
        # We need to verify the previous orientation.

        if (lc ($1) eq "portrait"
            || lc ($1) eq "landscape")
          {
            
            # OK.

            ;
          }
        else
          {
            
            # There is a problem.

            printf STDERR (gettext ("%s: paper orientation unknown %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ( $ARGV[$n] =~ m/^--page-numbering=(.*)$/ )
      {
        
        # The user tells how to handle page numbering.

        if ($page_numbering eq "")
          {
            $page_numbering = $1;
            if ($page_numbering eq "plain"
                || $page_numbering eq "default"
                || $page_numbering eq "tome")
              {
                
                # OK.

                ;
              }
            else
              {
                printf STDERR (gettext ("%s: only the words plain and default are allowed: %s\n"),
                               $PROGRAM_EXECUTABLE, $ARGV[$n]);
                exit 1;
              }
          }
        else
          {
            printf STDERR (gettext ("%s: page numbering may be specified only once: %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--tex"
           || $ARGV[$n] eq "--latex")
      {
        
        # The user wants to generate only a LaTeX source for debugging.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "latex";
            $typesetting = "LATEX";
            $sgml_target = "LATEX";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ( $ARGV[$n] eq "--dvi" )
      {
        
        # The user wants to generate a DVI output.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "dvi";
            $typesetting = "LATEX";
            $sgml_target = "DVI";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ( $ARGV[$n] eq "--sp" )
      {
        
        # The user wants to generate a SP output for debugging.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "sp";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--ps"
           || $ARGV[$n] eq "--postscript")
      {
        
        # The user wants to generate a PostScript output.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "ps";
            $typesetting = "LATEX";
            $sgml_target = "PS";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--pdf")
      {
    
        # The user wants to generate a PDF output.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "pdf";
            $typesetting = "LATEX";
            $sgml_target = "PS";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--html")
      {
        
        # The user wants to generate a standard HTML output.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "html";
            $typesetting = "HTML";
            $sgml_target = "HTML";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--html-text")
      {
        
        # The user wants to generate a single HTML output for text
        # browsers.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "html-text";
            $typesetting = "HTML";
            $sgml_target = "HTML-TEXT";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    elsif ($ARGV[$n] eq "--verbose")
      {
        
        # Verbose mode was required.

        $VERBOSE++;
      }
    elsif ($ARGV[$n] eq "--clean")
      {
        
        # The user wants to clean some stale files.
        # We need to verify that the action wasnt already definied.

        if ($action eq "")
          {
            $action = "clean";
          }
        else
          {
            printf STDERR (gettext ("%s: only one action option is allowed: %s\n"),
                           $PROGRAM_EXECUTABLE, $ARGV[$n]);
            exit 1;
          }
      }
    else
      {
        
        # Must be an unknown option.

        printf STDERR (gettext ("%s: unknown option: %s\n"),
                       $PROGRAM_EXECUTABLE, $ARGV[$n]);
        exit 1;
      }

  }

# Are arguments coherent?

if ($action eq "")
  {
    $action = "sp";
  }

# Prepare nsgmls options for parameter entity inclusion.

for ($n = 0 ; $n <= $#sgml_include ; $n++)
  {
    $nsgmls_include_options
      = $nsgmls_include_options . " -i" . $sgml_include[$n];
  }

## We assume that if we are here, all arguments are ok.
## If we are here, there is something to do.

# Define the root file name.

$ROOT_FILE_NAME = &root_name ("$SOURCE_FILE_NAME", ".sgml");

# Define temporary file name prefix.

$TEMP_FILE_NAME_PREFIX = $PROGRAM_EXECUTABLE . "_" . $ROOT_FILE_NAME;

# Prepare the diagnostic messages file. It will be reopened when
# necessary.

system( "mv -f $ROOT_FILE_NAME.diag $ROOT_FILE_NAME.diag~ 2> /dev/null" );
open (DIAG, "> $ROOT_FILE_NAME.diag");
close (DIAG);

# If we have to clean from stale files; we do here:

if ($action eq "clean")
  {
    system ("rm $ROOT_FILE_NAME.log      > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.log~     > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.aux      > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.aux~     > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.pageref  > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.pageref~ > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.pageloc  > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.pageloc~ > /dev/null 2>&1");
#    system ("rm $ROOT_FILE_NAME.titles   > /dev/null 2>&1");
#    system ("rm $ROOT_FILE_NAME.titles~  > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.diag     > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.diag~    > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.debug    > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.sp       > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.sp~      > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.sp2      > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.sp2~     > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.tex~     > /dev/null 2>&1");
    system ("rm $ROOT_FILE_NAME.out      > /dev/null 2>&1");

    exit 0;
  }

# If we have to check an HTML or XML file...

if ($action eq "html-check")
  {

    
    # We just check the HTML. The output is controlled by less, so
    # we can read it well.
    

    system ("cat $SOURCE_FILE_NAME | nsgmls -s -c $HTML_CATALOG 2>&1 | less");

    exit 0;
  }
if ($action eq "html320-check")
  {

    
    # We just check the HTML 3.2. The output is controlled by less, so
    # we can read it well.
    

    system
      ("cat $SOURCE_FILE_NAME | nsgmls -s -c $HTML320_CATALOG 2>&1 | less");

    exit 0;
  }
if ($action eq "html401-check")
  {

    
    # We just check the HTML 4.01. The output is controlled by less, so
    # we can read it well.
    

    system
      ("cat $SOURCE_FILE_NAME | nsgmls -s -c $HTML401_CATALOG 2>&1 | less");

    exit 0;
  }
if ($action eq "htmliso-check")
  {

    
    # We just check the HTML 4.01. The output is controlled by less, so
    # we can read it well.
    

    system
      ("cat $SOURCE_FILE_NAME | nsgmls -s -c $HTMLISO_CATALOG 2>&1 | less");

    exit 0;
  }
if ($action eq "xml-check")
  {
    
    # We just check the XML. The output is controlled by less, so
    # we can read it well.

    system
      ("cat $SOURCE_FILE_NAME | nsgmls -s -c $XML_CATALOG 2>&1 | less");

    exit 0;
  }

# At this point, the option --input-encoding is taken into
# consideration.

$working_source_file_name = $SOURCE_FILE_NAME;

if (lc ($input_encoding) eq "utf8"
    || lc ($input_encoding) eq "utf-8"
    || ($input_encoding) eq "latin1"
    || ($input_encoding) eq "latin-1"
    || ($input_encoding) eq "iso-8859-1")
  {
    
    # Nothing to change.

    ;

  }
elsif ($input_encoding ne "")
  {
    
    # This is a not allowed encoding.
    
    # The source cannot be converted into UTF-8 as it can be made
    # of different file linked together.

    &diag_output (sprintf (gettext ("%s:%s: ERROR: encoding seems to be %s, but ISO 8859-1 (latin1) will be used instead"),
                           $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME, $input_encoding), $V_ERROR);

  }
else
  {
    
    # Try to get locale configuration.
    
    if (defined ($ENV{LC_ALL}) && $ENV{LC_ALL} ne "")
      {
        $input_encoding = $ENV{LC_ALL};
      }
    elsif (defined ($ENV{LC_CTYPE}) &&$ENV{LC_CTYPE} ne "")
      {
        $input_encoding = $ENV{LC_CTYPE};
      }
    elsif (defined ($ENV{LANG}) &&$ENV{LANG} ne "")
      {
        $input_encoding = $ENV{LANG};
      }
    else
      {
        $input_encoding = "utf8";

        &diag_output (sprintf (gettext ("%s:%s: ERROR: cannot determinate input encoding: using default %s"),
                               $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME, $input_encoding), $V_ERROR);

      }

    if ($input_encoding =~ m/^[a-z][a-z]$/)
      {
        
        # It is just a two letters language encoding.
        # Set the default.

        $input_encoding = "utf8";

        &diag_output (sprintf (gettext ("%s:%s: ERROR: cannot determinate input encoding: using default %s"),
                               $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME, $input_encoding), $V_ERROR);

      }
    elsif ($input_encoding =~ m/^[a-z][a-z]_[A-Z][A-Z]$/)
      {
    
        # It is just a two letters language encoding, with
        # a two letters national encoding.
        # Set the default.
        

        $input_encoding = "utf8";

        &diag_output (sprintf (gettext ("%s:%s: ERROR: cannot determinate input encoding: using default %s"),
                               $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME, $input_encoding), $V_ERROR);

      }
    elsif ($input_encoding =~ m/\@euro/)
      {

        
        # It is a ISO 8859-15 (Euro) encodong.
        

        $input_encoding = "ISO-8859-15";

        &diag_output (sprintf (gettext ("%s:%s: ERROR: encoding seems to be %s, but ISO 8859-1 (latin1) will be used instead"),
                               $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME, $input_encoding), $V_ERROR);

      }
    elsif ($input_encoding =~ m/\.(.*)$/)
      {

        
        # There is a point and the encoding.
        

        $input_encoding = $1;

        if ($input_encoding eq "UTF-8"
            || $input_encoding eq "UTF8")
          {
            $input_encoding = "utf8";
          }
        elsif ($input_encoding eq "ISO-8859-1")
          {
            $input_encoding = "latin1";
          }
        else
          {
            &diag_output (sprintf (gettext ("%s:%s: ERROR: encoding seems to be %s, but ISO 8859-1 (latin1) will be used instead"),
                                   $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME, $input_encoding), $V_ERROR);
          }
      }
    else
      {
        $input_encoding = "utf8";
        &diag_output (sprintf (gettext ("%s:%s: ERROR: cannot determinate input encoding: %s"),
                               $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME, $input_encoding), $V_ERROR);
      }

    
    # The source cannot be converted into UTF-8 as it can be made
    # of different file linked together.
    

  }

# Now we call nsgmls from the SP package and do what it is required.

if ($action eq "sgml-check")
  {
    
    # We just check the SGML. The output is controlled by less, so
    # we can read it well.

    if ($input_encoding eq "utf8")
      {
        $ENV{SP_BCTF} = "utf-8";
      }

    system
      ("cat $working_source_file_name | nsgmls -butf-8 $nsgmls_include_options -s -c $CATALOG 2>&1 | less");
  }
elsif ($action eq "sgml-check-hard")
  {

    
    # We just check the SGML in an hard way.
    # The output is controlled by less, so
    # we can read it well.
    

    if ($input_encoding eq "utf8")
      {
        $ENV{SP_BCTF} = "utf-8";
      }

    system
      ("cat $working_source_file_name | nsgmls -butf-8 $nsgmls_include_options -wall -s -c $CATALOG 2>&1 | less");
  }
else
  {
    
    # Tell what we are doing.

    &diag_output (sprintf (gettext ("%s:%s: SGML parse\n"),
                           $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME), $V_SUPER);
    
    # We obtain a first pass SP output.

    if ($input_encoding eq "utf8")
      {
        $ENV{SP_BCTF} = "utf-8";
      }

    system
      ("cat $working_source_file_name | nsgmls -butf-8 $nsgmls_include_options -c $CATALOG > ${ROOT_FILE_NAME}.sp");

    # SP to SP elaboration.
    #
    # Example as program, to save some memory,
    # but it seems not useful enough.
    #
    #! system ("alml-sp2sp \"$ROOT_FILE_NAME.sp\" \"$typesetting\" \"$SOURCE_FILE_NAME\" \"$VERBOSE\"");
    #
    # Normal way with function call.

    &sp_to_sp_filter ("${ROOT_FILE_NAME}.sp", $typesetting);

    if ($action eq "sp")
      {
    
        # All done. The SP output is ready.

        ;
      }
    else
      {
        
        # We have to elaborate the post-SP output 
        
        # Tell what we are going to do.

        &diag_output (sprintf (gettext ("%s:%s: parsing post-SP for target %s\n"),
                               $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME, $sgml_target), $V_SUPER);

        #! system ("alml-sp2be \"${ROOT_FILE_NAME}.sp2\" \"$typesetting\"
        #! \"$sgml_target\" \"$draft\" \"$page_numbering\" \"$compact\"
        #! \"$long\" \"$source_file_name\" \"$ROOT_FILE_NAME\" \"$VERBOSE\"
        #! \"$paper_width\" \"$paper_height\"");

        &sgml_post_sp_elab ("${ROOT_FILE_NAME}.sp2",
                            $typesetting,
                            $sgml_target,
                            $draft,
                            $page_numbering,
                            "", #$compact,
                            "", #$long,
                            "", #! $source_file_name,
                            "${ROOT_FILE_NAME}.sp2",
                            "", #! $root_file_name,
                            $paper_width,
                            $paper_height);

        if ($action eq "latex")
          {

            # All done. The LaTeX source is ready.

            ;   
          }
        elsif ($action eq "html")
          {
            
            # All done. The HTML output is ready.

            ;   
          }
        elsif ($action eq "html-text")
          {
            
            # All done. The HTML output is ready.

            ;   
          }
        elsif ($action eq "dvi")
          {
            system ("mv -f $ROOT_FILE_NAME.aux $ROOT_FILE_NAME.aux~ 2> /dev/null");
            system ("mv -f $ROOT_FILE_NAME.pageref $ROOT_FILE_NAME.pageref~ 2> /dev/null");
            system ("mv -f $ROOT_FILE_NAME.log $ROOT_FILE_NAME.log~ 2> /dev/null");
            &system_diag_output ("$PROGRAM_EXECUTABLE", "latex  $ROOT_FILE_NAME.tex", $V_WARNING);

            
            # Before running again LaTeX, we need to call an external
            # program to elaborate page informations.
            
            #! system ("alml-pageref \"$ROOT_FILE_NAME\" 0 \"$VERBOSE\"");
            &page_ref_replace ("", #! $root_file_name,
                               0);
            &system_diag_output ("$PROGRAM_EXECUTABLE", "latex  $ROOT_FILE_NAME.tex", $V_WARNING);
            
            # Before running again LaTeX, we need to call an external
            # program to elaborate page informations.
            

            #! system ("alml-pageref \"$ROOT_FILE_NAME\" 1 \"$VERBOSE\"");
            &page_ref_replace ("", #! $root_file_name,
                               1);

            &system_diag_output ("$PROGRAM_EXECUTABLE", "latex  $ROOT_FILE_NAME.tex", $V_WARNING);
          }
        elsif ($action eq "ps")
          {
            system ("mv -f $ROOT_FILE_NAME.aux $ROOT_FILE_NAME.aux~ 2> /dev/null");
            system ("mv -f $ROOT_FILE_NAME.pageref $ROOT_FILE_NAME.pageref~ 2> /dev/null");
            system ("mv -f $ROOT_FILE_NAME.log $ROOT_FILE_NAME.log~ 2> /dev/null");
            &system_diag_output ("$PROGRAM_EXECUTABLE", "latex  $ROOT_FILE_NAME.tex", $V_WARNING);

            
            # Before running again LaTeX, we need to call an external
            # program to elaborate page informations.
            

            #! system ("alml-pageref \"$ROOT_FILE_NAME\" 0 \"$VERBOSE\"");
            &page_ref_replace ("", #! $root_file_name,
                               0);

            &system_diag_output ("$PROGRAM_EXECUTABLE", "latex  $ROOT_FILE_NAME.tex", $V_WARNING);

            
            # Before running again LaTeX, we need to call an external
            # program to elaborate page informations.
            

            #! system ("alml-pageref \"$ROOT_FILE_NAME\" 1 \"$VERBOSE\"");
            &page_ref_replace ("", #! $root_file_name,
                               1);

            &system_diag_output ("$PROGRAM_EXECUTABLE", "latex  $ROOT_FILE_NAME.tex", $V_WARNING);

            
            # Tell what we are going to do.
            

            &diag_output (sprintf (gettext ("%s:%s: converting DVI to PS\n"),
                               $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME), $V_SUPER);

            &system_diag_output ("$PROGRAM_EXECUTABLE", "dvips -K -o $ROOT_FILE_NAME.ps $ROOT_FILE_NAME.dvi", $V_WARNING);
          }
        elsif ($action eq "pdf")
          {
            system ("mv -f $ROOT_FILE_NAME.aux $ROOT_FILE_NAME.aux~ 2> /dev/null");
            system ("mv -f $ROOT_FILE_NAME.pageref $ROOT_FILE_NAME.pageref~ 2> /dev/null");
            system ("mv -f $ROOT_FILE_NAME.log $ROOT_FILE_NAME.log~ 2> /dev/null");
            &system_diag_output ("$PROGRAM_EXECUTABLE", "latex  $ROOT_FILE_NAME.tex", $V_WARNING);
            
            # Before running again LaTeX, we need to call an external
            # program to elaborate page informations.
            

            #! system ("alml-pageref \"$ROOT_FILE_NAME\" 0 \"$VERBOSE\"");
            &page_ref_replace ("", #! $root_file_name,
                               0);

            &system_diag_output ("$PROGRAM_EXECUTABLE", "latex  $ROOT_FILE_NAME.tex", $V_WARNING);

            
            # Before running again LaTeX, we need to call an external
            # program to elaborate page informations.
            

            #! system ("alml-pageref \"$ROOT_FILE_NAME\" 1 \"$VERBOSE\"");
            &page_ref_replace ("", #! $root_file_name,
                               1);

            &system_diag_output ("$PROGRAM_EXECUTABLE", "latex  $ROOT_FILE_NAME.tex", $V_WARNING);
            
            # Tell what we are going to do.

            &diag_output (sprintf (gettext ("%s:%s: converting DVI to PDF\n"),
                               $PROGRAM_EXECUTABLE, $SOURCE_FILE_NAME), $V_SUPER);
            
            # Convert DVI to PDF.

            &system_diag_output ("$PROGRAM_EXECUTABLE", "dvipdft -o $ROOT_FILE_NAME.pdf $ROOT_FILE_NAME.dvi", $V_WARNING);

          }
      }
}
#
# Delete residual temporary files.
# It is strange, but sometimes, unlink() doesn't work as expected.
#
system ("rm -f $TEMP_FILES_LIST");
system ("rm -fr $TEMP_FILES_LIST");
#
#======================================================================
