Re: tex2lyx for windows update
> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes: Georg> Angus, Jean-Marc, what shall I do now? Georg> - nothing - apply my patch - implement the suggestion above Apply the patch, then. JMarc
Re: tex2lyx for windows update
Georg Baum wrote: > Angus, Jean-Marc, what shall I do now? > > - nothing > - apply my patch I quite liked this. > - implement the suggestion above Implementing the suggestion above implies a change of behaviour. LyX currently does not mind if the graphic cannot be found. > I don't care very much, but would like to come to a conclusion. My personal preference is to apply the patch. There, you asked. -- Angus
Re: tex2lyx for windows update
Jean-Marc Lasgouttes wrote: >> "Georg" == Georg Baum >> <[EMAIL PROTECTED]> >> writes: > > Georg> An alternative that is also sensible IMHO is to create the > Georg> normal output and let latex export fail if the file is missing. > Georg> Normally this means that something is wrong, and if somebody > Georg> includes a graphic without actually having the file on purpose > Georg> he could as well put this inside a comment box. I did run into > Georg> this situation several times already when I copied the document > Georg> and forgot to copy the figures. If the latex export would fail > Georg> one could detect such situations more easily. > > Indeed. Moreover, it is possible to insert errors in the error > browser, so that people can have a look at them. Angus, Jean-Marc, what shall I do now? - nothing - apply my patch - implement the suggestion above I don't care very much, but would like to come to a conclusion. Georg
Re: tex2lyx for windows update
> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes: Georg> An alternative that is also sensible IMHO is to create the Georg> normal output and let latex export fail if the file is missing. Georg> Normally this means that something is wrong, and if somebody Georg> includes a graphic without actually having the file on purpose Georg> he could as well put this inside a comment box. I did run into Georg> this situation several times already when I copied the document Georg> and forgot to copy the figures. If the latex export would fail Georg> one could detect such situations more easily. Indeed. Moreover, it is possible to insert errors in the error browser, so that people can have a look at them. JMarc
Re: tex2lyx for windows update
Jean-Marc Lasgouttes wrote: > I only have one doubt: when running tex2lyx on the file, do you get > the original LyX settings back? No, because the draft options are added. But you can't get the original LyX settings in many other cases either, so this is no problem IMHO. Example: LyX file includes x.png -> TeX file contains \includegraphics{x}, and we have both x.png and x.eps. tex2lyx can't determine the original file, it could only do some guesswork "if both x.png and x.eps exist, x.png is probably the origiunal file". But I don't want it to do that by default, because this guess could be wrong and this might lead to data loss if the newly created LyX file is exported to TeX again. Included graphics are one of the few cases where the TeX file does not carry enough information to reconstruct the LyX file (note insets are another, we have a bug report for this). Georg
Re: tex2lyx for windows update
> "Georg" == Georg Baum <[EMAIL PROTECTED]> writes: Georg> Am Mittwoch, 16. Februar 2005 22:48 schrieb Angus Leeming: >> After the third or fourth loop, latex fails to process the file. Georg> Well, what do you expect? If I specify that a nonexisting Georg> figure should be included I tell LyX/LaTeX to do something Georg> impossible. Since I agree in general that playing too many nice Georg> tricks is bad, I propose the attached patch. The filename can Georg> of course have the wrong extension and may be relative to the Georg> child doc instead of the master doc, but I would rather not Georg> change prepareFile(). Is this patch OK? I only have one doubt: when running tex2lyx on the file, do you get the original LyX settings back? JMarc
Re: tex2lyx for windows update
Georg Baum wrote: > Am Mittwoch, 16. Februar 2005 22:48 schrieb Angus Leeming: > >> After the third or fourth loop, latex fails to process the file. > > Well, what do you expect? I expected it to fail. I was just pointing out that it actually did so. > If I specify that a nonexisting figure should > be included I tell LyX/LaTeX to do something impossible. Sure. > Since I agree in general that playing too many nice tricks is bad, I > propose the attached patch. The filename can of course have the wrong > extension and may be relative to the child doc instead of the master doc, > but I would rather not change prepareFile(). > Is this patch OK? It looks great to me. -- Angus
Re: tex2lyx for windows update
Am Mittwoch, 16. Februar 2005 22:48 schrieb Angus Leeming: > After the third or fourth loop, latex fails to process the file. Well, what do you expect? If I specify that a nonexisting figure should be included I tell LyX/LaTeX to do something impossible. Since I agree in general that playing too many nice tricks is bad, I propose the attached patch. The filename can of course have the wrong extension and may be relative to the child doc instead of the master doc, but I would rather not change prepareFile(). Is this patch OK? Georg diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/ChangeLog lyx-1.4-cvs/src/insets/ChangeLog --- lyx-1.4-clean/src/insets/ChangeLog 2005-02-15 20:46:44.0 +0100 +++ lyx-1.4-cvs/src/insets/ChangeLog 2005-02-17 19:50:58.0 +0100 @@ -1,3 +1,9 @@ +2005-02-17 Georg Baum <[EMAIL PROTECTED]> + + * insetgraphics.C (prepareFile): handle non-existing files + * insetgraphics.C (latex): remove special handling of non-existing + files + 2005-02-13 André Pönitz <[EMAIL PROTECTED]> * insettext.[Ch] (border_): new diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetgraphics.C lyx-1.4-cvs/src/insets/insetgraphics.C --- lyx-1.4-clean/src/insets/insetgraphics.C 2005-02-08 20:29:07.0 +0100 +++ lyx-1.4-cvs/src/insets/insetgraphics.C 2005-02-17 19:54:52.0 +0100 @@ -532,7 +540,10 @@ string const stripExtensionIfPossible(st string const InsetGraphics::prepareFile(Buffer const & buf, OutputParams const & runparams) const { - // We assume that the file exists (the caller checks this) + // The following code depends on non-empty filenames + if (params().filename.empty()) + return string(); + string const orig_file = params().filename.absFilename(); string const rel_file = params().filename.relFilename(buf.filePath()); @@ -549,6 +560,12 @@ string const InsetGraphics::prepareFile( // of include files Buffer const * m_buffer = buf.getMasterBuffer(); + // Return the output name if the file does not exist. + // We are not going to change the extension or using the name of the + // temporary file, the code is already complicated enough. + if (!IsFileReadable(orig_file)) + return params().filename.outputFilename(m_buffer->filePath()); + // We place all temporary files in the master buffer's temp dir. // This is possible because we use mangled file names. // This is necessary for DVI export. @@ -731,15 +747,10 @@ int InsetGraphics::latex(Buffer const & string latex_str = before + '{'; - if (file_exists) - // Convert the file if necessary. - // Remove the extension so the LaTeX will use whatever - // is appropriate (when there are several versions in - // different formats) - latex_str += prepareFile(buf, runparams); - else - latex_str += relative_file + " not found!"; - + // Convert the file if necessary. + // Remove the extension so LaTeX will use whatever is appropriate + // (when there are several versions in different formats) + latex_str += prepareFile(buf, runparams); latex_str += '}' + after; os << latex_str;
Re: tex2lyx for windows update
Georg Baum wrote: >> I thin this pretty printing should be removed and replaced if possible >> by something as simple as >> \includegraphics[draft, other options]{filename} >> >> We are playing too many nice tricks. > > The problem is that you need to specify 'draft', the file type and the > bounding box if the file does not exist, otherwise latex will fail. This > means that this document can't be used anyway to run latex if the file is > added subsequently. I think that the "not found" message is adequate in > this case, otherwise somebody looking at the document will not know why > the special options are there. > The fact that tex2lyx outputs a strange warning is not that important > IMHO. If somebody does not understand it, he will look at the file and > understand it then. After the third or fourth loop, latex fails to process the file. -- Angus
Re: tex2lyx for windows update
Am Mittwoch, 16. Februar 2005 17:13 schrieb Jean-Marc Lasgouttes: > > "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: > I thin this pretty printing should be removed and replaced if possible > by something as simple as > \includegraphics[draft, other options]{filename} > > We are playing too many nice tricks. The problem is that you need to specify 'draft', the file type and the bounding box if the file does not exist, otherwise latex will fail. This means that this document can't be used anyway to run latex if the file is added subsequently. I think that the "not found" message is adequate in this case, otherwise somebody looking at the document will not know why the special options are there. The fact that tex2lyx outputs a strange warning is not that important IMHO. If somebody does not understand it, he will look at the file and understand it then. An alternative that is also sensible IMHO is to create the normal output and let latex export fail if the file is missing. Normally this means that something is wrong, and if somebody includes a graphic without actually having the file on purpose he could as well put this inside a comment box. I did run into this situation several times already when I copied the document and forgot to copy the figures. If the latex export would fail one could detect such situations more easily. Georg
Re: tex2lyx for windows update
> "Angus" == Angus Leeming <[EMAIL PROTECTED]> writes: Angus> Angus Leeming wrote: >> $ ls -l *.dvi >> -rw-rw-r-- 1 angus angus 496736 Feb 15 22:33 UserGuide_13x.dvi >> -rw-rw-r-- 1 angus angus 496940 Feb 15 22:33 UserGuide_13x_2.dvi Angus> Repeating the loop (to get UserGuide_13x_3.dvi) I see these Angus> warnings: Angus> Warning: Could not find graphics file 'mobius.eps not found! Angus> not found!'. Warning: Could not find graphics file Angus> 'escher-lsd.eps not found! not found!'. Warning: Could not find Angus> graphics file 'platypus.eps not found! not found!'. Angus> (I'm running without the .eps files in place.) The pretty Angus> printing is causing us problems it would appear. I thin this pretty printing should be removed and replaced if possible by something as simple as \includegraphics[draft, other options]{filename} We are playing too many nice tricks. JMarc
Re: tex2lyx for windows update
Angus Leeming wrote: > As ever, this is pre-release software. Use at your own risk. > > Get it here (760kB): > http://www.devel.lyx.org/~leeming/tex2lyx_win32_15Feb05.zip I have removed the .zip file from this location and have placed it on the wiki instead. Find it, together with some notes, at http://wiki.lyx.org/LaTeX/LatexToLyx The page is a work-in-progress, so the section detailing how to build the package yourself is unfinished, but I hope that it will still be useful. As ever, feel free to comment, suggest, improve. Either here or to the wiki page itself. I'll try and post a package for Fedora Core 3 this evening. -- Angus
Re: tex2lyx for windows update
Angus Leeming wrote: > $ ls -l *.dvi > -rw-rw-r-- 1 angus angus 496736 Feb 15 22:33 UserGuide_13x.dvi > -rw-rw-r-- 1 angus angus 496940 Feb 15 22:33 UserGuide_13x_2.dvi Repeating the loop (to get UserGuide_13x_3.dvi) I see these warnings: Warning: Could not find graphics file 'mobius.eps not found! not found!'. Warning: Could not find graphics file 'escher-lsd.eps not found! not found!'. Warning: Could not find graphics file 'platypus.eps not found! not found!'. (I'm running without the .eps files in place.) The pretty printing is causing us problems it would appear. -- Angus
tex2lyx for windows update
As ever, this is pre-release software. Use at your own risk. Get it here (760kB): http://www.devel.lyx.org/~leeming/tex2lyx_win32_15Feb05.zip It will unzip to a directory LyX containing LyX/ bin/ reLyX tex2lyx.exe Resources/ lyx/ chkconfig.ltx configure credits lyxrc.defaults packages.lst textclass.lst layouts/ lyx2lyx/ lyx2lyx reLyX/ man/ man1/ reLyX.1 I've installed this as J:/Programs/LyX. This version allows us to have J:/Programs/LyX/bin in the PATH enabling tex2lyx to be executed as expected "tex2lyx foo.tex > foo_14x.lyx" More exitingly, the lyx -> tex -> lyx round trip is now much improved. Kudos to Georg Baum and to José Matos. The DVI files before and after conversion are now nearly identical: $ lyx-13x --export latex UserGuide_13x.lyx $ tex2lyx UserGuide_13x.tex > UserGuide_14x.lyx $ python J:/Programs/LyX/Resources/lyx/lyx2lyx/lyx2lyx \ --to 221 --output UserGuide_13x_2.lyx $ lyx-13x --export dvi UserGuide_13x.lyx $ lyx-13x --export dvi UserGuide_13x_2.lyx $ ls -l *.dvi -rw-rw-r-- 1 angus angus 496736 Feb 15 22:33 UserGuide_13x.dvi -rw-rw-r-- 1 angus angus 496940 Feb 15 22:33 UserGuide_13x_2.dvi Perhaps it's time to add a tex2lyx page to the wiki and to add these (linux also) packages to it? -- Angus