commit 8db5ff18cfc24199f02f15f18297206c3dd21028
Author: Juergen Spitzmueller <[email protected]>
Date:   Mon Jun 25 10:53:40 2018 +0200

    With xltabular, multi-page tables can have a fixed width
---
 src/frontends/qt4/GuiTabular.cpp |    2 +-
 src/insets/InsetTabular.cpp      |   21 +++++++++++++--------
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/frontends/qt4/GuiTabular.cpp b/src/frontends/qt4/GuiTabular.cpp
index 973bba0..284bf87 100644
--- a/src/frontends/qt4/GuiTabular.cpp
+++ b/src/frontends/qt4/GuiTabular.cpp
@@ -260,7 +260,7 @@ void GuiTabular::enableWidgets() const
 
        // setting as longtable is not allowed when table is inside a float
        bool const is_tabular_star = !tabularWidthED->text().isEmpty();
-       longTabularCB->setEnabled(!is_tabular_star && 
funcEnabled(Tabular::SET_LONGTABULAR));
+       longTabularCB->setEnabled(funcEnabled(Tabular::SET_LONGTABULAR));
        bool const longtabular = longTabularCB->isChecked();
        longtableGB->setEnabled(true);
        newpageCB->setEnabled(longtabular);
diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp
index 0146f3a..ee454fb 100644
--- a/src/insets/InsetTabular.cpp
+++ b/src/insets/InsetTabular.cpp
@@ -1491,10 +1491,9 @@ void Tabular::write(ostream & os) const
           << write_attribute("lastFootBottomDL", endlastfoot.bottomDL)
           << write_attribute("lastFootEmpty", endlastfoot.empty);
        // longtables cannot be aligned vertically
-       if (!is_long_tabular) {
+       if (!is_long_tabular)
                os << write_attribute("tabularvalignment", tabular_valignment);
-               os << write_attribute("tabularwidth", tabular_width);
-       }
+       os << write_attribute("tabularwidth", tabular_width);
        if (is_long_tabular)
                os << write_attribute("longtabularalignment", 
longtabular_alignment);
        os << ">\n";
@@ -2775,6 +2774,8 @@ void Tabular::TeXRow(otexstream & os, row_type row,
 void Tabular::latex(otexstream & os, OutputParams const & runparams) const
 {
        bool const is_tabular_star = !tabular_width.zero() && 
!hasVarwidthColumn();
+       bool const is_xltabular = is_long_tabular
+               && (hasVarwidthColumn() || !tabular_width.zero());
        TexRow::RowEntry pos = TexRow::textEntry(runparams.lastid, 
runparams.lastpos);
 
        //+---------------------------------------------------------------------
@@ -2793,7 +2794,7 @@ void Tabular::latex(otexstream & os, OutputParams const & 
runparams) const
        }
 
        if (is_long_tabular) {
-               if (hasVarwidthColumn())
+               if (is_xltabular)
                        os << "\\begin{xltabular}";
                else
                        os << "\\begin{longtable}";
@@ -2808,7 +2809,7 @@ void Tabular::latex(otexstream & os, OutputParams const & 
runparams) const
                        os << "[r]";
                        break;
                }
-               if (hasVarwidthColumn()) {
+               if (is_xltabular) {
                        if (tabular_width.zero())
                                os << "{" << from_ascii("\\columnwidth") << "}";
                        else
@@ -2984,7 +2985,7 @@ void Tabular::latex(otexstream & os, OutputParams const & 
runparams) const
        //+---------------------------------------------------------------------
 
        if (is_long_tabular) {
-               if (hasVarwidthColumn())
+               if (is_xltabular)
                        os << "\\end{xltabular}";
                else
                        os << "\\end{longtable}";
@@ -3545,8 +3546,12 @@ void Tabular::validate(LaTeXFeatures & features) const
        features.require("NeedTabularnewline");
        if (use_booktabs)
                features.require("booktabs");
-       if (is_long_tabular && !hasVarwidthColumn())
-               features.require("longtable");
+       if (is_long_tabular && !hasVarwidthColumn()) {
+               if (tabular_width.zero())
+                       features.require("longtable");
+               else
+                       features.require("xltabular");
+       }
        if (rotate && is_long_tabular)
                features.require("lscape");
        if (needRotating())

Reply via email to