Parent Directory
|
Revision Log
A number of small updates and corrections. Corrected typos in the documentation, fixed a few items in the samples, added the macros needed by the samples.
1 $bHTML = '\begin{rawhtml}'; 2 $eHTML = '\end{rawhtml}'; 3 4 ###################################################################### 5 ## 6 ## Functions for creating tables of various kinds 7 ## 8 ## ColumnTable() Creates a two-column display in HTML, 9 ## but only one column in TeX. 10 ## 11 ## ColumnMatchTable() Does a side-by-side match table 12 ## 13 ## BeginTable() Begin a borderless HTML table 14 ## Row() Create a row in the table 15 ## AlignedRow() Create a row with alignment in each column 16 ## TableSpace() Insert extra vertical space in the table 17 ## EndTable() End the table 18 ## 19 20 ###################################################################### 21 # 22 # Make a two-column table in HTML and Latex2HTML modes 23 # 24 # Usage: ColumnTable(col1,col2,[options]) 25 # 26 # Options can be taken from: 27 # 28 # indent => n the width to indent the first column 29 # (default is 0) 30 # 31 # separation => n the width of the separating gutter 32 # (default is 50) 33 # 34 # valign => type set the vertical alignment 35 # (default is "MIDDLE") 36 # 37 sub ColumnTable { 38 my $col1 = shift; my $col2 = shift; 39 my %options = (indent => 0, separation => 50, valign => "MIDDLE", @_); 40 my ($ind,$sep) = ($options{"indent"},$options{"separation"}); 41 my $valign = $options{"valign"}; 42 43 my ($bhtml,$ehtml) = ('\begin{rawhtml}','\end{rawhtml}'); 44 ($bhtml,$ehtml) = ('','') unless ($displayMode eq "Latex2HTML"); 45 46 my $HTMLtable = qq { 47 $bhtml<TABLE BORDER="0"><TR VALIGN="$valign"> 48 <TD WIDTH="$ind"> </TD><TD>$ehtml 49 $col1 50 $bhtml</TD><TD WIDTH="$sep"> </TD><TD>$ehtml 51 $col2 52 $bhtml</TD></TR></TABLE>$ehtml 53 }; 54 55 MODES( 56 TeX => '\par\medskip\hbox{\qquad\vtop{'. 57 '\advance\hsize by -3em '.$col1.'}}'. 58 '\medskip\hbox{\qquad\vtop{'. 59 '\advance\hsize by -3em '.$col2.'}}\medskip', 60 Latex2HTML => $HTMLtable, 61 HTML => $HTMLtable 62 ); 63 } 64 65 # 66 # Use columns for a match-list output 67 # 68 # Usage: ColumnMatchTable($ml,options) 69 # 70 # where $ml is a math list reference and options are those 71 # allowed for ColumnTable above. 72 # 73 sub ColumnMatchTable { 74 my $ml = shift; 75 76 ColumnTable($ml->print_q,$ml->print_a,@_); 77 } 78 79 80 # 81 # Command for tables with no borders. 82 # 83 # Usage: BeginTable(options); 84 # 85 # Options are taken from: 86 # 87 # border => n value for BORDER attribute (default 0) 88 # spacing => n value for CELLSPACING attribute (default 0) 89 # padding => n value for CELLPADDING attribute (default 0) 90 # tex_spacing => dimen value for spacing between columns in TeX 91 # (e.g, tex_spacing => 2em) (default 1em) 92 # tex_border => dimen value for left- and right border in TeX (0pt) 93 # center => 0 or 1 center table or not (default 1) 94 # 95 sub BeginTable { 96 my %options = (border => 0, padding => 0, spacing => 0, center => 1, 97 tex_spacing => "1em", tex_border => "0pt", @_); 98 my ($bd,$pd,$sp) = ($options{border},$options{padding},$options{spacing}); 99 my ($tsp,$tbd) = ($options{tex_spacing},$options{tex_border}); 100 my ($center,$tcenter) = (' ALIGN="CENTER"','\centerline'); 101 ($center,$tcenter) = ('','') if (!$options{center}); 102 my $table = 103 qq{<TABLE BORDER="$bd" CELLPADDING="$pd" CELLSPACING="$sp"$center>}; 104 105 MODES( 106 TeX => '\par\medskip'.$tcenter.'{\kern '.$tbd. 107 '\vbox{\halign{#\hfil&&\kern '.$tsp.' #\hfil', 108 Latex2HTML => $bHTML.$table.$eHTML."\n", 109 HTML => $table."\n" 110 ); 111 } 112 113 # 114 # Usage: EndTable(options) 115 # 116 # where options are taken from: 117 # 118 # tex_border => dimen extra vertical space in TeX mode (default 0pt) 119 # 120 sub EndTable { 121 my %options = (tex_border => "0pt", @_); 122 my $tbd = $options{tex_border}; 123 MODES( 124 TeX => '\cr}}\kern '.$tbd.'}\medskip'."\n", 125 Latex2HTML => $bHTML.'</TABLE>'.$eHTML."\n", 126 HTML => '</TABLE>'."\n" 127 ); 128 } 129 130 # 131 # Creates a row in the table 132 # 133 # Usage: Row([item1,item2,...],options); 134 # 135 # Each item appears as a separate entry in the table. 136 # 137 # Options control how the row is displayed: 138 # 139 # indent => num Specifies size of blank column on the left 140 # (default: indent => 0) 141 # 142 # separation => num Specifies separation of columns 143 # (default: spearation => 30) 144 # 145 # align => "type" Specifies alignment of initial column 146 # (default: align => "LEFT") 147 # 148 # valign => "type" Specified vertical alignment of row 149 # (default: valign => "MIDDLE") 150 # 151 sub Row { 152 my $rowref = shift; my @row = @{$rowref}; 153 my %options = ( 154 indent => 0, separation => 30, 155 align => "LEFT", valign => "MIDDLE", 156 @_ 157 ); 158 my ($cind,$csep) = ($options{indent},$options{separation}); 159 my ($align,$valign) = ($options{align},$options{valign}); 160 my $sep = '<TD WIDTH="'.$csep.'"> </TD>'; $sep = '' if ($csep < 1); 161 my $ind = '<TD WIDTH="'.$cind.'"> </TD>'; $ind = '' if ($cind < 1); 162 my $fill = ''; 163 $fill = '\hfil' if (uc($align) eq "CENTER"); 164 $fill = '\hfill' if (uc($align) eq "RIGHT"); 165 166 MODES( 167 TeX => "\\cr\n". $fill . join('& ',@row), 168 Latex2HTML => 169 $bHTML."<TR VALIGN=\"$valign\">$ind<TD ALIGN=\"$align\">".$eHTML . 170 join($bHTML."</TD>$sep<TD>".$eHTML,@row) . 171 $bHTML.'</TD></TR>'.$eHTML."\n", 172 HTML => "<TR VALIGN=\"$valign\">$ind<TD ALIGN=\"$align\">" . 173 join("</TD>$sep<TD>",@row) . '</TD></TR>'."\n" 174 ); 175 } 176 177 # 178 # AlignedRow([item1,item2,...],options); 179 # 180 # Options control how the row is displayed: 181 # 182 # indent => num Specifies size of blank column on the left 183 # (default: indent => 0) 184 # 185 # separation => num Specifies separation of columns 186 # (default: spearation => 30) 187 # 188 # align => "type" Specifies alignment of all columns 189 # (default: align => "CENTER") 190 # 191 # valign => "type" Specified vertical alignment of row 192 # (default: valign => "MIDDLE") 193 # 194 sub AlignedRow { 195 my $rowref = shift; my @row = @{$rowref}; 196 my %options = ( 197 indent => 0, separation => 30, 198 align => "CENTER", valign => "MIDDLE", 199 @_ 200 ); 201 my ($cind,$csep) = ($options{indent},$options{separation}); 202 my ($align,$valign) = ($options{align},$options{valign}); 203 my $sep = '<TD WIDTH="'.$csep.'"> </TD>'; $sep = '' if ($csep < 1); 204 my $ind = '<TD WIDTH="'.$cind.'"> </TD>'; $ind = '' if ($cind < 1); 205 my $fill = ''; 206 $fill = '\hfil ' if (uc($align) eq "CENTER"); 207 $fill = '\hfill ' if (uc($align) eq "RIGHT"); 208 209 MODES( 210 TeX => "\\cr\n". $fill . join('&'.$fill,@row), 211 Latex2HTML => 212 $bHTML."<TR VALIGN=\"$valign\">$ind<TD ALIGN=\"$align\">".$eHTML . 213 join($bHTML."</TD>$sep<TD ALIGN=\"$align\">".$eHTML,@row) . 214 $bHTML.'</TD></TR>'.$eHTML."\n", 215 HTML => "<TR VALIGN=\"$valign\">$ind<TD ALIGN=\"$align\">" . 216 join("</TD>$sep<TD ALIGN=\"$align\">",@row) . '</TD></TR>'."\n" 217 ); 218 } 219 220 # 221 # Add extra space between rows of a table 222 # 223 # Usage: TableSpace(pixels,points) 224 # 225 # where pixels is the number of pixels of space in HTML mode and 226 # points is the number of points to use in TeX mode. 227 # 228 sub TableSpace { 229 my $rsep = shift; 230 my $tsep = shift; 231 $rsep = $tsep if (defined($tsep) && $main::displayMode eq "TeX"); 232 return "" if ($rsep < 1); 233 MODES( 234 TeX => '\vadjust{\kern '.$rsep.'pt}' . "\n", 235 Latex2HTML => 236 $bHTML.'<TR><TD HEIGHT="'.$rsep.'"><!></TD></TR>'.$eHTML."\n", 237 HTML => '<TR><TD HEIGHT="'.$rsep.'"></TD></TR>'."\n", 238 ); 239 } 240 241 # 242 # A horizontal rule within a table. (Could have been a variable, 243 # but all the other table commands are subroutines, so kept it 244 # one to be consistent.) 245 # 246 sub TableLine { 247 MODES( 248 TeX => '\vadjust{\kern2pt\hrule\kern2pt}', 249 Latex2HTML => $bHTML. 250 '<TR><TD COLSPAN="10"><HR NOSHADE SIZE="1"></TD></TR>'. 251 $eHTML."\n", 252 HTML =>'<TR><TD COLSPAN="10"><HR NOSHADE SIZE="1"></TD></TR>'."\n" 253 ); 254 } 255 256 1;
| aubreyja at gmail dot com | ViewVC Help |
| Powered by ViewVC 1.0.9 |