]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.cpp
Protect label in moving argument
[lyx.git] / src / LaTeXFeatures.cpp
index 88a34cc876e8f72fac8fce31f60dbf40939e6e36..e2f32b55836e6a65944d0af01f92c1db2f460330 100644 (file)
@@ -63,12 +63,7 @@ namespace lyx {
 //\message{LyX LaTeX Extensions (LLE v0.2) of 11-Jan-1996.}
 
 static docstring const lyx_def = from_ascii(
-       "\\providecommand{\\LyX}{L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}");
-
-static docstring const lyx_hyperref_def = from_ascii(
-       "\\providecommand{\\LyX}{\\texorpdfstring%\n"
-       "  {L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}\n"
-       "  {LyX}}");
+       "{%\n  L\\kern-.1667em\\lower.25em\\hbox{Y}\\kern-.125emX\\@}");
 
 static docstring const noun_def = from_ascii(
        "\\newcommand{\\noun}[1]{\\textsc{#1}}");
@@ -904,16 +899,28 @@ void LaTeXFeatures::getFontEncodings(vector<string> & encs, bool const onlylangs
                        encs.insert(encs.begin(), "T2A");
        }
 
-       for (auto const & lang : UsedLanguages_)
-               if (!lang->fontencs().empty()) {
-                       vector<string> extraencs = lang->fontencs();
-                       for (auto const & extra : extraencs) {
-                               if (extra != "none" && find(encs.begin(), encs.end(), extra) == encs.end())
-                                       encs.insert(encs.begin(), extra);
-                       }
+       for (auto const & lang : UsedLanguages_) {
+               vector<string> extraencs =
+                       getVectorFromString(lang->fontenc(buffer().masterParams()));
+               for (auto const & extra : extraencs) {
+                       if (extra != "none" && find(encs.begin(), encs.end(), extra) == encs.end())
+                               encs.insert(encs.begin(), extra);
                }
+       }
 }
 
+
+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[] = {
@@ -943,8 +950,7 @@ char const * simplefeatures[] = {
        "units",
        "framed",
        "soul",
-       "textcomp",
-       "pmboxdraw",
+       "dingbat",
        "bbding",
        "ifsym",
        "txfonts",
@@ -956,7 +962,6 @@ char const * simplefeatures[] = {
        // "cancel",
        "ascii",
        "url",
-       "covington",
        "csquotes",
        "enumitem",
        "endnotes",
@@ -981,9 +986,12 @@ char const * simplefeatures[] = {
        "todonotes",
        "forest",
        "varwidth",
-       "footnote",
        "tablefootnote",
        "afterpage",
+       "tabularx",
+       "xltabular",
+       "chessboard",
+       "xskak"
 };
 
 char const * bibliofeatures[] = {
@@ -1106,6 +1114,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
@@ -1357,10 +1372,24 @@ TexString LaTeXFeatures::getMacros() const
        }
 
        if (mustProvide("LyX")) {
+               macros << "\\providecommand{\\LyX}";
+               // open conditional wrappers
+               if (runparams_.use_polyglossia && hasRTLLanguage())
+                       macros << "{\\@ensure@LTR";
                if (isRequired("hyperref"))
-                       macros << lyx_hyperref_def << '\n';
-               else
-                       macros << lyx_def << '\n';
+                       macros << "{\\texorpdfstring";
+               if (useBabel())
+                       macros << "{\\textlatin";
+               // main definition
+               macros << lyx_def;
+               // close conditional wrappers
+               if (useBabel())
+                       macros << '}';
+               if (isRequired("hyperref"))
+                       macros << "{LyX}}";
+               if (runparams_.use_polyglossia && hasRTLLanguage())
+                       macros << '}';
+               macros << '\n';
        }
 
        if (mustProvide("noun"))
@@ -1388,19 +1417,19 @@ TexString LaTeXFeatures::getMacros() const
 
        // non-standard text accents:
        if (mustProvide("textcommaabove") || mustProvide("textcommaaboveright") ||
-           mustProvide("textcommabelow") || mustProvide("textbalticdefs"))
+           mustProvide("textcommabelow") || mustProvide("textbaltic"))
                macros << lyxaccent_def;
 
-       if (mustProvide("textcommabelow") || mustProvide("textbalticdefs"))
+       if (mustProvide("textcommabelow") || mustProvide("textbaltic"))
                macros << textcommabelow_def << '\n';
 
-       if (mustProvide("textcommaabove") || mustProvide("textbalticdefs"))
+       if (mustProvide("textcommaabove") || mustProvide("textbaltic"))
                macros << textcommaabove_def << '\n';
 
        if (mustProvide("textcommaaboveright"))
                macros << textcommaaboveright_def << '\n';
 
-       if (mustProvide("textbalticdefs"))
+       if (mustProvide("textbaltic"))
                macros << textbaltic_def << '\n';
 
        // split-level fractions