Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
3  
Related: Dynamic signature/date line –  Werner Jul 26 '13 at 4:14
add comment

3 Answers

up vote 15 down vote accepted

Use \dotfill:

\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}
  \dotbox[Please sign below:]{A. U. Thor}

  \dotbox[And your initials:]{A. U. T.}[6ex][6em]
\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}

output

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.

share|improve this answer
    
how would I place 2 dotboxes on the same height? –  TheChymera Nov 10 '13 at 14:43
1  
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
add comment

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.

share|improve this answer
3  
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
4  
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
add comment

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}

Please sign here:

\dottedline{6cm}{A. U. Thor}

And your initials:

\dottedline[1ex]{3cm}{A. U. T.}

\end{document}

enter image description here

share|improve this answer
    
Good point; and neither of the existing solutions prevent the pagebreak. –  Sean Allred Jul 29 '13 at 17:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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