Images - PGML

From WeBWorK_wiki
Revision as of 07:17, 28 June 2023 by Pstaabp (talk | contribs)
Jump to navigation Jump to search

Static Images

Images can be inserted into a PGML block with

 [!alt text!]{'image_file'}{width (optional)}{height (optional)}

Image files are local to the problem (either in the same directory or a sub directory) or as a URL. Standard image types of gif, jpeg and png are supported.

Dynamically Created Images

Images can be created with macros as well. These include WWPlot, TikZ, LaTeXImage, or graphtool plots.

For example, consider a TikZ image created with

 loadMacros('PGtikz.pl')
 
 $TikZ = createTikZImage();
 $TikZ->BEGIN_TIKZ
 \draw (0,0) circle[radius=1.5];
 END_TIKZ
 

This can be added with

 [!Graph of a circle!]{$TikZ}{250}


Optional sizes

The width and height can be added optionally.

  • The width will be the width of the image in pixels. If not given, 100 is given as the default.
  • The height will be the height of the image in pixels. If not given, it is determined by the natural (based on aspect ratio) value of the image.

Note: For hardcopy output, there is a tex_size that is set automatically based on the formula width*1000/6000 to indicate a scale of the width as a proportion of the width of the page or column where 1000 mean 100% of the width.