[Tex/LaTex] Why some commands in \tcolorbox do not work

tcolorbox

For example, when trying to center the title of a box, the manual says that I should use halign title = center in the options of the box, for example, like this:

\documentclass{article}
\usepackage{tcolorbox}

\newenvironment{Myblock}[1]{\tcolorbox[noparskip,colback=red!5!white,colframe=green!45!black,arc=1mm,title=#1,halign title = center]}{\endtcolorbox}

\begin{document}

\begin{Myblock}{Title}
Some text
\end{Myblock}

\end{document}

Yet, that does not work. I get the error:

Package pgfkeys Error: I do not know the key '/tcb/halign title' and I am going to ignore it. Perhaps you misspelled it. ...1 and 2: ...

However, the command center title works instead. Why does not the manual apply to me? Do I have an older version of the tcolorbox Package?

Best Answer

Once you change the name, since \newbox is already defined by TeX and your document warns tou about this:

! LaTeX Error: Command \newbox already defined.
               Or name \end... illegal, see p.192 of the manual.

and use the proper name for the environment in your document, as in

\begin{Newbox}{Title}
Some text
\end{Newbox}

and not with \begin{newblock} \end{beamerblock3} which your original coe had, you'll see it works:

\documentclass{article}
\usepackage{tcolorbox}

\newenvironment{Newbox}[1]
  {\tcolorbox[noparskip,colback=red!5!white,colframe=green!45!black,arc=1mm,title=#1,halign title = center]}
  {\endtcolorbox}

\begin{document}

\begin{Newbox}{Title}
Some text
\end{Newbox}

\end{document}

enter image description here

However, this part of the error message you report

I do not know the key '/tcb/halign title' and I am going to ignore it.

suggests that you are using an outdated version of tcolorbox. Update to the latest version (2015/06/12 version 3.61 at the moment of this answer).

Related Question