5

With AUCTeX and preview-latex, I can see the preview of math equations with C-c C-p C-p. But I can't see its LaTeX code.

I wonder how can I see both the code and preview of math equations at the same time, for WYSIWYG editing?

4

So first of all, there's no easy way to get to that outcome.

While it would certainly be possible to hack around preview-toggle to make the overlay that displays the preview image also display the underlying text, I do believe that the design choice in AucTeX makes sense.

The reason is that previews are generated on demand, whenever the image needs to be displayed, and that generation can be quite compute-intensive. So intensive that regenerating images after each text change (which would be what's really needed to get true WYSIWYG) is generally not practical.

So the only reasonably easy change would be to keep displaying a potentially outdated image alongside it's source text, which might be more confusing that helpful.

2

You might want to try WhizzyTeX mode that tries to compile latex code on the fly. It comprises of a minor mode for emacs along with a bash script which provides a preview in a separate dvi window. Note that it only supports *nix platforms (no windows) and that too only in dvi mode. It also recommends using advi instead of xdvi to view generated dvi files. Disclaimer : I have not used this mode since a long time.

1

Put the following advices into your init-file and restart emacs.

In auctex buffers with preview the preview-icon is replaced with the last preview-image so you can see the last generated preview while you edit the equation.

(require 'preview)

(defadvice preview-inactive-string (around preview-show-old nil activate)
  "Show old preview when editing source code."
  (declare (special preview-icon)) ;; preview-icon is a local variable defined by preview-mode
  (when (overlay-get ov 'preview-state)
    (let ((preview-icon (or (car-safe (overlay-get ov 'preview-image)) preview-icon)))
      (overlay-put ov 'preview-old-image preview-icon)
      ad-do-it
      )))

(defadvice preview-disabled-string (around preview-show-old nil activate)
  "Show old preview when editing source code."
  (declare (special preview-icon))
  (when (overlay-get ov 'preview-state)
    (let ((preview-icon (or (overlay-get ov 'preview-old-image) preview-icon)))
      ad-do-it
      )))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.