In Japan, it is very common to underline an answer in a math exam sheet with this:

(Usual underline plus two slashes at the end.) Can I find a macro for this in some package? If not, do I have to create it with TikZ?

I've tried \underline{45\tiny$_{\!/\!\!/}$}, but the result was not what I desired.

• Are you familiar with the \underline macro? A comment up front: \underline does not add the two slashes. How important are these slashes?
– Mico
Jan 15 at 6:12
• @Mico Sorry for the unimportance. But at least for Japanese, it is in a way useful.
– Taro
Jan 15 at 6:17

With TikZ you can create a macro for this purpose. For example:

\documentclass{article}
\usepackage   {tikz}

\newcommand{\mysol}[1]
{% <-- We don't need a space here
\begin{tikzpicture}[baseline=(a.base),line width=0.1ex]
\node[inner sep=0] (a) at (0,0) {$#1$};
\draw (a.south west) -- ([xshift=1.5ex]a.south east);
\foreach\i in {0,0.5}
\draw ([xshift=\i ex,yshift=-0.5ex]a.south east) --++ (1ex,1ex);
\end{tikzpicture}% <-- We don't need a space here either
}

\begin{document}
\textbf{Problem.} The bottom of a ladder must be placed $3$ feet from a wall.  The ladder is $12$ feet long.  How far above the ground does the ladder touch the wall?
\bigskip

\textbf{Solution.} By the Pythagorean Theorem,
$a^2=b^2+c^2\Longrightarrow b=\sqrt{a^2-b^2}=\sqrt{12^2-3^2}=\sqrt{135}=\mysol{3\sqrt{15}}.$
So the ladder touches the wall \mysol{3\sqrt{15}} feet above the ground.
\end{document}


Note that if the solution will not be in math mode you must remove the $...$ inside the node in the macro.

• +1: What is the foreach for? Jan 15 at 7:08
• @Dr.ManuelKuehner To place two slash / but it's not necessary Jan 15 at 7:10
• @Dr.ManuelKuehner, thanks!! And the foreach is for the two slashes. Probably unnecessary, I know XD. Jan 15 at 7:11

I think you don't need TikZ for this:

\documentclass{article}
\usepackage{amsmath}
\newlength{\mylen}
\newlength{\mydepth}

\newcommand{\myunder}[1]{\settowidth{\mylen}{\tiny${\!/\!\!/}$}%
\settodepth{\mydepth}{#1}%
\underline{#1\hspace{\mylen}}\hspace{-\mylen}\raisebox{-\mydepth}{\tiny${\!/\!\!/}$}}
\begin{document}

Answer with \verb|\cfrac|: \myunder{$\cfrac{44}{45}$}
\end{document}


• Thanks. I tried \myunder{$\cfrac{44}{45}$} now and backslashes went to a weird position. Is it possible to tweak the code so that it can apply to this case too?
– Taro
Jan 15 at 7:10
• @Taro Of course! I have generalized my answer, look at it now, thanks! Jan 15 at 7:22

You could do this way:

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}

\newcommand{\solution}[1]{%
% store the text so we can measure it
% the underline will always be below the baseline
\sbox0{\underline{#1}}%
% measure the double slash
\sbox2{\raisebox{\depth}{\solutionsymbol}}%
% do the job (assuming the underline is 0.4pt thick)
\dimen0=\dimexpr\dp0+\ht2/2-\fontdimen8\textfont3\relax
\underline{#1\!\raisebox{-\dimen0}[0pt][0pt]{\usebox{2}}}%
% add the depth we smashed out
\vphantom{\raisebox{-\dimen0}{\usebox{2}}}%
}
\newcommand{\solutionsymbol}{\scalebox{1}[0.33333]{/\!\!/}}

\begin{document}

Some text \solution{$45$}

\bigskip

Some text \solution{$\dfrac{1}{2}$}

\end{document}