auctex-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-devel] preview-latex, dvipng, and LyX


From: Enrico Forestieri
Subject: [AUCTeX-devel] preview-latex, dvipng, and LyX
Date: Fri, 6 Jan 2006 02:50:35 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Hello,

sorry if this is not the right list. In this case, please, redirect me
to the right one.

As you know, LyX (http://www.lyx.org) uses both the preview-latex package
and dvipng to display snippet previews of LaTeX math formulas. In order
to do so it also relies on the output (stdout) of dvipng to capture the
snippet number and its height and depth.

However, in recent versions of preview-latex and dvipng the output
devised for LyX's sake gets corrupted in the following way:

$ dvipng ...
This is dvipng 1.7 Copyright 2002-2005 Jan-Ake Larsson
[1 (preview-latex version 11.81) depth=6 height=16]

this output confuses the script LyX uses for generating preview
snippets, which, instead, is expecting an output like this:

$ dvipng ...
This is dvipng 1.7 Copyright 2002-2005 Jan-Ake Larsson
[1 depth=6 height=16]

I found that the problem is due to both recent versions of preview-latex
and dvipng. For example, this problem doesn't show up in debian testing
but manifests itself on Windows with MikTeX (where a more recent version
of preview.sty is installed).

Here is the relevant part of the diff between the versions of preview.sty
in debian tetex and in MikTeX:

$ diff -u preview.sty.tetex preview.sty.miktex
...
@@ -83,6 +85,7 @@
 \DeclareOption{dvips}{%
   address@hidden@ne
   address@hidden
+      \special{!/address@hidden(address@hidden)def}
       \special{!userdict begin/preview-bop-level 0 def%
       /bop-hook{/preview-bop-level dup load dup 0 le{/isls false def%
           /vsize 792 def/hsize 612 def}if 1 add store}bind def%
...


and here is the relevant code in the dvipng (version 1.7) special.c source
file causing the problem:


  if (strncmp(buffer,"!/address@hidden(",18)==0) {
    buffer+=18;
    length-=18;
    while (length>0 && buffer[length]!=')')
      length--;
    if (page_imagep==NULL)
      Message(BE_NONQUIET," (preview-latex version %.*s)",length,buffer);
    return;
  }

  /* preview-latex' tightpage option */
  if (strncmp(buffer,"!/address@hidden",19)==0) {
    buffer+=19;
    SKIPSPACES(buffer);
    if (strncmp(buffer,"true",4)==0) {
      if (page_imagep==NULL)
        Message(BE_NONQUIET," (preview-latex tightpage option detected,\
 will use its bounding box)");
      flags |= PREVIEW_LATEX_TIGHTPAGE;
      return;
    }
  }
  if (strncmp(buffer,"!userdict",9)==0
      && strstr(buffer+10,"7{currentfile token not{stop}if 65781.76 div")!=NULL)
 {
    if (page_imagep==NULL && ~flags & PREVIEW_LATEX_TIGHTPAGE)
      Message(BE_NONQUIET," (preview-latex <= 0.9.1 tightpage option detected,\
 will use its bounding box)");
    flags |= PREVIEW_LATEX_TIGHTPAGE;
    return;
  }


As a solution, it would suffice to replace BE_NONQUIET with
BE_VERBOSE in the code snippet above, such as to not clutter stdout
between "[1 " and "depth=...]".

I would like to ask if this acceptable for you, or, in case it is not,
if you can suggest an alternative. In this regard, what it is important
is that nothing goes inside "[" ... "]" except snippet number and depth
and height information.

A second problem that I noticed is that when a font is missing and
mktexpk (or alike) gets called to generate it, its stdout gets intermixed
with that of dvipng, causing a similar (but worse) confusion.

Is it possible to have the stdout of those helper programs redirected to
stderr?

Thank you for your attention.

--
Enrico







reply via email to

[Prev in Thread] Current Thread [Next in Thread]