1

I want to set the boxrule of a tcolorbox, but when I add a tabularx to it, it is suddenly ignored.

box widths of tcolorboxes

\documentclass{article}

\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{colortbl}

\begin{document}

\begin{tcolorbox}[boxrule=5pt,tabularx={l}]
hello world
\end{tcolorbox}

\begin{tcolorbox}[boxrule=5pt]
hello world
\end{tcolorbox}

\end{document}

How do I enforce the boxrule?

What I want to do is force the frame width to match \hline.

7
  • I am running tcolorbox v4.20.
    – bitmask
    Commented Sep 18, 2019 at 15:47
  • 1
    Change the order of the pgf keys: \begin{tcolorbox}[tabularx={l},boxrule=5pt] hello world \end{tcolorbox}. That is, boxrule=5pt needs to go after tabularx={l}.
    – user194703
    Commented Sep 18, 2019 at 15:48
  • Oh, this is just evil! I've been at it for over half an hour. Works.
    – bitmask
    Commented Sep 18, 2019 at 15:50
  • 1
    Being a cat helps. ;-)
    – user194703
    Commented Sep 18, 2019 at 15:50
  • If you want the rep, feel free to turn the comment into an answer.
    – bitmask
    Commented Sep 18, 2019 at 15:52

1 Answer 1

2

pgf keys are "only" some cleverly packaged macros. Therefore the order in which you use them matters, simply because the order in which you execute macros matters, too. So you may want to put the key that sets the line width "as late as possible". In your case, there are only two keys so you may want to put boxrule=5pt last.

\documentclass{article}

\usepackage{tcolorbox}
\usepackage{tabularx}
\usepackage{colortbl}

\begin{document}

\begin{tcolorbox}[boxrule=5pt,tabularx={l}]
hello world
\end{tcolorbox}

\begin{tcolorbox}[tabularx={l},boxrule=5pt]
hello world
\end{tcolorbox}

\begin{tcolorbox}[boxrule=5pt]
hello world
\end{tcolorbox}

\end{document}

enter image description here

You must log in to answer this question.

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