]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.cpp
Update tex2lyx tests
[lyx.git] / src / LaTeXFeatures.cpp
index 17d7ae40474a8578131a065fd5046f83e8b3425a..c78e73573001bfbf36e48b33a808733e0e17e2a4 100644 (file)
@@ -65,6 +65,10 @@ namespace lyx {
 static docstring const lyx_def = from_ascii(
        "\\providecommand{\\LyX}{L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}");
 
+static docstring const lyx_rtl_def = from_ascii(
+       "\\let\\@@LyX\\LyX\n"
+       "\\def\\LyX{\\@ensure@LTR{\\@@LyX}}");
+
 static docstring const lyx_hyperref_def = from_ascii(
        "\\providecommand{\\LyX}{\\texorpdfstring%\n"
        "  {L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}\n"
@@ -914,6 +918,17 @@ void LaTeXFeatures::getFontEncodings(vector<string> & encs, bool const onlylangs
        }
 }
 
+
+bool LaTeXFeatures::hasRTLLanguage() const
+{
+       if (params_.language->rightToLeft())
+               return true;
+       for (auto const & lang : UsedLanguages_)
+               if (lang->rightToLeft())
+                       return true;
+       return false;
+}
+
 namespace {
 
 char const * simplefeatures[] = {
@@ -981,9 +996,10 @@ char const * simplefeatures[] = {
        "todonotes",
        "forest",
        "varwidth",
-       "footnote",
        "tablefootnote",
        "afterpage",
+       "tabularx",
+       "xltabular"
 };
 
 char const * bibliofeatures[] = {
@@ -1106,6 +1122,13 @@ string const LaTeXFeatures::getPackages() const
        // The rest of these packages are somewhat more complicated
        // than those above.
 
+       if (mustProvide("footnote")) {
+               if (isRequired("hyperref"))
+                       packages << "\\usepackage{footnotehyper}\n";
+               else
+                       packages << "\\usepackage{footnote}\n";
+       }
+
        // [pdf]lscape is used to rotate longtables
        if (mustProvide("lscape")) {
                if (runparams_.flavor == OutputParams::LATEX
@@ -1361,6 +1384,8 @@ TexString LaTeXFeatures::getMacros() const
                        macros << lyx_hyperref_def << '\n';
                else
                        macros << lyx_def << '\n';
+               if (runparams_.use_polyglossia && hasRTLLanguage())
+                       macros << lyx_rtl_def << '\n';
        }
 
        if (mustProvide("noun"))