version 1.246, 2004/11/19 21:17:56
|
version 1.248, 2004/12/27 14:06:32
|
Line 163 sub start_html {
|
Line 163 sub start_html {
|
'\usepackage{textcomp}'. |
'\usepackage{textcomp}'. |
'\usepackage{makeidx}'. |
'\usepackage{makeidx}'. |
'\usepackage[dvips]{graphicx}'. |
'\usepackage[dvips]{graphicx}'. |
|
'\usepackage{picins}'. |
'\usepackage{epsfig}'. |
'\usepackage{epsfig}'. |
'\usepackage{calc}'. |
'\usepackage{calc}'. |
'\usepackage{amsmath}'. |
'\usepackage{amsmath}'. |
Line 531 sub start_body {
|
Line 532 sub start_body {
|
$token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents(). |
$token->[2]->{'onunload'}=&Apache::lonmenu::unloadevents(). |
';'.$onUnload; |
';'.$onUnload; |
|
|
$currentstring .= '<'.$token->[1]; |
if ($ENV{'request.state'} ne 'construct') { |
|
$currentstring .= '<'.$token->[1]; |
|
} |
foreach (keys %{$token->[2]}) { |
foreach (keys %{$token->[2]}) { |
$currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"'; |
$currentstring.=' '.$_.'="'.$token->[2]->{$_}.'"'; |
} |
} |
$currentstring.='>'; |
if ($ENV{'request.state'} ne 'construct') { |
|
$currentstring.='>'; |
|
} |
if ($ENV{'request.state'} ne 'published') { |
if ($ENV{'request.state'} ne 'published') { |
|
my $remote=($ENV{'environment.remote'} ne 'off'); |
|
$currentstring=&Apache::loncommon::bodytag(undef,undef, |
|
$currentstring,$remote); |
$currentstring.=(<<EDITBUTTON); |
$currentstring.=(<<EDITBUTTON); |
<form method="post"> |
<form method="post"> |
<input type="submit" name="editmode" accesskey="e" value="Edit" /> |
<input type="submit" name="editmode" accesskey="e" value="Edit" /> |
Line 2436 sub start_img {
|
Line 2444 sub start_img {
|
$currentstring.='[IMAGE: '.$alttag.']'; |
$currentstring.='[IMAGE: '.$alttag.']'; |
} |
} |
} elsif ($target eq 'tex') { |
} elsif ($target eq 'tex') { |
|
# |
|
# The alignment will require some superstructure to be put around |
|
# the \includegraphics stuff. At present we can only partially |
|
# simulate the alignments offered by html. |
|
# |
|
# |
|
my $align = lc(&Apache::lonxml::get_param('align', |
|
$parstack, |
|
$safeeval, |
|
undef,1)); |
|
if(!$align) { |
|
$align = "bottom"; # This is html's default so it's ours too. |
|
} |
|
# |
|
&Apache::lonxml::debug("Alignemnt = $align"); |
|
# LaTeX's image/text wrapping is really bad since it wants to |
|
# make figures float. |
|
# The user has the optional parameter (applicable only to l/r |
|
# alignment to use the picins/parpic directive to get wrapped text |
|
# this is also imperfect.. that's why we give them a choice... |
|
# so they can't yell at us for our choice. |
|
# |
|
my $latex_rendering = &Apache::lonxml::get_param('TeXwrap', |
|
$parstack, |
|
$safeeval, |
|
undef,0); |
|
&Apache::lonxml::debug("LaTeX rendering = $latex_rendering"); |
|
if(!$latex_rendering) { |
|
$latex_rendering = "parbox"; |
|
} |
|
&Apache::lonxml::debug("LaTeX rendering = $latex_rendering"); |
|
|
my $oldSRC=$src; |
my $oldSRC=$src; |
$oldSRC=~s/\.(gif|jpg|png)$/\.eps/; |
$oldSRC=~s/\.(gif|jpg|png)$/\.eps/; |
$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); |
$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src); |
#if original gif/jpg/png file exist do following: |
#if original gif/jpg/png file exist do following: |
if (-e $src) { |
if (-e $src) { |
#what is the image size? |
#what is the image size? |
my $width_param=&image_size($src,$scaling,$parstack,$safeeval); |
my $width_param=&image_width($src,$scaling,$parstack,$safeeval); |
|
my $height_param=&image_height($src,$scaling,$parstack,$safeeval); |
my ($file,$path)=&file_path($src); |
my ($file,$path)=&file_path($src); |
my $newsrc = $src; |
my $newsrc = $src; |
$newsrc =~ s/\.(gif|jpg|png)$/.eps/i; |
$newsrc =~ s/\.(gif|jpg|png)$/.eps/i; |
Line 2452 sub start_img {
|
Line 2493 sub start_img {
|
if (-e $newsrc) { |
if (-e $newsrc) { |
#eps counterpart for image exist |
#eps counterpart for image exist |
if ($path) { |
if ($path) { |
$currentstring .= '\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} '; |
$currentstring .= '\graphicspath{{'.$path.'}}' |
|
.'\includegraphics[width='.$width_param.' mm,height='.$height_param.'mm]{'.$file.'} '; |
} |
} |
} else { |
} else { |
#there is no eps counterpart for image - check for ps one |
#there is no eps counterpart for image - check for ps one |
Line 2468 sub start_img {
|
Line 2510 sub start_img {
|
$currentstring.=&eps_generation($src,$file,$width_param); |
$currentstring.=&eps_generation($src,$file,$width_param); |
} |
} |
} |
} |
|
# If there's an alignment specification we need to honor it here. |
|
# For the horizontal alignments, we will also honor the |
|
# value of the latex specfication. The default is parbox, |
|
# and that's used for illegal values too. |
|
# |
|
# Even though we set a default alignment value, the user |
|
# could have given us an illegal value. In that case we |
|
# just use the default alignment of bottom.. |
|
if ($align eq "top") { |
|
$currentstring = '\raisebox{-'.$height_param.'mm}{'.$currentstring.'}'; |
|
} elsif (($align eq "center") || ($align eq "middle")) { # Being kind |
|
my $offset = $height_param/2; |
|
$currentstring = '\raisebox{-'.$offset.'mm}{'.$currentstring.'}'; |
|
} elsif ($align eq "left") { |
|
if ($latex_rendering eq "parpic") { |
|
$currentstring = '\parpic[l]{'.$currentstring.'}'; |
|
} else { # parbox rendering |
|
$currentstring = '\newline'."\n".'\parbox{'.$width_param.'mm}{'.$currentstring.'}'; |
|
} |
|
} elsif ($align eq "right") { |
|
if ($latex_rendering eq "parpic") { |
|
$currentstring = '\parpic[r]{'.$currentstring.'}'; |
|
} else { # parbox rendering. |
|
$currentstring = '\parbox{'.$width_param.'mm}{\begin{flushright}' |
|
.$currentstring.'\end{flushright}} \newline'."\n"; |
|
} |
|
} else { # Bottom is also default. |
|
# $currentstring = '\raisebox{'.$height_param.'mm}{'.$currentstring.'}'; |
|
} |
} else { |
} else { |
#original image file doesn't exist so check the alt attribute |
#original image file doesn't exist so check the alt attribute |
my $alt = |
my $alt = |
Line 3692 sub image_size {
|
Line 3763 sub image_size {
|
$width_param = $TeXwidth; |
$width_param = $TeXwidth; |
} |
} |
} elsif ($TeXheight ne '') { |
} elsif ($TeXheight ne '') { |
$width_param = $TeXheight/$height_param*$width_param; |
$height_param = $TeXheight; |
|
$width_param = $TeXheight/$height_param*$width_param; |
} elsif ($width ne '') { |
} elsif ($width ne '') { |
$width_param = $width*$scaling; |
$width_param = $width*$scaling; |
} |
} |
if ($width_param > $ENV{'form.textwidth'}) {$width_param =0.95*$ENV{'form.textwidth'}} |
if ($width_param > $ENV{'form.textwidth'}) {$width_param =0.95*$ENV{'form.textwidth'}} |
return $width_param; |
return ($height_param, $width_param); |
|
} |
|
|
|
sub image_width { |
|
my ($height, $width) = &image_size(@_); |
|
return $width; |
|
} |
|
# Not yet 100% sure this is correct in all circumstances.. |
|
# due to my uncertainty about mods to image_size. |
|
# |
|
sub image_height { |
|
my ($height, $width) = &image_size(@_); |
|
return $height; |
} |
} |
|
|
sub eps_generation { |
sub eps_generation { |