Difference between revisions of "StaticImages"

From WeBWorK_wiki
Jump to navigation Jump to search
m
m
Line 26: Line 26:
 
<td style="background-color:#ffcccc;padding:7px;">
 
<td style="background-color:#ffcccc;padding:7px;">
 
<p>
 
<p>
Here it's easy: we just use the <code>image</code> macro in the text section of the problem to include the image. The image to be included should be a GIF or a PNG file. For each problem with static images, you should put both the image file and the PG file into their own separate subdirectory. This subdirectory should be located somewhere under the course <code>templates</code> directory. PNG files are recommended since they generally look better when rescaled. (When the alias() command in dangerousMacros.pl is rewritten in the future, support for JPG, PDF, and SWF files should become available.) The name of the image file must have only one period in it (imagename.png works but image.name.png does not) in order for PDF hardcopy generation to work properly.
+
Here it's easy: we just use the <code>image</code> 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. The names of image files must have only one period in them (imagename.png works but image.name.png does not) in order for PDF hardcopy generation to work properly.
  +
</p>
  +
<p>
  +
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 <code>templates</code> directory.
 
</p>
 
</p>
 
<p>
 
<p>
 
We can, of course, include options such as specifying the <code>tex_size</code>, etc., in this call, as shown in the [[DynamicImages|including dynamic images]] code snippet.
 
We can, of course, include options such as specifying the <code>tex_size</code>, etc., in this call, as shown in the [[DynamicImages|including dynamic images]] code snippet.
  +
</p>
  +
<p>
  +
(When the alias() command in dangerousMacros.pl is rewritten in the future, support for JPG, PDF, and SWF files should become available.)
 
</p>
 
</p>
 
</td>
 
</td>

Revision as of 11:41, 9 November 2009

Static Graphic Images: PG Code Snippet

This code snippet shows the essential PG code to insert a static (pre-generated) graphic image into a problem. Note that these are insertions, not a complete PG file. This code will have to be incorporated into the problem file on which you are working.

Problem Techniques Index

PG problem file Explanation
BEGIN_TEXT
\{ image( "imagename.png" ) \}

\{ image( "imagename.png", width=>150, height=>150,  
tex_size=>250, extra_html_tags=>'alt="Graph of a function."' ) \}

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. The names of image files must have only one period in them (imagename.png works but image.name.png does not) in order for PDF hardcopy generation to work properly.

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.

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.)

Problem Techniques Index