7

I need to create lines for signatures. I need 3 of them with different texts below them, but i want all lines to have the same length and the texts centered below them.
Tables with \hlines made the horizontal placement easy, but then the vertical placement of the lines was not as good as with \overline.

The following code achieves centering the text under the (over-)line with length of xDatum/Unterschrift Ausbildungsleiterx, but the question is: is there a better way to do it, because this feels like a very 'odd' solution.

\documentclass{article}
\usepackage{calc}
\newcommand{\strich}[1]{%
  \makebox[\width][c]{%
    \makebox[0pt][l]{%
      \makebox[\widthof{xDatum/Unterschrift\ Ausbildungsleiterx}]{%
        #1%
      }%
    }%
    \makebox{%
      \ensuremath{%
        \overline{%
          \phantom{%
            \mathrm{xDatum/Unterschrift\ Ausbildungsleiterx}%
          }%
        }%
      }%
    }%
  }%
}

\begin{document}
    \begin{center}
    \footnotesize{\strich{Datum/Unterschrift\ Auszubildender}}
    \vspace{2.5cm}\\
    \footnotesize{\strich{Datum/Unterschrift\ Betreuer}\hfill\strich{Datum/Unterschrift\ Ausbildungsleiter}}
    \end{center}
\end{document}

Notice, that Datum/Unterschrift Ausbildungsleiter is the longest of the 3 texts i need to place under the signature-lines.

  • you are missing an awful lot of % from the ends of your lines (which is why the lines are longer on the right than the left of your texts) – David Carlisle Jul 15 '13 at 12:12
  • You are right. That happens, when you test your code and then start indenting it. – MaPePeR Jul 15 '13 at 12:26
6

You can create a \parbox and insert a \rule:

\documentclass{article}
\usepackage{calc}

%Specify the longest signaturekey here:
\newcommand{\sigwidth}{\widthof{\footnotesize xDatum/Unterschrift\ Ausbildungsleiterx}}
%Define a signaturbox of 2.5 cm in height with a mandatory argument of the signature
\newcommand{\signaturehere}[1]{%
\parbox[b][2.5cm][b]{\sigwidth}{%
\footnotesize%Everything in footnotesize
\centering% 
\rule[-3pt]{\linewidth}{0.4pt}\\[0ex]%
{#1}%
}}

\begin{document}
\begin{center}
\signaturehere{Datum/Unterschrift\ Auszubildender}\\
\signaturehere{Datum/Unterschrift\ Betreuer}\hfill%
\signaturehere{Datum/Unterschrift\ Ausbildungsleiter}
\end{center}

\end{document}

enter image description here

  • This is more or less what I just posted but you were first so +1, I deleted mine. – David Carlisle Jul 15 '13 at 12:27
  • @David Yeah, just saw yours, it was a little more elegant though. But I guess multiple answers are often generated like that. (I will update my post in a second to make it more universal) – Martin - マーチン Jul 15 '13 at 12:29
  • Thanks for that solution. Only one thing to point out for future readers: This breaks, if the current font size is bigger, so add a \normalsize in front of the signature lines. – MaPePeR Jul 15 '13 at 13:35
  • This is unfortunately correct. I am going to fix that now, like in egreg's answer below the key is to set \footnotesize first. – Martin - マーチン Jul 15 '13 at 13:45
6

You can also automatize the computation of the largest text:

\documentclass{article}
\usepackage{calc}

\newlength{\signaturelength}
\newcommand{\signatures}[3]{%
  \begin{center}\footnotesize % all is \footnotesize
  % compute the maximum width
  \setlength{\signaturelength}{\maxof{\widthof{#1}}{\widthof{#2}}}%
  \setlength{\signaturelength}{\maxof{\signaturelength}{\widthof{#3}}}%
  \addtolength{\signaturelength}{2em}% Add some space
  % print the three lines with their caption
  \strich{#1}\\[2.5cm]
  \strich{#2}\hfill
  \strich{#3}
  \end{center}
}

\newcommand{\strich}[1]{% The line and its caption
  \parbox[t]{\signaturelength}{\footnotesize % \parbox does \normalsize
    \centering\hrule\vspace{.5ex}\strut#1}}

\begin{document}

\signatures{Datum/Unterschrift Ausbildungsleiter}
  {Datum/Unterschrift Betreuer}
  {Datum/Unterschrift Ausbildungsleiter}

\end{document}

enter image description here

(Thanks to Heiko for spotting the misalignment of the rules.

  • \parbox[t] aligns the rules. – Heiko Oberdiek Jul 15 '13 at 13:18
  • @HeikoOberdiek You're right. I'll also add a strut. – egreg Jul 15 '13 at 13:26

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.