Consider a package file eqbox.sty:
% Preamble
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{eqbox}[2018/01/01 Boxed Equations]
% Packages
\RequirePackage{xcolor}
\RequirePackage{pgfopts}
\RequirePackage{amsmath}
\RequirePackage{fancybox}
\RequirePackage[most]{tcolorbox}
% Options
\pgfkeys{
/eqbox/.cd,
colframe/.store in = \colframe,
colframe/.default = {black},
colback/.store in = \colback,
colback/.default = {white},
shadow/.store in = \shadow,
shadow/.default = {black},
}
\ProcessPgfPackageOptions*
% Body
\tcbset{
highlight math style={
enhanced,
sharp corners,
breakable,
colframe=\colframe{},
colback=\colback{},
boxrule=0.4pt,
shadow={2pt}{-2pt}{0mm}{\shadow{}},
boxsep = 3pt,
left = 0pt,
right = 0pt,
top = 0pt,
bottom = 0pt
}
}
and a .tex file that uses this package:
% Preamble
\documentclass[letterpaper, 11pt, onecolumn]{article}
% Packages
\usepackage{lipsum}
\usepackage{eqbox}
% Body
\begin{document}
\lipsum
\begin{equation}
\tcbhighmath{x^2 + 3}
\end{equation}
\lipsum
\end{document}
I am a beginer with pgf and what I tried does not seem to work. What I would like to do is have three options in the package: colback, colframe and shadow. For example with the syntax:
\usepackage{eqbox}
or
\usepackage[shadow=blue]{eqbox}
or
\usepackage[%
colback=red,
shadow=\color[RGB]{100,150,200},
]{eqbox}
For the sake of the example, I would like:
colframeto beblueby defaultcolbackto beundefinedby defaultshadowto beundefinedby default (and ifshadowisundefined, don't want this lineshadow={2pt}{-2pt}{0mm}{\shadow{}}to appear in thetcbset)
I also don't want to "pollute" the global namespace, so from the package user's standpoint I don't want the command \shadow to be known in the main tex file (I want it to be an internal detail of the package eqbox).
How to do that in the cleanest possible way?

@within the command name. Concerning "is it the right thing to do": Why not simply doing a\tcbsetwith default parameters and providing an optional argument for the macro? – TeXnician Jan 20 '19 at 08:43