# Placeholder with hint for handwritten text

How can I typeset form with hint which will flow nicely with other text in paragraph?

Approximate sample of what I'm trying to achieve is like this

• Please post a minimal working example (MWE) showing what you've tried. – cfr Apr 5 '15 at 18:38
• My code was not even near the solution, it was like \dotfill. I really didn't know in which direction to go. Thankfully Boris read my mind and gave good solution. – avsej Apr 5 '15 at 20:05

Some improvements based on Boris's answer. It's easier to control the spacing between the dots and the hint text.

\documentclass{article}

\usepackage[T2A]{fontenc} % avoid annoying warning
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}

% First parameter is size, second is hint
\newcommand\HandwrittenText[2]{%
\parbox[t]{#1}{%
\centering
\vspace*{.5\baselineskip}
\dotfill\par
\nointerlineskip\vspace{2pt}
{\footnotesize\strut (\textit{#2})}%
\par
}%
}

\begin{document}

В инспекцию Министерства по налогам и сборам\\
республики Беларусь (далее "--- инспекция МНС)\\
по\hspace*{1cm}\HandwrittenText{8cm}{наименование района, города, района в городке}

\end{document}


If you don't want the vertical space an that the dots are at the same baseline as по, remove the \vspace* instruction.

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}

% First parameter is size, second is hint
\newcommand\HandwrittenText[2]{%
\parbox[t]{#1}{%
\centering
\dotfill\par
\nointerlineskip\vspace{2pt}
{\footnotesize\strut (\textit{#2})}%
\par
}%
}

\begin{document}

В инспекцию Министерства по налогам и сборам\\
республики Беларусь (далее "--- инспекция МНС)\\
по\hspace*{1cm}\HandwrittenText{8cm}{наименование района, города, района в городке}

\end{document}


• nice answer it even simulates issues of original MS Excel version (that \vspace{}) :) – avsej Apr 5 '15 at 19:48
• @avsej If you don't want that space, just remove \vspace*{.5\baselineskip} and the dots will be at the same baseline as по – egreg Apr 5 '15 at 19:56
• Eventually I'm accepting this answer, because it works better. I only replaced \dotfill with \dotuline{#3\hfill}, because it allows to fill it in case the value known before printing out. – avsej Apr 5 '15 at 21:03

You create two boxes of the given size, one below another. The command \makebox[size]{\dotfill} creates the dotted line. The command \llap creates a box of zero length to the left of the point; you create a \parbox with centered hint.

Below we define a command \HandwrittenText with two parameters: size and hint:

\documentclass{article}
\usepackage[russian]{babel}
\usepackage[utf8]{inputenc}
% First parameter is size, second is hint
\newcommand\HandwrittenText[2]{%
\makebox[#1]{\dotfill}\llap{\raisebox{-0.8\baselineskip}{%
\parbox{#1}{\hfil\small\itshape#2\hfil}}}}
\begin{document}
\pagestyle{empty}
В инспекцию Министерства по налогам и сборам\\ республики Беларусь
(далее "---~инспекция МНС)\\ по \HandwrittenText{8cm}{(наименование
района, города, района в городке)}
\end{document}


There are couple of ways to do this. Some of them are rather hacky - e.g. use table with only the top hline.

Nicer solution that also gives you more control is to use mdframed, see http://texdoc.net/texmf-dist/doc/latex/mdframed/mdframed.pdf.

\documentclass{article}
\usepackage{tikz}

% Set the look of the node
\tikzset{mynode/.style={append after command={
[thick](\tikzlastnode.north west) edge[dashed] (\tikzlastnode.north east)}}}

% New environment for the form hint, change the baseline if needed
\newcommand{\formhint}[2][rectangle,draw]
{\tikz[baseline=0.8em] \node[mynode]{#2};}

\begin{document}
Some long text describing what should be put in the form.

no \formhint{Hello world}

\end{document}


It will look like this: