2

I use the fancybox's \boxput command to create reminder boxes in my documents. I like the fact about \boxput, that it lets you place a label above the box. This label is placed like a water mark, hence it does not take up any space.

Here is a quote from the documentation:

The command

\boxput*(x,y){LR stuff1}{LR stuff2}

puts LR stuff1 either behind (the default) or in front of (with the*) LR stuff2. The resulting box has the dimensions of LR stuff2.

The coordinates (x,y) determine where the center of LR stuff1 is positioned. For example, (0,0) puts it at the center of LR stuff2, (0,1) puts it at the center-top, and (-1,-1) puts it in the bottom-left corner.

More generally, the origin of the coordinate system is at the center of LR stuff2, one unit in the vertical direction is half the vertical size of LR stuff2, and one unit in the horizontal direction is half the width of LR stuff2. Thus, x and y should always be numbers (without units such as pt or cm), with one exception: If y is b or B, LR stuff1 is positioned vertically at the baseline of LR stuff2. (x,y) is optional — the default is (0,0).

My problem is, that (0,0) is at the center of LR stuff2 (the text inside the box). I would want it to be at the top of LR stuff2. The problem for me is, that I would like to place LR stuff1 as a title above the box. But since the positioning is relative to the center of LR stuff2, it moves, when LR stuff2 becomes longer, hence I have to adjust the y coordinate manually.

Here is how I create the reminder boxes:

\newcommand{\reminder}[2][1.58]{%
 \begin{center}
   \Ovalbox{%
     \begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}%
        \boxput(0.7,#1)%
          {\textcolor{gray!60}{\textbf{\Large R e m i n d e r}}}%
          {\parbox[t]{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}{~\\#2}}
     \end{minipage}%
   }%
 \end{center}%
}

Here is a picture to show you, what I am trying to say:

Notice how the second reminder moves up, when the text inside the box becomes longer.

Notice how the second reminder moves up, when the text inside the box becomes longer. The first reminder box is actually, what I am aiming for.

And finally here is the MWE:

\documentclass{article}

\usepackage{tikz}
\usepackage{fancybox}

\usepackage{lipsum}
\usepackage{amsmath}

\newcommand{\reminder}[2][1.58]{%
 \begin{center}
   \Ovalbox{%
     \begin{minipage}{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}%
        \boxput(0.7,#1)%
          {\textcolor{gray!60}{\textbf{\Large R e m i n d e r}}}%
          {\parbox[t]{\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}{~\\#2}}
     \end{minipage}%
   }%
 \end{center}%
}

\begin{document}
\lipsum[2] 

\reminder{This is to remind you:
         \begin{equation}
           a \cdot b = b \cdot a
         \end{equation}
}

\lipsum[2]

\reminder{And now I remind you three times in a row:
         \begin{align}
           a \cdot b &= b \cdot a\\
           a \cdot b &= b \cdot a\\
           a \cdot b &= b \cdot a
         \end{align}
}

\lipsum[2]

\end{document}

As far as I can tell, I would have to calculate the distance from the center of the box to where I would like to place the LR stuff1 and divide this by half the height of LR stuff2. But I have no clue, how to do that. Help much appreciated!

2

I'd like to suggest you tcolorbox instead; it oggers you endless customization possibilities and now your box admits page breaks (if you want to, otherwise, delete breakable):

enter image description here

The code (adjust the settings according to your needs):

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{amsmath}
\usepackage{lipsum}

\newtcolorbox{reminder}{
  breakable,
  enhanced,
  colback=white,
  colframe=black,
  arc=10pt,
  outer arc=10pt,
  boxrule=0.4pt,
  attach boxed title to top right,
  boxed title style={
    colback=white,
    empty
  },
  coltitle=gray!80,
  fonttitle=\Large,
  title=Reminder
}

\begin{document}
\lipsum[2] 
\begin{reminder}
This is to remind you:
         \begin{equation}
           a \cdot b = b \cdot a
         \end{equation}
\end{reminder}
\lipsum[2]
\begin{reminder}
And now I remind you three times in a row:
         \begin{align}
           a \cdot b &= b \cdot a\\
           a \cdot b &= b \cdot a\\
           a \cdot b &= b \cdot a
         \end{align}
\end{reminder}

\lipsum[2]

\end{document}
  • I was not aware of this package, thank you! – Wamseln Jul 11 '15 at 10:15
  • With attach boxed title to top right= {xshift=0mm,yshift=-0.7em} the title may be positioned as desired. – Wamseln Jul 12 '15 at 14:04

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.