This shows how to use LayoutTable for layout.
DOCUMENT(); loadMacros( 'PGstandard.pl', 'PGML.pl', 'niceTables.pl', 'PGtikz.pl', 'PGcourse.pl' );
Preamble
This shows how to use the LayoutTable
function in niceTables.pl
to give a nice two column format.
Note the LayoutTable
does the right thing for accessibility and webpage responsiveness.
$a = random(0, 3); $ans = Compute("x^2+$a")->reduce; $left = qq| A common situation is that there is a problem with a graph and the problem is on the left column and the graph is on the right column. $PAR This even works if we add an equation like \(e^{i\pi}+1 = 0\) $PAR Or if we add an answer blank. $PAR A formula for the function graphed on the right is \(f(x)=\)| . ans_rule(10); $graph = createTikZImage(); $graph->tikzLibraries('arrows.meta'); $graph->BEGIN_TIKZ \tikzset{>={Stealth[scale=1.5]}} \filldraw[ draw=LightBlue, fill=white, rounded corners=10pt, thick,use as bounding box ] (-6,7) rectangle (6,-1); \draw[->,thick] (-6,0) -- (6,0) node[above left,outer sep=3pt] {\(x\)}; \foreach \x in {-5,...,-1,1,2,...,5} \draw(\x,5pt) -- (\x,-5pt) node [below] {\(\x\)}; \draw[->,thick] (0,-1) -- (0,7) node[below right,outer sep=3pt] {\(y\)}; \foreach \y in {1,...,6} \draw (5pt,\y) -- (-5pt,\y) node[left] {\(\y\)}; \draw[blue,ultra thick] plot[domain=-2.5:2.5,smooth] (\x,{\x*\x+$a}); END_TIKZ
Setup
We use the LayoutTable
function from niceTables.pl
to demonstrate some of it’s features.
The basic form of a LayoutTable
is identical to that of DataTable
or
$table = LayoutTable([
[row1],
[row2],
...
[rowN]
], options);
where the data goes in as an array ref of array refs. However, if using a table for layout purposes, LayoutTable
has more appropriate default options. See the niceTables.pl POD for more details.
Notice in this example that we make two columns. The left column is written using older style PG, with $PAR
as a paragraph break.
TEXT(LayoutTable( [ [ $left, image($graph, width => 400, tex_size => 600) ] ], align => 'lc' ));
Statement
Since the only output is the table, we use this line to output the problem as the two columns. This is the LayoutTable
with only one row.
ANS($ans->cmp);
Answer
Since ans_rule
is used to produce answer blanks, this in needed.
BEGIN_PGML_SOLUTION Solution explanation goes here. END_PGML_SOLUTION ENDDOCUMENT();
Solution
A solution should be provided here.