In the manual of tcolorbox package, the author Thomas Sturm gives the syntax of

\DeclareTotalTCBox command as

`\DeclareTotalTCBox[init options]{\name}{specification}{options}{content}`
  1. What is the difference between specification and options?
  2. He used O{red} v O{} as specification in his example, how can such code be interpreted?

The specification refers to the box arguments. In order to understand this, it's necessary to understand that \DeclareTotalTCBox is based on the xparse package.

The xparse package provides \NewDocumentCommand{\foo}{argument specification}{...}, where the specification can be really versatile (so the xparse documentation is a good point to start with too!)

The options have the same meaning as the usual options to tcolorbox - based environments.

Now the second question:

The specification O{red}vO{} means that the first argument is optional, with a default value of red, the second v is a verbatim argument (i.e. the content is used literally, not interpreted as LaTeX code) and the O{} is an optional argument at the end which has an empty default value. The mentioned example was used to display LaTeX code in a tcolorbox - box. That's why v as argument was used.

To use \DeclareTotalTCBox comparable to \newtcbox it's important to know that the specification changes from [2][] (for example) to {O{}m}, meaning first argument optional, the second mandatory!

I've added a small example too:


This will define a tcbox-like command with an optional first argument, giving the title background colour, the second (mandatory) argument is used for the title, the 3rd (optional) argument holds additional options for the box setup and the 4th is mandatory again -- it will go the last {...} pair as the content of the box.



%%% Example taken from tcolorbox.pdf v. 3.72 manual

\DeclareTotalTCBox{\myverb}{ O{red} v O{} }
{ fontupper=\ttfamily,nobeforeafter,tcbox raise base,arc=0pt,outer arc=0pt,



\mybox{My first box}{Ducks are great}

\mybox[green]{My first box}{Ducks are great}
To set a word \textbf{bold} in \myverb{\LaTeX}, use
\myverb[green]{\textbf{bold}}. Alternatively, write
\myverb[yellow]{{\bfseries bold}}.
In \myverb[blue]{\LaTeX}[enhanced,fuzzy halo], other font settings are
done in the same way, e.\,g. \myverb{\textit}, \myverb{\itshape}\\
or \myverb[brown]{\texttt}, \myverb[brown]{\ttfamily}.


enter image description here

| improve this answer | |

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.