Diff for /loncom/xml/londefdef.pm between versions 1.398 and 1.415.4.6

version 1.398, 2009/01/20 12:01:00 version 1.415.4.6, 2011/11/15 17:34:19
Line 48  use Image::Magick; Line 48  use Image::Magick;
 use Apache::lonmenu();  use Apache::lonmenu();
 use Apache::lonmeta();  use Apache::lonmeta();
 use Apache::lonlocal;  use Apache::lonlocal;
   use Apache::loncommon();
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use File::Basename;  use File::Basename;
 use LONCAPA();  use LONCAPA();
Line 176  sub start_html { Line 177  sub start_html {
     if ($target eq 'web' || $target eq 'edit' || $target eq 'webgrade' ) {      if ($target eq 'web' || $target eq 'edit' || $target eq 'webgrade' ) {
  # start_body() takes care of emitting the <html>    # start_body() takes care of emitting the <html> 
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring .=   
     '\documentclass[letterpaper,twoside]{article}\raggedbottom';  
  if (($env{'form.latex_type'}=~'batchmode') ||  
             (!$env{'request.role.adv'})) {$currentstring .='\batchmode';}   
  $currentstring .= '\newcommand{\keephidden}[1]{}'.  
                           '\renewcommand{\deg}{$^{\circ}$}'.  
   '\usepackage{multirow}'.  
                           '\usepackage{longtable}'.  
                           '\usepackage{textcomp}'.  
                           '\usepackage{makeidx}'.  
                           '\usepackage[dvips]{graphicx}'.  
   '\usepackage{wrapfig}'.  
   '\usepackage{picins}'.  
   '\usepackage[T1]{fontenc}'."\n".  
                           '\usepackage{lmodern}'."\n".  
   '\usepackage[postscript]{ucs}'."\n".  
   '\usepackage[utf8x]{inputenc}'."\n".  
   '\usepackage{pifont}' ."\n".  
   '\usepackage{latexsym}'."\n".  
                           '\usepackage{epsfig}'.  
   "\\usepackage{xtab}\n".  
   "\\usepackage{tabularx}\n".  
   "\\usepackage{booktabs}\n".  
   "\\usepackage{array}\n".  
   "\\usepackage{colortbl}\n".  
   "\\usepackage{xcolor}\n".  
                           '\usepackage{calc}'.  
                           '\usepackage{amsmath}'.  
                           '\usepackage{amssymb}'.  
                           '\usepackage{amsfonts}'.  
                           '\usepackage{amsthm}'.  
                           '\usepackage{amscd}';  
   
         if($env{'form.pdfFormFields'} eq 'yes') {  
             $currentstring .= '\usepackage{hyperref}'.  
                               '\usepackage{eforms}'.  
                               '\usepackage{tabularx}';  
         }   
   
         $currentstring .= '\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}'.   $currentstring .= &latex_header();
                           '\renewenvironment{theindex}{\begin{list}{}{{\vskip 1mm \noindent \large\textbf{Index}} \newline \setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.01in}\setlength{\itemsep}{0.1in}\setlength{\parsep}{-0.02in}\setlength{\belowdisplayskip}{0.01in}\setlength{\abovedisplayskip}{0.01in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.01in}}}{\end{list}}';  
     }      }
     return $currentstring;      return $currentstring;
 }  }
