]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.cpp
Correct the mess introduced in r33250.
[lyx.git] / src / LaTeXFeatures.cpp
index e39dc92bb7d15cfd1dc44a1d6fb9ee26f0754f4b..1629186280413fe8ba5d87bcd18f183f107ed095 100644 (file)
@@ -182,12 +182,12 @@ static docstring const changetracking_dvipost_def = from_ascii(
 
 static docstring const changetracking_xcolor_ulem_def = from_ascii(
        "%% Change tracking with ulem\n"
-       "\\newcommand{\\lyxadded}[3]{{\\color{lyxadded}#3}}\n"
+       "\\newcommand{\\lyxadded}[3]{{\\color{lyxadded}{}#3}}\n"
        "\\newcommand{\\lyxdeleted}[3]{{\\color{lyxdeleted}\\sout{#3}}}\n");
 
 static docstring const changetracking_xcolor_ulem_hyperref_def = from_ascii(
        "%% Change tracking with ulem\n"
-       "\\newcommand{\\lyxadded}[3]{{\\texorpdfstring{\\color{lyxadded}}{}#3}}\n"
+       "\\newcommand{\\lyxadded}[3]{{\\texorpdfstring{\\color{lyxadded}{}}{}#3}}\n"
        "\\newcommand{\\lyxdeleted}[3]{{\\texorpdfstring{\\color{lyxdeleted}\\sout{#3}}{}}}\n");
 
 static docstring const changetracking_none_def = from_ascii(
@@ -195,8 +195,11 @@ static docstring const changetracking_none_def = from_ascii(
        "\\newcommand{\\lyxdeleted}[3]{}\n");
 
 static docstring const textgreek_def = from_ascii(
-       "\\DeclareRobustCommand{\\greektext}{%\n"
-       "  \\fontencoding{LGR}\\selectfont\\def\\encodingdefault{LGR}}\n"
+       "\\providecommand*{\\perispomeni}{\\char126}\n"
+       "\\AtBeginDocument{\\DeclareRobustCommand{\\greektext}{%\n"
+       "  \\fontencoding{LGR}\\selectfont\\def\\encodingdefault{LGR}%\n"
+       "  \\renewcommand{\\~}{\\perispomeni}%\n"
+       "}}\n"
        "\\DeclareRobustCommand{\\textgreek}[1]{\\leavevmode{\\greektext #1}}\n"
        "\\DeclareFontEncoding{LGR}{}{}\n");
 
@@ -365,12 +368,10 @@ void LaTeXFeatures::useInsetLayout(InsetLayout const & lay)
 {
        docstring const & lname = lay.name();
        DocumentClass const & tclass = params_.documentClass();
-       if (!tclass.hasInsetLayout(lname)) {
-               lyxerr << "LaTeXFeatures::useInsetLayout: layout `"
-                      << to_utf8(lname) << "' does not exist in this class"
-                      << endl;
+
+       // this is a default inset layout, nothing useful here
+       if (!tclass.hasInsetLayout(lname))
                return;
-       }
        // Is this layout already in usedInsetLayouts?
        if (find(usedInsetLayouts_.begin(), usedInsetLayouts_.end(), lname) 
                        != usedInsetLayouts_.end())
@@ -640,7 +641,7 @@ string const LaTeXFeatures::getPackages() const
        // the document does not contain integrals (then isRequired("esint")
        // is false) or if esint is used, since esint redefines all relevant
        // integral symbols from wasysym and amsmath.
-       // See http://bugzilla.lyx.org/show_bug.cgi?id=1942
+       // See http://www.lyx.org/trac/ticket/1942
        if (mustProvide("wasysym") &&
            (params_.use_esint != BufferParams::package_off || !isRequired("esint")))
                packages << "\\usepackage{wasysym}\n";
@@ -744,7 +745,8 @@ string const LaTeXFeatures::getPackages() const
                packages << "\\PassOptionsToPackage{normalem}{ulem}\n"
                            "\\usepackage{ulem}\n";
 
-       if (mustProvide("mhchem"))
+       if (mustProvide("mhchem") &&
+               params_.use_mhchem != BufferParams::package_off)
                packages << "\\PassOptionsToPackage{version=3}{mhchem}\n"
                            "\\usepackage{mhchem}\n";
 
@@ -763,18 +765,27 @@ string const LaTeXFeatures::getPackages() const
 }
 
 
+string LaTeXFeatures::getPreambleSnippets() const 
+{
+       ostringstream snip;
+       SnippetList::const_iterator pit  = preamble_snippets_.begin();
+       SnippetList::const_iterator pend = preamble_snippets_.end();
+       for (; pit != pend; ++pit)
+               snip << *pit << '\n';
+       return snip.str();
+}
+
+
 docstring const LaTeXFeatures::getMacros() const
 {
        odocstringstream macros;
 
-       if (!preamble_snippets_.empty())
+       if (!preamble_snippets_.empty()) {
                macros << '\n';
-       SnippetList::const_iterator pit  = preamble_snippets_.begin();
-       SnippetList::const_iterator pend = preamble_snippets_.end();
-       for (; pit != pend; ++pit)
-               macros << *pit << '\n';
+               macros << from_utf8(getPreambleSnippets());
+       }
 
-        if (mustProvide("papersize")) {
+       if (mustProvide("papersize")) {
                if (runparams_.flavor == OutputParams::LATEX)
                        macros << papersizedvi_def << '\n';
                else
@@ -793,8 +804,19 @@ docstring const LaTeXFeatures::getMacros() const
        if (mustProvide("lyxarrow"))
                macros << lyxarrow_def << '\n';
 
-       if (mustProvide("textgreek"))
-               macros << textgreek_def << '\n';
+       if (mustProvide("textgreek")) {
+               // Avoid a LaTeX error if times fonts are used and the grtimes
+               // package is installed but actual fonts are not (bug 6469).
+               if (params_.fontsRoman == "times")
+                       macros << subst(textgreek_def,
+                                       from_ascii("\\greektext #1"),
+                                       from_ascii("%\n  \\IfFileExists"
+                                                  "{grtm10.tfm}{}{\\fontfamily"
+                                                  "{cmr}}\\greektext #1"))
+                              << '\n';
+               else
+                       macros << textgreek_def << '\n';
+       }
 
        if (mustProvide("textcyr"))
                macros << textcyr_def << '\n';