1

I would like to wrap colored boxes around theorems in my documents. Since I only need them to be plain rectangles with a solid color, and occasionally a border line on a single side, mdframed would be enough to get the job done, but it has been discontinued years ago and it has a well-known problem with the skipbelow option, so I went for tcolorbox.

TCB boxes have many features by default, which I would like to remove to create my own, plain box from scratch. After reading the documentation, I got to this setup, which works for me (later adjusting padding, color, and beforeafter skip for individual boxes):

\tcbsetforeverylayer{enhanced, size=minimal, frame hidden, sharp corners}

However, the fact that I need so many options just to display a simple rectangle seems pretty unnatural to me, so I might be missing something: is this actually the intended way to create a plain box without additional features in tcolorbox?

I know the blanker and blankest skins exist, but they also deactivate the background color engine.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 31 '22 at 22:17
  • What about the spartan skin? It has no rounded corners and still allows for background color and frames. You can additionally disable frames using the option frame empty. – Jasper Habicht Jul 31 '22 at 22:19

2 Answers2

1

I don't think that four options are really that many. You can use the blanker skin and re-activate the interior engine to spartan (wich comes with only very little settings). This allows you to set a background color.

Adding a border line on one side can also be achieved using the blanker skin.

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

\begin{document}

\begin{tcolorbox}[blanker, interior engine=spartan, colback=blue!10] Hello \end{tcolorbox}

\begin{tcolorbox}[blanker, borderline west={1mm}{-2mm}{blue}] Hello \end{tcolorbox}

\end{document}

enter image description here

0

I had this same question, and I've been trying to research this the past few days, and here’s what I've found. If the theorem takes up the whole textwidth, then I'd use this, as an example theorem:

\begin{tcolorbox}[colback=white,colframe=red,sharp corners]
\textbf{Theorem} \hspace{0.5cm} If $f(x)=T_n(x)+R_n(x)$, where $T_n$ is the 
$n$th-degree Taylor polynomial of $f$ at $a$ and \begin{equation*}
    \lim_{n\rightarrow \infty} R_n(x)=0
\end{equation*}
for $|x-1|<R$, then $f$ is equal to the sum of its Taylor series on 
the interval $|x-a|<R$.
\end{tcolorbox}

enter image description here (colback is the background color, which I set to white because the default is another color, and we'd want the background to be the same color as the page. colframe is the frame color of the rectangle, I used red because those are how the theorems in my calculus textbook are colored).

If the theorem doesn't take up the whole space and you only need the box to be large enough to wrap the text, then you can use something like this:

\begin{center}
\tcbox[colback=white,colframe=red,sharp corners,boxsep=0cm,
left=1mm,right=1mm,top=0.7mm,bottom=0.7mm]{Theorem goes here...}
\end{center}

enter image description here The parameters left and right define how much space is between the left and right sides of the box, and same with top and bottom.

This might seem like a lot of parameters (although I don't think it's too bad) but they're pretty simple.