I have defined the following package:

% Configuration
\ProvidesPackage{eqbox}[2018/01/01 Boxed Equations]

% Package options
    colframe/.store in = \colframe,
    colframe = ,
    colback/.store in = \colback,
    colback = white,
    shadow/.store in = \shadow,
    shadow = ,

% Main style
    highlight math style={
        sharp corners,
        boxrule = 0.4pt,
        boxsep = 3pt,
        left = 0pt,
        right = 0pt,
        top = 0pt,
        bottom = 0pt

% Conditional styles
\ifx\colframe\empty\else\tcbset{colframe = \colframe}\fi
\ifx\colback\empty\else\tcbset{colback = \colback}\fi
\ifx\shadow\empty\else\tcbset{shadow = {2pt}{-2pt}{0mm}{\shadow}}\fi

The way it works it that, first, a main style is defined. And then, if the user provide their options when loading the package (for example \usepackage[shadow=blue]{eqbox}), then options are added.

The problem is that in the current version, the global tcolorbox colframe, colback and shadow parameters are changed. Instead of that, I would like to change the highlight math style colframe, colback and shadow. But if I write:

% Conditional styles
\ifx\colframe\empty\else\tcbset{highlight math style = {colframe = \colframe}}\fi
\ifx\colback\empty\else\tcbset{highlight math style = {colback = \colback}}\fi
\ifx\shadow\empty\else\tcbset{highlight math style = {shadow = {2pt}{-2pt}{0mm}{\shadow}}}\fi

It seems to forget the main previously defined highlight math style options, and just set the concerned conditional options. How to make this work?

Note: use case:

\documentclass[letterpaper, 11pt, onecolumn]{article}

\usepackage[colback = blue]{eqbox}

\tcbhighmath{x^2 + 3}

According to how I read the tcolorbox manual /tcb/highlight math style={...} is a shortcut for /tcb/highlight math/.style={...}, so this overrides styles, as you say. Therefore I suspect you want /tcb/highlight math/.append style={...} instead, and propose to replace the last three lines of your style file by

\ifx\colframe\empty\else\tcbset{highlight math/.append style={colframe=\colframe}}\fi
\ifx\colback\empty\else\tcbset{highlight math/.append style={colback=\colback}}\fi
\ifx\shadow\empty\else\tcbset{highlight math/.append style={shadow={2pt}{-2pt}{0mm}{\shadow}}}\fi
  • Off topic, but your comment is the 1000th item in my inbox :)) I just discovered that. – JouleV Apr 21 at 3:46
  • @JouleV Have you already lost some messages? Let's clean up here... – marmot Apr 21 at 3:47
  • If inboxes from chat and other sites are counted, I must have got more than 1000. But, well, I have got exactly 999 from TeX.SE (you deleted some comments). – JouleV Apr 21 at 3:55
  • @JouleV I sometimes really do not see them (in the sense that I do not get the red number on my inbox). In some cases this is a blessing, though. ;-) – marmot Apr 21 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.