I've been trying to draw a line with width the same as the page width. I use fancyhdr and I have a line for my footer, and I want the their widths to be equal.

I tried \line(1, 0){\textwidth} and \line(1,0){\pagewidth} but no luck. I know I can use \line(1,0){450} for example, but that means I would have to play around and find the exact page width.


2 Answers 2


Assuming that the rule is needed in "normal" places of the document, i.e. not in list environments or other special places, the most efficient way is

\vskip\medskipamount % or other desired dimension
\leaders\vrule width \textwidth\vskip0.4pt % or other desired thickness
\vskip\medskipamount % ditto

Sensible values for the vertical spaces are \smallskipamount, \medskipamount, \bigskipamount or \topsep; it can be given also explicitly.

Such a rule will vanish should it fall at the bottom or at the top of a page, together with the spaces.

  • I've seen this answer several times and I like it. It's a clever use of \leaders.
    – TH.
    Jun 4, 2011 at 23:59

To get a line from one margin to the other, use


To get a line from one end of the page to the other, use

  • 2
    doesn't \rule{\textwidth}{1pt} alone works?
    – henrique
    Jun 4, 2011 at 19:35
  • 5
    @henrique @yoda \rule, if given between paragraphs, adds the normal indent. The use of \linewidth is correct and does not give overfull boxes, but it should be \makebox[\linewidth][r]{...}.
    – egreg
    Jun 4, 2011 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.