--- loncom/xml/londefdef.pm 2003/03/18 15:32:15 1.122 +++ loncom/xml/londefdef.pm 2003/06/27 14:01:19 1.145 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Tags Default Definition Module # -# $Id: londefdef.pm,v 1.122 2003/03/18 15:32:15 albertel Exp $ +# $Id: londefdef.pm,v 1.145 2003/06/27 14:01:19 albertel Exp $ # # # Copyright Michigan State University Board of Trustees @@ -46,7 +46,7 @@ package Apache::londefdef; use Apache::lonnet(); use strict; -use Apache::lonxml(); +use Apache::lonxml; use Apache::File(); use Image::Magick; use Apache::lonmenu(); @@ -54,7 +54,7 @@ use Apache::lonmeta(); BEGIN { - &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr')); + &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr','hideweboutput')); } @@ -157,8 +157,9 @@ sub start_html { &Apache::lonxml::fontsettings(); } elsif ($target eq 'tex') { @Apache::londefdef::table = (); - $currentstring .= '\documentclass[letterpaper]{article} - \newcommand{\keephidden}[1]{} + $currentstring .= '\documentclass[letterpaper]{article}'. + #'\batchmode'. + '\newcommand{\keephidden}[1]{} \renewcommand{\deg}{$^{\circ}$} \usepackage{textcomp} \usepackage[dvips]{graphicx} @@ -354,8 +355,7 @@ sub start_meta { } else { $currentstring = $token->[4]; } - } - if ($target eq 'meta') { + } elsif ($target eq 'meta') { unless (&Apache::lonxml::get_param ('http-equiv',$parstack,$safeeval,undef,1)) { my $name=$token->[2]->{'name'}; @@ -366,9 +366,11 @@ sub start_meta { $currentstring='<'.$name.'>'. &Apache::lonxml::get_param ('content',$parstack,$safeeval,undef,1). - ''; + ''; } } + } elsif ($target eq 'tex') { + &Apache::lonxml::startredirection(); } return $currentstring; } @@ -382,7 +384,10 @@ sub end_meta { if ($args ne '') { $currentstring = $token->[4]; } - } + } elsif ($target eq 'tex') { + $currentstring=&Apache::lonxml::endredirection(); + $currentstring=''; + } return $currentstring; } @@ -394,10 +399,15 @@ sub start_accessrule { ('effect',$parstack,$safeeval,undef,1); my $realm=&Apache::lonxml::get_param ('realm',$parstack,$safeeval,undef,1); - my $cont=&Apache::lonxml::get_param - ('content',$parstack,$safeeval,undef,1); - $cont=~s/\s+//g; - $cont=~s/\W/\;/g; + my $role=&Apache::lonxml::get_param + ('role',$parstack,$safeeval,undef,1); + $realm=~s/\s+//g; + $realm=~s/\//\_/g; + $realm=~s/^\_//; + $realm=~s/\W/\;/g; + $role=~s/\s+//g; + $role=~s/\//\_/g; + $role=~s/\W/\;/g; if ($target eq 'web') { my $args=''; if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; } @@ -408,7 +418,7 @@ sub start_accessrule { } } if ($target eq 'meta') { - $currentstring=''.$eff.':'.$realm.':'.$cont.''; + $currentstring=''.$eff.':'.$realm.':'.$role.''; } return $currentstring; } @@ -492,9 +502,7 @@ sub start_center { $currentstring = $token->[4]; } elsif ($target eq 'tex') { $currentstring = '\begin{center}'; - } elsif ($target eq 'latexsource') { - $currentstring = '\begin{center}'; - } + } return $currentstring; } @@ -505,9 +513,7 @@ sub end_center { $currentstring = $token->[2]; } elsif ($target eq 'tex') { $currentstring = '\end{center}'; - } elsif ($target eq 'latexsource') { - $currentstring = '\end{center}'; - } + } return $currentstring; } @@ -519,8 +525,6 @@ sub start_b { $currentstring = $token->[4]; } elsif ($target eq 'tex') { $currentstring = '\textbf{'; - } elsif ($target eq 'latexsource') { - $currentstring = '\textbf{'; } return $currentstring; } @@ -532,8 +536,6 @@ sub end_b { $currentstring = $token->[2]; } elsif ($target eq 'tex') { $currentstring = '}'; - } elsif ($target eq 'latexsource') { - $currentstring = '}'; } return $currentstring; } @@ -546,8 +548,6 @@ sub start_strong { $currentstring = $token->[4]; } elsif ($target eq 'tex') { $currentstring = '\textbf{'; - } elsif ($target eq 'latexsource') { - $currentstring = '\textbf{'; } return $currentstring; } @@ -560,20 +560,29 @@ sub end_strong { $currentstring = $token->[2]; } elsif ($target eq 'tex') { $currentstring = '}'; - } elsif ($target eq 'latexsource') { - $currentstring = '}'; - } + } return $currentstring; } #--

