答案1
答案2
可能性tcolorbox
(如下所述)
\documentclass{article}
\usepackage[most]{tcolorbox}
\begin{document}
\tcbox[colback=white,boxrule=0pt,enhanced jigsaw,borderline horizontal={1pt}{0pt}{dashed},borderline vertical={1pt}{0pt}{dashed}]{$E=mc^2$}
\end{document}
简易版
tcolorbox
为框和框架等提供了很好的功能。我定义了一个\dashedbox
命令,它有一个宽度为 1 的虚线框1pt
和白色背景 (colback=white),不绘制通常的框架 ( boxrule=0pt
)。为了提供相等的高度,使用了相等高度组。
可以使用可选参数来否决所有设置\dashedbox
(就像第二个例子所做的那样!)
\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcbox{\dashedbox}[1][]{equal height group=dashedbox,
nobeforeafter,
colback=white,
boxrule=0pt,
enhanced jigsaw,
borderline horizontal={1pt}{0pt}{dashed},
borderline vertical={1pt}{0pt}{dashed},
#1
}
\begin{document}
\dashedbox{$E=mc^2$} \dashedbox[colback=yellow]{$E^2=(mc^2)^2 + (pc)^2$}
\end{document}
下次更新
\documentclass{article}
\usepackage[most]{tcolorbox}
\newtcbox{\dashedbox}[1][]{
math upper,
baseline=0.4\baselineskip,
equal height group=dashedbox,
nobeforeafter,
colback=white,
boxrule=0pt,
enhanced jigsaw,
boxsep=0pt,
top=2pt,
bottom=2pt,
left=2pt,
right=2pt,
borderline horizontal={0.5pt}{0pt}{dashed},
borderline vertical={0.5pt}{0pt}{dashed},
drop lifted shadow,
#1
}
\begin{document}
Einstein said: $\dashedbox{E=mc^2} \; \dashedbox[colback=yellow]{E^2=(mc^2)^2 + (pc)^2}$
\end{document}