Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why /tcb/before not used for floating boxes? #172

Closed
dbitouze opened this issue Feb 21, 2022 · 8 comments
Closed

Why /tcb/before not used for floating boxes? #172

dbitouze opened this issue Feb 21, 2022 · 8 comments
Assignees

Comments

@dbitouze
Copy link
Contributor

dbitouze commented Feb 21, 2022

According to the documentation (currently page 81), /tcb/before is not used for floating boxes.

However, this option would be useful with floats in some cases. E.g., in case of floating boxes not on their call out pages, one may want to automatically insert (just before theses boxes call out locations), text such as "See example ⟨n⟩ page ⟨m⟩." (for this, one can rely on /tcb/label and tests such as \int_compare:nNnF {\getpagerefnumber{⟨label⟩}} = {\thepage}{...}, thanks to refcount package).

@T-F-S
Copy link
Owner

T-F-S commented Feb 22, 2022

It is not used, because mainly before and after are used to control the vertical distance of a box to the preceding and following text. These options are not empty be default, but set such that normally the vertical distance looks alright.

After headings, the before code is typically removed, also for floating boxes. In both cases the space settings would be disturbing since in these cases there already is space provided.

Using before to output texts like see example is not the intended purpose (even if you can use it like that).

In the use case you mentioned, I could image wrapping the tcolorbox into an environment which also outputs the intended text before the tcolotbox. Or, if the text is always a one-liner like "See example x on page y", enlarge top initially by could be used to reserve space before the box and an underlay to print the text.

@dbitouze
Copy link
Contributor Author

It is not used, because mainly before and after are used to control the vertical distance of a box to the preceding and following text. These options are not empty be default, but set such that normally the vertical distance looks alright.

I see.

After headings,

I'm not sure what you mean here.

the before code is typically removed, also for floating boxes. In both cases the space settings would be disturbing since in these cases there already is space provided.

OK for floating boxes.

Using before to output texts like see example is not the intended purpose (even if you can use it like that).

That's what I guessed. And I was desperate to not find any hook that let me insert something before the boxes.

In the use case you mentioned, I could image wrapping the tcolorbox into an environment which also outputs the intended text before the tcolorbox.

I'm not sure it could be an option: the "See example x on page y" text is supposed to appear only if the floating box is located on a page other than its call out page so I have to performed the test (on pages numbers) within (the options of) the tcolorbox (BTW a TCBListing in my use case).

Or, if the text is always a one-liner like "See example x on page y", enlarge top initially by could be used to reserve space before the box and an underlay to print the text.

Is it necessary to "enlarge top initially" since the "See example x on page y" text is supposed to appear only if the floating box is located on a page other than its call out page?

About underlay:

  • since it is documented as /tcb/underlay=⟨graphical code⟩, I couldn't imagine use it for something else than, well, graphical code,
  • is it appropriate for inserting something which is supposed to be located on a page other than the page where is located its corresponding tcolorbox?

@muzimuzhi
Copy link
Contributor

muzimuzhi commented Feb 22, 2022

Seems to be an opportunity for a set of new options like /tcb/before float, /tcb/after float, and their pre/app variants. Currently tcolorbox already provides /tcb/every float=<code> which will insert <code> at the beginning of every floating box.

@T-F-S
Copy link
Owner

T-F-S commented Feb 23, 2022

@dbitouze Maybe, I had not completely understood what you like to achieve. underlay can contain a \node to position text outside a tcolorbox frame, but this is useful for static or near-static text like a one-liner. If it is context dependend, if the text is to be shown or not, this is not a good option since the space reservation is fixed.

@muzimuzhi Adding /tcb/before float and /tcb/after float is a reasonable feature request. Alas, changing the very sensible before/after code has a high danger of influencing the interaction of all tcolorboxes with other text elements. In the past, every tiny change caused many, many hours of debugging. The float part should not be as critical, but I will postpone investigation of such a feature until I have more time.

@dbitouze
Copy link
Contributor Author

Adding /tcb/before float and /tcb/after float is a reasonable feature request.

Good news! 😄

Alas, changing the very sensible before/after code has a high danger of influencing the interaction of all tcolorboxes with other text elements. In the past, every tiny change caused many, many hours of debugging. The float part should not be as critical, but I will postpone investigation of such a feature until I have more time.

Since before/after code is disabled for floats, new /tcb/before float and /tcb/after float should not change anything to before/after, isn't it?

@T-F-S
Copy link
Owner

T-F-S commented Feb 24, 2022

Alas, changing the very sensible before/after code has a high danger of influencing the interaction of all tcolorboxes with other text elements. In the past, every tiny change caused many, many hours of debugging. The float part should not be as critical, but I will postpone investigation of such a feature until I have more time.

Since before/after code is disabled for floats, new /tcb/before float and /tcb/after float should not change anything to before/after, isn't it?

That's why I hope a change is not critical. I will look into that matter with more time.

@T-F-S T-F-S self-assigned this Jun 21, 2022
@T-F-S
Copy link
Owner

T-F-S commented Jun 21, 2022

The next version will contain the requested option.

  • Options to insert code at begin and end of floats
    • Option before float
    • Option after float
    • Option before float app
    • Option before float pre
    • Option after float app
    • Option after float pre

But, these options are restricted to unbreakable floating objects. For breakable floating objects, the space needed for these code parts cannot be computed in advance and therefore the break algorithm cannot be adapted (For non-floating boxes, the situation is different).

@T-F-S
Copy link
Owner

T-F-S commented Jun 22, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants