# Why is code appended to \endabstract still indented?

I'm trying to automatically append "keywords" (defined in the preamble) to the end of the abstract environment. The keywords should not be flush with the abstract, but flush with the body text / left margin.

My aproach is to use:

\g@addto@macro\endabstract{\par\noindent{KEYWORDS}\par}


but KEYWORDS is still flush with the abstract. The strange thing is, if I remove the \par after KEYWORDS, then the alignment is correct, but I need glue space below KEYWORDS (so \\ isn't an option).

I also overwrote the quotation environment (which is used by abstract) using:

\renewenvironment{quotation}{START}{STOP}


and apparently KEYWORDS is outside STOP, so I don't know why it's still indented.

I've tried etoolbox and xpatch packages too (see below). I'm thinking it has something to do with "modes" or groups but I don't know enough, and I thought \par escaped the local group and mode, or something...

Anyways, thanks in advance.

## MWE

\documentclass{article}
\usepackage{lipsum}

\makeatletter
\makeatother

%\usepackage{etoolbox}
%\AtEndEnvironment{abstract}{\par\noindent{KEYWORDS}\par}

%\usepackage{xpatch}
%\xapptocmd{\endabstract}{\par\noindent{KEYWORDS}\par}{}{}

%\renewenvironment{quotation}{START}{STOP}

\begin{document}
\begin{abstract}
\lipsum[1]
\end{abstract}
\lipsum[2-3]
\end{document}


## Result

You can add it outside the group of the abstract environment

\documentclass{article}
\usepackage{lipsum}

\makeatletter
\makeatother

%\usepackage{etoolbox}
%\AtEndEnvironment{abstract}{\par\noindent{KEYWORDS}\par}

%\usepackage{xpatch}
%\xapptocmd{\endabstract}{\par\noindent{KEYWORDS}\par}{}{}

%\renewenvironment{quotation}{START}{STOP}

\begin{document}
\begin{abstract}
\lipsum[1]
\end{abstract}
\lipsum[2-3]
\end{document}

• Bless your soul. Since I already had a macro \makekeywords which only printed the first \par and they keyword stuff if any keywords were given, I adapted your solution to: \g@addto@macro\endabstract{\aftergroup\makekeywords\aftergroup\bigbreak}. – jessexknight Jul 29 at 21:02

With the upcoming LaTeX kernel, due to be released in October, you can use a 'hook' to achieve this. (You'll need to run e.g. pdflatex-dev at present for this to work: that uses the pre-release version of the kernel.)

\documentclass{article}
\usepackage{lipsum}