Difference between revisions of "Tables - PGML"

From WeBWorK_wiki
Jump to navigation Jump to search
m (Pstaabp moved page PGML tables to Tables -- PGML without leaving a redirect: this name is better in the topic listing)
Line 9: Line 9:
 
A simple table
 
A simple table
   
[* [. col 1 .] [. col 2 .] [. col 3 .]*
+
[# [. col 1 .] [. col 2 .] [. col 3 .]*
 
[. 1 .] [. 2 .] [. 3 .]*
 
[. 1 .] [. 2 .] [. 3 .]*
[. 4 .] [. 5 .] [. 6 .]*
+
[. [`x`] .] [. [`x^2`] .] [. [`x^3`] .]*
]*
+
#]
   
 
Would make a table similar to
 
Would make a table similar to
Line 21: Line 21:
 
|1||2||3
 
|1||2||3
 
|-
 
|-
|4||5||6
 
  +
|x||x<sup>2</sup>||x<sup>3</sup>
 
|}
 
|}
  +
  +
Notice that other PGML structures can exist inside of table cells. A PGML table uses niceTables to create the table and options can also be included.
  +
  +
The example:
  +
  +
[#
  +
[. [`x`] .]{bgcolor => 'yellow'}
  +
[. [`x^2`].]*{bgcolor => 'yellow'}
  +
  +
[. [`2`] .]
  +
[. [_]{4} .]*
  +
#]{align => '|c|c|', horizontalrules => 1}
  +
  +
will generate a table that looks like:
  +
  +
Notice that the table-level options should added to the table tags <tt> [# #]</tt>, which include <tt>align</tt> and <tt>horizontalrules</tt>.
  +
Cell-level options are included on the individual cells.
   
 
[[Category:PGML]]
 
[[Category:PGML]]

Revision as of 05:34, 9 May 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 *.

BEGIN_PGML

A simple table

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

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 niceTables to create the table and options can also be included.

The example:

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

will generate a table that looks like:

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.