## Drawing Horizontal Lines in LaTeX

Posted: 15th August 2009 by Tim in LaTeX
Tags: , , , , , ,

Lines can be drawin in LaTeX using the \line function. This takes an x-slope, y-slope and length like so:

\line(x-slope,y-slope){length}

To draw a horizontal line (or horizontal rule), set the x-slope to 1 and the y-slope to zero.

Depending on the margins which have been set, a length of 450 will draw a line which is the width of the page (minus the margins).

If you’re looking for a clean line to divide the page, try the following:

\begin{center} \line(1,0){250} \end{center}

1. […] line in a presentation for a in-lecture “fill-in-the-blank”. I found the link http://timmurphy.org/2009/08/15/drawing-horizontal-lines-in-latex/. Basically, all you have to do […]

2. Hello Tim. Thank you for this tip. I get an error when I try your snippet in a LaTeX article documentclass I’m creating. Does the \line command need to be called within a picture block? Or perhaps I need to include a particular package with \usepackage?

3. cw says:

Works great. Thanks!

4. Zach says:

Thanks! Works great.

5. Simon says:

Thanks!

6. Jay says:

Thanks.
It works great.
I just wanted to create line for putting signature.

7. […] Latex ????? ???? ?? ??????? ???? ???? line ????? ???. ??? ???? ?? ??????? ??????? ?? ????? ????? ????? […]

8. Fiona says:

Hi, this is great, thanks. Do you know how to get a double horizonal line please? Just to tart it up a bit… Thanks!

9. Tim says:

Hi Kristofer,
No picture environment or packages required. Here’s an example of an entire document with a line in it:
\documentclass{article} \begin{document} \line(1,0){250} \end{document}

10. teodor says:

Excellent solution! Also works within a math environment

11. Katarina says:

Thank you?
And what if I want to change the color and the thickness of the line? Which additional commands can I use?

Katarina

12. Tim says:

Hi Katarina,

To change the line thickness you can use something like \linethickness{2mm} before the \line command.

To change the color, see this post.

-T

13. Tim says:

Hi Fiona,

You can create yourself a definition for this (note: the blank lines matter here!):

\def\doubleline{

    \vspace{-0.9em}     \hspace{\fill}\line(1,0){240}\hspace{\fill}

    \vspace{-0.9em}     \hspace{\fill}\line(1,0){250}\hspace{\fill}

}

You can then put this in your document by adding \doubleline (the first \vspace in the definition may or may not be needed, depending on what you’re doing).

14. Linnea says:

Thank you so much! Just what I needed!

15. Billy says:

Thanks for this tip. What is the unit of the length?

16. Thanks. It worked great.

17. PWS says:

Concise and to the point. Great tip!!

18. Chris says:

Great aid! Thanks!

19. Shroom says:

Thank you very much, Tim.
Worked like a charm for me.

20. prakash says:

Thanks dude

21. Lili says:

Yay!! Just what I needed, a simple explanation without all the imaginable possibilities. Thanks a lot!

22. Cristian says:

Thanks!

23. Autumn says:

This seems to have a lot of padding just above the line. Any way to reduce that?

24. Saven says:

Autumn,
To reduce the vertical gap, this worked for me: \vspace{-1cm}
Immediately before the \line command.

25. moataz elmasry says:

thanks

26. Steve Bauer says:

Thanks for this clear and concise description of making use of lines! And also thanks for your careful replies. They were quite helpful too.

27. Manish says:

How to increase its thickness?

28. Tim says:

You can use the \linethickness{...} command to set the line thickness. For example, \linethickness{1.0mm}

29. Abhinav says:

How to align these lines to right side?

30. somedatta says:

how can I draw margin in every page of my write-up using Latex?

31. ponchwwa says:

Thanks, very nice!

32. Milan SHarma says:

How to double underline (underline title with two horizontal lines?) and how to draw horizontal line after some text, for example, EDUCATION————————–, but soid line, not the dotted line,
Thanks