Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
\colorlet{shadecolor}{yellow!50}

\begin{document}
\Huge
\keytip{M2} \begin{shaded}
\[
M= \begin{bmatrix}
\alpha & \beta   \\
\gamma & \delta  \\
\end{bmatrix}
\]
\end{shaded}
\end{document}
share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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}
\colorlet{shadecolor}{yellow!50}

\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}
\begin{shaded}
\usebox\mybox
\end{shaded}
\end{minipage}

\end{document}

enter image description here

share|improve this answer
add comment

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

\documentclass{article}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage[createtips]{fancytooltips}
\colorlet{shadecolor}{yellow!50}
\begin{document}
\Huge
\keytip{M2} \colorbox{shadecolor}{
  $\displaystyle
  M= \begin{bmatrix}
    \alpha & \beta   \\
    \gamma & \delta  \\
  \end{bmatrix}
  $}
\end{document}

enter image description here

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.

share|improve this answer
    
Thanks. Is there any way of interactively moving the tip around by dragging it? –  Maesumi Jun 12 '12 at 21:49
1  
Not now. To get such a behavior I can suggest the technique used in this paper: austms.org.au/Publ/Bulletin/V72P1/pdf/721-5019-LoPo.pdf - click the reference to some of the figures. Then hover mouse to the popup to see the instructions. Note that you are allowed to have more popup widgets on one PDF page, which is impossible in current fancytooltips. –  robert.marik.cz Jun 13 '12 at 5:19
    
I noticed that, there, the popup is used even if a figure is on the same page as the reference and, on page [9]/25, it causes half of tip to be cut off by the top of the page. What package is used on that paper? –  Maesumi Jun 13 '12 at 8:27
    
I think that the package is not available on CTAN (Juny 2012). –  robert.marik.cz Jun 16 '12 at 16:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.