Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical Supply Distributor100,000+ medical supplies. 48-hour critical dispatch.Ships from 8 regional U.S. hubs. Net-30 terms for verified institutional accounts.Shop lac.us CodeCASRAIlac.us

Horizontal Line in LaTeX: \rule, \hrulefill and \hline

Which command draws a horizontal line in LaTeX? rule in text, hrulefill to fill a line, hline and cline in tables, with examples.

Written and maintained by CASRAI Editorial Board

Last updated

To draw a horizontal line in LaTeX, use \rule{width}{thickness} for a line of a set length in running text, \hrulefill for a line that fills the rest of the current line, and \hline for a line between rows of a table. Which one you want depends on where the line sits, which is why searches for “latex horizontal line”, “latex hrule” and “hline in latex” lead to different commands.

What horizontal lines are used for in research documents

Researchers and analysts typically need a horizontal line for one of four jobs: a signature or fill-in line on a form, a divider between sections of a report, a rule under a heading, or the row separators in a results table. Each job maps to a different command, summarised below and explained step by step in the sections that follow.

You need Command Documented behaviour
A line of a chosen length and thickness inside text \rule[raise]{width}{thickness} Both arguments are rigid lengths; the optional raise lifts the rule above the baseline, a negative value lowers it.
A line that stretches across the rest of the current line \hrulefill Works like \hfill but inserts a horizontal ruler instead of blank space.
Lines between table rows or at the top and bottom of a table \hline Inserts a horizontal line on top of the table and at the bottom too; it can be used any number of times.
A line across only some table columns \cline{i-j} A partial horizontal line beginning in column i and ending in column j.
Publication-quality table rules The booktabs package A CTAN package that enhances the quality of tables in LaTeX.

Install or access

The \rule, \hrulefill, \hline and \cline commands are documented in the LaTeX2e reference and in Overleaf’s online guides, so they are available in an ordinary LaTeX document, including one edited in Overleaf. The booktabs package is distributed through CTAN, the Comprehensive TeX Archive Network. Its CTAN entry lists the maintainer as Daniel Els, version 1.61803398, with a listed update of 2020-01-15 (checked 2026-11-07). To use it, add \usepackage{booktabs} to the preamble.

Step by step: a horizontal line in text with \rule

  1. Write the command where the line should appear: \rule{5cm}{0.4pt} draws a line 5 cm wide and 0.4 pt thick.
  2. Give both arguments. The LaTeX2e reference gives the syntax as \rule{width}{thickness} and \rule[raise]{width}{thickness}, and describes width and thickness as rigid lengths.
  3. To move the line relative to the text, add the optional raise argument: \rule[0.5ex]{5cm}{0.4pt} lifts the rule above the baseline, and a negative value such as \rule[-0.5ex]{5cm}{0.4pt} lowers it.
  4. Use \vspace{5mm} before or after a line when you need vertical space around it; per Overleaf’s documentation it inserts a vertical space of 5 mm.
Signed: \rule[-0.5ex]{6cm}{0.4pt} \quad Date: \rule[-0.5ex]{3cm}{0.4pt}

Step by step: a line that fills the line with \hrulefill

  1. Place \hrulefill in a line of text. Overleaf’s page on line breaks and blank spaces describes it as working like \hfill, but inserting a horizontal ruler instead of blank space.
  2. Put text before it if you want a labelled divider, for example Name: \hrulefill: the line stretches to use the remaining width.
Name: \hrulefill

Step by step: horizontal lines in a table with \hline and \cline

  1. Start a tabular environment with the column specification, for example \begin{tabular}{lcc}.
  2. Put \hline before the first row. Overleaf’s tables documentation says it inserts a horizontal line on top of the table and at the bottom too.
  3. End each row with a double backslash and place another \hline after any row you want underlined. There is no restriction on the number of times you can use it.
  4. Write \hline\hline in succession for a double rule.
  5. Use \cline{2-3} after a row to draw a partial line from column 2 to column 3 only.
\begin{tabular}{lcc}
\hline
Group & Mean & SD \\
\hline
Control & 4.2 & 0.8 \\
\cline{2-3}
Treated & 5.1 & 0.9 \\
\hline
\end{tabular}

What about \hrule and booktabs?

Searches for “hrule latex” usually have one of the commands above in mind, since \hrulefill and \rule are the line commands described in the LaTeX2e reference and Overleaf’s guides. For journal-style tables, the booktabs package is the package built to improve table quality compared with the default; its CTAN page links its documentation.

Output and how to read it

A \rule prints a solid bar whose length is the width you gave and whose height is the thickness; the raise value shifts it vertically but does not change its size. A \hrulefill prints a line whose length is whatever width is left on that line, so it grows or shrinks with the text around it. \hline lines span the table, while \cline spans only the named columns.

Troubleshooting

  • The line sits on the baseline and looks like an underscore. Add a raise value to \rule; a negative value lowers it below the baseline.
  • The line has no visible height. Check that the thickness argument is not zero and is given with a unit, since width and thickness are lengths.
  • A line fills the whole width when you wanted a short one. \hrulefill fills the remaining width; switch to \rule with an explicit width.
  • A table separator does not appear where you expect. \hline is documented as a table command, so place it between rows of a tabular environment, after the row-ending double backslash.
  • You need space around a line, not a line. Use \vspace{5mm} for vertical space.

Free alternatives

Every approach below is free to use in a LaTeX document.

Approach Where the line goes Length
\rule Anywhere in text; position adjustable with raise You set it
\hrulefill In a line of text, like \hfill Fills remaining line width
\hline / \cline Between table rows Table width / selected columns
booktabs package Table rules See package documentation

Frequently asked questions

How do I add a horizontal line in LaTeX?

Use \rule{width}{thickness} for a line of known length, \hrulefill to fill the rest of a line, or \hline inside a table.

What is the difference between hline and hrule in LaTeX?

\hline is the table command that draws a line betThe sources listed below describe \hrulefill and
ule
for lines in text.

How do I make a short horizontal line in LaTeX?

Give \rule a short width, for example \rule{2cm}{0.4pt}.

How do I lower a horizontal line relative to text?

Use the optional first argument of \rule; a negative raise value lowers the rule.

How do I add vertical space or a blank line?

Use \vspace{5mm}, which inserts a vertical space of 5 mm.

How do I draw a horizontal line across only some table columns?

Use \cline{i-j}, which starts in column i and ends in column j.

Related guides

See Matrix in LaTeX for another table-like layout, Overleaf font sizes for text sizing, collaborative LaTeX writing in Overleaf and LaTeX bibliography styles.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Horizontal Line in LaTeX: \rule, \hrulefill and \hline

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →