PPTools/Ppgen/Table examples

From DPWiki
< PPTools‎ | Ppgen

Examples of ppgen tables

Without borders

Example 1: Table of contents with 5 spaces for first column and 23 for second. Ppgen will automatically wrap the chapter titles if needed. First column is right justified. Second is left justified. Consider this form if book does not use page numbers

 .ta r:5 l:23
 I | #The Encounter:ch01#
 II | #“Family Affairs”:ch02#
 III | #The Sleepwalker:ch03#
 IV | #Meet Flash!:ch04#
 V | #On Secret Service:ch05#
 VI | #Who’s Who?:ch06#
 VII | #Playing a Part:ch07#
 VIII | #“Walk Into My Parlor”:ch08#
 IX | #In the Night:ch09#
 X | #Surprises:ch10#
 XI | #Gretchen:ch11#
 XII | #Tests:ch12#
 XIII | #Winnite:ch13#
 XIV | #Professor:ch14#
 XV | #Tea and Orders:ch15#
 XVI | #Caught in the Act:ch16#
 XVII | #Professor Makes Good:ch17#
 XVIII | #The Christmas Spirit:ch18#
 .ta-

Example 2: Another Table of Contents; consider this form if book does use page numbers Justification is right, left, right with auto column width; no automatic wrapping of text will occur.

 .ta rlr
 I | The Encounter | #15#
 II | “Family Affairs” | #27#
 III | The Sleepwalker | #39#
 IV | Meet Flash! | #55#
 V | On Secret Service | #67#
 VI | Who’s Who? | #79#
 VII | Playing a Part | #91#
 etc.
 .ta-

Example 3: Complex tables can be made with an escape by media type. In general, though, this should not be necessary.


 .if t
 .nf b
 I. ARRIVAL                7
 II. ROBBERY              14
 III. GALE’S ADVENTURE    20
 IV. DISCOVERY            33
 . . . . .
 XXI. ADIOS              240
 .nf-
 .if-
 .if h
 .de table { margin:1em auto }
 .de td.tch { text-align:center; padding-bottom:0.5em; padding-top:1em }
 .de td.tc1 { text-align:right;padding-right:0.5em }
 .de td.tc2 { text-align:left }
 .de td.tc3 { text-align:right }
 .li
 <table summary='toc'>
 <tr><td colspan='2' class='tch'>CONTENTS</td></tr>
 <tr><td class='tc1'>I</td><td class='tc2'><a href='#ch01'>ARRIVAL</a></td><td class='tc3'>7</td></tr>
 <tr><td class='tc1'>II</td><td class='tc2'><a href='#ch02'>ROBBERY</a></td><td class='tc3'>14</td></tr>
 <tr><td class='tc1'>III</td><td class='tc2'><a href='#ch03'>GALE’S ADVENTURE</a></td><td class='tc3'>20</td></tr>
 <tr><td class='tc1'>IV</td><td class='tc2'><a href='#ch04'>DISCOVERY</a></td><td class='tc3'>33</td></tr>
 . . . . .
 <tr><td class='tc1'>XXI</td><td class='tc2'><a href='#ch21'>ADIOS</a></td><td class='tc3'>240</td></tr>
 </table>
 .li-
 .if-

Example 4: A table may use display page numbers and link to actual chapters.

.ta rlr
   I | THE AMERICAN AX |#7:bk1ch01#
  II | THE AMERICAN RIFLE |#11:bk1ch03#
 III | THE AMERICAN BOAT |#19:bk1ch03#
  IV | THE AMERICAN HORSE |#25:bk1ch04#
   V | THE PATHWAY OF THE WATERS |#32:bk1ch05#
  VI | THE MISSISSIPPI, AND INDEPENDENCE |#58:bk1ch06#
 VII | ORIGIN OF THE PIONEER |#73:bk1ch07#
VIII | DANIEL BOONE |#87:bk1ch08#
  IX | A FRONTIER REPUBLIC |#122:bk1ch09#
.ta-

Example 5: A table may have an optional summary field. It must be specified after all the cell/column specifications.

 .ta r:5 l:23 s=Table of Contents
   I | #The Encounter:ch01#
   II | #“Family Affairs”:ch02#
   III | #The Sleepwalker:ch03#
 .ta-

Example 6: This version aligns the page numbers at the bottom of the cell when the chapter title wraps to two lines by specifying the first two columns as top-aligned, and the third column as bottom-aligned.

 .ta rt:5 lt:23 rb:5
 I | The Encounter Was Too Short To Demonstrate This Feature | #15#
 II | “Family Affairs” | #27#
 III | The Sleepwalker | #39#
 IV | Meet Flash! | #55#
 V | On Secret Service | #67#
 VI | Who’s Who? | #79#
 VII | Playing a Part | #91#
 etc.
 .ta-

Example 6a: This simple table displays how colspan can be obtained with ppgen

  .ta ccc s='' w=none
  A|<span>|B
  ||
  1|2|3
  1|2|3
  ||
  1|2|3
  .ta- 

Example 6a yields the following HTML:

  <table class='table0' summary=''>
  <tr>
    <td class='c000' colspan='2'>A</td>
    <td class='c001'>B</td>
  </tr>
  <tr>
    <td class='c000'>&nbsp;</td>
    <td class='c000'>&nbsp;</td>
    <td class='c001'>&nbsp;</td>
  </tr>
  <tr>
    <td class='c000'>1</td>
    <td class='c000'>2</td>
    <td class='c001'>3</td>
  </tr>
  <tr>
    <td class='c000'>1</td>
    <td class='c000'>2</td>
    <td class='c001'>3</td>
  </tr>
  <tr>
    <td class='c000'>&nbsp;</td>
    <td class='c000'>&nbsp;</td>
    <td class='c001'>&nbsp;</td>
  </tr>
  <tr>
    <td class='c000'>1</td>
    <td class='c000'>2</td>
    <td class='c001'>3</td>
  </tr>
  </table>

With borders

Example 7: This input:

   .ta |l:10 |l:10| |l:10|
   _
   +Row 1 Cell 1+ | +Row 1 Cell 2+ | +Row 1 Cell 3+
   _
   <al=c>+Row 2 Cell 1+ | <span> | +Row 2 Cell 3+
   =
   <al=r>+Row 3 Cell 1+ | <span> | <span>
   =
   +Row 4 Cell 1+ | +Row 4 Cell 2+ | <span>
   _
   .ta-

Generates this text output:

   ┌──────────┬──────────┬┬──────────┐
   │+Row 1    │+Row 1    ││+Row 1    │
   │Cell 1+   │Cell 2+   ││Cell 3+   │
   ├──────────┴──────────┼┼──────────┤
   │   +Row 2 Cell 1+    ││+Row 2    │
   │                     ││Cell 3+   │
   ╞═════════════════════╧╧══════════╡
   │                   +Row 3 Cell 1+│
   ╞══════════╤══════════════════════╡
   │+Row 4    │+Row 4 Cell 2+        │
   │Cell 1+   │                      │
   └──────────┴──────────────────────┘


Example 8: This input specifies a centered line with vertical borders:

 .ta |l:10 |l:10| |l:10|
 _
 +Row 1 Cell 1+ | +Row 1 Cell 2+ | +Row 1 Cell 3+
 _
 <al=c>+Row 2 Cell 1+ | <span> | +Row 2 Cell 3+
 =
 <al=c>+Some text to be centered+ | <span> | <span>
 =
 +Row 4 Cell 1+ | +Row 4 Cell 2+ | <span>
 _
 .ta-

It has this result:

 ┌──────────┬──────────┬┬──────────┐
 │+Row 1    │+Row 1    ││+Row 1    │
 │Cell 1+   │Cell 2+   ││Cell 3+   │
 ├──────────┴──────────┼┼──────────┤
 │   +Row 2 Cell 1+    ││+Row 2    │
 │                     ││Cell 3+   │
 ╞═════════════════════╧╧══════════╡
 │   +Some text to be centered+    │
 ╞══════════╤══════════════════════╡
 │+Row 4    │+Row 4 Cell 2+        │
 │Cell 1+   │                      │
 └──────────┴──────────────────────┘


Example 9: This one has the old style of centered text, without using <al=c> and the two <span>s:

 .ta |l:10 |l:10| |l:10|
 _
 +Row 1 Cell 1+ | +Row 1 Cell 2+ | +Row 1 Cell 3+
 _
 <al=c>+Row 2 Cell 1+ | <span> | +Row 2 Cell 3+
 =
 +Some text to be centered+
 =
 +Row 4 Cell 1+ | +Row 4 Cell 2+ | <span>
 _
 .ta-

The output looks like this:

 ┌──────────┬──────────┬┬──────────┐
 │+Row 1    │+Row 1    ││+Row 1    │
 │Cell 1+   │Cell 2+   ││Cell 3+   │
 ├──────────┴──────────┼┼──────────┤
 │   +Row 2 Cell 1+    ││+Row 2    │
 │                     ││Cell 3+   │
 ╘═════════════════════╧╧══════════╛
      +Some text to be centered+
 ╒══════════╤══════════════════════╕
 │+Row 4    │+Row 4 Cell 2+        │
 │Cell 1+   │                      │
 └──────────┴──────────────────────┘


Example 10: This input specifies padding for cells in the text output:

 .nr text-cell-padding-left " "
 .nr text-cell-padding-right " "
 
 .ta |l:10 |l:10| |l:10|
 _
 +Row 1 Cell 1+ | +Row 1 Cell 2+ | +Row 1 Cell 3+
 _
 <al=c>+Row 2 Cell 1+ | <span> | +Row 2 Cell 3+
 =
 <al=r>+Row 3 Cell 1+ | <span> | <span>
 =
 +Row 4 Cell 1+ | +Row 4 Cell 2+ | <span>
 _
 .ta-

and generates this text output:

 ┌───────────┬────────────┬┬────────────┐
 │ +Row 1    │ +Row 1     ││ +Row 1     │
 │ Cell 1+   │ Cell 2+    ││ Cell 3+    │
 ├───────────┴────────────┼┼────────────┤
 │     +Row 2 Cell 1+     ││ +Row 2     │
 │                        ││ Cell 3+    │
 ╞════════════════════════╧╧════════════╡
 │                       +Row 3 Cell 1+ │
 ╞═══════════╤══════════════════════════╡
 │ +Row 4    │ +Row 4 Cell 2+           │
 │ Cell 1+   │                          │
 └───────────┴──────────────────────────┘