]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetGraphics.cpp
Re-fix #2005
[features.git] / src / insets / InsetGraphics.cpp
index 15c87e4e5e98aab81b2f901f28dfa2ef9b3c99ac..04edf265a87ecf7e8bef12754baf30becde15a1f 100644 (file)
@@ -109,7 +109,7 @@ namespace {
 /// Note that \p format may be unknown (i. e. an empty string)
 string findTargetFormat(string const & format, OutputParams const & runparams)
 {
-       // Are we using latex or XeTeX/LuaTeX/pdflatex?
+       // Are we latexing to DVI or PDF?
        if (runparams.flavor == OutputParams::PDFLATEX
            || runparams.flavor == OutputParams::XETEX
            || runparams.flavor == OutputParams::LUATEX) {
@@ -586,8 +586,14 @@ copyToDirIfNeeded(DocFileName const & file, string const & dir)
                // extension removed, because base.eps and base.eps.gz may
                // have different content but would get the same mangled
                // name in this case.
+               // Also take into account that if the name of the zipped file
+               // has no zip extension then the name of the unzipped one is
+               // prefixed by "unzipped_".
                string const base = removeExtension(file.unzippedFileName());
-               string::size_type const ext_len = file_in.length() - base.length();
+               string::size_type const prefix_len =
+                       prefixIs(onlyFileName(base), "unzipped_") ? 9 : 0;
+               string::size_type const ext_len =
+                       file_in.length() + prefix_len - base.length();
                mangled[mangled.length() - ext_len] = '.';
        }
        FileName const file_out(makeAbsPath(mangled, dir));
@@ -835,18 +841,25 @@ void InsetGraphics::latex(otexstream & os,
        string before;
        string after;
 
-       if (runparams.moving_arg)
-               before += "\\protect";
-
-       // We never use the starred form, we use the "clip" option instead.
-       before += "\\includegraphics";
-
        // Write the options if there are any.
        bool const ps = runparams.flavor == OutputParams::LATEX
                || runparams.flavor == OutputParams::DVILUATEX;
        string const opts = createLatexOptions(ps);
        LYXERR(Debug::GRAPHICS, "\tOpts = " << opts);
 
+       if (contains(opts, '=') && contains(runparams.active_chars, '=')) {
+               // We have a language that makes = active. Deactivate locally
+               // for keyval option parsing (#2005).
+               before = "\\begingroup\\catcode`\\=12";
+               after = "\\endgroup";
+       }
+
+       if (runparams.moving_arg)
+               before += "\\protect";
+
+       // We never use the starred form, we use the "clip" option instead.
+       before += "\\includegraphics";
+
        if (!opts.empty() && !message.empty())
                before += ('[' + opts + ',' + message + ']');
        else if (!opts.empty() || !message.empty())