Horizontal line spanning the entire document in LaTeX

I have used the \hrulefill command to create a horizontal rule, along with some other commands. In each case I have the rules extended up to the margin.

I want the rule width to be controllable, i.e. I want them to span the entire page. How can this be done? The existing help on Internet looks pretty scarce. Thanks for your help.

-

migrated from stackoverflow.comJun 1 '11 at 1:18

To get horizontal lines of any fixed length you can use the \rule command. To get a horizontal line spanning the whole page width you can use a \makebox command and then a \rule with a width equal to \paperwidth:

\documentclass{article}

\begin{document}

\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}

\noindent\rule{2cm}{0.4pt}

\noindent\rule{4cm}{0.4pt}

\noindent\rule{8cm}{0.4pt}

\end{document}


Rules in LaTeX are 0.4pt "thick", by default.

-