Difference between revisions of "Tables - PGML"

From WeBWorK_wiki
Jump to navigation Jump to search
m (Glennric moved page Tables -- PGML to Tables - PGML: Consistent naming needed.)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
== PGML Tables ==
 
== PGML Tables ==
   
One can make a table inside a PGML within the tags <tt>[* *]</tt>
+
One can make a table inside a PGML within the tags <tt>[# #]</tt>
   
 
Then cells use the tags <tt>[. .]</tt> and the last cell in a row ends in a <tt>*</tt>.
 
Then cells use the tags <tt>[. .]</tt> and the last cell in a row ends in a <tt>*</tt>.

Latest revision as of 08:06, 7 August 2024

PGML Tables

One can make a table inside a PGML within the tags [# #]

Then cells use the tags [. .] and the last cell in a row ends in a *.

A simple table can be made with

 BEGIN_PGML
 [# [. col 1 .] [. col 2 .] [. col 3 .]*
   [. 1 .] [. 2 .] [. 3 .]*
   [. [`x`] .] [. [`x^2`] .] [. [`x^3`] .]*
 #]
 END_PGML

Would make a table similar to

col 1 col 2 col 3
1 2 3
x x2 x3

Notice that other PGML structures can exist inside of table cells. A PGML table uses the niceTables macro to create the table and options can also be included.

The example:

[#
 [. [`x`] .]{bgcolor => 'yellow'}
 [. [`x^2`].]*{bgcolor => 'lightblue'}
 
 [. [`2`] .]
 [. [_]{4} .]*
#]{align => '|c|c|', horizontalrules => 1}

will generate a table that looks like:

x x2
2

Notice that the table-level options should added to the table tags [# #], which include align and horizontalrules. Cell-level options are included on the individual cells.