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.

5 Answers 5


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:



Below is a Line spanning the entire width of the page


Below is a 2cm long line


Below is a 4cm long line


Below is a 8cm long line



Output: enter image description here Rules in LaTeX are 0.4pt "thick", by default.

  • 4
    Maybe you could also include a rule of length \textwidth, for comparison with the one of \paperwidth placed in a '\makebox`. Sep 1, 2016 at 18:33
  • Is there a way to modify this to set the top and bottom margin/padding of the line? It could be useful to set the space between paragraphs above and below, respectively. Apr 26, 2019 at 18:57

Another option is this one, which makes a horizontal line stretch the entire page. I prefer this one, because it's short, easy to remember and exactly what I need. I hope this works for you too.

  • 17
    +1 It helped me to get a gray horizontal line: \textcolor[RGB]{220,220,220}{\rule{\linewidth}{0.2pt}} Apr 13, 2015 at 6:22
  • 2
    Where's the \noindent? :-(
    – einpoklum
    Jun 10, 2017 at 18:07
  • 6
    This behaviour is exactly the same as \noindent\hrulefill. Sadly, OP wants the line to ignore margin. Nov 15, 2017 at 19:31

I used the \line command: \line(x slope, y slope){length}.

  • 2
    It was useful for me to define it as its own command: \newcommand{\hr}{\begin{center} \line(1,0){450} \end{center}}. Dec 29, 2016 at 21:17

\underline{\hspace{ x in}} gives you a line of length x inches.

  • 3
    Welcome to TeX.SX! Don't be so chatty! ;-) I don't think that this answers the (old) question
    – user31729
    Sep 26, 2014 at 14:07

Attending the horizontal line problem I used the \rule as other has mentioned. Although, if you want to have a centered line that separates your paragraphs you can use this simple code. You can add another \bigskip in order to add empty spacing :)

    Some random text above \\
    Some random text below 

Your Answer

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