From c1c439b94dd6d5802e9a48b8c4e45c13fad6f869 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Mon, 29 Dec 2014 22:54:06 +0100 Subject: [PATCH] Handle unknown table column specifiers (bug #9311) Previously tex2lyx did ignore table columns if the column specifier was unknown. This can lead to data loss, and now it does not ignore these columns, but assumes that the column specifiers use only once character. This can still lead to data loss, but less often. --- src/tex2lyx/table.cpp | 10 +- src/tex2lyx/test/test-insets.lyx.lyx | 319 +++++++++++++++++++++++++++ src/tex2lyx/test/test-insets.tex | 18 ++ 3 files changed, 344 insertions(+), 3 deletions(-) diff --git a/src/tex2lyx/table.cpp b/src/tex2lyx/table.cpp index eed7bb91c8..75a0317465 100644 --- a/src/tex2lyx/table.cpp +++ b/src/tex2lyx/table.cpp @@ -434,9 +434,13 @@ void handle_colalign(Parser & p, vector & colinfo, '}'; colinfo.push_back(next); next = ColInfo(); - } else - cerr << "Ignoring column specification" - " '" << t << "'." << endl; + } else { + // unknown column specifier, assume no arguments + ci2special(next); + next.special += t.character(); + colinfo.push_back(next); + next = ColInfo(); + } break; } } diff --git a/src/tex2lyx/test/test-insets.lyx.lyx b/src/tex2lyx/test/test-insets.lyx.lyx index 643f0cf361..d0622bdffa 100644 --- a/src/tex2lyx/test/test-insets.lyx.lyx +++ b/src/tex2lyx/test/test-insets.lyx.lyx @@ -4976,6 +4976,325 @@ in % of pixel size \end_inset +\end_layout + +\begin_layout Standard +A table using dcolumn: +\end_layout + +\begin_layout Standard + +\begin_inset Float table +wide false +sideways false +status open + + +\begin_layout Standard + +\begin_inset Tabular + + + + + + + + + +\begin_inset Text + +\begin_layout Standard +One +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +Two +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\family roman +Three +\family default + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\family roman +Four +\family default + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\family roman +Five +\family default + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Standard +one +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +two +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\begin_inset Box Frameless +position "c" +hor_pos "c" +has_inner_box 1 +inner_pos "c" +use_parbox 0 +use_makebox 1 +width "" +special "none" +height "1in" +height_special "totalheight" +status open + + +\begin_layout Standard +three +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\begin_inset Box Frameless +position "c" +hor_pos "c" +has_inner_box 1 +inner_pos "c" +use_parbox 0 +use_makebox 1 +width "" +special "none" +height "1in" +height_special "totalheight" +status open + + +\begin_layout Standard +four +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard + +\begin_inset Box Frameless +position "c" +hor_pos "c" +has_inner_box 1 +inner_pos "c" +use_parbox 0 +use_makebox 1 +width "" +special "none" +height "1in" +height_special "totalheight" +status open + + +\begin_layout Standard +five +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Standard +He +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +2 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +2.77234 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +45672. +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +0.69 +\end_layout + +\end_inset + + + + +\begin_inset Text + +\begin_layout Standard +C +\begin_inset Foot +status collapsed + + +\begin_layout Standard +Some tables require footnotes. +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +C +\begin_inset Foot +status collapsed + + +\begin_layout Standard +Some tables need more than one footnote. +\end_layout + +\end_inset + + +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +12537.64 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +37.66345 +\end_layout + +\end_inset + + +\begin_inset Text + +\begin_layout Standard +86.37 +\end_layout + +\end_inset + + + + +\end_inset + + +\end_layout + +\end_inset + + \end_layout \begin_layout Section diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex index 5fd3930307..e6249fc665 100644 --- a/src/tex2lyx/test/test-insets.tex +++ b/src/tex2lyx/test/test-insets.tex @@ -34,6 +34,7 @@ \usepackage{booktabs} \usepackage{multirow} \usepackage{hhline} +\usepackage{dcolumn} \usepackage{pdfpages} \usepackage{textcomp} \usepackage{amssymb} @@ -452,6 +453,23 @@ in \% of pixel size & 76.3 & 95.9 & 92.3\tabularnewline \end{tabular} \end{table} +A table using dcolumn: + +\begin{table} +\begin{tabular}{ccddd} +One&Two& +\multicolumn{1}{c}{\textrm{Three}}& +\multicolumn{1}{c}{\textrm{Four}}& +\multicolumn{1}{c}{\textrm{Five}}\\ +\hline +one&two&\mbox{three}&\mbox{four}&\mbox{five}\\ +He&2& 2.77234 & 45672. & 0.69 \\ +C\footnote{Some tables require footnotes.} +&C\footnote{Some tables need more than one footnote.} +& 12537.64 & 37.66345 & 86.37 \\ +\end{tabular} +\end{table} + \section{Macros} -- 2.39.5