tag sub start_h1 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } elsif ($target eq 'meta') { $currentstring=''; &start_output(); @@ -582,12 +591,21 @@ sub start_h1 { } sub end_h1 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } elsif ($target eq 'meta') { &end_output(); $currentstring=''; @@ -597,115 +615,215 @@ sub end_h1 { #--

tag sub start_h2 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h2 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } #--

tag sub start_h3 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h3 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } #--

tag sub start_h4 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h4 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } #--

tag sub start_h5 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h5 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } #--
tag sub start_h6 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\large \textbf{'; + my $pre; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre='\begin{center}'; + } elsif ($align eq 'left') { + $pre='\rlap{'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; + } + my $TeXsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval,undef,0); + if (not defined $TeXsize) {$TeXsize="large";} + $currentstring .= $pre.'{\\'.$TeXsize.' \textbf{'; } return $currentstring; } sub end_h6 { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { - $currentstring .= '}}'; + my $post; + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $post='\end{center}'; + } elsif ($align eq 'left') { + $post='} \hfill'.'\vskip 0 mm '; + } elsif ($align eq 'right') { + $post='}'.'\vskip 0 mm '; + } + $currentstring .= '}}'.$post; } return $currentstring; } @@ -718,9 +836,7 @@ sub start_cite { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $currentstring .= "\\textit{"; - } elsif ($target eq 'latexsource') { - $currentstring .= "\\textit{"; - } + } return $currentstring; } @@ -731,9 +847,7 @@ sub end_cite { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= "}"; - } elsif ($target eq 'latexsource') { - $currentstring .= "}"; - } + } return $currentstring; } @@ -745,9 +859,7 @@ sub start_i { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $currentstring .= '\textit{'; - } elsif ($target eq 'latexsource') { - $currentstring .= '\textit{'; - } + } return $currentstring; } @@ -758,8 +870,6 @@ sub end_i { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= '}'; - } elsif ($target eq 'latexsource') { - $currentstring .= '}'; } return $currentstring; } @@ -772,9 +882,7 @@ sub start_address { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $currentstring .= "\\textit{"; - } elsif ($target eq 'latexsource') { - $currentstring .= "\\textit{"; - } + } return $currentstring; } @@ -785,8 +893,6 @@ sub end_address { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= "}"; - } elsif ($target eq 'latexsource') { - $currentstring .= "}"; } return $currentstring; } @@ -799,8 +905,6 @@ sub start_dfn { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $currentstring .= "\\textit{"; - } elsif ($target eq 'latexsource') { - $currentstring .= "\\textit{"; } return $currentstring; } @@ -812,9 +916,7 @@ sub end_dfn { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= "}"; - } elsif ($target eq 'latexsource') { - $currentstring .= "}"; - } + } return $currentstring; } @@ -826,9 +928,7 @@ sub start_tt { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $currentstring .= '\texttt{'; - } elsif ($target eq 'latexsource') { - $currentstring .= '\texttt{'; - } + } return $currentstring; } @@ -839,8 +939,6 @@ sub end_tt { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= '}'; - } elsif ($target eq 'latexsource') { - $currentstring .= '}'; } return $currentstring; } @@ -853,9 +951,7 @@ sub start_kbd { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $currentstring .= "\\texttt"; - } elsif ($target eq 'latexsource') { - $currentstring .= "\\texttt{"; - } + } return $currentstring; } @@ -866,9 +962,7 @@ sub end_kbd { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= "}"; - } elsif ($target eq 'latexsource') { - $currentstring .= "}"; - } + } return $currentstring; } @@ -903,9 +997,7 @@ sub start_em { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $currentstring .= '\emph{'; - } elsif ($target eq 'latexsource') { - $currentstring .= '\emph{'; - } + } return $currentstring; } @@ -916,9 +1008,7 @@ sub end_em { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= '}'; - } elsif ($target eq 'latexsource') { - $currentstring .= '}'; - } + } return $currentstring; } @@ -930,8 +1020,6 @@ sub start_q { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $currentstring .= "\\emph{"; - } elsif ($target eq 'latexsource') { - $currentstring .= "\\emph{"; } return $currentstring; } @@ -943,9 +1031,7 @@ sub end_q { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= "}"; - } elsif ($target eq 'latexsource') { - $currentstring .= "}"; - } + } return $currentstring; } @@ -956,10 +1042,8 @@ sub start_p { if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '{\par '; - } elsif ($target eq 'latexsource') { - $currentstring .= '{\par '; - } + $currentstring .= '\par '; + } return $currentstring; } @@ -968,10 +1052,6 @@ sub end_p { my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[2]; - } elsif ($target eq 'tex') { - $currentstring .= '}'; - } elsif ($target eq 'latexsource') { - $currentstring .= '}'; } return $currentstring; } @@ -986,9 +1066,7 @@ sub start_br { if ($$tagstack[-2] ne 'sub' && $$tagstack[-2] ne 'sup') { $currentstring .= '\vskip 0.2 mm'; } - } elsif ($target eq 'latexsource') { - $currentstring .= '\\'; - } + } return $currentstring; } @@ -1008,10 +1086,8 @@ sub start_big { if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '\large{'; - } elsif ($target eq 'latexsource') { - $currentstring .= '{\Large '; - } + $currentstring .= '{\large '; + } return $currentstring; } @@ -1022,8 +1098,6 @@ sub end_big { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= '}'; - } elsif ($target eq 'latexsource') { - $currentstring .= '}'; } return $currentstring; } @@ -1036,9 +1110,7 @@ sub start_small { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { $currentstring .= '{\footnotesize '; - } elsif ($target eq 'latexsource') { - $currentstring .= '{\footnotesize '; - } + } return $currentstring; } @@ -1049,28 +1121,36 @@ sub end_small { $currentstring .= $token->[2]; } elsif ($target eq 'tex') { $currentstring .= '}'; - } elsif ($target eq 'latexsource') { - $currentstring .= '}'; } return $currentstring; } #-- tag sub start_basefont { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $basesize) { + $currentstring = '{\\'.$basesize.' '; + } + } return $currentstring; } sub end_basefont { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + my $basesize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $basesize) { + $currentstring = '}'; + } + } return $currentstring; } @@ -1082,7 +1162,12 @@ sub start_font { my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval); if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode++;} $currentstring = $token->[4]; - } + } elsif ($target eq 'tex') { + my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $fontsize) { + $currentstring = '{\\'.$fontsize.' '; + } + } return $currentstring; } @@ -1093,7 +1178,12 @@ sub end_font { my $face=&Apache::lonxml::get_param('face',$parstack,$safeeval); if ($face=~/symbol/i) {$Apache::lonxml::prevent_entity_encode--;} $currentstring = $token->[2]; - } + } elsif ($target eq 'tex') { + my $fontsize=&Apache::lonxml::get_param('TeXsize',$parstack,$safeeval); + if (defined $fontsize) { + $currentstring = '}'; + } + } return $currentstring; } @@ -1197,12 +1287,31 @@ sub end_sup { #--
tag sub start_hr { - my ($target,$token) = @_; + my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_; my $currentstring = ''; if ($target eq 'web') { $currentstring .= $token->[4]; } elsif ($target eq 'tex') { - $currentstring .= '\vskip 0 mm \noindent\makebox[\textwidth/2 ][b]{\hrulefill}\vskip 0 mm '; + my $LaTeXwidth = &Apache::lonxml::get_param('TeXwidth',$parstack,$safeeval,0); + if (defined $LaTeXwidth) { + if ($LaTeXwidth=~/^%/) { + substr($LaTeXwidth,0,1)=''; + $LaTeXwidth=($LaTeXwidth/100).'\textwidth'; + } + } else { + $LaTeXwidth ='0.95\textwidth'; + } + my ($pre,$post); + my $align=&Apache::lonxml::get_param('align',$parstack,$safeeval,undef,1); + if (($align eq 'center') || (not defined $align)) { + $pre=''; $post=''; + } elsif ($align eq 'left') { + $pre='\rlap{'; $post='} \hfill'; + } elsif ($align eq 'right') { + $pre=' \hfill \llap{'; $post='}'; + } + $currentstring .= ' \vskip 0 mm \noindent\makebox[\textwidth]{'.$pre.'\makebox['. + $LaTeXwidth.'][b]{\hrulefill}'.$post.'}\vskip 0 mm '; } return $currentstring; } @@ -1324,12 +1433,29 @@ sub end_u { #--