3

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

3
  • 1
    I think you're better off including a \strut with each \tcbox.
    – Werner
    Commented Dec 21, 2014 at 7:37
  • I tried adding the \strut, but that does not make the expression in subsection 0.0.2 have its base aligned. I am trying to get 0.0.1 and 0.0.3 in the same document.
    – Eugene
    Commented Dec 21, 2014 at 7:40
  • 1
    I think you are misunderstanding "base": It means that the baseline of the inner text sits on the outer baseline, not that the bottom of the box is align, for this you would have to ensure that every box has the same depth, e.g. with before upper=\strut Commented Dec 21, 2014 at 11:33

1 Answer 1

6

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .