I have to write a format using undescores like this
But when I put antislash before every one to escape it, it doesn't look nice, the underscores looks seperated
Is there a solution to escape the hole word
Set a \rule of specified width:
\documentclass{article}
\newcommand{\format}[2][-.2\baselineskip]{\rule[#1]{#2}{.4pt}}
\begin{document}
Format (\format{2em}) \format{2em}-\format{2em}-\format{2em}-\format{2em}
\end{document}
Some vertical adjustment can be tweaked by trying different lengths. The optional argument to \format sets the rule .2\baselineskip below the baseline by default.
\documentclass{article}
\newcommand{\format}[2][2pt]{\underline{\hspace{#1}\phantom{#2}\hspace{#1}}}
\begin{document}
Format (\format{000}) \format{000}-\format{000}-\format{000}-\format{000}
\end{document}
The above option uses an \underlined \phantom with some padding.
I suggest making \format to use a sample argument to define the width (plus buffer, in this case 2pt). For example, \format{000} will make the underline the width of "000" plus 2pt.
\documentclass{article}
\newcommand{\format}[1]{\setbox0=\hbox{#1}\rule[-.2\baselineskip]{\dimexpr2pt+\wd0}{.4pt}}
\begin{document}
Format (\format{00}) \format{000}-\format{000}-\format{000}-\format{000}
\end{document}
If one wanted to account for the difference between typeset versus handwritten lettering, one could apply a multiplier to \wd0, as in
\documentclass{article}
\newcommand{\format}[1]{\setbox0=\hbox{#1}\rule[-.2\baselineskip]{\dimexpr3pt+1.5\wd0}{.4pt}}
\begin{document}
Format (\format{00}) \format{000}-\format{000}-\format{000}-\format{000}
\end{document}
\underline{...}or the various commands from thesoulpackage. I wouldn't use\underlinehowever as a real typesetting tool ;-). And you meanbackslash, most likely, i.e.\_– Aug 11 '16 at 15:29