T-F-S / tcolorbox

A LaTeX package to create highly customizable colored boxes.
http://www.ctan.org/pkg/tcolorbox
LaTeX Project Public License v1.3c
213 stars 15 forks source link

Section in a tcolorbox is not transfered to \rightmark #242

Closed Sk1nk closed 10 months ago

Sk1nk commented 10 months ago

I described the issue over on stackexchange here, with a minimal working example. Unfortunately it seems like \sectionmark is trapped inside a tcolorbox and not transfered outside for further use.

The sections do appear in a table of contents.

muzimuzhi commented 10 months ago

\mark commands can't excape boxes --- Ulrike Fischer https://tex.stackexchange.com/questions/509817/markboth-inside-tikz-node-text-not-working#comment1289306_509817

Sk1nk commented 10 months ago

\mark commands can't excape boxes --- Ulrike Fischer https://tex.stackexchange.com/questions/509817/markboth-inside-tikz-node-text-not-working#comment1289306_509817

So no solution possible. Thanks for the clarification.

Sophanatprime commented 10 months ago

It is true that \mark (\marks) command can't excape boxes, but it is possible to extract the first mark and the last mark in a box, just like the multicol package or \__mark_update_structure:nn of LaTeX kernel do.

You split off a box to \maxdimen, and you will get \splitfirstmark and \splitbotmark (\splitfirstmarks and \splitbotmarks), which are exactly the first mark and the last mark in this box (unless the height of box is greater than \maxdimen), you store them and do \mark at appropriate time.

I have written a package updatemarks (no documentation for now), it can automatically update marks in minipage environment for now, and will take more time (much more, actually) to support tcolorbox, multicol and paracol because their codes are rather complicate. The main obstacle is to find appropriate point to extract and reinsert these marks.

But if you find the appropriate point by yourself, you can use \ExtractMarks{<box num>} (any box you want to extract marks, must be the innermost one) or \ExtractSplitMarks (after you did \vsplit) to extract and save marks and \UpdateMarks to reinsert marks.

Sophanatprime commented 10 months ago

Now, updatemarks can automatically update marks in tcolorbox, just type

\usepackage[tcolorbox]{updatemarks}

or

\begin{tcolorbox}[updatemarks=true]
...

or

\tcbset{updatemarks=true}

But, when you use \leftmark and \rightmark and find it cannot show the correct value, try

\renewcommand\leftmark{\LastMark{2e-left}}
\renewcommand\rightmark{\FirstMark{2e-right}}

Feel free to report issues.

T-F-S commented 10 months ago

Now, updatemarks can automatically update marks in tcolorbox

Thank you for adding your helpful package!