# Automatic \rule width

Suppose I have some title text that I format as follows:

\begin{center}
{\small Brief Notes on}\\[-0.2em]
Some Topic of Questionable Interest\\[-0.6em]
\rule{12em}{0.75pt}
\end{center}


This produces two lines of text with a 12em-wide rule beneath them.

Is there a way to get LaTeX to automatically adjust the length of the rule to be equal to that of the bottom line of text (plus some user-specified offset)?

• Perhaps tikzmark would be a good tool for that... – jub0bs May 1 '13 at 10:48

use a tabular:

\documentclass{article}
\begin{document}
\begin{center}
\begin{tabular}{@{}c@{}}
\small Brief Notes on\\[-0.2em]
Some Topic of Questionable Interest\\\hline
\end{tabular}
\end{center}

\end{document}


• Thanks, I guess this is indeed the most straightforward way to do this. – Ubiquitous May 2 '13 at 9:06

Here's a way to achieve this using tikzmark as suggested by Jubobs:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calc}
\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

\begin{document}
\begin{center}
{\small Brief Notes on}\\[-0.2em]
\tikzmark{leftend}Some Topic of Questionable Interest\tikzmark{rightend}
\begin{tikzpicture}[overlay, remember picture]
\draw(leftend.south west) -- (rightend.south east);
\end{tikzpicture}
\end{center}
\end{document}


Replacing south west and south east with south eliminates the small offset between the line ends and the edge of the text.