## WeBWorK Main Forum

### Nested tables for formatting - hardcopy error

by Gavin LaRose -
Number of replies: 1
Hi all,

I think this may be a case of abusing the power that one has been given, without considering if the use is strictly appropriate. I'm trying to get some nesting of arrays of answer blanks in a problem, and while it displays fine on the screen it chokes in hardcopy. This is the outline of what I'm doing in the PG file (for brevity I've omitted the arguments of various function calls).

    loadMacros( "unionTables.pl",
...
$m1 = Matrix(...);$chk = MultiAnswer(...)->with(...);
...
Context()->texStrings;
BEGIN_TEXT
$$m1$$ $BR \{ BeginTable(...) . AlignedRow( [ "$$\qquad\sim \Bigg[$$", BeginTable(...) . AlignedRow( [ 1,$chk->ans_rule(5), $chk->ans_rule(5),$chk->ans_rule(5) ],
align=>'CENTER', separation=>0 ) .
AlignedRow( [ 0, 1, $chk->ans_rule(5),$chk->ans_rule(5) ],
align=>'CENTER', separation=>0 ) .
EndTable(), "$$\Bigg]$$" ],
align=>'CENTER', valign=>'MIDDLE', separation=>0 ) .
EndTable() \}


The problem is that the BeginTable calls insert a paragraph break, which trips TeX by inserting a \par in the midst of a \centerline. Hopefully that's clear. Is there an easy work-around for this?

Thanks,
Gavin

### Re: Nested tables for formatting - hardcopy error

by Davide Cervone -
You are right, BeginTable() does insert a \par. I can think of two ways around this (well, three if you count copying unionTables.pl and editing out the \par).

The first would be to capture the output of BeginTable() and substituting out the \par. You could do that in a separate macro, e.g.,

    sub myBeginTable {
my $table = BeginTable(@_);$table = substr($table,4) if$displayMode eq "TeX";
return \$table;
}


A second option would be to add some extra TeX to turn the \par into something less troublesome. Something like inserting {\let\par=\relax before the outer table and } afterward to return \par to its usual meaning. I think this is trickier, and probably more fragile.

Hope one of those helps.

Davide