1

I define a new environment named myequation (later I would like to taylor it to my needs). I can use it the same way as the original equation environment, except that the text following \end{myequation} begins with an unwanted leading space. I can remove this unwanted space by writing \end{myequation}% instead of just \end{myequation}. In the following code equation (2) and (3) were produced using myequation. I would like to have a definition where there is no need for this trailing percentage sign (in case I forget it).

My example LaTeX document:

\documentclass{article}
\newenvironment{myequation}{\begin{equation}}{\end{equation}}
\setlength{\textwidth}{10em}
\setlength{\parindent}{0pt}
\begin{document}
III III III III III III
III III III III III III
\begin{equation}\alpha\beta\alpha\beta\alpha\beta\end{equation}
III III III III III III
III III III III III III
\begin{myequation}\alpha\beta\alpha\beta\alpha\beta\end{myequation}
% unwanted indentation here because of missing % after \end{myequation}
III III III III III III
III III III III III III
\begin{myequation}\alpha\beta\alpha\beta\alpha\beta\end{myequation}%
III III III III III III
III III III III III III
\end{document}

Is there a solution (ideally without having to load an additional package)?

1 Answer 1

4
\newenvironment{myequation}
 {\begin{equation}}
 {\end{equation}\ignorespacesafterend}
1
  • \ignorespacesafterend did the trick. Thank you! Commented Nov 22, 2022 at 22:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .