0

Regarding the command below, it creates a box around the designated letter (B) with colored background (Light gray) and does not affect the inter-character spacing of the word:

\uline{\adjustbox{cframe=black 0.1mm 2pt 0mm,bgcolor=gray!25}{{\textbf{B}}}}ob

I need to have exactly the same result but with a dotted box instead, so I tried the dashbox package, yet I cannot set the dimensions as shown above and also I cannot set the background color, intercharacter spacing, box size and background color cannot be set

\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}

enter image description here

Silva
  • 743

1 Answers1

2

A solution using tikz:

enter image description here

\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}

Alan Xiang
  • 5,227
  • you can also refer to macros proposed in these posts: https://tex.stackexchange.com/questions/528341/emphasizing-arabic-text-characters, https://tex.stackexchange.com/a/529439/54817, https://tex.stackexchange.com/a/529602/54817 – Silva Aug 15 '20 at 23:56