BEGIN_TEXT
\{ image( "imagename.png" ) \}
\{ image( "imagename.png", width=>150, height=>150,
tex_size=>250, extra_html_tags=>'alt="Graph of a function."' ) \}
\{ imageRow( ["graph1.png","graph2.png"], ["A","B"], width=>150, height=>150 ) \}
END_TEXT
|
Here it's easy: we just use the image macro in the text section of the problem to include the image. The images to be included should be GIF or PNG files. PNG files are recommended since they generally look better when rescaled. In order for PDF hardcopy generation to work properly, the names of image files must have only one period in them (imagename.png works but image.name.png does not).
The imageRow function works similarly. Its second argument, ["A","B"] , is a list of caption names. The double quotes in caption names are necessary, for example, to prevent the string "E" from being interpreted as E = 2.718...
For each PG problem with static images, you should put both the PG file and the image files into their own separate subdirectory. This subdirectory should be located somewhere under the course templates directory and have the same root name as the PG file. For example, if you have a PG file called Contour-plots.pg which uses static graphic files Contour-plot-01.gif and Contour-plot-02.gif , you should create a subdirectory somewhere under the course templates directory called Contour-plots and put the PG file and all the GIF files in it. Putting a PG file and all of its graphics files into their own separate subdirectory like this makes it easier to find the graphics files that go with each PG file, thereby making the problem easier to maintain. The reason for having the subdirectory and the root name of the PG file be the same is as follows. When the library is browsed via directories, the library browser in WeBWorK is configured to recognize that when a subdirectory has the same name as the root name of the only PG file in that subdirectory, the subdirectory and PG file should be treated as a single entity.
We can, of course, include options such as specifying the tex_size , etc., in this call, as shown in the including dynamic images code snippet.
(When the alias() command in dangerousMacros.pl is rewritten in the future, support for JPG, PDF, and SWF files should become available.)
|