I am writing some text where I usually have some text and then some figure/tikz picture/table (with tabular or array environment) side by side, in this orden. The command that I use is


My idea is to have both side by side, optimizing the horizontal space.

My question is, how can I extract automatically the bounding box of the second minipage and insert it in the first minipage? in order to use all de horizontal space. Something like this

    \begin{minipage}{\linewidth-<width of bounding box>-#1}%
    #3 % extract <width of bounding box>

where #3 is a figure, tikzpicture, array, tabular environment, or may be only \includegraphics{}.

Is there a general solution?

  • Thank you John, but your suggest doesn't help me, because de tikzpicture is on the right to the text, and I am looking for a general solution. Thanks again. – Gitano Oct 12 '17 at 15:02
  • As I said, these days I just stick it in a savebox, as was done in ignasi's solution. But you did ask. – John Kormylo Oct 12 '17 at 21:17

You can use a sidebyside tcolorbox. In its documentation (page 122) is explained how to build a new mysidebox command which adjusts left hand side to its contents. I've just changed to adjust right hand side. I show two examples, one using colors and amrgins, and the second one uses the blankest skin to avoid all toclorbox lines and colors.



\DeclareTotalTColorBox{\mysidebox}{ O{} +m +m }{
fonttitle=\bfseries,center title,
righthand width=\wd\mysavebox,
drop lifted shadow,


(0,0) node[below]{A} -- (3,1) node[right]{B}
-- (1,4) node[above]{C} -- cycle;

(0,0) node[below]{A} -- (3,1) node[right]{B}
-- (1,4) node[above]{C} -- cycle;

enter image description here

  • Thank you very much! this is exactly what I am looking for. – Gitano Oct 12 '17 at 15:53

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.