tcolorbox add tag
a year ago CarLaTeX

With the help of frougon, I almost get what I like.

The last thing I’m missing is how to set the flush right option when the tcolorbox has the varwidth option. Please look at the third green boxes of the two examples below:

image.png

a year
samcarter replying to CarLaTeX — Saturday, 2nd Mar 2024 19:26

Yeah!

an hour
CarLaTeX replying to samcarter — Saturday, 2nd Mar 2024 18:32

Article just sent to the TUGBoat, prof. van Duck also added your note about \tcbsetforeverylayer. He didn’t know about it and found it useful 😄

a day
samcarter — Friday, 1st Mar 2024 12:51

@CarLaTeX The professor got mail 😃

a day
frougon replying to CarLaTeX — Thursday, 29th Feb 2024 08:14

Ah, you’re right. So yes, that’s slightly weird IMHO, but then it can be considered to be “part of the contract” that etoolbox is loaded whenever \usepackage{tcolorbox} has been issued (an explicit \usepackage{etoolbox} wouldn’t hurt, though, as TeX won’t reread the .sty file a second time).

27 minutes
CarLaTeX replying to frougon — Thursday, 29th Feb 2024 07:47

Thank you! tcolorbox explicitly says it loads etoolbox in its documentation

13 hours
frougon replying to CarLaTeX — Wednesday, 28th Feb 2024 18:37
  1. Right. Some people sometimes say “you don’t need to load X because Y already does”, however unless Y explicitly states that it loads X in its documentation, one should not (ideally) rely on this fact. It doesn’t cost anything to add \usepackage{etoolbox}, and this ensures your document will still work even in the hypothetical case where a future version of tcolorbox were not to use etoolbox.
frougon replying to CarLaTeX — Wednesday, 28th Feb 2024 18:34
  1. Sure, that part was mostly for fun and FYI (using an expl3 dim expr to hopefully make the calculation easier to read).
frougon replying to CarLaTeX — Wednesday, 28th Feb 2024 18:29

You’re welcome!

  1. I wouldn’t say it is an error strictly speaking, however it is best not to use them when possible (except when the internals are yours, of course). In this case, I can’t see any good way not to use them. Well, you could probably use, e.g., /tcb/righttitle=... to set a value you know and then use that value instead of \kvtcb@righttitle, but this is really ugly and not equivalent (this modifies the parameter).
    The internals are marked by the @ in macro names. The tcolorbox author could e.g. change righttitle/.store in=\kvtcb@righttitle to righttitle/.store in=\tcbfoo@righttitle or something completely different and no one would have any “right” to complain—even though that would break some of your examples.
    Internals are mechanisms that programmers use in their code but for which they don’t promise anything (in particular, they don’t promise continued existence nor behavior). The internals of LaTeX2e have been and are still heavily used by thousands of package and document authors, so we probably won’t shock anybody here… expl3 tries to improve this situation by mandating an orderly naming scheme where, among others, the owning package/class/etc. and the public vs. internal status are clearly “encoded” in control sequence names.
13 minutes
CarLaTeX — Wednesday, 28th Feb 2024 18:16

@frougon ^^^

CarLaTeX — Wednesday, 28th Feb 2024 18:10
  1. tcolorbox loads etoolbox, I will add it
CarLaTeX — Wednesday, 28th Feb 2024 18:08
  1. I prefer not to complicate the code too much, the article is aimed at newbies
CarLaTeX — Wednesday, 28th Feb 2024 18:07
  1. Is it an error to use the tcolorbox internals?
CarLaTeX replying to frougon — Wednesday, 28th Feb 2024 18:06

Thank you very much!

an hour
frougon replying to CarLaTeX — Wednesday, 28th Feb 2024 17:10

Hi, thanks a lot for the notice! I haven’t read the article yet, but after a quick look at box 6, I have two little comments (that’s FYI and for fun, I’m not asking you to modify your article).

  1. First, I feel guilty for having suggested using \kvtcb@width since it is a tcolorbox internal. The obvious way to make me feel less guilty is to encapsulate all uses of this internal so that it only appears in one place:

    With this, you can use \my@tcbget{width} instead of \kvtcb@width and ditto for \kvtcb@lefttitle and \kvtcb@righttitle.

  2. The second thing is just a different way of computing \mytitlelen in the mywidth style—using expl3, of course. 😃

Here is the full example for box 6 (sorry, I recreated the indentation as I copy/pasted from the PDF which presumably wasn’t a great idea; as a result, it doesn’t necessarily match yours):

This example doesn’t require etoolbox, but presumably yours should have the \usepackage call? (Yes, it works as is, but “by luck” because some of the packages you explicitly load must itself load etoolbox…)

6 hours
CarLaTeX replying to samcarter — Wednesday, 28th Feb 2024 10:58

❤️

20 minutes
samcarter replying to CarLaTeX — Wednesday, 28th Feb 2024 10:38

Thank you for sharing! I’m looking forward to read it tonight!

CarLaTeX — Wednesday, 28th Feb 2024 10:33

@frougon @samcarter If you like to read the pre-view of van Duck’s article: https://www.overleaf.com/read/thfwczqpywzr#c6ca2b (you are cited)

14 days
samcarter replying to frougon — Wednesday, 14th Feb 2024 01:36

Haha! 😄

4 hours
frougon — Tuesday, 13th Feb 2024 21:46

Young ducklings can solve problems by just staring at them. Witchcraft, I dare say! 😃

2 hours
samcarter replying to CarLaTeX — Tuesday, 13th Feb 2024 19:44

Great to hear that is working!

34 minutes
CarLaTeX replying to samcarter — Tuesday, 13th Feb 2024 19:11

I confirm that it works with my up-to-date distribution, thank you!

2 hours
CarLaTeX replying to samcarter — Tuesday, 13th Feb 2024 17:38

It’s not a problem. I made only the test on Overleaf, my actual project is on my pc, thank you!

4 hours
samcarter replying to CarLaTeX — Tuesday, 13th Feb 2024 13:11

Ah! I can reproduce in overleaf and locally with texlive22. If you can wait a couple of days, you could ask yo’ to move your project to texlive24. This should solve the problem.

CarLaTeX replying to samcarter — Tuesday, 13th Feb 2024 13:04

I created the example on Overleaf, I’ll try with my distrution tonight, thank you!

3 hours
samcarter — Tuesday, 13th Feb 2024 09:44

Can’t test as I can’t reproduce the problem, but maybe something like before upper={\flushright} might work for your situation.

samcarter — Tuesday, 13th Feb 2024 09:40

How do you compile your document? With pdflatex from TL24 and TL23 I get:

Screenshot 2024-02-13 at 10.39.20.png

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.