Closed muzimuzhi closed 6 months ago
Assuming the current behavior is expected (except for the warning message), below is an attempt for better warning message(s). Documentation still need adaptions.
BTW, although it can be inferred from key descriptions "no default, initially empty", that an empty <file name>
passed to one of saveto
, savelowerto
, and redirectlowerto
will deactivate (or partially deactivate, for the last one) the effect of corresponding option, do users need a direct statement like "An empty <file name>
deactivates ... ."?
\tcb@set@@upper@and@lower
to give better warning message(s)```tex \documentclass{article} \usepackage{tcolorbox} \usepackage{xpatch} \makeatletter \xpatchcmd\tcb@set@@upper@and@lower {% \ifx\kvtcb@savelowerto\@empty% \else% \tcb@warning{'saveto' and 'savelowerto' cannot be combined. I deactivate 'savelowerto'}% \tcbset{savelowerto=}% \fi% } {% \ifx\kvtcb@savelowerto\@empty% \else% \iftcb@redirectlowerto% \tcb@warning{% 'saveto' and 'redirectlowerto' cannot be combined.\MessageBreak I deactivate 'redirectlowerto' but retain its\MessageBreak 'lowerbox' setting}% \tcb@redirectlowertofalse% \tcbset{savelowerto=}% \else% \tcb@warning{% 'saveto' and 'savelowerto' cannot be combined.\MessageBreak I deactivate 'savelowerto'}% \tcbset{savelowerto=}% \fi% \fi% } {}{\PatchFailed} \makeatother \begin{document} \setcounter{enumi}{1} Test counter: \theenumi \begin{tcolorbox}[saveto=\jobname_mysave1, savelowerto=\jobname_mysave2, title={\texttt{saveto} and \texttt{savelowerto}}] upper part \tcblower lower part \stepcounter{enumi} \end{tcolorbox} New value of test counter: \theenumi. \IfFileExists{\jobname_mysave1} {\verbatiminput*{\jobname_mysave1}} {non-existent} \IfFileExists{\jobname_mysave2}{}{\texttt{savelowerto} file doesn't exist.} \begin{tcolorbox}[saveto=\jobname_mysave3, redirectlowerto=\jobname_mysave4, title={\texttt{saveto} and \texttt{redirectlowerto}}] upper part 2 \tcblower lower part 2 \stepcounter{enumi} \end{tcolorbox} New value of test counter: \theenumi. \IfFileExists{\jobname_mysave3} {\verbatiminput*{\jobname_mysave3}} {non-existent} \IfFileExists{\jobname_mysave4}{}{\texttt{redirectlowerto} file doesn't exist.} \end{document} ```
PDF output is the same as before, and the new warning message is
Package tcolorbox Warning: 'saveto' and 'redirectlowerto' cannot be combined.
(tcolorbox) I deactivate 'redirectlowerto' but retain its
(tcolorbox) 'lowerbox' setting on input line 54.
OK, I will update the warning code and also add additional documentation for the next version. Thank you.
The interaction between
saveto
andsavelowerto
is well documented and handled in code base, but the interaction betweensaveto
andredirectlowerto
which was newly introduced in v6.1.0 (https://github.com/T-F-S/tcolorbox/commit/4918308ef96e482e4ee0f1343e6fe8c96984bf71) is not.Currently in v6.1.0, if
redirectlowerto
is used along withsaveto
,saveto
andsavelowerto
is thrownsavelowerto
and no lower part typesetting features are deactivatedlowerbox=ignored
feature is retained.