The main tool for this is
ColumnTable() from the
unionTables.pl macro file. This takes two strings and makes a side-by-side display from them on screen, and a one-atop-the-other display in hardcopy.
The difficulty is that you need to produce the two strings, and you want the text string to be formatted using PGML. That means you need to capture the PGML output. That can be done using
PGML::Format(), but we didn't talk about that.
Here is one solution:
DOCUMENT(); loadMacros( "PGstandard.pl", "PGML.pl", "unionTables.pl", "PGcourse.pl" ); loadMacros("PGML.pl","unionTables.pl"); $column1 = PGML::Format(<<END_PGML); A list: * Item 1 is a longer one than the next * Item 2 >> Centered << END_PGML $column2 = image("great-wave.png",width=>400, tex_size=>800); TEXT(ColumnTable($column1,$column2)); ENDDOCUMENT();
$column1is text that is formatted using PGML, but saved into a string.
$column2is the string that will insert the image into the page.
TEXT() command inserts the
ColumnTable() into the page, using the two halves. I have attached a screen shot of the result.
- An image caption: Use $BCENTER and $ECENTER to center the results. Use $BR to get a line break after the image. After the line break, use a quoted string for the caption. Put it all together by using the Perl concatenation operator . (that is, the concatenation operator is a period).
$column2 =$BCENTER.image("smile.png", width=>400, height=>400, tex_size=>800).$BR."Image caption".$ECENTER;
- The tex_size argument: The width and height arguments to image should both be specified and control the size of the image when displayed in html output mode. Whether you use a ColumnTable or not, you should always specify width and height. The tex_size argument to image controls the size of the image when displayed in pdf hardcopy mode.
- PGML command substitution: The way that PGML processes the its arguments is to (1) be aware of whether it is trying to produce html or pdf output and (2) make command substitutions for various values, so that [` `] interprets things using MathJax or images in html output mode and as latex math in pdf output mode. The [` $R `] versus [` [$R] `] difference arises from when and how the arguments get interpreted and how much explicit instruction is necessary to get them interpreted in the correct way. Yes, there is a difference between PGML::Format() and BEGIN_PGML, and this might be one of the most obvious differences. [` $R `] versus [` [$R] `] has nothing to do with ColumnTable().
- A complete working example is available in the homework set "Dragonfly Column Table Example" in the 2015 PREP Problem Authoring webwork course.