X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FLaTeXFeatures.cpp;h=a9ad21ca2c6e028674dfb95189fa677b7e76b879;hb=e41c790f9156e3b889e4b4f48653380c7a5c737d;hp=c28d7958f6908e64ef3818b6fe518a25decfe618;hpb=c2d121f663b2814cad9190f03358d1362aab5ce5;p=lyx.git diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index c28d7958f6..a9ad21ca2c 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -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" @@ -200,6 +204,39 @@ static docstring const lyxgreyedout_def = from_ascii( " {\\textcolor{note_fontcolor}\\bgroup\\ignorespaces}\n" " {\\ignorespacesafterend\\egroup}\n"); +static docstring const lyxgreyedout_rtl_def = from_ascii( + "%% The greyedout annotation environment (with RTL support)\n" + "\\NewEnviron{lyxgreyedout}{%\n" + "\\if@rl%\n" + "\\everypar{\\textcolor{note_fontcolor}\\beginL\\ignorespaces}%\n" + "\\BODY\\everypar{\\ignorespacesafterend\\endL}\n" + "\\else%\n" + "\\textcolor{note_fontcolor}\\bgroup\\ignorespaces%\n" + "\\BODY\\ignorespacesafterend\\egroup\n" + "\\fi}\n"); + +static docstring const lyxgreyedout_luartl_def = from_ascii( + "%% The greyedout annotation environment (with RTL support)\n" + "\\NewEnviron{lyxgreyedout}{%\n" + "\\if@RTL%\n" + "\\everypar{\\color{note_fontcolor}\\pardir TRT \\textdir TRT\\ignorespaces}%\n" + "\\BODY\\everypar{\\ignorespacesafterend}\n" + "\\else%\n" + "\\textcolor{note_fontcolor}\\bgroup\\ignorespaces%\n" + "\\BODY\\ignorespacesafterend\\egroup\n" + "\\fi}\n"); + +static docstring const lyxgreyedout_luartl_babel_def = from_ascii( + "%% The greyedout annotation environment (with RTL support)\n" + "\\NewEnviron{lyxgreyedout}{%\n" + "\\if@rl%\n" + "\\everypar{\\color{note_fontcolor}\\pardir TRT \\textdir TRT\\ignorespaces}%\n" + "\\BODY\\everypar{\\ignorespacesafterend}\n" + "\\else%\n" + "\\textcolor{note_fontcolor}\\bgroup\\ignorespaces%\n" + "\\BODY\\ignorespacesafterend\\egroup\n" + "\\fi}\n"); + // We want to omit the file extension for includegraphics, but this does not // work when the filename contains other dots. // Idea from http://www.tex.ac.uk/cgi-bin/texfaq2html?label=unkgrfextn @@ -908,6 +945,17 @@ void LaTeXFeatures::getFontEncodings(vector & encodings) const } } + +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[] = { @@ -915,7 +963,6 @@ char const * simplefeatures[] = { "array", "verbatim", "longtable", - "rotating", "latexsym", "pifont", // subfig is handled in BufferParams.cpp @@ -927,7 +974,6 @@ char const * simplefeatures[] = { the `float' package. See the caption package documentation for explanation.*/ "float", - "rotfloat", "wrapfig", "booktabs", "dvipost", @@ -937,6 +983,7 @@ char const * simplefeatures[] = { "framed", "soul", "textcomp", + "dingbat", "pmboxdraw", "bbding", "ifsym", @@ -949,7 +996,6 @@ char const * simplefeatures[] = { // "cancel", "ascii", "url", - "covington", "csquotes", "enumitem", "endnotes", @@ -974,7 +1020,7 @@ char const * simplefeatures[] = { "todonotes", "forest", "varwidth", - "footnote", + "environ" }; char const * bibliofeatures[] = { @@ -1097,6 +1143,22 @@ 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 + || 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 @@ -1181,6 +1243,16 @@ string const LaTeXFeatures::getPackages() const << "]{graphicx}\n"; } + // These must be loaded after graphicx, since they try + // to load graphicx without options + if (mustProvide("rotating")) + packages << "\\usepackage{rotating}\n"; + if (mustProvide("rotfloat")) + packages << "\\usepackage{rotfloat}\n"; + // and this must be loaded after rotating + if (mustProvide("tablefootnote")) + packages << "\\usepackage{tablefootnote}\n"; + // lyxskak.sty --- newer chess support based on skak.sty if (mustProvide("chess")) packages << "\\usepackage[ps,mover]{lyxskak}\n"; @@ -1231,7 +1303,11 @@ string const LaTeXFeatures::getPackages() const // Some classes load natbib themselves, but still allow (or even require) // plain numeric citations (ReVTeX is such a case, see bug 5182). // This special case is indicated by the "natbib-internal" key. - if (mustProvide("natbib") && !isProvided("natbib-internal")) { + if (mustProvide("natbib") + && !isProvided("natbib-internal") + && !isProvided("biblatex") + && !isProvided("biblatex-natbib") + && !isProvided("jurabib")) { packages << "\\usepackage["; if (params_.citeEngineType() == ENGINE_TYPE_NUMERICAL) packages << "numbers"; @@ -1250,7 +1326,11 @@ string const LaTeXFeatures::getPackages() const } // jurabib -- we need version 0.6 at least. - if (mustProvide("jurabib")) { + if (mustProvide("jurabib") + && !isProvided("natbib-internal") + && !isProvided("natbib") + && !isProvided("biblatex") + && !isProvided("biblatex-natbib")) { packages << "\\usepackage"; if (!params_.biblio_opts.empty()) packages << '[' << params_.biblio_opts << ']'; @@ -1317,6 +1397,9 @@ TexString LaTeXFeatures::getMacros() const macros << getPreambleSnippets(); } + if (mustProvide("xetexdashbreakstate")) + macros << "\\XeTeXdashbreakstate 0" << '\n'; + if (mustProvide("papersize")) { if (runparams_.flavor == OutputParams::LATEX || runparams_.flavor == OutputParams::DVILUATEX) @@ -1332,6 +1415,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")) @@ -1461,8 +1546,19 @@ TexString LaTeXFeatures::getMacros() const // greyed-out environment (note inset) // the color is specified in the routine // getColorOptions() to avoid LaTeX-package clashes - if (mustProvide("lyxgreyedout")) - macros << lyxgreyedout_def; + if (mustProvide("lyxgreyedout")) { + // We need different version for RTL (#8647) + if (hasRTLLanguage()) { + if (runparams_.flavor == OutputParams::LUATEX) + if (useBabel()) + macros << lyxgreyedout_luartl_babel_def; + else + macros << lyxgreyedout_luartl_def; + else + macros << lyxgreyedout_rtl_def; + } else + macros << lyxgreyedout_def; + } if (mustProvide("lyxdot")) macros << lyxdot_def << '\n';