5

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)?

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

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}

enter image description here

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

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}

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.