]> git.lyx.org Git - features.git/commitdiff
Fix toprule with booktabs/longtable and captions
authorJuergen Spitzmueller <spitz@lyx.org>
Fri, 31 May 2019 08:48:00 +0000 (10:48 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 19 Jun 2019 07:45:20 +0000 (09:45 +0200)
(cherry picked from commit fe589d562224b2cebaade60facb9c727d8ea7a60)

src/insets/InsetTabular.cpp
status.23x

index 375d7561b68c7875c2c4af573821692f44fc2236..36e99b62c6068a48cb706aea76b24016eaa0c0d2 100644 (file)
@@ -2203,14 +2203,18 @@ void Tabular::TeXTopHLine(otexstream & os, row_type row, string const & lang,
        if ((row == 0 && nset == 0) || (row > 0 && nset != ncols()))
                return;
 
+       // Is this the actual first row (excluding longtable caption row)?
+       bool const realfirstrow = (row == 0
+                                  || (is_long_tabular && row == 1 && ltCaption(0)));
+
        // only output complete row lines and the 1st row's clines
        if (nset == ncols()) {
                if (use_booktabs) {
-                       os << (row == 0 ? "\\toprule " : "\\midrule ");
+                       os << (realfirstrow ? "\\toprule " : "\\midrule ");
                } else {
                        os << "\\hline ";
                }
-       } else if (row == 0) {
+       } else if (realfirstrow) {
                for (auto & c : columns) {
                        if (topline.find(c)->second) {
                                col_type offset = 0;
@@ -4014,7 +4018,9 @@ void InsetTabular::drawCellLines(PainterInfo & pi, int x, int y,
        // Top
        bool drawline = tabular.topLine(cell)
                || (row > 0 && tabular.bottomLine(tabular.cellAbove(cell)));
-       bool heavy = tabular.use_booktabs && row == 0 && tabular.rowTopLine(row);
+       bool heavy = tabular.use_booktabs
+                       && (row == 0 || (tabular.is_long_tabular && row == 1 && tabular.ltCaption(0)))
+                       && tabular.rowTopLine(row);
        tabline(pi, x, y, x + w, y, drawline, heavy);
 
        // Bottom
index fcd96572d7893d9be15859187b32fac3ec6cab94..9b0ff657f2d8f3ab8251ee04a6b68194fbcb912a 100644 (file)
@@ -45,7 +45,7 @@ What's new
 
 * DOCUMENT INPUT/OUTPUT
 
-
+- Fix toprule with booktabs/longtable and captions (bug 11589).
 
 
 * USER INTERFACE