When I run
\documentclass{article}
\usepackage{amsmath}
\usepackage[active, tightpage, displaymath]{preview}
\begin{document}
\begin{equation*}
1+2 = 3
\end{equation*}
\end{document}
I checked this question "Crop equations with preview package" but the solutions provided there, using external script or replace equations all inline, don't work for me because that image snippet will be used for Emacs auctex preview that automatically inserts "\usepackage[options...]{preview}
" to the original tex document, generate equation snippets, then overlay them on the equation strings making the editing like more WYSIWYG-ish.
Anyway, Emacs auctex variable preview-default-preamble
enables me to insert some custom strings to the preamble when it generates the preview images, so I was looking for something like
\renewcommand{\begin{equation*}}{\begin{math}\displaystyle}
\renewcommand{\end{equation*}}{\end{math}}
to be inserted to the preamble when I run preview-document
.
But those naively written \renewcommand
commands don't work of course. I know that I can use \renewcommand
or even \def
or \let
to redefine macros, but how can I do it for the macro with certain arguments? More directly,
What should I put in the preamble so that whenever the compiler sees
\begin{equation*}
it replaces it with\begin{math}\displaymath
and run it?
PS. This may look like an XY question, but I'm also interested in finding the solution because I have something else that I could do with that. :-)
\renewenvironment
etc and understand how LaTeX environments work.