[Tex/LaTex] customizing the length of \dotfill


How can I set a length of \dotfill ?
I used \dotfill {3 cm} and \dotfill \phantom{3 cm} without success. I can create a box and put dotted line there, but can it not be simpler?

Write down your name ? \dotfill \newline 
What is your age ? \dotfill {3 cm} and Gender \dotfill {3cm} 

Best Answer

Here is \dotline[<period>]{length}. EDITED to \leavevmode.

\def\dotfill#1{\cleaders\hbox to #1{.}\hfill}
\newcommand\dotline[2][.5em]{\leavevmode\hbox to #2{\dotfill{#1}\hfil}}


enter image description here

Related Question