# Redefine commands / Remove left spacing for equations in LaTeX Preview (also in Emacs AUCTeX)

When I run

\documentclass{article}

\usepackage{amsmath}
\usepackage[active, tightpage, displaymath]{preview}

\begin{document}

\begin{equation*}
1+2 = 3
\end{equation*}

\end{document}

I get the following result

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.


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. :-)

• You may find it useful to read up on \renewenvironment etc and understand how LaTeX environments work. – ShreevatsaR Dec 12 '20 at 3:59