Line 577  sub start_body { Line 539  sub start_body {
   
  my $extra_head = &generate_css_links();   my $extra_head = &generate_css_links();
   
       # Breadcrumbs
       &Apache::lonhtmlcommon::clear_breadcrumbs();
       if ($env{'request.state'} eq 'construct') {
           &Apache::lonhtmlcommon::add_breadcrumb({
               'text'  => 'Construction Space',
               'href'  => &Apache::loncommon::authorspace(),
           });
           &Apache::lonhtmlcommon::add_breadcrumb({
               'text'  => 'HTML Editor',
               'href'  => '',
           });
           # breadcrumbs (and tools) will be created 
           # in start_page->bodytag->innerregister
       } else {
           # FIXME Where are we?
       }
   
  $currentstring =    $currentstring = 
     &Apache::loncommon::start_page($Apache::londefdef::title,      &Apache::loncommon::start_page($Apache::londefdef::title,
    $Apache::londefdef::head     $Apache::londefdef::head
       .$extra_head,        .$extra_head,
    {'add_entries'    => $token->[2],     {'add_entries'    => $token->[2],
     'no_title'       => 1,  #    'no_title'       => 1,
     'force_register' => 1});      'force_register' => 1});
   
  if ($env{'request.state'} ne 'published') {          my $header = '';
     $currentstring.=&Apache::lonmenu::constspaceform();          if ($env{'request.state'} ne 'published' &&
     $currentstring.=&Apache::londefdef::edit_controls();              $env{'request.state'} ne 'construct') {
  }              $header=&Apache::lonmenu::constspaceform();
  $currentstring.=&Apache::lonxml::message_location();          }
           if ($env{'request.state'} ne 'published') {
               $header.=&Apache::londefdef::edit_controls();
           }
           if ($env{'request.state'} eq 'construct') {
               $currentstring.=&Apache::loncommon::head_subbox(
                                   &Apache::loncommon::CSTR_pageheader()
                                  .$header);
           } elsif ($env{'request.state'} eq 'edit') {
               $currentstring.=&Apache::loncommon::head_subbox($header);
           }
           $currentstring.=&Apache::lonxml::message_location();
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  $currentstring = '\begin{document}';            $currentstring = '';   #  '\begin{document}' is in header.
     }       }
   
     return $currentstring;      return $currentstring;
 }  }
   
 sub edit_controls {  sub edit_controls {
       my ($nochgview) = @_;
     my $result .= '      my $result .= '
 <form method="post">  <form method="post" action="">
 <div class="LC_edit_problem_header">  <div class="LC_edit_problem_header">';
       unless ($nochgview) {
           $result .= '
 <div class="LC_edit_problem_header_row1">'.  <div class="LC_edit_problem_header_row1">'.
 &Apache::lonxml::renderingoptions().'  &Apache::lonxml::renderingoptions().'
 <input type="submit" name="changeproblemmode" value="'.&mt('Change View').'" />  <input type="submit" name="changeproblemmode" value="'.&mt('Change View').'" />
   </div>';
       }
       $result .= '
   <div><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" />';
       if (($env{'request.course.id'}) && ($env{'form.forceedit'})) {
           my $viewtext = &mt('Course View');
           if (&Apache::loncommon::course_type() eq 'Community') {
               $viewtext = &mt('Community View');
           }
           $result .= ('&nbsp;' x 3).'<input type="button" value="'.
                      $viewtext.'" onclick="javascript:location.href=currentURL" />';
       }
       $result .= '</div>
 </div>  </div>
 <div class="LC_edit_problem_header_edit_row"><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" /></div></div>  
 </form>  </form>
 <br />';  ';
     return $result;      return $result;
 }  }
   
Line 1383  sub start_font { Line 1389  sub start_font {
     my $currentstring = '';      my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {      if ($target eq 'web' || $target eq 'webgrade') {
  my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);   my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval);
  if ($face!~/symbol/i) {  
     if (($env{'browser.fontenhance'} eq 'on') ||   
  ($env{'browser.blackwhite'} eq 'on')) { return ''; }  
  }  
  $currentstring = $token->[4];        $currentstring = $token->[4];     
     }  elsif ($target eq 'tex') {      }  elsif ($target eq 'tex') {
  my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);   my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval);
