latex3 / babel

The babel system for LaTeX, LuaLaTeX and XeLaTeX
LaTeX Project Public License v1.3c
126 stars 34 forks source link

Issue with 'attach boxed title to .... ' keys from tcolorbox (layout=graphics) #145

Closed seloumi closed 2 years ago

seloumi commented 2 years ago

From this question https://tex.stackexchange.com/questions/612173/problem-with-lualatex-arabic-personal-tcolorbox/612236#612236 I noticed that keys attach boxed title to top right (top left ,top center, bottom right, .... ) produce a title box without title and the position of the box is not in the correct place

Minimal example

\documentclass{book}
\usepackage[most]{tcolorbox}
\usepackage[bidi=basic,layout=graphics]{babel}
\babelprovide[import,main]{arabic}
\babelfont{rm}{Amiri}

\begin{document}

\begin{tcolorbox}[enhanced,title=عنوان الاطار,attach boxed title to top right]
This is a \textbf{tcolorbox}.
\end{tcolorbox}

\end{document}

image

Patching tikzpicture@tcb@hooked defined in https://github.com/T-F-S/tcolorbox/blob/e25e8f51ff49417ff96d0435f7bbd9483f321dfe/tex/latex/tcolorbox/tcbskins.code.tex#L24 like this give correct result

\documentclass{book}
\usepackage[most]{tcolorbox}
\usepackage[bidi=basic,layout=graphics]{babel}
\babelprovide[import,main]{arabic}
\babelfont{rm}{Amiri}

\makeatletter
\bbl@sreplace\tikzpicture@tcb@hooked{\noexpand\tikzpicture}%
          {\textdir TLT\noexpand\tikzpicture}%
\makeatother

\begin{document}

\begin{tcolorbox}[enhanced,title=عنوان الاطار,attach boxed title to top right]
This is a \textbf{tcolorbox}.
\end{tcolorbox}

\end{document}
seloumi commented 2 years ago

Sorry I forgot to mention that \tikzpicture@tcb@hooked is defined with skins library so this give error

\documentclass{book}
\usepackage{tcolorbox}
\usepackage[bidi=basic,layout=graphics]{babel}
\babelprovide[import,main]{arabic}
\babelfont{rm}{Amiri}

\makeatletter
\bbl@sreplace\tikzpicture@tcb@hooked{\noexpand\tikzpicture}%
          {\textdir TLT\noexpand\tikzpicture}%
\makeatother

\begin{document}

\begin{tcolorbox}[title=عنوان الاطار]
This is a \textbf{tcolorbox}.
\end{tcolorbox}

\end{document}

To bypass this problem patching of \tikzpicture@tcb@hooked should be like this

\ifx\tikzpicture@tcb@hooked\@undefined\else
\bbl@sreplace\tikzpicture@tcb@hooked{\noexpand\tikzpicture}%
          {\textdir TLT\noexpand\tikzpicture}%
\fi