WeBWorK::PG::ImageGenerator - create an object for holding bits of math for LaTeX, and then to process them all at once.
my $image_generator = WeBWorK::PG::ImageGenerator->new(
tempDir => $pg_envir->{directories}{tmp},
latex => $pg_envir->{externalPrograms}{latex},
dvipng => $pg_envir->{externalPrograms}{dvipng},
useCache => 1,
cacheDir => $pg_envir->{directories}{equationCache},
cacheURL => $pg_envir->{URLs}{equationCache},
cacheDB => $pg_envir->{equationCacheDB},
useMarkers => 0,
dvipng_align => $pg_envir->{displayModeOptions}{images}{dvipng_align},
dvipng_depth_db => $pg_envir->{displayModeOptions}{images}{dvipng_depth_db},
);
Arguments to pass to dvipng.
If true, don't delete temporary files.
TeX to prepend to equations to be processed.
TeX to append to equations to be processed.
Returns a new ImageGenerator object. %options
must contain the following entries:
tempDir => directory in which to create temporary processing directory
latex => path to latex binary
dvipng => path to dvipng binary
useCache => boolean, whether to use global image cache
If useCache
is false, %options
must also contain the following entries:
dir => directory for resulting files
url => url to directory for resulting files
basename => base name for image files (i.e. "eqn-$psvn-$probNum")
If useCache
is true, %options
must also contain the following entries:
cacheDir => directory for resulting files
cacheURL => url to cacheDir
cacheDB => path to cache database file
Options may also contain:
dvipng_align => Vertical alignment option. This should be any of the valid values
for the css vertical-align rule like 'baseline' or 'middle'.
dvipng_depth_db => Database connection information for a database that has the 'depths' table.
useMarkers => If you want to have the dvipng images vertically aligned, this involves adding markers.
This only works if dvipng depths are stored and the body_text is provided.
Adds the string as part of the TeX preamble for all equations in the problem. For example $rh_envir->{imagegen}->addToTeXPreamble("\newcommand{\myVec}[#1]{\vec{#1}} ");
Will define a question wide style for interpreting \( \myVec{v} \)
If this statement is placed in PGcourse.pl then the backslashes must be doubled since it is a .pl file not a .pg file
Forces every equation picture to be recalculated. Useful for debugging.
$rh_envir->{imagegen}->refresh(1);
Adds the equation in $string
to the object. $mode
can be "display" or "inline". If not specified, "inline" is assumed. Returns the proper HTML tag for displaying the image.
Uses LaTeX and dvipng to render the equations stored in the object.
The option body_text
is a reference to the text of the problem's text. After rendering the images and figuring out their depths, we go through and fix the tags of the images to get the vertical alignment right. If it is left out, then we skip that step.