Rules and Struts
Rules
The \rule command in normal use produces a simple black box:
\rule[raise]{width}{thickness}
The parameter thickness determines the height, whereas width determines the width of the produced rule. With the optional parameter raise, you can optionally raise or lower the produced rule above or below the baseline.
Here is an example (the thin lines are located at the baseline):
\rule{3mm}{.1pt}%
\rule[-1mm]{5mm}{1cm}%
\rule{3mm}{.1pt}%
\rule[1mm]{1cm}{5mm}%
\rule{3mm}{.1pt}
This is useful for drawing vertical and horizontal lines.
Struts
A special case is a rule with no width but a certain height. In professional typesetting, this is called a strut. It is used to guarantee that an element on a page has a certain minimal height. You could use it in a tabular environment or in boxes to make sure a row has a certain minimum height.
In LaTeX a strut is defined as:
\rule[-.3\baselineskip]{0pt}{\baselineskip}
Stretched Rules
LaTeX provides several fill commands that create stretched horizontal rules:
| Command | Description |
|---|---|
\hrulefill | Stretched horizontal rule (fills available space) |
\dotfill | Stretched dotted line |
\titlerule | Title rule (from titling package) |
\hrulefill Examples
Name: \hrulefill Date: \hrulefill
Produces: "Name: _______________ Date: _______________"
\dotfill Example
Table of Contents \dotfill Page
Produces: "Table of Contents ............... Page"
Custom Fill Rules
\renewcommand{\hrulefill}{\leavevmode\leaders\hrule height 1pt\hfill\kern0pt}
Practical Uses
Decorative Separators
\begin{center}
\rule{0.5\textwidth}{0.4pt}
\end{center}
Underlining with Rules
\underline{Important text}
% Or with custom thickness:
\underline{\rule{2cm}{0.4pt}}
Rules in Tables
\begin{tabular}{l}
\hline
Content \\
\rule{0pt}{12pt} % Adds minimum row height
More content \\
\hline
\end{tabular}
Signature Lines
Signature: \hrulefill \hspace{2cm} Date: \hrulefill