Angus Leeming wrote:
> The attached patch allows reLyX to recognise 'm' column descriptors in
> tables. Applying it would squash bug. (I forget which number because
> bugzilla is currently refusing connections.)
>
> 'm' column descriptors are functionally equivalent to 'p' ones, but this
> patch simply adds to the 'special' field so that the LaTeX exported by LyX
> is identical to the LaTeX it imported.
>
> The user has no visual feedback about this fixed width column, but it
> strikes me that we could actually have the best of both worlds if I also
> set the pwidth field. Ie, invariant LaTeX _and_ visual feedback.
>
> Shall I do this?
> Jean-Marc, is this something that you'd like to see in 1.3.x too?
I thought it might be easier for people to comment if I attached a re-worked
patch with my suggestion incorporated together with a test case showing it
in action.
Jean-Marc, please consider this for 1.3.x.also. It fixes a bug (722 I
think).
--
Angus
Index: lib/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v
retrieving revision 1.365
diff -u -p -r1.365 ChangeLog
--- lib/ChangeLog 7 Feb 2003 12:11:57 -0000 1.365
+++ lib/ChangeLog 7 Feb 2003 12:42:17 -0000
@@ -5,6 +5,8 @@
* reLyX/BasicLyX.pm, reLyX/CleanTeX.pm, reLyX/Verbatim.pm: pass
$...$ and $$...$$ through reLyX unchanged.
+ * reLyX/RelyxTable.pm: provide support for 'm' column descriptors.
+
2003-02-04 Joao Luis Meloni Assirati <[EMAIL PROTECTED]>
* images/math/rbracket.xpm: new file.
Index: lib/reLyX/RelyxTable.pm
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/reLyX/RelyxTable.pm,v
retrieving revision 1.5
diff -u -p -r1.5 RelyxTable.pm
--- lib/reLyX/RelyxTable.pm 5 Feb 2003 11:27:51 -0000 1.5
+++ lib/reLyX/RelyxTable.pm 7 Feb 2003 12:42:18 -0000
@@ -68,7 +68,7 @@ sub parse_cols {
while (@group) {
$tok = shift(@group);
- # Each $tok will consist of /^[clr|]*[p*@]?$/
+ # Each $tok will consist of /^[clr|]*[mp*@]?$/
# (Except first may have | and/or @ expressions before it)
# p*@ will end the $tok since after it comes a group in braces
# @ will be a TT::Token, everything else will be in TT::Text
@@ -86,13 +86,14 @@ sub parse_cols {
@new_cols = ($description =~ /[clr]\|*/g);
push @cols, @new_cols;
- # parse a p or * or @ if necessary
+ # parse a 'p', an 'm', a '*' or a '@' as necessary
# use exact_print in case there's weird stuff in the @ descriptions
$description = substr($description,-1);
- if ($description eq 'p') {
+ # The m and p descriptors have identical form.
+ if ($description eq 'p' || $description eq 'm') {
$tok = shift(@group);
- my $pdes = $description . $tok->exact_print; # "p{foo}"
- push @cols, $pdes;
+ my $des = $description . $tok->exact_print; # 'p{foo}' or 'm{foo}'
+ push @cols, $des;
} elsif ($description eq '@') {
$tok = shift(@group);
@@ -376,25 +377,25 @@ package RelyxTable::Column;
$col->{"pwidth"} = "";
$col->{"special"} = "";
- # Any special (@) column should be handled differently
- if ($description =~ /\@/) {
- # Just put the whole description in "special" field --- this
- # corresponds the the "extra" field in LyX table popup
- # Note that LyX ignores alignment, r/l lines for a special column
- $col->{"special"} = $description;
- print "\n'$description' column won't display WYSIWYG in LyX\n"
- if $debug_on;
-
- # It's not a special @ column
- } else {
+ # LyX does not know about '@' or 'm' column descriptors so, to
+ # ensure that the LaTeX -> LyX -> LaTeX cycle is invariant,
+ # these descriptors are placed in the 'special' field.
+ if ($description =~ /\@/ || $description =~ /^m/ ) {
+ $col->{"special"} = $description;
+ print "\n'$description' column won't display WYSIWYG in LyX\n"
+ if $debug_on;
+ }
+ # '@' columns really can't be displayed WYSIWYG in LyX,
+ # but we can get visual feedback on 'm' columns.
+ if (!($description =~ /\@/)) {
# left line?
$description =~ s/^\|*//;
$col->{"left_line"} = length($&);
# main column description
- $description =~ s/^[clrp]//;
- if ($& eq "p") {
+ $description =~ s/^[clrpm]//;
+ if ($& eq 'p' || $& eq 'm') {
$description =~ s/^\{(.+)\}//; # eat the width
$col->{"pwidth"} = $1; # width without braces
# note: alignment is not applicable for 'p' columns
\documentclass{article}
\usepackage{array}
\providecommand{\tabularnewline}{\\}
\begin{document}
\begin{tabular}{m{1.5in}rrr}
\hline
A&
B&
C&
D\tabularnewline
&
E&
F&
G\tabularnewline
&
H&
I&
J\tabularnewline
\hline
K&
L&
M&
N\tabularnewline
\end{tabular}
\end{document}