Line 1651  sub start_a { Line 1653  sub start_a {
  my $href=&Apache::lonxml::get_param('href',$parstack,$safeeval,   my $href=&Apache::lonxml::get_param('href',$parstack,$safeeval,
     undef,1);      undef,1);
  $currentstring=&Apache::lonenc::encrypt_ref($token,{'href'=>$href});   $currentstring=&Apache::lonenc::encrypt_ref($token,{'href'=>$href});
           if ($href =~ /\S/) {
               if ($href !~ m{^https?://}) {
                   my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
                   my $linkurl;
                   if ($href =~ m{^/uploaded/}) {
                       $linkurl = $href;
                   } elsif ($href =~ m{^[^/]}) {
                       my $path = $url;
                       $path  =~ s{[^/]*$}{};
                       $linkurl = $path.$href;
                   }
                   if ($linkurl =~ m{^/uploaded/}) {
                       if (!&Apache::lonnet::allowed('bre',$linkurl)) {
                           if (&Apache::lonnet::is_on_map($url)) {
                               &Apache::lonxml::extlink($linkurl);
                           }
                       }
                   }
               }
           }
     }      }
     return $currentstring;      return $currentstring;
 }  }
Line 2023  sub start_table { Line 2045  sub start_table {
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
  &disable_para(); # Can't have paras in a table.   &disable_para(); # Can't have paras in a table.
   
   
  #  New table code:  
   
  #  Get the parameters that we can do something about:   #  Get the parameters that we can do something about:
   
  my $border = &Apache::lonxml::get_param('border', $parstack, $safeeval, undef, 0);   my $border = &Apache::lonxml::get_param('border', $parstack, $safeeval, undef, 0);
  my $width  = &Apache::lonxml::get_param('TeXwidth', $parstack, $safeeval, undef, 0);   my $width  = &Apache::lonxml::get_param('TeXwidth', $parstack, $safeeval, undef, 0);
  my $theme  = &Apache::lonxml::get_param('TeXtheme', $parstack, $safeeval, undef, 0);   my $theme  = &Apache::lonxml::get_param('TeXtheme', $parstack, $safeeval, undef, 0);
  my $align  = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef, 0);   my $align  = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef, 0);
           my $cell_border = &Apache::lonxml::get_param('rules', $parstack, $safeeval, undef, 0);
   
  # The only thing that needs any figuring out is the width.. and then only if it is   # The only thing that needs any figuring out is the width.. and then only if it is
  # a percent. If not it's assumed to be some valid TeX measurement unit e.g. 3.0cm   # a percent. If not it's assumed to be some valid TeX measurement unit e.g. 3.0cm
  #   #
   
  my $table = new Apache::lontable();   my $table = new Apache::lontable();
  if ($border ne '') {          if ((defined $border) && ($border > 0)) {
     $table->table_border(1);          #    &Apache::lonnet::logthis("Turning on table borders: $border");
     $table->cell_border(1);              $table->table_border(1);
  }              if (!defined $cell_border) {
  if ($theme ne '') {                  $table->cell_border(1); # Default for rules is all if rules not defined.
               }
           }
   
           if ((defined $cell_border)) {
               if ($cell_border eq 'all') {
                   $table->cell_border(1);
               } elsif ($cell_border eq 'rows') {
                   $table->cell_border(2);
               } elsif ($cell_border eq 'cols') {
                   $table->cell_border(3);
               } elsif($cell_border eq 'groups') {
                   $table->cell_border(4);
               } else {
                   $table->cell_border(0);
               }
           }
           if (defined $theme) {
     $table->theme($theme);      $table->theme($theme);
  }   }
  if ($align ne '') {   if (defined $align) {
     $table->alignment($align);      $table->alignment($align);
  }   }
   
  # Missing width is most of page width   # Missing width is most of page width
   
  if ($width eq "") {   if (!(defined $width)) {
     $width = '70%';      $width = '70%';
  }   }
   
