# How to produce a period sequence

I would like to create a document which has a sequence of periods like:

......................
Date


and

............................
Signature


Is there any way to do it without typing all the periods myself (maybe even a way which was made for this often seen typographical quirk)?

-
Related: Dynamic signature/date line – Werner Jul 26 '13 at 4:14

\documentclass{article}
\usepackage{xparse}
\usepackage{multicol}

\NewDocumentCommand \dotbox {o O{.5\linewidth} m O{3ex} O{\linewidth}}
{
\begin{minipage}{#2}
\IfValueTF{#1}{#1}{\null}
\\[#4]
\makebox[#5]{\dotfill}
\\
#3
\end{minipage}
}

\begin{document}
\hrule
\begin{multicols}{2}

\end{multicols}
\hrule
\vspace*{3cm}
\hrule
\dotbox[Sign here (4ex)][4cm]{\TeX.SX}[4ex]
\hspace*{2cm}
\dotbox[And here (3ex)][3cm]{\TeX.SX}
\hrule
\end{document}


Note that while this implementation allows you to have successive calls to \dotbox without a paragraph break, the baseline may be screwed up if you do so with differing dimensions, as can be seen from the second two uses.

-
how would I place 2 dotboxes on the same height? – TheChymera Nov 10 '13 at 14:43
I would use multicol; I haven't tried it, but I think it'd work. – Sean Allred Nov 10 '13 at 18:13
@TheChymera See my edit. – Sean Allred Nov 10 '13 at 19:21

Here is a sample TeX file to do it:

\documentclass{article}

\begin{document}

\makeatletter
\def\mydots#1{\hbox to #1{\leaders\hbox{$\m@th \mkern 1mu\hbox{.}\mkern 1mu$}\hfil}}
\makeatother

\mydots{5pc}

\end{document}


\mydot{5pc} will put dots for a width 5pc. You can customize this.

Note: There is also a package named dashrule which has so may features.

-
FYI, you missed the \makeatother – Sean Allred Jul 26 '13 at 4:05
@SeanAllred: I don't think \makeatother is a must. You can check by giving @@@ later in the text. – Jagath AR Jul 26 '13 at 4:08
Put \@ifundefined{fakemacro}{Should I be able to do this?}{I think not.} right after \mydots. Writing @@@ is just like writing aaa or bbb as far as catcodes are concerned once you say \makeatletter; @ is used for internal macros and should not be generally available at the document level. – Sean Allred Jul 26 '13 at 4:17
your example is great - and dashrule is indeed even better. Thanks! – TheChymera Jul 26 '13 at 4:45

Using \hbox is not really recommended, because it can have unexpected effects.

\newcommand{\dottedline}[3][3ex]{%
\par % end the current paragraph (if necessary)
\nopagebreak % don't break a page here
\vspace{#1}% space before the signature
\noindent\makebox[#2]{\dotfill}% make the dotted line
\\* % go to a new line without any page break
\noindent#3% signature
\par % end the paragraph
}


Here's a complete example:

\documentclass{article}

\newcommand{\dottedline}[3][3ex]{%
\par % end the current paragraph (if necessary)
\nopagebreak % don't break a page here
\vspace{#1}% space before the signature
\noindent\makebox[#2]{\dotfill}% make the dotted line
\\* % go to a new line without any page break
\noindent#3% signature
\par % end the paragraph
\vspace{#1}% space below the signature
}

\begin{document}