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
- Write the command where the line should appear:
\rule{5cm}{0.4pt}draws a line 5 cm wide and 0.4 pt thick. - 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. - 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. - 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
- Place
\hrulefillin 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. - 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
- Start a
tabularenvironment with the column specification, for example\begin{tabular}{lcc}. - Put
\hlinebefore the first row. Overleaf’s tables documentation says it inserts a horizontal line on top of the table and at the bottom too. - End each row with a double backslash and place another
\hlineafter any row you want underlined. There is no restriction on the number of times you can use it. - Write
\hline\hlinein succession for a double rule. - 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.
\hrulefillfills the remaining width; switch to\rulewith an explicit width. - A table separator does not appear where you expect.
\hlineis documented as a table command, so place it between rows of atabularenvironment, 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 for lines in text.
ule
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
- Overleaf, Line breaks and blank spaces (checked 2026-11-07).
- Overleaf, Tables (checked 2026-11-07).
- LaTeX2e reference manual, \rule (checked 2026-11-07).
- CTAN, booktabs package (checked 2026-11-07).