Line 2069  sub start_table { Line 2106  sub start_table {
  push(@Apache::londefdef::table, $table);   push(@Apache::londefdef::table, $table);
         $currentstring.=' \keephidden{NEW TABLE ENTRY}';          $currentstring.=' \keephidden{NEW TABLE ENTRY}';
   
  #--------------------------------------------------------  
  #  Old table code here.  
  #--------------------------------------------------------  
   
   
  if (0) {  
  push(@Apache::londefdef::table, {});   
  $Apache::londefdef::table[-1]{'row_number'} = -1;  
         #maximum table's width (default coincides with text line length)  
  if ($#Apache::londefdef::table==0) {  
     $textwidth=&recalc($env{'form.textwidth'}); #result is always in mm  
     $textwidth=~/(\d+\.?\d*)/;  
     $textwidth=0.85*$1; #accounts "internal" LaTeX space for table frame  
  } else {  
     if ($Apache::londefdef::table[-2]{'TeXlen'}[$Apache::londefdef::table[-2]{'row_number'}][$Apache::londefdef::table[-2]{'counter_columns'}]=~/\d/) {  
  #the maximum width of nested table is determined by LATeX width of parent cell  
  $textwidth=$Apache::londefdef::table[-2]{'TeXlen'}[$Apache::londefdef::table[-2]{'row_number'}][$Apache::londefdef::table[-2]{'counter_columns'}];   
     } else {  
               #try to use all space not used before (minus 5% for LaTeX table internal) - rather silly  
  $textwidth=$Apache::londefdef::table[-2]{'width'};  
  for (my $i=0;$i<$Apache::londefdef::table[-2]{'counter_columns'};$i++) {  
     $textwidth=$textwidth-$Apache::londefdef::table[-2]{'TeXlen'}[0][$i];  
  }  
     }  
  }  
   
  # width either comes forced from the TeXwidth or the width parameters.  
  # in either case it can be a percentage or absolute width.  
  # in the width case we ignore absolute width   
  my $TeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,undef,0);  
  if (!defined($TeXwidth)) {  
     my $htmlwidth = &Apache::lonxml::get_param('width',$parstack,  
        $safeeval,undef,1);  
     if ($htmlwidth =~ /%/) {  
  $TeXwidth = $htmlwidth;  
     } else {   
  $TeXwidth = $textwidth;  
     }  
  }  
  # if the width is specified as a % it is converted to an absolute width.  
  # otherwise.. just plugged right in the hash  
   
  if ($TeXwidth=~/%/) {  
     $TeXwidth=~/(\d+)/;  
             $Apache::londefdef::table[-1]{'width'}=$1*$textwidth/100;  
  } else {  
     $Apache::londefdef::table[-1]{'width'}=$TeXwidth;  
  }  
         #  In the end, however the table width cannot be wider than $textwidth...  
   
  if ($Apache::londefdef::table[-1]{'width'} > $textwidth) {  
     $Apache::londefdef::table[-1]{'width'} = $textwidth;  
  }  
         #table's border  
  my $border = &Apache::lonxml::get_param('border',$parstack,$safeeval);   
         my $permission=&Apache::lonxml::get_param('TeXDropEmptyColumns',$parstack,$safeeval,undef,0);  
  unless (defined $border) { $border = 0; }  
  if ($border) {   
     $Apache::londefdef::table[-1]{'hinc'} = '\hline ';   
     $Apache::londefdef::table[-1]{'vinc'} = '&';   
     $Apache::londefdef::table[-1]{'vvinc'} = '|';  
  } else {  
     $Apache::londefdef::table[-1]{'hinc'} = '';   
     $Apache::londefdef::table[-1]{'vinc'} = '&';   
     $Apache::londefdef::table[-1]{'vvinc'} = '';  
  }  
  if ($#Apache::londefdef::table==0) {  
     #    Note that \newline seems to destroy the alignment envs.  
     # $Apache::londefdef::table[-1]{'output'}='\strut\newline\strut\setlength{\tabcolsep}{1 mm}';  
     $Apache::londefdef::table[-1]{'output'}='\strut'.'\\\\'."\n".'\strut\setlength{\tabcolsep}{1 mm}';  
  }  
  $Apache::londefdef::table[-1]{'output'}.=' \noindent \begin{tabular} ';  
         $Apache::londefdef::table[-1]{'TeXlen'}=[];  
         $Apache::londefdef::table[-1]{'objectlen'}=[];  
         $Apache::londefdef::table[-1]{'objectsignal'}=[];  
         $Apache::londefdef::table[-1]{'maxlen'}=[];  
         $Apache::londefdef::table[-1]{'minlen'}=[];  
         $Apache::londefdef::table[-1]{'content'}=[];  
         $Apache::londefdef::table[-1]{'align'}=[];  
         $currentstring.=' \keephidden{NEW TABLE ENTRY}';  
     }  
   
     }      }
     return $currentstring;      return $currentstring;
 }  }
