2

When using bidi with tcolorbox package the box is not inline with the text. Running the MWE with bidi commented or not makes it all clear. Can somebody explain this behaviour and possibly come up with a solution/workaround.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{bidi}

\begin{document}
Lorem ipsum before \tcbox[size=tight, on line]{some tcb text} lorem ipsum after
\end{document}
4

The cause of the problem is that the bidi package redefines tikzpicture and pgfpicture in a way which puts them into a paragraph. The following also does not work properly with your MWE, if bidi is enabled:

Lorem ipsum before \tikz\node[draw] {text}; lorem ipsum after

One could reset pgfpicture locally to its original behaviour. But, of course, this would disable the bidi adaptions also (locally). But, maybe, this does not matter for you application. Try the following:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{bidi}

\makeatletter

\tcbset{%
  bidi reset/.code={%
    \let\pgfpicture\origin@pgfpicture%
    \let\endpgfpicture\origin@endpgfpicture%
  }
}

\makeatother

\begin{document}
Lorem ipsum before \tcbox[bidi reset, size=tight, on line]{some tcb text} lorem ipsum after
\end{document}

This works for the MWE. But, it may not give the expected results for your intended application since you will have included bidi for a reason...

2
1

This is fixed in version 18.3 of the bidi package. You can even have it RTL:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{bidi}
\setRTL
\begin{document}
Lorem ipsum before \tcbox[size=tight, on line]{some tcb text} lorem ipsum after
\end{document}

which produces the following output:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.