Center hrule in the middle of the page

I would like to center a horizontal line on my page and I would like the width of this line to be half \textwidth. Here is what I tried but it doesn't work :

\documentclass[10pt,a4paper]{article}
\begin{document}

Hello everyone !

\begin{center}
\hrule width 0.5\textwidth
\end{center}

\end{document}


Thank you for your help !

• \rule{0.5\textwidth}{0.5pt}? Aug 17, 2013 at 9:16
• BTW: Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Aug 17, 2013 at 9:17
• @karlkoeller \rule{0.5\textwidth}{0.4pt} is a better equivalent to \hrule. Aug 17, 2013 at 9:18
• Thanks for your comment but it seems it doesn't produce a line centered on the page. Aug 17, 2013 at 9:19
• @lockstep Yes, you're right, 0.4pt is the exact equivalent, according to the TeXbook. Aug 17, 2013 at 9:59

You can replace

\hrule width 0.5\textwidth


with

\rule{0.5\textwidth}{.4pt}


Also, if you don't need the center environment for anything else, you can replace

\begin{center}
\rule{0.5\textwidth}{.4pt}
\end{center}


with simply

\noindent\hfil\rule{0.5\textwidth}{.4pt}\hfil


MWE

\documentclass[10pt,a4paper]{article}
\begin{document}

Hello everyone !

\begin{center}
\rule{0.5\textwidth}{.4pt}
\end{center}

\noindent\hfil\rule{0.5\textwidth}{.4pt}\hfil

\end{document}


Output

I tried using \rule in the accepted answer, but I ended up going with \hrule like the original question asked too:

\newcommand{\SectionBreak}{%
%\vskip 0.5ex

\nointerlineskip
\moveright 0.125\textwidth \vbox{\hrule width0.75\textwidth}
\nointerlineskip
%\vskip 0.5ex
\makeatletter
%\@afterindenfalse%
\makeatother

}