This question is an extension of tcolorbox: advance / complex template with arbitrary number of arguments. The goal of that question was to take verbose and repetitive code used to make the following figure into a function for multiple reuse.

enter image description here

@Andrew produced a remarkable answer which answered the question (for convenience copy-pasted below). However it is missing one capability that I would greatly like to learn how to implement. In the figure above, when an argument is being spoken of, it is highlighted with elliptic tcolorbox. @Andrew's answer made the elliptic highlighting for the original appearance of the arguments, but does not highlight them elsewhere. Thus it was discussed to add some type of flourish to arguments so they can be recognized and colored appropriately e.g. an_argument or borrowing from html's tag style: <>arg<>.


The goal is to modify @Andrew's answer (excerpt and link to original provided below), to incorporate the kind of argument highlighting seen in the figure. Highlighted arguments should maintain the same color as when first introduced.


One obvious solution to this problem is simply to not be so lazy and call the following whenever needed:

\newtcbox{\arg}[1][red]{on line, arc=7pt,colback=#1!10!white,colframe=#1!50!black, before upper={\rule[-3pt]{0pt}{10pt}},boxrule=1pt, boxsep=0pt,left=6pt,right=6pt,top=2pt,bottom=2pt}


However this question is about how to solve this problem via a flourish or tag that automatically colors the arguments according to the function @Andrew provided.

@Andrew's answer


\definecolor{eastern-blue}{cmyk}{0.80, 0.13, 0.14, 0.04, 1.00}
\definecolor{orient}{cmyk}{0.85, 0.44, 0.17, 0.14, 1.00}
\definecolor{dove-gray}{cmyk}{0.47, 0.39, 0.35, 0.01, 1.00}

subtitle style={
\pgfkeys{/function/.is family, /function,
  function/.initial=unknown function,
  class/.initial=unknown class,
  description/.initial=no description,
  % the remaining code deals with arguments
    arguments/.initial=0, % number of arguments
    % any unknowns are assumed to be arguments with their descriptions
    argument line/.initial={},
    argument description/.initial={},
    .unknown/.code = {
      \xdef\argcol{\pgfkeysvalueof{/function/argument color \args}}
      \ifnum\args>1\pgfkeys{/function/argument line/.append code={,\space}}\fi
      \pgfkeys{/function/argument line/.append code/.expanded={\noexpand\xmybox[\argcol]{\argument}}}
      \pgfkeys{/function/argument description/.append code/.expanded={\noexpand\item[\argument]#1}}
    % list of colours used for arguments
    argument color 1/.initial=eastern-blue,
    argument color 2/.initial=blue,
    argument color 3/.initial=orient,
    argument color 4/.initial=dove-gray,

  on line, arc=7pt,colback=#1!10!white,colframe=#1!50!black,
  before upper={\rule[-3pt]{0pt}{10pt}},boxrule=1pt,

\DeclareDocumentCommand\SetArguments{ > {\SplitArgument{1}{ = }} m}{\setarguments#1}
\NewDocumentCommand\Function{ m o}{%
  \bgroup% do everything inside a group so that we do not need to reset function values
    \pgfkeys{/function, function=#1}% set function name
    \IfNoValueF{#2}{\pgfkeys{/function, #2}}% set other parameters
    \addcontentsline{toc}{section}{% add toc entry
       \pgfkeys{/function/description} % add description
       \ifnum\args>0% add argument block if the function has arguments
         $\Bigl\langle$\pgfkeys{/function/argument line}$\Bigr\rangle$
         \begin{description}\pgfkeys{/function/argument description}\end{description}
       {\anonymous \pgfkeys{/function/function}} returns %
  \egroup% close group



     description=Reorders the calling {\anonymous OrderedNestedDictionary} based on a subkey
                 found in each element of the calling {\anonymous OrderedNestedDictionary},
     subkey=a strings representing a subkey found in the values of the callings
             {\anonymous OrderedNestedDictionary} associated keys,
     reverse=a boolean of whether or not to reverse the resulting sorted collection,


Your Answer

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

Browse other questions tagged or ask your own question.