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
\newcommand{\mycommand}[4][15pt]{%
\begin{minipage}{\linewidth-#4-#1}%
#2
\end{minipage}%
\hfill
\begin{minipage}{#4}
#3
\end{minipage}
}
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
\newcommand{\mycommand}[3][15pt]{%
\begin{minipage}{\linewidth-<width of bounding box>-#1}%
#2
\end{minipage}%
\hfill
#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?