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.

  • 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). – John Kormylo Mar 2 at 15:51
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}
| improve this answer | |
  • Cool, that works! Thanks! Is there an easy way to clear the upper border as well? – pelegs Mar 2 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.