Line 2163  sub end_table { Line 2118  sub end_table {
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
   
   
  #  New table code:  
   
  my $table = pop(@Apache::londefdef::table);   my $table = pop(@Apache::londefdef::table);
  my $t     = $table->generate();   my $t     = $table->generate();
  $currentstring = $t->generate_string();   $currentstring = $t->generate_string();
Line 2706  sub tag_check { Line 2659  sub tag_check {
 #  #
   
 sub cell_config_hash {  sub cell_config_hash {
     my ($align, $rowspan, $colspan) = @_;      my ($align, $rowspan, $colspan, $width) = @_;
       if ($rowspan ne '') {
           $rowspan =~ s/^\s+|\s+$//g;
       }
       if ($colspan ne '') {
           $colspan =~ s/^\s+|\s+$//g;
       }
     my %config;      my %config;
     if ($align ne '') {      if ($align ne '') {
  $config{'halign'} = $align;   $config{'halign'} = $align;
     }      }
     if ($colspan ne "") {      if (($colspan =~ /^\d+$/) && ($colspan > 0)) {
  $config{'colspan'} = $colspan;   $config{'colspan'} = $colspan;
     }      }
     if ($rowspan ne '') {      if (($rowspan =~ /^\d+$/) && ($rowspan > 0)) {
  $config{'rowspan'} = $rowspan;   $config{'rowspan'} = $rowspan;
     }      }
       if ($width ne '') {
           $config{'width'} = $width;
       }
     return \%config;      return \%config;
 }  }
     
Line 2728  sub start_td_tex { Line 2690  sub start_td_tex {
     # attributes, but empty of text.  end_td_tex will      # attributes, but empty of text.  end_td_tex will
     # fetch the contents from the recursive parse and      # fetch the contents from the recursive parse and
     # fill the cell with them:      # fill the cell with them:
     my $align   = &Apache::lonxml::get_param('align', $parstack, $safeeval, undef, 1);      my $align   = &Apache::lonxml::get_param('align', $parstack, $safeeval);
     my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval, undef, 1);      my $rowspan = &Apache::lonxml::get_param('rowspan', $parstack, $safeeval);
     my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval, undef, 1);      my $colspan = &Apache::lonxml::get_param('colspan', $parstack, $safeeval);
       my $width   = &Apache::lonxml::get_param('TeXwidth', $parstack, $safeeval);
     my $config = &cell_config_hash($align, $rowspan, $colspan);      my $config = &cell_config_hash($align, $rowspan, $colspan, $width);
   
     my $table = $Apache::londefdef::table[-1];      my $table = $Apache::londefdef::table[-1];
     $table->add_cell('', $config);      $table->add_cell('', $config);
Line 3259  sub start_img { Line 3221  sub start_img {
    ['','bottom','middle','top','left','right'],$token,5);     ['','bottom','middle','top','left','right'],$token,5);
  $currentstring .=&Apache::edit::select_arg('TeXwrap:', 'TeXwrap',   $currentstring .=&Apache::edit::select_arg('TeXwrap:', 'TeXwrap',
    ['', 'none','parbox', 'parpic', 'wrapfigure'], $token, 2);     ['', 'none','parbox', 'parpic', 'wrapfigure'], $token, 2);
           my $alt=    &Apache::lonxml::get_param('alt',$parstack,$safeeval);
           my $enc=    &Apache::lonxml::get_param('encrypturl',$parstack,$safeeval);
   
  $currentstring .=&Apache::edit::select_arg('Encrypt URL:','encrypturl',   $currentstring .=&Apache::edit::select_arg('Encrypt URL:','encrypturl',
    ['no','yes'], $token, 2);     ['no','yes'], $token, 2);
           if (($alt=~/\S/) && (lc($enc) eq 'yes')) {
              $currentstring.='<br /><span class="LC_warning">'.&mt('Warning: the description "[_1]" will be available, even for encrypted URL',$alt).'</span><br />';
           }
  $currentstring .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();   $currentstring .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
  my $src=    &Apache::lonxml::get_param('src',$parstack,$safeeval);   my $src=    &Apache::lonxml::get_param('src',$parstack,$safeeval);
  my $alt=    &Apache::lonxml::get_param('alt',$parstack,$safeeval);  
  my $width=  &Apache::lonxml::get_param('width',$parstack,$safeeval);   my $width=  &Apache::lonxml::get_param('width',$parstack,$safeeval);
  my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);   my $height= &Apache::lonxml::get_param('height',$parstack,$safeeval);
   
         if ($token->[2]{'src'}=~/\$/) {          if ($token->[2]{'src'}=~/\$/) {
            $currentstring.='Variable image source';             $currentstring.=&mt('Variable image source');
           } elsif ($token->[2]{'src'}=~/\S/) {
              $currentstring .= '<img src="'.$src.'" alt="'.$alt.'" ';
              if ($width) { $currentstring.=' width="'.$width.'" '; }
              if ($height) { $currentstring.=' height="'.$height.'" '; }
              $currentstring .= ' />';
         } else {          } else {
    $currentstring .= '<img src="'.$src.'" alt="'.$alt.'" ';             $currentstring.=&mt("No image source specified");
    if ($width) { $currentstring.=' width="'.$width.'" '; }  
    if ($height) { $currentstring.=' height="'.$height.'" '; }  
    $currentstring .= ' />';  
         }          }
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
  my ($osrc,$owidth,$oheight)=   my ($osrc,$owidth,$oheight)=
Line 3343  sub start_applet { Line 3312  sub start_applet {
     my $currentstring = '';      my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {      if ($target eq 'web' || $target eq 'webgrade') {
  if ($env{'browser.appletsuppress'} ne 'on') {   if ($env{'browser.appletsuppress'} ne 'on') {
     $currentstring = &Apache::lonenc::encrypt_ref($token,              $currentstring = $token->[4];
   {'code'=>$code,  
    'archive'=>$archive}  
   );  
  } else {   } else {
     my $alttag= &Apache::lonxml::get_param('alt',$parstack,      my $alttag= &Apache::lonxml::get_param('alt',$parstack,
    $safeeval,undef,1);     $safeeval,undef,1);
Line 3522  sub start_frameset { Line 3488  sub start_frameset {
     &Apache::loncommon::start_page($Apache::londefdef::title,      &Apache::loncommon::start_page($Apache::londefdef::title,
    $Apache::londefdef::head,     $Apache::londefdef::head,
    {'add_entries'    => $token->[2],     {'add_entries'    => $token->[2],
     'no_title'       => 1,  #    'no_title'       => 1,
     'force_register' => 1,      'force_register' => 1,
     'frameset'       => 1,});      'frameset'       => 1,});
   
Line 3864  sub end_col { Line 3830  sub end_col {
   
 #-- <colgroup> tag (end tag optional)  #-- <colgroup> tag (end tag optional)
 sub start_colgroup {  sub start_colgroup {
     my ($target,$token) = @_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
     my $currentstring = '';      my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {      if ($target eq 'web' || $target eq 'webgrade') {
  $currentstring = $token->[4];        $currentstring = $token->[4];     
     }       }
       if ($target eq 'tex') {
           # TODO: Ensure this tag is in a table:
   
           # Fetch the attributes and build the hash for the
           # call to define_colgroup.
   
           my $span    = &Apache::lonxml::get_param('span',   $parstack, $safeeval);
           my $halign  = &Apache::lonxml::get_param('halign', $parstack, $safeeval);
   
           my %colgroup_params;
           if ($span ne '') {
               $colgroup_params{'span'} = $span;
           }
           if ($halign ne '') {
               $colgroup_params{'halign'} = $halign;
           }
   
           my $table = $Apache::londefdef::table[-1];
           $table->define_colgroup(\%colgroup_params);
   
       }
     return $currentstring;      return $currentstring;
 }  }
   
Line 4354  sub start_tbody { Line 4341  sub start_tbody {
     my $currentstring = '';      my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {      if ($target eq 'web' || $target eq 'webgrade') {
  $currentstring = $token->[4];        $currentstring = $token->[4];     
       }
       if ($target eq 'tex') {
           # TODO: Ensure this tag is within a table:
   
           my $table = $Apache::londefdef::table[-1];
           $table->start_body();
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 4363  sub end_tbody { Line 4356  sub end_tbody {
     my $currentstring = '';      my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {      if ($target eq 'web' || $target eq 'webgrade') {
  $currentstring = $token->[2];       $currentstring = $token->[2];    
       }
       if($target eq 'tex') {
           # TODO: Ensure this tag is within a table:
   
           my $table = $Apache::londefdef::table[-1];
           $table->end_body();
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 4373  sub start_tfoot { Line 4372  sub start_tfoot {
     my $currentstring = '';      my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {      if ($target eq 'web' || $target eq 'webgrade') {
  $currentstring = $token->[4];        $currentstring = $token->[4];     
       }
       if ($target eq 'tex') {
           # TODO: ensure this is within a table tag.
           my $table = $Apache::londefdef::table[-1];
           $table->start_foot();
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 4382  sub end_tfoot { Line 4386  sub end_tfoot {
     my $currentstring = '';      my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {      if ($target eq 'web' || $target eq 'webgrade') {
  $currentstring = $token->[2];       $currentstring = $token->[2];    
       }
       if ($target eq 'tex') {
           #  TODO: Ensure this is in side a table
           my $table = $Apache::londefdef::table[-1];
           $table->end_foot();
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 4392  sub start_thead { Line 4401  sub start_thead {
     my $currentstring = '';      my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {      if ($target eq 'web' || $target eq 'webgrade') {
  $currentstring = $token->[4];        $currentstring = $token->[4];     
       }
       if ($target eq 'tex') {
           # Assume we're in a table... TODO: Verify that and ignore tag if not.
           my $table = $Apache::londefdef::table[-1];
           $table->start_head();
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 4401  sub end_thead { Line 4415  sub end_thead {
     my $currentstring = '';      my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {      if ($target eq 'web' || $target eq 'webgrade') {
  $currentstring = $token->[2];       $currentstring = $token->[2];    
       }
       if ($target eq 'tex') {
           # TODO: Verify we are in a table and ignore tag if not.
   
           my $table = $Apache::londefdef::table[-1];
           $table->end_head();
     }       } 
     return $currentstring;      return $currentstring;
 }  }
Line 4735  sub align_latex_image { Line 4755  sub align_latex_image {
     #    Even though we set a default alignment value, the user      #    Even though we set a default alignment value, the user
     #    could have given us an illegal value.  In that case we      #    could have given us an illegal value.  In that case we
     #    just use the default alignment of bottom..      #    just use the default alignment of bottom..
     $currentstring = "\n% figurewrapping \n";      $currentstring = '';
     if      ($align eq "top")    {      if      ($align eq "top")    {
  $currentstring .= '\raisebox{-'.$height.'mm}{'.$image;   $currentstring .= '\raisebox{-'.$height.'mm}{'.$image;
  $closure = '}';   $closure = '}';
Line 4778  sub align_latex_image { Line 4798  sub align_latex_image {
  $currentstring .= "{$image";   $currentstring .= "{$image";
  $closure       = '}';   $closure       = '}';
     }      }
     $currentstring .= "\n% end wrappage\n";  
     $closure        = "\n% Begin closure\n".$closure."\n% End closure\n";  
     return ($currentstring, $closure);      return ($currentstring, $closure);
 }  }
   
Line 4796  sub is_inside_of { Line 4814  sub is_inside_of {
 }  }
   
   
   #
   #   This sub provides the typical LaTeX prefix matter for tex output:
   #
   sub latex_header {
       my ($mode) = @_;
       my $currentstring = '';
   
       $currentstring .= 
    "\n% &Apache::lonxml::londefdef \n" .
    '\documentclass[letterpaper,twoside]{article}\raggedbottom';
       if (($env{'form.latex_type'}=~'batchmode') ||
    (!$env{'request.role.adv'}) || 
    ($mode eq 'batchmode')) {$currentstring .='\batchmode';} 
       $currentstring .= '\newcommand{\keephidden}[1]{}'.
    '\renewcommand{\deg}{$^{\circ}$}'.
    '\usepackage{multirow}'.
    '\usepackage{longtable}'.
    '\usepackage{textcomp}'.
    '\usepackage{makeidx}'.
    '\usepackage[dvips]{graphicx}'.
    '\usepackage{wrapfig}'.
    '\usepackage{picins}'.
    '\usepackage[T1]{fontenc}'."\n".
    '\usepackage{lmodern}'."\n".
    '\usepackage[postscript]{ucs}'."\n".
    '\usepackage[utf8x]{inputenc}'."\n".
    '\usepackage{pifont}' ."\n".
    '\usepackage{latexsym}'."\n".
    '\usepackage{epsfig}'.
    "\\usepackage{xtab}\n".
    "\\usepackage{tabularx}\n".
    "\\usepackage{booktabs}\n".
    "\\usepackage{array}\n".
    "\\usepackage{colortbl}\n".
    "\\usepackage{xcolor}\n".
    '\usepackage{calc}'.
    '\usepackage{amsmath}'.
    '\usepackage{amssymb}'.
    '\usepackage{amsfonts}'.
    '\usepackage{amsthm}'.
    '\usepackage{amscd}'
           .'\usepackage{picins}\usepackage{calc}'."\n". # From lonprintout.pm
    '\usepackage[T1]{fontenc}'."\n".
    '\usepackage{lmodern}'."\n".
    '\usepackage[postscript]{ucs}'."\n".
    '\usepackage[utf8x]{inputenc}'."\n".
    '\usepackage{pifont}'  . "\n";
   
       if($env{'form.pdfFormFields'} eq 'yes') {
    $currentstring .= '\usepackage{hyperref}'.
       '\usepackage{eforms}'.
       '\usepackage{tabularx}';
       } 
       
           $currentstring .= '\newenvironment{choicelist}{\begin{list}{}{\setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.05in}\setlength{\itemsep}{0.022in}\setlength{\parsep}{0in}\setlength{\belowdisplayskip}{0.04in}\setlength{\abovedisplayskip}{0.05in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.04in}}}{\end{list}}'.
                             '\renewenvironment{theindex}{\begin{list}{}{{\vskip 1mm \noindent \large\textbf{Index}} \newline \setlength{\rightmargin}{0in}\setlength{\leftmargin}{0.13in}\setlength{\topsep}{0.01in}\setlength{\itemsep}{0.1in}\setlength{\parsep}{-0.02in}\setlength{\belowdisplayskip}{0.01in}\setlength{\abovedisplayskip}{0.01in}\setlength{\abovedisplayshortskip}{-0.04in}\setlength{\belowdisplayshortskip}{0.01in}}}{\end{list}}';
       $currentstring .= '\begin{document}';
       
       return $currentstring;
   
   }
   
 =pod  =pod
   
 =head1 NAME  =head1 NAME

Removed from v.1.398  
changed lines
  Added in v.1.415.4.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>