On Fri, Feb 6, 2015 at 11:54 PM, Karl Berry <k...@freefriends.org> wrote: > Possibly any xref command inside a multitable should be implicitly > handled as if enclosed in @w, to avoid the unable-to-find-the-reference > problem.
Here's a possible fix. Index: Plaintext.pm =================================================================== --- Plaintext.pm (revision 6106) +++ Plaintext.pm (working copy) @@ -2013,6 +2013,26 @@ sub _convert($$) $args[3] = $args[2]; $args[2] = undef; } + + # Treat cross-reference commands in a multitable cell as if they + # were surrounded by @w{ ... }, so the output will not be split across + # lines, leading text from other columns appearing to be part of the + # cross-reference. + # + # Normally in this case, $self->{'format_context'}->[-2]->{'cmdname'} + # is 'multitable' and $self->{'format_context'}->[-1]->{'cmdname'} is + # one of 'headitem', 'item' and 'tab', but it is possible for other + # contexts to follow (like 'quotation'). Hence we check if + # 'multitable' occurs anywhere in the stack of format contexts. + my $in_multitable = 0; + if (grep {$_->{'cmdname'} eq 'multitable'} @{$self->{'format_context'}}) { + $in_multitable = 1; + $formatter->{'w'}++; + $result .= $self->_count_added($formatter->{'container'}, + $formatter->{'container'}->set_space_protection(1,undef)) + if ($formatter->{'w'} == 1); + } + if ($command eq 'xref') { $result = $self->_convert({'contents' => [{'text' => '*Note '}]}); } else { @@ -2112,6 +2132,13 @@ sub _convert($$) unshift @{$self->{'current_contents'}->[-1]}, @added; } } + + if ($in_multitable) { + $formatter->{'w'}--; + $result .= $self->_count_added($formatter->{'container'}, + $formatter->{'container'}->set_space_protection(0,undef)) + if ($formatter->{'w'} == 0); + } return $result; } return '';