[Tex/LaTex] Abstract on the title page in LaTeX

abstractformattingsharelatex

I would like the abstract on the title page in the following style:
1. The word 'Abstract' centred above the text
2. A horizontal line immediately underneath the word 'Abstract', with a width equal to that of the text
3. A horizontal line of that same length immediately underneath the text
4. The word 'Keywords:' at the left-side that allows me to put some keywords specific to the thesis.

I have been trying to get this right, but apparently I am missing something. Thanks for the help! Current code can be found here:

\renewenvironment{abstract}
{\begin{quote}
\noindent \rule{\linewidth}{.5pt}\par{\bfseries \abstractname.}}
{\medskip\noindent \rule{\linewidth}{.5pt}
\end{quote}
}

Picture of the end result I aspire:

enter image description here

Best Answer

A solution based on tabularx, threeparttable and xparse for the keywords: it defines the abstract as a threeparttable – the abstract itself being a single row of a tabularx environment, and the list of keywords, input as an optional argument of the environment, inserted as a table note.

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{lipsum}
\usepackage{tabularx, threeparttable, booktabs}
\usepackage{xparse} 
\title{Some Title}
\author{Some One}
\RenewDocumentEnvironment{abstract}{o}%
{\small\noindent\threeparttable\tabularx{\linewidth}{@{}>{\arraybackslash}X@{}}\bfseries\centering \abstractname\tabularnewline\addlinespace[1.5ex]\midrule\addlinespace[1ex]}%
{\endtabularx\vspace{-2ex}\hrule\IfNoValueF{#1}{ \begin{tablenotes}[flushleft, online]\smallskip\item[Keywords: ] #1
\end{tablenotes}}
\endthreeparttable\vspace*{6ex}}%

\begin{document}

\maketitle
\begin{abstract}%[small $\beta$s, Fama-MacBeth two-pass procedure; foreign currency portfolios; factor pricing; stochastic discount factors; weak identification; principal components]
\lipsum[1]
\end{abstract}
\lipsum[2-8]

\end{document} 

enter image description here

Related Question