答案1
含钛钾Z 您可以为此目的创建一个宏。例如:
\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}
请注意,如果解决方案不是数学模式,则必须删除$...$
宏中的节点内部。
答案2
我认为你不需要 TikZ 来实现这一点:
\documentclass{article}
\usepackage{amsmath}
\newlength{\mylen}
\newlength{\mydepth}
\newcommand{\myunder}[1]{\settowidth{\mylen}{\tiny${\!/\!\!/}$}%
\settodepth{\mydepth}{#1}%
\addtolength{\mydepth}{.6ex}%
\underline{#1\hspace{\mylen}}\hspace{-\mylen}\raisebox{-\mydepth}{\tiny${\!/\!\!/}$}}
\begin{document}
Ordinary answer: \myunder{45}
Answer with \verb|\cfrac|: \myunder{$\cfrac{44}{45}$}
\end{document}
答案3
你可以这样做:
\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}