diff --git a/src/ChangeLog b/src/ChangeLog index a791b44d1a..b65a681ce6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2004-04-26 Georg Baum + + * LaTeXFeatures.C, lyx_sty.[Ch]: add \lyxdot macro + 2003-09-24 Jean-Marc Lasgouttes * output_latex.C (TeXEnvironment): make sure that there is a line diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index 99bb39ee29..c19dd75417 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -377,6 +377,9 @@ string const LaTeXFeatures::getMacros() const if (isRequired("lyxgreyedout")) macros << lyxgreyedout_def; + if (isRequired("lyxdot")) + macros << lyxdot_def << '\n'; + // floats getFloatDefinitions(macros); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index bbff53fa77..3f3e4c711d 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2004-04-26 Georg Baum + + * insetgraphics.C (latex): strip the extension and replace dots in + the filename if doing a "nice" export. This is a partial fix for + bug 1231 without reintroducing bug 655. + 2004-04-19 Jean-Marc Lasgouttes * insetoptarg.h: remove the editable() method (InsetCollapsable diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 2b40892f5e..3f9f3465a3 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -93,6 +93,7 @@ using lyx::support::getExtFromContents; using lyx::support::IsFileReadable; using lyx::support::LibFileSearch; using lyx::support::rtrim; +using lyx::support::subst; using lyx::support::Systemcall; using lyx::support::unzipFile; using lyx::support::unzippedFileName; @@ -591,7 +592,16 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os, if (runparams.nice) { // a relative filename should be relative to the master // buffer. - latex_str += params().filename.outputFilename(m_buffer->filePath()); + string basename = params().filename.outputFilename(m_buffer->filePath()); + // Remove the extension so the LaTeX will use whatever + // is appropriate (when there are several versions in + // different formats) + if (!(IsFileReadable(file_ + ".eps") || IsFileReadable(file_ + ".ps"))) + basename = RemoveExtension(basename); + // This works only if the filename contains no dots besides + // the just removed one. We can fool here by replacing all + // dots with a macro whose definition is just a dot ;-) + latex_str += subst(basename, ".", "\\lyxdot "); } else if (file_exists) { // Make the filename relative to the lyx file // and remove the extension so the LaTeX will use whatever @@ -663,6 +673,17 @@ void InsetGraphics::validate(LaTeXFeatures & features) const features.require("graphicx"); + if (features.nice()) { + Buffer const * m_buffer = features.buffer().getMasterBuffer(); + string basename = + params().filename.outputFilename(m_buffer->filePath()); + string const file_ = params().filename.absFilename(); + if (!(IsFileReadable(file_ + ".eps") || IsFileReadable(file_ + ".ps"))) + basename = RemoveExtension(basename); + if (contains(basename, ".")) + features.require("lyxdot"); + } + if (params().subcaption) features.require("subfigure"); } diff --git a/src/lyx_sty.C b/src/lyx_sty.C index 0d754ea08d..ed25658d3e 100644 --- a/src/lyx_sty.C +++ b/src/lyx_sty.C @@ -126,3 +126,10 @@ string const tabularnewline_def = string const lyxgreyedout_def = "%% The greyedout annotation environment\n" "\\newenvironment{lyxgreyedout}{\\color[gray]{0.8}}{}\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 +string const lyxdot_def = + "%% A simple dot to overcome graphicx limitations\n" + "\\newcommand{\\lyxdot}{.}\n"; diff --git a/src/lyx_sty.h b/src/lyx_sty.h index d549735f5e..79c79a2952 100644 --- a/src/lyx_sty.h +++ b/src/lyx_sty.h @@ -52,5 +52,7 @@ extern std::string const mathcircumflex_def; extern std::string const tabularnewline_def; /// extern std::string const lyxgreyedout_def; +/// +extern std::string const lyxdot_def; #endif // LYX_STY_H