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

capture=<mode> added to every box style has no effect #246

Closed
muzimuzhi opened this issue Sep 25, 2023 · 3 comments
Closed

capture=<mode> added to every box style has no effect #246

muzimuzhi opened this issue Sep 25, 2023 · 3 comments
Assignees

Comments

@muzimuzhi
Copy link
Contributor

For tcolorbox environment, in \tcb@@icolorbox

  • First, one of the every box styles, every box on layer <n> or every box on higher layers are used by \tcb@layer@inc.
  • Then, the capture mode is (re)set by \tcb@apply@box@options{capture=minipage,#1}.
    \long\def\tcb@@icolorbox[#1]{%
    \tcb@layer@inc%
    \tcb@apply@box@options{capture=minipage,#1}\tcb@height@adjust%
    \tcb@hasLowerfalse%
    \csname tcb@@capture@\kvtcb@capture\endcsname%
    }

For \tcbox and \tcboxfit, similar capture mode overwriting happen in \tcb@ox, where its #1, a comma-separated style list starting with capture=hbox|fitbox, is applied after \tcb@layer@inc.

This is a long-existing behavior, so long that it's reproducible with Overleaf's TeX Live 2014 mirror. If classified as a feature, only documentation refinement is needed.

\documentclass{article}
\usepackage{tcolorbox}

\tcbset{
  every box/.append style={
    capture=hbox
  }
}

\def\tcbEveryBoxCaptureModeTests{
  \begin{tcolorbox}
    Use \texttt{hbox} from \texttt{every box}
  \end{tcolorbox}
  
  \begin{tcolorbox}[hbox]
    Set \texttt{hbox} per box
  \end{tcolorbox}
}

\begin{document}

\subsection*{Before}
\tcbEveryBoxCaptureModeTests

% set "capture=<mode>" _before_ applying "every box on layer <n>"/"every box on higher layers"
% tcolorbox part only
\makeatletter
\long\def\tcb@@icolorbox[#1]{%
  \tcbset{capture=minipage}% or pass "capture=<mode>" to \tcb@layer@inc
  \tcb@layer@inc%
  \tcb@apply@box@options{#1}\tcb@height@adjust%
  \tcb@hasLowerfalse%
  \csname tcb@@capture@\kvtcb@capture\endcsname%
}
\makeatother

\subsection*{After \textnormal{(for display only, not really a proposal)}}
\tcbEveryBoxCaptureModeTests
\end{document}

image

@T-F-S
Copy link
Owner

T-F-S commented Sep 26, 2023

I think the current behavior is not especially intended. I am not sure, if a global every box setting of a capture mode is a good idea, and, maybe, therefore I paid not attention to such a possibility until now.

Nevertheless, changing the code as you have proposed should do no harm to existing documents. So, I will do this (and also for \tcb@ox) for the next version.

@T-F-S T-F-S self-assigned this Sep 26, 2023
@muzimuzhi
Copy link
Contributor Author

I am not sure, if a global every box setting of a capture mode is a good idea

May be only handy in small document for testing. :)

@T-F-S
Copy link
Owner

T-F-S commented Sep 28, 2023

@T-F-S T-F-S closed this as completed Sep 28, 2023
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

2 participants