Le 01/06/2015 18:16, Enrico Forestieri a écrit :
On Mon, Jun 01, 2015 at 03:50:49PM +0200, Enrico Forestieri wrote:
On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
2) In master, preview incorrectly calls latex instead of pdflatex if the
default output format is set to "default". More details in the attached
lyx-bug-microtype.lyx. (It causes the instant preview to fail, while the
"default" (pdflatex) compilation with Ctrl+R succeeds.)
Stable also fails because it seems to call latex instead of pdflatex all the
time, but it does not appear to be a regression wrt 2.1.3.
Note that we have to guarantee backward compatibility and using latex
when the document does not specify a default output format is a must,
otherwise instant preview may fail for existing documents.
See #9371 for details.
When using pdflatex (or other formats producing a pdf) for generating
the previews, the legacy method is used. It turns out to be much slower
than the dvipng route, so that care is taken to try to use dvi output for
all previews not failing and then trying pdflatex for those that fail.
For some reason, the failure you report escapes those checks. So, this
reason should be identified and accordingly corrected. Typically, in
open source projects one can suggest a patch to speed up the correction
of an issue.
I had a closer look at this issue and it turned out to be as follows.
If a snippet produces latex errors it is now not previewed at all.
Now, when using the microtype package in dvi mode, latex issues an
error about not finding the tfm file for a font, but nevertheless
goes on and produces a correct output. This error is issued only at
the beginning so that it associated with the first snippet, which is
for this reason marked as bad. Actually, the script generates a valid
preview but it is not used. All other snippets are used, so only the
first one is omitted even if it would be Ok.
There are 2 possible solutions. The first one is omitting the microtype
package for the sake of generating the previews by using the faster
dvipng method (attached patch no-microtype.diff for master).
The second one is forcing the use of pdflatex when the use of microtype
is detected. In this case the slower legacy mathod will be used for
generating the previews (attached patch yes-microtype.diff for master).
Please, vote for the one or the other. I will commit the patch getting
more votes.
I do not think that treating microtype as a special case is the way to
go. First, the issue is with the option "expansion=true". Without this
option, microtype correctly works with latex and correctly activates
expansion with pdflatex.
This was more to illustrate the fact that it is a great new feature in
master to compile the previews using the default output format because
of many small details like this error. For instance, although this seems
easy to fix now that I understood the issue (just remove the option
expansion=true, or set the default output format to pdflatex) it really
took me a while to figure this out (partly because it is hard to access
the error messages for the instant preview).
As I described, I think the issue is regarding the meaning of "Default
output format: Default". For the Ctrl+R shortcut, this means pdflatex
while for instant preview this means latex. I don't understand the
backwards-compatibility argument here, I think that it is safer to use
the same default format as Ctrl+R in all cases.
This looks like a small detail, but for a general user, setting
explicitly "default output format: PDF (pdflatex)" does not appear as an
obvious solution to "instant preview does not work". And the error can
always be more fatal than this error with microtype.
IF the inconsistency regarding the meaning of "Default output format:
Default" is intended for performance reason and that I did not make you
change your mind, then I vote for:
> omitting the microtype
> package for the sake of generating the previews by using the faster
> dvipng method
But again it is hard to guess that "default output format: default" has
this optimisation while "default output format: PDF (pdflatex)" does
not. (But at least there is the option to force the use of pdflatex by
instant preview if really needed.)
By the way, a safer way to force not loading a package is to prepend
\usepackage with "\@namedef{[email protected]}{9999/12/31}". If you just
strip the line from the preamble you can easily run into troubles. In
addition, at some point I had it on two lines like this (note the %):
\usepackage[protrusion=true%,expansion=false
]{microtype}
in which case your regexp fails if I understood correctly. I suggest
just adding "\@namedef{[email protected]}{9999/12/31}" before the
preamble whether we suspect that microtype is used or not, without
testing for its presence. (Unless you see other errors this might generate.)
Again the philosophy of my comment is not "please deal explicitly with
these corner cases" but "it's better to take the safe route".
I really like the direction of the new patches trying to make instant
preview "just work", I hope that my tests and comments help you in this
regard.
I also noticed that when microtype is used in dvi mode latex takes a
lot more of time to process the same file. Maybe this is the cause of
the slowdown observed by Guillaume.
You may be right that microtype may have been the reason why I had the
impression that latex is slower than pdflatex, but this does not account
for the 55s (on a good computer) during which LyX is frozen while
generating the 16MB tex file. I will run tests again to confirm (and
also test the new patch) and will reply to the previous message in a
short while. (BTW yes I have epstopdf and pdfcairo.)
Guillaume