François Poulain <[email protected]> writes:

> Hi,
>
> I encounter errors when I try to use the preview LaTeX package on the
> macro or environments with math mode. For example, the following file
> does not compile:
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%
> \documentclass{article}
> \usepackage[active]{preview}
> \PreviewMacro[{{}{}}]{\frac}
>
> \begin{document}
>
> \[
>   x= \frac{\alpha}{\beta}
> \]
>
> \end{document}
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%

> I guess this is relyed to the math mode, but I don't know how to deal
> with. I tried to add @{\ensuremath} in the PreviewMacro options, but it
> didn't work.
>
> Notice that, as far as possible, I don't want to preview the entire
> equation environment, but only a part of it.
>
> Any idea?

Well, the preview stuff is funneled off for separate typesetting, and
you need to get the math mode back into it.  I get nice results for
preview-latex (namely C-c C-p C-d inside of Emacs/AUCTeX) with

\documentclass{article}
\usepackage{preview}
\PreviewMacro[{{}{}}][$\displaystyle #1$]{\frac}

\begin{document}

\[
  x= \frac{\alpha}{\beta}
\]

\end{document}
Depending on your needs, you might consider using \[#1\] in the optional
argument instead, but that gives a full-length display math environment
with indentation and spacing that's less suited for previewing.

-- 
David Kastrup
_______________________________________________
auctex mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex

Reply via email to