3

How to make a key for producing second title in tcolorbox? - I am thinking about making title with command title=Title in the first language, and the second title with a command which looks like additional title=Title in the second language - used as an optional argument of tcolorbox. The second title should automatically adopt such a settings of a title, like fonttitle=\bfseries or text indentation.

MWE:

\documentclass{standalone}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\tcbset{skin=bicolor,colframe=blue!70!black,fonttitle=\bfseries,
    colback=blue!20!white,colbacklower=green!20!white,left=0ex,right=0ex}

\begin{document}
\begin{tcolorbox}[title=Title in the first language,
    title code={\node at (title.center) [anchor=west,text=green,font=\bfseries] {Title in the second language};}]
    Original text.
    \tcblower
    Translated text.
\end{tcolorbox}
\end{document}

enter image description here

7

You can use after title.

\documentclass{standalone}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\tcbset{skin=bicolor,colframe=blue!70!black,fonttitle=\bfseries,
    colback=blue!20!white,colbacklower=green!20!white,left=0ex,right=0ex}

\begin{document}
\begin{tcolorbox}[
  title={Title in the first language},
  after title={\hfill Title in the second language},
  ]
    Original text.
    \tcblower
    Translated text.
\end{tcolorbox}
\end{document}

enter image description here

Or, if you insist on the key additional title

\documentclass{standalone}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\tcbset{skin=bicolor,colframe=blue!70!black,fonttitle=\bfseries,
    colback=blue!20!white,colbacklower=green!20!white,left=0ex,right=0ex}

\tcbset{
  additional title/.style={after title={\hfill #1}}
}

\begin{document}
\begin{tcolorbox}[
  title={Title in the first language},
  additional title={Title in the second language},
  ]
    Original text.
    \tcblower
    Translated text.
\end{tcolorbox}
\end{document}
2
  • Thx. Line inside new \tcbset is very helpful for me. Is it possible to align the second title to the center of the title area? (left alignment to the midway of the title line) – forrest Dec 6 '16 at 20:23
  • 1
    Probably sequence additional title/.style={after title={\hfill\begin{minipage}{0.5\textwidth} #1\end{minipage}}} solves my problem. Good hint - thx. – forrest Dec 6 '16 at 20:36

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.