# tcolorbox & text vertically center align

tcolorbox and text does not vertically align to the center with one another.

\documentclass{book}

\usepackage{tcolorbox}% for framed rounded boxes
\tcbset{colframe=black,colback=white,colupper=black,
fonttitle=\bfseries,nobeforeafter,center title,size=small}

\begin{document}

\tcbox{1}, \tcbox{2}, ... ,\tcbox{9} -- numbers\\
\tcbox{$+$}, \tcbox{$-$}, \tcbox{$\times$}, \tcbox{$\div$} -- operators\\
\tcbox{$(-)$} -- negative sign\\
\tcbox{$=$} or \tcbox{\sc{Enter}} -- equal sign\\

\end{document}


As can be seen, the text is aligned to the bottom. How do I make both of them align next to one another?

You have to use the option box align=base (or tcbox raise base, which is equivalent) in your \tcbset.

MWE

\documentclass{book}

\usepackage{tcolorbox}% for framed rounded boxes
\tcbset{colframe=black,colback=white,colupper=black,
fonttitle=\bfseries,nobeforeafter,center title,size=small,box align=base}

\begin{document}

\tcbox{1}, \tcbox{2}, ... ,\tcbox{9} -- numbers

\tcbox{$+$}, \tcbox{$-$}, \tcbox{$\times$}, \tcbox{$\div$} -- operators

\tcbox{$(-)$} -- negative sign

\tcbox{$=$} or \tcbox{\sc{Enter}} -- equal sign

\end{document}


Output

P.S. Don't use \\ to start a new paragraph, but either a blank line or \par.

## EDIT

If you need this behavior only for some of the boxes, assign that property locally instead of globally. This means to remove the option from your \tcbset and set it for the boxes where it is needed, e.g.

\tcbox[tcbox raise base]{$(-)$}


MWE

\documentclass{book}

\usepackage{tcolorbox}% for framed rounded boxes
\tcbset{colframe=black,colback=white,colupper=black,
fonttitle=\bfseries,nobeforeafter,center title,size=small}

\begin{document}

\tcbox[tcbox raise base]{1}, \tcbox{2}, ... ,\tcbox{9} -- numbers

\tcbox{$+$}, \tcbox{$-$}, \tcbox{$\times$}, \tcbox{$\div$} -- operators

\tcbox[tcbox raise base]{$(-)$} -- negative sign

\tcbox{$=$} or \tcbox{\sc{Enter}} -- equal sign

\end{document}


Output

• I tried this but it gives me the error: I do not know the key '/tcb/box align', to which you passed 'base', and I am going to ignore it. Perhaps you mispelled it. – Eugene Dec 21 '14 at 7:03
• What is the difference between \newline and \\? – Eugene Dec 21 '14 at 7:06
• @Eugene Try tcbox raise base instead of box align=base – karlkoeller Dec 21 '14 at 7:07
• @Eugene See What is the difference between \newline and \\?. Anyway, I didn't mention \newline but \par. – karlkoeller Dec 21 '14 at 7:09
• @Eugene See the edit. – karlkoeller Dec 21 '14 at 7:59