Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Jun 1 '11 at 1:18

This question came from our site for professional and enthusiast programmers.

3 Answers 3

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}

Below is a Line spanning the entire width of the page

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

Below is a 2cm long line

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

Below is a 4cm long line

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

Below is a 8cm long line

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

\end{document}

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

share|improve this answer

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

\begin{center}
\line(1,0){450}
\end{center}
share|improve this answer

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.

\rule{\textwidth}{1pt}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.