]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.cpp
Remove hardcoded values
[lyx.git] / src / LaTeXFeatures.cpp
index cab81caaddae606214e880cac3ed7f23c5fc8a0b..4c993b6f7b9c55041a4a08e1e9b2f0490b5725d2 100644 (file)
@@ -118,6 +118,25 @@ static docstring const guilsinglright_def = from_ascii(
        "  {\\usefont{U}{lasy}{m}{n}\\char'51}%\n"
        "}");
 
+static docstring const textquotedbl_def = from_ascii(
+       "\\DeclareTextSymbolDefault{\\textquotedbl}{T1}");
+
+static docstring const textquotedblp_xetex_def = from_ascii(
+       "\\providecommand\\textquotedblplain{%\n"
+       "  \\bgroup\\addfontfeatures{Mapping=}\\textquotedbl\\egroup}");
+
+static docstring const textquotedblp_luatex_def = from_ascii(
+       "\\providecommand\\textquotedblplain{%\n"
+       "  \\bgroup\\addfontfeatures{RawFeature=-tlig}\\textquotedbl\\egroup}");
+
+static docstring const textquotesinglep_xetex_def = from_ascii(
+       "\\providecommand\\textquotesingleplain{%\n"
+       "  \\bgroup\\addfontfeatures{Mapping=}\\textquotesingle\\egroup}");
+
+static docstring const textquotesinglep_luatex_def = from_ascii(
+       "\\providecommand\\textquotesingleplain{%\n"
+       "  \\bgroup\\addfontfeatures{RawFeature=-tlig}\\textquotesingle\\egroup}");
+
 static docstring const paragraphleftindent_def = from_ascii(
        "\\newenvironment{LyXParagraphLeftIndent}[1]%\n"
        "{\n"
@@ -193,12 +212,25 @@ static docstring const changetracking_dvipost_def = from_ascii(
 static docstring const changetracking_xcolor_ulem_def = from_ascii(
        "%% Change tracking with ulem\n"
        "\\DeclareRobustCommand{\\lyxadded}[3]{{\\color{lyxadded}{}#3}}\n"
-       "\\DeclareRobustCommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\sout{#3}}}\n");
+       "\\DeclareRobustCommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\lyxsout{#3}}}\n"
+       "\\DeclareRobustCommand{\\lyxsout}[1]{\\ifx\\\\#1\\else\\sout{#1}\\fi}\n");
 
 static docstring const changetracking_xcolor_ulem_hyperref_def = from_ascii(
        "%% Change tracking with ulem\n"
        "\\DeclareRobustCommand{\\lyxadded}[3]{{\\texorpdfstring{\\color{lyxadded}{}}{}#3}}\n"
-       "\\DeclareRobustCommand{\\lyxdeleted}[3]{{\\texorpdfstring{\\color{lyxdeleted}\\sout{#3}}{}}}\n");
+       "\\DeclareRobustCommand{\\lyxdeleted}[3]{{\\texorpdfstring{\\color{lyxdeleted}\\lyxsout{#3}}{}}}\n"
+       "\\DeclareRobustCommand{\\lyxsout}[1]{\\ifx\\\\#1\\else\\sout{#1}\\fi}\n");
+
+static docstring const changetracking_tikz_math_sout_def = from_ascii(
+       "%% Strike out display math with tikz\n"
+       "\\usepackage{tikz}\n"
+       "\\usetikzlibrary{calc}\n"
+       "\\newcommand{\\lyxmathsout}[1]{%\n"
+       "  \\tikz[baseline=(math.base)]{\n"
+       "    \\node[inner sep=0pt,outer sep=0pt](math){#1};\n"
+       "    \\draw($(math.south west)+(2em,.5em)$)--($(math.north east)-(2em,.5em)$);\n"
+       "  }\n"
+       "}\n");
 
 static docstring const changetracking_none_def = from_ascii(
        "\\newcommand{\\lyxadded}[3]{#3}\n"
@@ -314,6 +346,23 @@ static docstring const textbaltic_def = from_ascii(
         "\\DeclareTextCompositeCommand{\\c}{T1}{r}{\\textcommabelow{r}}\n"
         "\\DeclareTextCompositeCommand{\\c}{T1}{R}{\\textcommabelow{R}}\n");
 
+// split-level fractions
+static docstring const xfrac_def = from_ascii(
+          "\\usepackage{xfrac}\n");
+static docstring const smallLetterFrac_def = from_ascii(
+        "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{default}{text}\n"
+               "  {phantom=c, scale-factor=1.0, slash-left-kern=-.05em}\n"
+               "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{lmr}{text}\n"
+               "  {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
+               "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{lmss}{text}\n"
+               "  {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
+               "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{cmr}{text}\n"
+               "  {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
+               "\\DeclareCollectionInstance{smallLetterFrac}{xfrac}{cmss}{text}\n"
+               "  {slash-symbol-font=ptm, phantom=c, scale-factor=1, slash-left-kern=-.05em}\n"
+               "\\newcommand{\\smallLetterFrac}[2]{%\n"
+               "  {\\UseCollection{xfrac}{smallLetterFrac}\\sfrac{#1}{#2}}}\n");
+
 static docstring const lyxref_def = from_ascii(
                "\\RS@ifundefined{subsecref}\n"
                "  {\\newref{subsec}{name = \\RSsectxt}}\n"
@@ -390,7 +439,8 @@ static docstring const lyxstrikeout_style = from_ascii(
 
 LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p,
                             OutputParams const & r)
-       : buffer_(&b), params_(p), runparams_(r), in_float_(false)
+       : buffer_(&b), params_(p), runparams_(r), in_float_(false),
+         in_deleted_inset_(false)
 {}
 
 
@@ -722,6 +772,42 @@ bool LaTeXFeatures::hasPolyglossiaExclusiveLanguages() const
 }
 
 
+vector<string> LaTeXFeatures::getPolyglossiaExclusiveLanguages() const
+{
+       vector<string> result;
+       // first the main language
+       if (params_.language->isPolyglossiaExclusive())
+               result.push_back(params_.language->display());
+       // now the secondary languages
+       LanguageList::const_iterator const begin = UsedLanguages_.begin();
+       for (LanguageList::const_iterator cit = begin;
+            cit != UsedLanguages_.end();
+            ++cit) {
+               if ((*cit)->isPolyglossiaExclusive())
+                       result.push_back((*cit)->display());
+       }
+       return result;
+}
+
+
+vector<string> LaTeXFeatures::getBabelExclusiveLanguages() const
+{
+       vector<string> result;
+       // first the main language
+       if (params_.language->isBabelExclusive())
+               result.push_back(params_.language->display());
+       // now the secondary languages
+       LanguageList::const_iterator const begin = UsedLanguages_.begin();
+       for (LanguageList::const_iterator cit = begin;
+            cit != UsedLanguages_.end();
+            ++cit) {
+               if ((*cit)->isBabelExclusive())
+                       result.push_back((*cit)->display());
+       }
+       return result;
+}
+
+
 string LaTeXFeatures::getBabelLanguages() const
 {
        ostringstream languages;
@@ -743,15 +829,16 @@ string LaTeXFeatures::getBabelLanguages() const
 }
 
 
-std::map<std::string, std::string> LaTeXFeatures::getPolyglossiaLanguages() const
+set<string> LaTeXFeatures::getPolyglossiaLanguages() const
 {
-       std::map<std::string, std::string> languages;
+       set<string> languages;
 
        LanguageList::const_iterator const begin = UsedLanguages_.begin();
        for (LanguageList::const_iterator cit = begin;
             cit != UsedLanguages_.end();
             ++cit) {
-               languages[(*cit)->polyglossia()] = (*cit)->polyglossiaOpts();
+               // We do not need the variants here
+               languages.insert((*cit)->polyglossia());
        }
        return languages;
 }
@@ -863,7 +950,7 @@ char const * simplefeatures[] = {
        "fixme",
        "todonotes",
        "forest",
-       "varwidth"
+       "varwidth",
 };
 
 char const * bibliofeatures[] = {
@@ -1222,7 +1309,7 @@ TexString LaTeXFeatures::getMacros() const
                macros << lyxarrow_def << '\n';
 
        if (!usePolyglossia() && mustProvide("textgreek")) {
-               // ensure LGR font encoding is defined also if fontenc is not loaded by LyX
+           // ensure LGR font encoding is defined also if fontenc is not loaded by LyX
                if (params_.font_encoding() == "default")
                        macros << textgreek_LGR_def;
                macros << textgreek_def << '\n';
@@ -1235,7 +1322,7 @@ TexString LaTeXFeatures::getMacros() const
                macros << textcyr_def << '\n';
        }
 
-        // non-standard text accents:
+       // non-standard text accents:
        if (mustProvide("textcommaabove") || mustProvide("textcommaaboveright") ||
            mustProvide("textcommabelow") || mustProvide("textbaltic"))
                macros << lyxaccent_def;
@@ -1252,6 +1339,13 @@ TexString LaTeXFeatures::getMacros() const
        if (mustProvide("textbaltic"))
                macros << textbaltic_def << '\n';
 
+       // split-level fractions
+       if (mustProvide("xfrac") || mustProvide("smallLetterFrac"))
+               macros << xfrac_def << '\n';
+
+       if (mustProvide("smallLetterFrac"))
+               macros << smallLetterFrac_def << '\n';
+
        if (mustProvide("lyxmathsym"))
                macros << lyxmathsym_def << '\n';
 
@@ -1298,6 +1392,20 @@ TexString LaTeXFeatures::getMacros() const
                macros << guillemotleft_def << '\n';
        if (mustProvide("guillemotright"))
                macros << guillemotright_def << '\n';
+       if (mustProvide("textquotedbl"))
+               macros << textquotedbl_def << '\n';
+       if (mustProvide("textquotesinglep")) {
+               if (runparams_.flavor == OutputParams::XETEX)
+                       macros << textquotesinglep_xetex_def << '\n';
+               else
+                       macros << textquotesinglep_luatex_def << '\n';
+       }
+       if (mustProvide("textquotedblp")) {
+               if (runparams_.flavor == OutputParams::XETEX)
+                       macros << textquotedblp_xetex_def << '\n';
+               else
+                       macros << textquotedblp_luatex_def << '\n';
+       }
 
        // Math mode
        if (mustProvide("binom") && !isRequired("amsmath"))
@@ -1353,6 +1461,9 @@ TexString LaTeXFeatures::getMacros() const
                        macros << changetracking_xcolor_ulem_def;
        }
 
+       if (mustProvide("ct-tikz-math-sout"))
+                       macros << changetracking_tikz_math_sout_def;
+
        if (mustProvide("ct-none"))
                macros << changetracking_none_def;