答案1
你的想法很好:
\documentclass{article}
\usepackage{amsmath,array}
\newcommand{\lyet}[1]{%
\begingroup
\renewcommand{\arraystretch}{0}% no added height
\setlength{\arraycolsep}{0pt}% no intercolumn padding
\begin{array}[b]{|l}
\hline
% some room above
\rule{0pt}{0.2ex}\\
% small space at the sides
\mspace{1mu}\smash[b]{#1}\mspace{1mu}
\end{array}%
\vphantom{#1}% fix the depth
\endgroup
}
\begin{document}
$\lyet{2}+\lyet{x+y-d}$
\end{document}