0

When I use the following code to generate two colored boxes:

\documentclass[border={0pt 0pt 0pt 0pt}]{standalone} % left bottom right top
\usepackage{varwidth}
\usepackage{xcolor}
\usepackage[xparse]{tcolorbox}

\begin{document}
\tcbset{left skip=0pt, boxrule=0pt,
        size=fbox, sharp corners,
        colframe=black, width=0.75\linewidth}
\begin{varwidth}{0.5\linewidth}
  \begin{tcolorbox}[colback=red!30]
    Some random text
  \end{tcolorbox}
  \begin{tcolorbox}[colback=blue!30]
    Some more random text...

    With a line skip!
  \end{tcolorbox}
\end{varwidth}

\end{document}

I get the following result:

enter image description here

No matter what I do, I can't get rid of the white border on the left.

Any help would be appreciated.

1
  • I'm not sure what you are hoping for varwidth to do here that a minipage wouldn't also do (except for losing the 0,25\linwidth not used by the tcoloboxes). Outside the varwidth, \linewidth=345pt. inside the varwidth, \linewidth=175.5pt (0.5 previous). Inside the colorbox \linewidth=122.57501pt (0.75 previous minus inner sep). Commented Mar 2, 2020 at 15:51

1 Answer 1

2
\documentclass[border={0pt 0pt 0pt 0pt}]{standalone} % left bottom right top
\usepackage{varwidth}
\usepackage{xcolor}
\usepackage[xparse]{tcolorbox}

\begin{document}
\tcbset{left skip=0pt, boxrule=0pt,
        size=fbox, sharp corners,
        colframe=black, width=0.75\linewidth}% <-- hide this space
\begin{varwidth}{0.5\linewidth}
  \begin{tcolorbox}[colback=red!30]
    Some random text
  \end{tcolorbox}
  \begin{tcolorbox}[colback=blue!30]
    Some more random text...

    With a line skip!
  \end{tcolorbox}
\end{varwidth}

\end{document}
1
  • Cool, that works! Thanks! Is there an easy way to clear the upper border as well?
    – pelegs
    Commented Mar 2, 2020 at 18:28

You must log in to answer this question.

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