关于下面的命令,它在指定字母(B)周围创建一个带有彩色背景(浅灰色)的框,并且不会影响单词的字符间距:
\uline{\adjustbox{cframe=black 0.1mm 2pt 0mm,bgcolor=gray!25}{{\textbf{B}}}ob
我需要得到完全相同的结果,但是用虚线框代替,因此我尝试了 dashbox 包,但是我无法设置如上所示的尺寸,也无法设置背景颜色、字符间距、框大小和背景颜色
\uline{\textbf{\dbox{B}}}ob
\documentclass[a4paper,12pt,twoside]{book}
\usepackage{dashbox}
\usepackage[normalem]{ulem}
\usepackage{adjustbox}
\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}
\babelfont[arabic]{rm}{Simplified Arabic}
\babelfont[english]{rm}{Times New Roman}
\begin{document}
\uline{\textbf{\dbox{B}}}ob
\uline{\adjustbox{cframe=black 0.1mm 2pt 0mm,bgcolor=gray!25}{{\textbf{B}}}}ob
\end{document}
答案1
使用以下解决方案tikz
:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\begin{document}
\newcommand{\solidbox}[1]{%
\tikz[baseline]\node[anchor=base, draw=black, outer sep=0pt, inner sep=1pt, fill=black!20] {#1};%
}
\newcommand{\dashedbox}[1]{%
\tikz[baseline]\node[anchor=base, draw=black, dash pattern=on 2pt off 1pt, outer sep=0pt, inner sep=1pt, fill=black!20] {#1};%
}
\noindent ob\solidbox{B}cdef
\noindent ob\dashedbox{B}cdef
\end{document}