LaTeX offers several ways to draw horizontal lines, some requiring arguments and others not. This guide covers all available methods.
Using \rule for Customizable Lines
The simplest way to create a horizontal line is with the \rule[raise-height]{length}{thickness}
command, allowing customization of length and thickness.
An optional argument adjusts the vertical position—positive values move it up, negative move it down.
To draw a line matching the paragraph width, use \textwidth
. Adding \noindent
improves the appearance.
\par\noindent\rule{\textwidth}{0.5pt}
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\begin{center}
\verb|Without using \noindent|
\end{center}
\lipsum[1][1-3]
\par\rule{\textwidth}{0.5pt}
\par
\lipsum[1][1-3]
\begin{center}
\verb|Using \noindent|
\end{center}
\lipsum[1][1-3]
\par\noindent\rule{\textwidth}{0.5pt}
\par
\lipsum[1][1-3]
\end{document}
Output :
Using \hrule for Simple Lines
The \hrule
command requires no arguments and is typically used between paragraphs. To add spacing above and below, use \vspace{}
.
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1][1-3]
\vspace{4pt}
\hrule
\vspace{4pt}
\lipsum[1][1-3]
\end{document}
Output :
Using \line for Adjustable Line Lengths
The \line(x-slope,y-slope){length}
command allows for sloped or horizontal lines. For a line, use (1,0)
. Centering can be done with the center environment.
\line(x-slope,y-slope){length}
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1][1-3]
\begin{center}
\line(1,0){340}
\end{center}
\lipsum[1][1-3]
\begin{center}
\line(1,0){70}
\end{center}
\end{document}
Output :
Using \hline for Simple Table-Like Lines
The \hline
command is another option, but it lacks customization. To adjust spacing, use \vspace{}
. Double lines can be created by using \hline
twice
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1][1-3]
\vspace{5pt}
\hline
\vspace{5pt}
\lipsum[1][1-3]
\vspace{5pt}
\hline
\hline
\end{document}
Output :
Using \hrulefill for Inline Horizontal Lines
The \hrulefill
command extends to fill available space in a line. It is useful for titles or decorative elements. Using \par
forces the line onto the next line, and \noindent
improves the appearance.
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\begin{center}
\verb|\hrulefill use for Title|
\end{center}
\noindent\hrulefill Title \noindent\hrulefill
\begin{center}
\verb|Without using \par|
\end{center}
\lipsum[1][1-2]
\noindent\hrulefill
\begin{center}
\verb|Using \par|
\end{center}
\lipsum[1][1-2]
\par\noindent\hrulefill
\end{document}
Output :
Using \dotfill for Dotted Lines
The \dotfill
command functions like \hrulefill
but creates a dotted line, commonly used for visual separation in documents.
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\begin{center}
\verb|\dotfill use for Title|
\end{center}
\noindent\dotfill Title \noindent\dotfill
\begin{center}
\verb|Without using \par|
\end{center}
\lipsum[1][1-2]
\noindent\dotfill
\begin{center}
\verb|Using \par|
\end{center}
\lipsum[1][1-2]
\par\noindent\dotfill
\end{document}
Output :