Horizontal line options in latex

Written by kevin walker

LaTeX, an open source document preparation and typesetting system, takes an alternative approach to word processing compared with a conventional word processor. Rather than provide a set of graphical buttons and show the results immediately after an edit, LaTeX documents contain programming commands that specify how a document looks, and typically multiple options are given to allow the writer to refine the look exactly as they like. A good example of this are the five different options for drawing horizontal lines in LaTeX.

\hline

The command "\hline" is the simplest of the horizontal line options in LaTeX and, most of the time, it is the one you want. It will simply draw a horizontal line between the paragraphs that proceed and follow it when the document is rendered. This also means that, of course, if "\hline" is used in mid-paragraph, then it will force a break in paragraphs.

\rule

The "\rule{length}{thickness}" command provides a little more power than the ordinary "\hline." First, rule does not force a break between paragraphs: it is acceptable to use a rule mid-paragraph, if that is the effect you desire. Second, you can specify two arguments for rule. The first is the length of the line, and the second is the thickness of the line. Both require a unit to be used, such as "cm" (centimetre) or "pt" (points).

\line

The LaTeX "\line(x,y){length}" allows you to draw a line segment anywhere on the page you like, horizontal or otherwise. The line will have the length defined in the length argument and the slope (x,y). A 10-centimeter horizontal line would be "\line(0,0){10cm}." It can only be used within the "LaTeX picture" environment.

\dotfill

The "\dotfill" command allows you to draw a line of dots. This creates a "rubber" space that will have a minimise size of a few dots, but will expand as needed to fill the available horizontal space. This is useful for defining a table of contents where the chapter title is left justified, the page number right justified and the space between contains the "\dotfill" command to fill it with dots. However, it can draw a horizontal line of dots across the page if it is followed by the "\" new paragraph command.

\hrulefill

The "\hrulefill" command has the same functionality as the "\dotfill" command, except it will fill the available space with the "horizontal rule," a thin line along the bottom of the text.

References

• All types
• Articles
• Slideshows
• Videos
Sort:
• Most relevant
• Most popular
• Most recent