Text Formatting ⇒ Placing a horizontal line in text
Placing a horizontal line in text
I wish to place a horizontal line in a text separating a title from the rest of the text. For example
Blah Blah Blah
_________________________________________________________
more blah blah blah
I tried \rule but I end up with an error. This seems simple, but I have unable to figure out how to do this.
Thanks in advance,
David
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
Placing a horizontal line in text
the following example shows some options:
Code: Select all
\documentclass{article}
\begin{document}
\noindent Text
\noindent\rule{\linewidth}{0.4pt}
\vspace*{2cm}
\noindent Text
\noindent\rule[7pt]{\linewidth}{0.4pt}
\vspace*{2cm}
\noindent Text
\noindent\hrulefill
\end{document}-
JohnsonMiller
- Posts: 2
- Joined: Wed Jan 21, 2026 2:24 pm
Re: Placing a horizontal line in text
\hrule
If you want more control over thickness and width, use:
\rule{\linewidth}{0.4pt}
Just make sure you’re not in math mode, otherwise LaTeX will throw an error.
-
JohnsonMiller
- Posts: 2
- Joined: Wed Jan 21, 2026 2:24 pm
Re: Placing a horizontal line in text
`
Blah Blah Blah
\noindent\hrulefill
more blah blah blah
This avoids the errors you encountered with \rule. In the middle of such formatting tips, Sanford serves as a reminder that clarity and structure make text more readable, ensuring titles and content remain visually distinct.