I want something like a tcolorbox but that it's width and heigth is just as large as its content, I mean that the margin of the box is as tight as possible and the box is centered, is important too that I can enter things like verbatim or lst listings, like I would be able to in a regular tcolorbox

enter image description here

  • 3
    Welcome! \tcbox does precisely that. \documentclass{article} \usepackage{tcolorbox} \begin{document} \tcbox{A tight tcolorbox.} \end{document}. – user194703 May 11 at 5:35
  • yeah but I can't use verbatim inside that \tcbox{} – Rodolfo Reyes S. May 11 at 19:32

tcolorbox already has this. You basically need the hbox key. For example,


listing only,enhanced,drop fuzzy shadow,hbox,
frame style={upper left=blue,upper right=red,lower left=yellow,lower right=green}, 
interior style={left color=blue!30,right color=cyan!30,middle
color=white,shading angle=10}}


WRITE (*,(2I6,F10.4)) istart,istop,step

enter image description here

| improve this answer | |
  • Thank you so much, I hadn't thought about \newtcblisting because I was going for verbatim, because with lstlisting the tcolorbox took the width of the page, but I solved that problem by eliminating "\lstset{style=mystyle}", you see I had defined mystyle for other codes, but now when I want to use that style I just add [style=mystyle], so thank you again, you've solved all of my problems – Rodolfo Reyes S. May 11 at 20:01

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.