]> git.lyx.org Git - features.git/commitdiff
Add support for rotated longtabulars (via [pdf]lscape)
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 18 Apr 2018 11:22:29 +0000 (13:22 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 18 Apr 2018 16:10:06 +0000 (18:10 +0200)
Fixes: #9194
See #9194 for why we use an earlier file format change here.

(cherry picked from commit feab528fd1555065592284603d8443b71f534a7a)

lib/chkconfig.ltx
lib/doc/LaTeXConfig.lyx
lib/lyx2lyx/lyx_2_3.py
src/LaTeXFeatures.cpp
src/frontends/qt4/GuiTabular.cpp
src/insets/InsetTabular.cpp
status.23x

index 3fd95722bf13ba2ce0a31f6f432398f11e291f5d..4adc56ac3ab6c7e8bc4d0283404aaab70883da44 100644 (file)
 \TestPackage{listings}
 \TestPackage[lithuanian.ldf]{lithuanian}
 \TestPackage{longtable}
+\TestPackage{lscape}
 \TestPackage{luainputenc}
 \TestPackage{mathdots}
 \TestPackage{mathrsfs}
 \TestPackage{nomencl}
 \TestPackage{paralist}
 \TestPackage{pdfcolmk}
+\TestPackage{pdflscape}
 \TestPackage{polyglossia}
 \TestPackage{pdfcomment}
 \TestPackage{pdfpages}
index 2fbba56ab9699c1d9e138c26d8d95253a1c78191..b99b340187a3d07fd14d891c5870d95efb8a34cf 100644 (file)
@@ -5918,6 +5918,38 @@ natbib
  You'll need to have jurabib version 0.6 at least.
 \end_layout
 
+\begin_layout Subsection
+lscape
+\end_layout
+
+\begin_layout Description
+Found: 
+\begin_inset Info
+type  "package"
+arg   "lscape"
+\end_inset
+
+
+\end_layout
+
+\begin_layout Description
+CTAN:
+\series medium
+\family typewriter
+\series default
+macros/latex/contrib/graphics/
+\end_layout
+
+\begin_layout Description
+Notes: The package 
+\family sans
+lscape
+\family default
+ is used to turn specific contents (longtables particularly) to landscape
+ mode with DVI/PS output.
+\end_layout
+
 \begin_layout Subsection
 mslapa
 \end_layout
@@ -6031,6 +6063,38 @@ jurabib
  instead).
 \end_layout
 
+\begin_layout Subsection
+pdflscape
+\end_layout
+
+\begin_layout Description
+Found: 
+\begin_inset Info
+type  "package"
+arg   "pdflscape"
+\end_inset
+
+
+\end_layout
+
+\begin_layout Description
+CTAN:
+\series medium
+\family typewriter
+\series default
+macros/latex/contrib/oberdiek/
+\end_layout
+
+\begin_layout Description
+Notes: The package 
+\family sans
+pdflscape
+\family default
+ is used to turn specific contents (longtables particularly) to landscape
+ mode with PDF output.
+\end_layout
+
 \begin_layout Section
 Packages required by modules
 \end_layout
index a39aaadd0919265a61cd210fa6e76643a11995ac..9a395687df7d1255f5e82770fb65ab2d7733df0d 100644 (file)
@@ -2256,6 +2256,30 @@ def revert_minted(document):
         document.header.pop(i)
 
 
+def revert_longtable_lscape(document):
+    " revert the longtable landcape mode to ERT "
+    i = 0
+    regexp = re.compile(r'^<features rotate=\"90\"\s.*islongtable=\"true\"\s.*$', re.IGNORECASE)
+    while True:
+        i = find_re(document.body, regexp, i)
+        if i == -1:
+            return
+
+        document.body[i] = document.body[i].replace(" rotate=\"90\"", "")
+        lay = get_containing_layout(document.body, i)
+        if lay == False:
+            document.warning("Longtable has not layout!")
+            i += 1
+            continue
+        begcmd = put_cmd_in_ert("\\begin{landscape}")
+        endcmd = put_cmd_in_ert("\\end{landscape}")
+        document.body[lay[2] : lay[2]] = endcmd + ["\\end_layout"]
+        document.body[lay[1] : lay[1]] = ["\\begin_layout " + lay[0], ""] + begcmd
+
+        add_to_preamble(document, ["\\usepackage{pdflscape}"])
+        i = lay[2]
+
+
 ##
 # Conversion hub
 #
@@ -2301,7 +2325,7 @@ convert = [
           ]
 
 revert =  [
-           [543, [revert_minted]],
+           [543, [revert_minted, revert_longtable_lscape]],
            [542, [revert_mathnumberingname]],
            [541, [revert_mathnumberpos]],
            [540, [revert_allowbreak]],
index 850af10169d5c09034eda8bc419f9c430af1edd2..029124286f189eea970a20177638a56e754784ea 100644 (file)
@@ -1098,6 +1098,15 @@ string const LaTeXFeatures::getPackages() const
        // The rest of these packages are somewhat more complicated
        // than those above.
 
+       // [pdf]lscape is used to rotate longtables
+       if (mustProvide("lscape")) {
+               if (runparams_.flavor == OutputParams::LATEX
+                   || runparams_.flavor == OutputParams::DVILUATEX)
+                       packages << "\\usepackage{lscape}\n";
+               else
+                       packages << "\\usepackage{pdflscape}\n";
+       }
+
        // The tipa package and its extensions (tipx, tone) must not
        // be loaded with non-TeX fonts, since fontspec includes the
        // respective macros
index 151a714ae974d976bc6b8ea8cc68e810fdbafe63..71be3085749ed5f63fae82753c424c188f7f462f 100644 (file)
@@ -230,7 +230,8 @@ void GuiTabular::enableWidgets() const
        tabularWidthED->setEnabled(setwidth);
        tabularWidthUnitLC->setEnabled(setwidth);
 
-       rotateTabularAngleSB->setEnabled(rotateTabularCB->isChecked());
+       rotateTabularAngleSB->setEnabled(rotateTabularCB->isChecked()
+                                        && !longTabularCB->isChecked());
        rotateCellAngleSB->setEnabled(rotateCellCB->isChecked());
 
        bool const enable_valign =
@@ -258,11 +259,8 @@ void GuiTabular::enableWidgets() const
        // longtables and tabular* cannot have a vertical alignment
        TableAlignLA->setDisabled(is_tabular_star || longtabular);
        TableAlignCO->setDisabled(is_tabular_star || longtabular);
-       // longtable cannot be rotated (with rotating package)
-       // FIXME: Add support for [pdf]lscape
-       rotateTabularCB->setDisabled(longtabular);
-       rotateTabularLA->setDisabled(longtabular);
-       // this one would also be disabled with [pdf]lscape
+       // longtable cannot be rotated with rotating package, only
+       // with [pdf]lscape, which only supports 90 deg.
        rotateTabularAngleSB->setDisabled(longtabular);
 
        // FIXME: This Dialog is really horrible, disabling/enabling a checkbox
@@ -743,12 +741,16 @@ void GuiTabular::paramsToDialog(Inset const * inset)
                        rotateCellAngleSB->setValue(90);
        }
 
-       rotateTabularCB->setChecked(tabular.rotate != 0);
-       if (rotateTabularCB->isChecked())
-               rotateTabularAngleSB->setValue(tabular.rotate != 0 ? tabular.rotate : 90);
-
        longTabularCB->setChecked(tabular.is_long_tabular);
 
+       rotateTabularCB->setChecked(tabular.rotate != 0);
+       if (rotateTabularCB->isChecked()) {
+               if (longTabularCB->isChecked())
+                       rotateTabularAngleSB->setValue(90);
+               else
+                       rotateTabularAngleSB->setValue(tabular.rotate != 0 ? tabular.rotate : 90);
+       }
+
        borders->setTop(tabular.topLine(cell));
        borders->setBottom(tabular.bottomLine(cell));
        borders->setLeft(tabular.leftLine(cell));
index 2037b76707110a6bf253539b2b80b2d4bf1d7c6b..26397ea62af150075c66fb4aefa5544314e38123 100644 (file)
@@ -2731,8 +2731,12 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const
        if (!TexRow::isNone(pos))
                os.texrow().start(pos);
 
-       if (rotate != 0 && !is_long_tabular)
-               os << "\\begin{turn}{" << convert<string>(rotate) << "}\n";
+       if (rotate != 0) {
+               if (is_long_tabular)
+                       os << "\\begin{landscape}\n";
+               else
+                       os << "\\begin{turn}{" << convert<string>(rotate) << "}\n";
+       }
 
        if (is_long_tabular) {
                os << "\\begin{longtable}";
@@ -2882,8 +2886,12 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const
                        os << "\\end{tabular}";
        }
 
-       if (rotate != 0 && !is_long_tabular)
-               os << breakln << "\\end{turn}";
+       if (rotate != 0) {
+               if (is_long_tabular)
+                       os << breakln << "\\end{landscape}";
+               else
+                       os << breakln << "\\end{turn}";
+       }
 
        if (!TexRow::isNone(pos))
                os.texrow().start(pos);
@@ -3428,6 +3436,8 @@ void Tabular::validate(LaTeXFeatures & features) const
                features.require("booktabs");
        if (is_long_tabular)
                features.require("longtable");
+       if (rotate && is_long_tabular)
+               features.require("lscape");
        if (needRotating())
                features.require("rotating");
        for (idx_type cell = 0; cell < numberofcells; ++cell) {
index 1662e826270aa1275458ab42ccdbcaa3546b6df4..65eacbb3f5a9bced777b47cd8aa2adc60056f48b 100644 (file)
@@ -20,6 +20,8 @@ What's new
 - It possible to anonymize document's content for bug submissions
   via buffer-anonymize lfun (bug 7259).
 
+- Support rotation of multi-page tables via (pdf)lscape (bug 9194).
+
 
 * TEX2LYX IMPROVEMENTS