Avoid repeating codes when defining tcolorbox environments

Is there a way to factorize the following code in which the only difference between the environments doclatex and doclatex-flat is about the use of listing side text?

\documentclass[12pt]{article}

\RequirePackage{tcolorbox}

\tcbuselibrary{minted, breakable}

\newtcblisting{doclatex}{%
breakable,
sharp corners,
left   = 1mm, right = 1mm,
bottom = 1mm, top   = 1mm,
listing side text
}

\newtcblisting{doclatex-flat}{
breakable,
sharp corners,
left   = 1mm, right = 1mm,
bottom = 1mm, top   = 1mm,
}

\begin{document}

\begin{doclatex}
$just + A = test$
\end{doclatex}

\begin{doclatex-flat}
$just + A = test$
\end{doclatex-flat}

\end{document}

• You should be able to use \tcbset to define a style which defines the common settings and then can then be used in two spots. Jul 13 at 9:14
• @PeterGrill Ok, I look at that, and thereafter I try to answer my own question. Thanks! Jul 13 at 9:16

tcolorbox's key-val scheme is from pgfkeys, which is auto loaded by either pgf or tikz. So you can define a style key using /.style key handler.

\documentclass[12pt]{article}

\RequirePackage{tcolorbox}

\tcbuselibrary{minted, breakable}

\tcbset{
doc latex common/.style={
breakable,
sharp corners,
left   = 1mm, right = 1mm,
bottom = 1mm, top   = 1mm,
}
}

\newtcblisting{doclatex}{%
doc latex common,
listing side text
}

\newtcblisting{doclatex-flat}{
doc latex common,
bottom = 1mm, top   = 1mm,
}

\begin{document}

\begin{doclatex}
$just + A = test$
\end{doclatex}

\begin{doclatex-flat}
$just + A = test$
\end{doclatex-flat}

\end{document}

• Great! Thanks a lot! Jul 13 at 9:23