5

I need to create a recipient section with 3 lines. I'd like to have them underlined and with the same length, regardless of how many words I write in them.

I could achieve the result with the {soul} package, as displayed in How to continue thick underline beyond text?. However he wants to continue the like for a fixed length, and I'd have to empirically find the distance to have all 3 lines terminate together, which is not convenient.

The closest I've got to is:

\documentclass[12pt]{letter}

\usepackage{makecell}
\usepackage{eurosym}
\usepackage{setspace}

\usepackage[a4paper, total={17cm, 23cm}]{geometry}

\def \tab {\hspace*{3ex}} % Define \tab to create some horizontal white space
\begin{document}
\pagenumbering{gobble}

\begin{spacing}{1.4}
{\bf invoice number {\bf 4} for:} \\
\tab \makebox[0.5\textwidth][l]{\underline{PdP snc, Uncle Scrooge}\hrulefill} \\
\tab \makebox[0.5\textwidth][l]{\underline{123 BullSlaughter hill, Duckburg}\hrulefill} \\
\tab \makebox[0.5\textwidth][l]{\underline{P. IVA: BO 01688021201}\hrulefill} \\ 

\end{spacing}
\end{document}

Which does what I want except the continuing underline is not at the same height of the previous oneenter image description here

Is there a better way that I am overlooking or I should try to tweak the height of the \hrulefill?

3
  • 2
    Welcome to TeX.SX! Please add your preamble ... to make your code compilable. The line should start after some space (tab) and not start at the left margin?
    – Bobyandbob
    Oct 4, 2017 at 7:00
  • 2
    \underline{\makebox[0.5\textwidth][l]{PdP snc, Uncle Scrooge}}?
    – esdd
    Oct 4, 2017 at 7:11
  • @esdd yes, does exactly what I want. Looks so obvious now... If you add the answer I'll accept it
    – Maldus
    Oct 4, 2017 at 7:49

1 Answer 1

5

Use \makebox[.5\textwidth][l]{...} inside the argument of \underline.

Example:

\documentclass{article}
\usepackage{setspace}
\usepackage{soul}

\begin{document}
\pagenumbering{gobble}
\begin{spacing}{1.4}
\noindent
\underline{\makebox[0.5\textwidth][l]{PdP snc, Uncle Scrooge}} \\
\underline{\makebox[0.5\textwidth][l]{123 BullSlaughter hill, Duckburg}} \\
\underline{\makebox[0.5\textwidth][l]{P. IVA: BO 01688021201\vphantom{g}}} \\ 
\end{spacing}
\end{document}

Result:

enter image description here

Note that I have added \vphantom{g} in the third line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .