[Tex/LaTex] How to stretch table or minipage to fill remaining space

formatting

I am trying to make a document like this:

enter image description here

Since there's quite a lot of such sections, I want to make a new command like \textwithline{}{} so I can then type

Author: \textwithline{Joe Shmoe}{First name, Last name}

This author's editor: \textwithline{Billy Willy}{First name, Last name}

in my document.

Note the important features:

  • The line must fill all available remaining space
  • The text above and below the line must be centered on the line
  • The text on the left is variable length (or may be blank)

What is a good way of making such a command? I have tried:

  • tabular with \hfill but it doesn't actually stretch the table
  • tabular* but it doesn't "give room" to the text on the left
  • minipage but that requires me to hard code width every time
  • \uline{\hfill Billy Willy \hfill}{\hfill First name, Last name \hfill} with \centering but then text below line is not centered on the line, but on the page

Best Answer

enter image description here

\documentclass{article}

\newcommand\textwithline[2]{{%
\setlength\parfillskip{0pt}%
\hrulefill
\raisebox{5pt}{\makebox[0pt]{#1}}%
\raisebox{-12pt}{\makebox[0pt]{#2}}%
\hrulefill
\par
\bigskip}}

\begin{document}



Author: \textwithline{Joe Shmoe}{First name, Last name}

This author's editor: \textwithline{Billy Willy}{First name, Last name}

\end{document}
Related Question