I'm using beamer
and want to call out a few items in a list by drawing a box around them, and, ideally, having a small comment appear next to the box, like this:
[Tex/LaTex] Box around a few items in an itemize environment
beamerframedlists
beamerframedlists
I'm using beamer
and want to call out a few items in a list by drawing a box around them, and, ideally, having a small comment appear next to the box, like this:
Best Answer
One way to do that is to adapt the code from Highlight elements in the matrix. Below, I provide two macros
\DrawBox
and\DrawBoxWide
depending on if you want to include the list markers or not. The default below is to produce a red box, but this can be adjusted to suit, or the options can be specified on a per use basis (as in the second example):However, since the width of the box is based on the width of the last item, there is a possibility that the box won't be wide enough if the last item is shorter than the wides item within the box. For this case I have defined
\DrawBox*
and\DrawBoxWide*
which use enclose the items in a box as wide as the line:Note that in the above the width of the box is the full
\linewidth
. This is not an issue if the text uses the full width as is the case of the blue box above, but for the case where the text is not the full width (as is the case for the red box), one might desire a tight box around the text. In this case I would recommend that the last line be set in a box as wide as the widest text using:which yields:
Syntax:
To use this you place
\tikzmark{left}
to mark the position where the top left of the box is, and\tikzmark{right}
to mark the position of the bottom right of the box. After these two positions have been marked you call the\DrawBox
or\DrawBoxWide
(or the starred variant) macros to draw the box.Notes:
tikz
, you automatically get all the flexibility inherent intikz
, such as line styles, line thickness, line color, fill, etc. These can be passed to the\DrawBox
macros to customize each instance or provided as default options to maintain consistency.Code: