TeX - LaTeX Asked by Victor Lequin on October 24, 2020
I use some tcolorbox
boxes, created using newtcbtheorem
with the option auto counter
on so that they come with automatic numbering. That works fine, but in my language (French), there should be a space before columns (i.e. I want the box to display "My box n : title" instead of "My box n: title"). I have been able to achieve this result by styling the number, using option number freestyle={noexpandarabic{tcbcounter}~}
. The problem is, when I use the version of these boxes without a number (by using the starred environment, i.e. begin{myBox*}
), the title becomes "My box: title". How could I turn this to "My box : title"?
Below is a minimal working example.
documentclass{article}
usepackage[T1]{fontenc}
usepackage[french]{babel}
usepackage[most]{tcolorbox}
newtcbtheorem[auto counter, number freestyle={noexpandarabic{tcbcounter}~}]{myBox}{My box}{}{myBox}
begin{document}
begin{myBox}{Title}{}
Text
end{myBox}
begin{myBox*}{Title}
Text
end{myBox*}
end{document}
Output:
What I would like (I edited the picture with Paint):
The title of a tcolorbox theorem can be separated into 4 components: The type, the number, the separator sign and the title text itself.
While the regule aversion of the box uses all four elements, the starred version uses all elements except of the number.
Adding the space between the missing number and the seprator sign (: in your case) will therefore only add the space in the numbered version of the box, while it sill still be missing in the unnumbered version.
Thus, it might be better, to directly change the separators sign and include the space there.
Inspired by the definition of the dash separator sign ( --
) I suggest, redefining your colon separator as follows: separator sign={ :}
To globally use this new separator sign for all myBox
boxes, you can use
newtcbtheorem[auto counter]{myBox}{My box}{separator sign={ :}}{myBox}
A full MWE looks like the following and produces this output:
documentclass{article}
usepackage[T1]{fontenc}
usepackage[french]{babel}
usepackage[most]{tcolorbox}
newtcbtheorem[auto counter]{myBox}{My box}{separator sign={ :}}{myBox}
begin{document}
begin{myBox}{Title}{}
Text
end{myBox}
begin{myBox*}{Title}
Text
end{myBox*}
end{document}
Correct answer by leandriis on October 24, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP