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 am trying to highlight, at the end of my slide, several items in a list with a box in something similar as in the method shown in Box around a few items in an itemize environment.

The difference is that instead of only one box I want to use two boxes as I compare the elements with another block.

I used the following code:

\documentclass[pdf,10pt,xcolor=table]{beamer}
    \usepackage{xparse}%  For \NewDocumentCommand
    \usepackage{calc}%    For the \widthof macro
    \usepackage{tikz}
    \usetikzlibrary{calc}
    \newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
    %
    \makeatletter
    %
    \NewDocumentCommand{\DrawBox}{s O{}}{%
        \tikz[overlay,remember picture]{
        \IfBooleanTF{#1}{%
            \coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
            }{%
            \coordinate (RightPoint) at (right.east);
            }%
        \draw[red,#2]
            ($(left)+(-0.2em,0.9em)$) rectangle
            ($(RightPoint)+(0.2em,-0.3em)$);}
        }

    \NewDocumentCommand{\DrawBoxWide}{s O{}}{%
        \tikz[overlay,remember picture]{
        \IfBooleanTF{#1}{%
             \coordinate (RightPoint) at ($(left |- right)+(\linewidth-\labelsep-\labelwidth,0.0)$);
             }{%
             \coordinate (RightPoint) at (right.east);
             }%
         \draw[red,#2]
             ($(left)+(-\labelwidth,0.9em)$) rectangle
             ($(RightPoint)+(0.2em,-0.3em)$);}
         }
    %
    \makeatother
    %
    \begin{document}
        \begin{frame}
            \begin{block}{\centering Unsteady models}
                \begin{itemize}\setbeamertemplate{itemize  item}[triangle]\small
                    \item\tikzmark{left}\textbf{Aerodynamics}
                        \begin{itemize}\small
                            \item[+] \textbf<3->{Accuracy}
                            \item[+] \textbf<3->{Flow physics}\tikzmark{right}
                        \end{itemize}
                    \item\tikzmark{left}\textbf{Structure}
                        \begin{itemize}\small
                    \item[+] \textbf<3->{Full wing flexibility}\tikzmark{right}
                        \end{itemize}
                    \item \textbf{Implementation}
                        \begin{itemize}\small
                            \item[-] Complex formulation
                            \item[-] High computational load
                        \end{itemize}
                \end{itemize}
            \end{block}
            \only<3->{\DrawBoxWide[thick, green, fill=green, fill opacity=.25]}
        \end{frame}
    \end{document}

Additionally, I am not completely satisfied with the box solution as I am using the list in a block which has a background color and thus diminishes the effect of the surrounding box.

I saw that the tikz style can also highlight parts of a list, as in Beamer overlay box around text - the correct way? and Highlighting in beamer using TikZ nodes, but I didn't see an example around several items without any blank between the items.

Furthermore in the example given the item marker is included by \DrawBoxWide*{} which is not the case for me.

Do you have a solution, for these issues?

share|improve this question
1  
Please post complete documents, not just snippets. –  Gonzalo Medina Jun 17 '13 at 17:59
    
Ah yes if i don't give the definition of the command it might be difficult for you to help me –  TazgerO Jun 17 '13 at 18:12
    
@TazgerO: if you use the solution in Beamer overlay box around text - the correct way? called Customizable offsets you probably just have to adjust the offsets. –  Claudio Fiandrino Jun 17 '13 at 18:40
    
@Claudio Indeed customizing the offset solve the issue with embedding the marker within the box... Thanks –  TazgerO Jun 17 '13 at 20:08

1 Answer 1

up vote 4 down vote accepted

Perhaps this is what you need?

\documentclass[10pt,xcolor=table]{beamer}
\usetheme{Madrid}
\usepackage{tikz}
\usepackage{twoopt}
\usetikzlibrary{calc}

\makeatletter
\tikzset{%
  remember picture with id/.style={%
    remember picture,
    overlay,
    save picture id=#1,
  },
  save picture id/.code={%
    \edef\pgf@temp{#1}%
    \immediate\write\pgfutil@auxout{%
      \noexpand\savepointas{\pgf@temp}{\pgfpictureid}}%
  },
  if picture id/.code args={#1#2#3}{%
    \@ifundefined{save@pt@#1}{%
      \pgfkeysalso{#3}%
    }{
      \pgfkeysalso{#2}%
    }
  }
}

\def\savepointas#1#2{%
  \expandafter\gdef\csname save@pt@#1\endcsname{#2}%
}

\def\tmk@labeldef#1,#2\@nil{%
  \def\tmk@label{#1}%
  \def\tmk@def{#2}%
}

\tikzdeclarecoordinatesystem{pic}{%
  \pgfutil@in@,{#1}%
  \ifpgfutil@in@%
    \tmk@labeldef#1\@nil
  \else
    \tmk@labeldef#1,(0pt,0pt)\@nil
  \fi
  \@ifundefined{save@pt@\tmk@label}{%
    \tikz@scan@one@point\pgfutil@firstofone\tmk@def
  }{%
  \pgfsys@getposition{\csname save@pt@\tmk@label\endcsname}\save@orig@pic%
  \pgfsys@getposition{\pgfpictureid}\save@this@pic%
  \pgf@process{\pgfpointorigin\save@this@pic}%
  \pgf@xa=\pgf@x
  \pgf@ya=\pgf@y
  \pgf@process{\pgfpointorigin\save@orig@pic}%
  \advance\pgf@x by -\pgf@xa
  \advance\pgf@y by -\pgf@ya
  }%
}
\makeatother
\newcommand\tikzmark[2][]{%
\tikz[remember picture with id=#2] #1;}

\newcommandtwoopt\DrawBox[4][][-\labelwidth+\labelsep]{%
\begin{tikzpicture}[overlay,remember picture]
\draw[red,#1]
            ($(pic cs:#3)+(-0.2em+#2,0.9em)$) rectangle
            ($(pic cs:#4)+(0.2em,-0.3em)$);
\end{tikzpicture}}

\begin{document}

\begin{frame}
\begin{block}{\centering Unsteady models}
\only<3->{\DrawBox[thick, green!50!black, fill=green!80!black]{lefta}{righta}}
\only<4->{\DrawBox[thick, green!50!black, fill=green!80!black]{leftb}{rightb}}
\begin{itemize}\setbeamertemplate{itemize  item}[triangle]\small
\item\tikzmark{lefta}\textbf{Aerodynamics}
  \begin{itemize}\small
  \item[+] \textbf<3->{Accuracy}
  \item[+] \textbf<3->{Flow physics}\tikzmark{righta}
  \end{itemize}
\item\tikzmark{leftb}\textbf{Structure}
  \begin{itemize}\small
  \item[+] \textbf<3->{Full wing flexibility}\tikzmark{rightb}
  \end{itemize}
\item \textbf{Implementation}
  \begin{itemize}\small
  \item[-] Complex formulation
  \item[-] High computational load
  \end{itemize}
\end{itemize}
\end{block}
\end{frame}

\end{document}

enter image description here

The new \DrawBox command has two optional arguments: the first one, to pass options to the \draw command internally used for the frame, and the second one, to control the horizontal offset to the left (default value=-\labelwidth+\labelsep); the two mandatory arguments are for the marks which should be set in the proper locations.

I used the improved \tikzmark defined by Andrew Stacey in his answer to tikzmark to have different behaviour if first run (and mark locations not yet available). This, in particular, places the box behind the text, so no need to use opacity (unless its effect is really required).

share|improve this answer
    
Well it is almost that. Just want to include the marker in the green box and it should be ok. I assume I have to play with the rectangle size. Another matter is that my green box are not as green as yours but maybe it is due to the fill color of my block defined as a light blue. –  TazgerO Jun 17 '13 at 19:30
    
Ok I switch the first -0.2em by -\labelwidth and it works. I have to solve now the color issue –  TazgerO Jun 17 '13 at 19:35
    
@TazgerO please see my updated answer. What exactly seems to be the color issue? You are using opacity=0.25, so perhaps you want a higher value? –  Gonzalo Medina Jun 17 '13 at 19:44
    
@TazgerO with the definition of my example, opacity can even be 1 and the color won't override the text. –  Gonzalo Medina Jun 17 '13 at 19:56
    
@Gonzalo... Ok the opacity was the issue. I wanted the box to be of the same color as an example block and misuse the !25 argument to the opacity as it has to be applied to the fill color instead. Thanks a lot.... –  TazgerO Jun 17 '13 at 20:13

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.