1 \documentclass[a4paper,12pt]{scrartcl}
9 \definecolor{title}{rgb}{0.86,0.86,0.86}
10 \definecolor{bit}{rgb}{0.8,0.86,0.8}
11 \definecolor{bitval}{rgb}{0.8,0.8,0.8}
12 \definecolor{names}{rgb}{0.86,0.93,0.86}
14 \arrayrulecolor{black}
18 \perlnewcommand{\ins}[5]
32 @fields = split(/\|/, $_[3]);
33 foreach my $field (@fields) {
34 #remove heading and trailing spaces
39 #$tabular .= $field." \\\\";
43 return "Num of Fields not equal to Bits!";
46 @fieldnames = split(/\|/, $_[4]);
48 if(scalar(@fields) != scalar(@fieldnames)) {
49 return "Num of Fields != Num of Names";
53 foreach my $fieldn (@fieldnames) {
54 #remove heading and trailing spaces
58 if($fieldn =~ m/^[^\(.]*\(\s*([0-1]+)\s*\).*$/) {
59 if(length($1) == $fields[$count]) {
61 $fieldn =~ s/\s?\(\s*[0-1]+\s*\)//;
66 for($i = 1; $i <= $fields[$count]; $i++) {
74 for($i = 1; $i <= $fields[$count]; $i++) {
79 #$tabular .= $fieldn.": ". $bits." \\\\";
82 $bitlist = join("",@bitlist);
84 #$tabular .= "\\textbf{names:} @fieldnames \n";
85 #$tabular .= "\\textbf{bitlist:} $bitlist \n";
89 $tabular = "\\begin{center} \n \\resizebox{\\textwidth}{!}{\n";
90 $tabular .= "\\begin{tabular}{|l|";
91 for($i = $bits-1; $i >= 0; $i--) {
101 $bline .= "\\\\ \\hline \n";
105 $vline .= substr($bitlist,($bits-1)-$i,1);
110 $vline .= "\\\\ \\hline \n";
114 #because of multicolumn we need to limit execution
116 $nline .= "\\multicolumn{@fields[0]}{>{\\columncolor{names}}c|}{@fieldnames[0]}";
119 $count -= @fields[0];
122 $nline .= "\\\\ \\hline \n";
132 $tabular .= "} \\hline \n";
133 $tabular .= "\\multicolumn{".($bits+1)."}{|>{\\columncolor{title}}c|}{\\textbf{".$_[1]."} (".$_[2].")} \\\\ \\hline \n";
134 $tabular .= "\\rowcolor{bit} \\cellcolor{title} &". $bline;
136 $tabular .= "\\rowcolor{bitval} \\cellcolor{title}Values &". $vline;
138 $tabular .= "\\cellcolor{title}Field &". $nline;
139 $tabular .= "\\end{tabular}\n}\n \\end{center}\n";