Tcolorbox – How to Raise Base for Selected Text Only in tcbox

tcolorbox

tcbox raise base is wonderful to help align my text and tcbox. However, what if I want tcbox raise base for some text and not for others? Meaning that I am trying to get 0.0.1 and 0.0.3 in the same document.

\documentclass{book}

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

\begin{document}

\subsection{tcbox raise base works here}

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

\tcbox{.} -- decimal point

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

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

\subsection{tcbox raise base does not work here}

\tcbox{$($} \tcbox{$(-)$} \tcbox{$3$} \tcbox{$.$} \tcbox{$6$} \tcbox{$+$} \tcbox{$5$} \tcbox{$x^2$} \tcbox{$)$} \tcbox{$\div$}  \tcbox{$2$} 

\end{document} 

tcbox raise base

no tcbox raise base

Best Answer

I suggest you to issue a new \tcbset with new settings each time you need to change them.

So remove tcbox raise base from the first \tcbset and issue

\tcbset{tcbox raise base}

when you need that, and

\tcbset{tcbox raise=0mm}

when you don't.

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}

\subsection{tcbox raise base is used here}
\tcbset{tcbox raise base}

\tcbox{0}, \tcbox{1}, \tcbox{2}, ... ,\tcbox{8}, \tcbox{9} -- numbers
\smallskip

\noindent\tcbox[tcbox raise=-0.5mm]{.} -- decimal point
\smallskip

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

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

\subsection{tcbox raise base is not used here}

\tcbset{tcbox raise=0mm}

\tcbox{$($} \tcbox{$(-)$} \tcbox{$3$} \tcbox{$.$} \tcbox{$6$} \tcbox{$+$} \tcbox{$5$} \tcbox{$x^2$} \tcbox{$)$} \tcbox{$\div$}  \tcbox{$2$}

\end{document} 

Output

enter image description here

Related Question