# In fancytooltips, how to set size of background color box

I want the size of background colore box to automatically match the "size" of formula to be displayed. What I get is a box spanning size of page. as in

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{framed}
\usepackage[createtips]{fancytooltips}

\begin{document}
\Huge
$M= \begin{bmatrix} \alpha & \beta \\ \gamma & \delta \\ \end{bmatrix}$
\end{document}

-

One option would be to box the equation, calculate its width and use this width for a minipage containing the expression; here's an example:

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{framed}
\usepackage[createtips]{fancytooltips}

\newsavebox\mybox

\begin{document}

% fill the box
\savebox\mybox{%
\Huge$\displaystyle M= \begin{bmatrix} \alpha & \beta \\ \gamma & \delta \\ \end{bmatrix}$%
}

\keytip{M2}
% use the width of the box as the minipage width
\noindent\begin{minipage}{\wd\mybox}
\usebox\mybox
\end{minipage}

\end{document}


-

Another possibility: do not use diplayed equation, use inline math and the \colorbox command.

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage[createtips]{fancytooltips}
\begin{document}
\Huge
$\displaystyle M= \begin{bmatrix} \alpha & \beta \\ \gamma & \delta \\ \end{bmatrix}$}

Note that for optimal result you should either use \pagestyle{empty} and pdfcrop to remove the margins or set the dimensions of the page to the dimensions of the yellow box.