Tables - PGML: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 5: | Line 5: | ||
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>. | ||
A simple table can be made with | |||
A simple table | |||
BEGIN_PGML | |||
[# [. col 1 .] [. col 2 .] [. col 3 .]* | [# [. col 1 .] [. col 2 .] [. col 3 .]* | ||
[. 1 .] [. 2 .] [. 3 .]* | [. 1 .] [. 2 .] [. 3 .]* | ||
[. [`x`] .] [. [`x^2`] .] [. [`x^3`] .]* | [. [`x`] .] [. [`x^2`] .] [. [`x^3`] .]* | ||
#] | #] | ||
END_PGML | |||
Would make a table similar to | Would make a table similar to | ||
Line 24: | Line 24: | ||
|} | |} | ||
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. | Notice that other PGML structures can exist inside of table cells. A PGML table uses [https://openwebwork.github.io/pg-docs/pod/pg/macros/ui/niceTables.html the niceTables macro] to create the table and options can also be included. | ||
The example: | The example: | ||
Line 30: | Line 30: | ||
[# | [# | ||
[. [`x`] .]{bgcolor => 'yellow'} | [. [`x`] .]{bgcolor => 'yellow'} | ||
[. [`x^2`].]*{bgcolor => ' | [. [`x^2`].]*{bgcolor => 'lightblue'} | ||
[. [`2`] .] | [. [`2`] .] | ||
Line 37: | Line 37: | ||
will generate a table that looks like: | will generate a table that looks like: | ||
<center> | |||
<table style="border: 1px solid black; border-collapse: collapse"> | |||
<tr><td style="background-color: yellow; border: 1px solid black"><em>x</em></td><td style="background-color: lightblue; border: 1px solid black"><em>x</em><sup>2</sup></td><tr> | |||
<tr><td style="border: 1px solid black; background-color: #ddd;">2</td><td style="background-color: #ddd; border: 1px solid black"><div style="background-color: white; border: solid 1px black; height: 2ex; width: 2ex; border-radius: 3px;"></td></tr> | |||
</table> | |||
</center> | |||
Notice that the table-level options should added to the table tags <tt> [# #]</tt>, which include <tt>align</tt> and <tt>horizontalrules</tt>. | Notice that the table-level options should added to the table tags <tt> [# #]</tt>, which include <tt>align</tt> and <tt>horizontalrules</tt>. |
Revision as of 11:39, 18 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 *.
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.