7

I am trying to highlight equations of a linear program starting from buttom and add constraints to the highlight. Here is my MWE:

\documentclass{beamer}
\usepackage{lmodern,amsmath,amssymb}
\usepackage[beamer]{hf-tikz}

\usetheme{Copenhagen}

\begin{document}

\section{Mysection}
\subsection{A subsection}
\begin{frame}{The equations}
\begin{block}{}
\[
  \begin{array}{r@{}r@{}r@{}l}
    \text{Max} \quad z=x_1 &{} + 12x_2 \\[\jot]
    \text{s.t.}\qquad 3x_1  &{} + \phantom{12}x_2 &{} &{} \leq 5 \\
    x_1 &         &{}  &{} \leq 16 \\
    \tikzmarkin<2->{a}
                    15x_1 &{} + \phantom{12}x_2 &           &{} = 14 \\ \tikzmarkend<2->{a} 
                    \tikzmarkin<1>{a}x_1 &{} &{}   &{} \geq 0 \\
                    &{} x_2 & &{} \geq 0\tikzmarkend{a}\\ 
  \end{array}
\]
\end{block}
\end{frame}

\end{document}

I get a weird 2-> expression in my slides and also my highlight box doesn't cover the equation fully (in second slide). Am I missing something? Thank you in advance for your help.

NOTE: ht-tikz always needs two comilation. The manual says: Two compilation runs are always necessary: the first one to compute the position of the markers (also called delimiters) and the second one to place the box. So, if you get an error in the first run, don't panic! Run it again...

David Carlisle
  • 757,742
N Nik
  • 3,669
  • I get a Package tikz Error: Cannot parse this coordinate. message. Please ensure your example is compilable. – Peter Grill Dec 02 '12 at 01:12
  • @ Peter: Yeah; it works. As it is mentioned in ht-tikz manual, you need to compile it twice to get it work. – N Nik Dec 02 '12 at 04:51
  • 1
    Thanks. It would be helpful if you added such information to the question as that is really unusual behavior for a package. Perhaps ht-tikz needs to be updated to use the upcoming tikzmark package. I just retried it and get the same error message upon every compilation. – Peter Grill Dec 02 '12 at 04:53
  • @PeterGrill: This is exactly from the manual: Two compilation runs are always necessary: the first one to compute the position of the markers (also called delimiters) and the second one to place the box. And I remember I read somewhere that in the first run it is normal to get the error you mentioned. – N Nik Dec 02 '12 at 05:40
  • 1
    I believe you when you say that, but for those who are not that familiar with ht-tikz something that strange should be mentioned in the question. However, I don't know why I was not able to compile it. – Peter Grill Dec 02 '12 at 05:43
  • @PeterGrill: I'll edit the question to include this comment. Thank you – N Nik Dec 02 '12 at 05:47
  • 1
    @PeterGrill: that's my fault; incidentally you already noticed to me in this previous answer. But, as you said, when there will be the tikzmark package on CTAN I'll probably make use of it in hf-tikz. – Claudio Fiandrino Dec 02 '12 at 10:40

1 Answers1

8

Only \tikzmarkin receives the overlay specification (not \tikzmarkend); for the other issue you can use a \phantom; since the ending mark is the same for both frames, you can use it only once:

\documentclass{beamer}
\usepackage{lmodern,amsmath,amssymb}
\usepackage[beamer]{hf-tikz}

\usetheme{Copenhagen}

\begin{document}

\section{Mysection}
\subsection{A subsection}

\begin{frame}{The equations}
\begin{block}{}
\[
\begin{array}{r@{}r@{}r@{}l}
  \text{Max} \quad z=x_1 &{} + 12x_2 \\[\jot]
  \text{s.t.}\qquad 3x_1  &{} + \phantom{12}x_2 &{} &{} \leq 5 \\
  x_1 & & &{} \leq 16 \\
  \tikzmarkin<2->{a}15x_1 & {} + \phantom{12}x_2 & & {} = 14 \\ 
  \tikzmarkin<1>{a}x_1 & & & {} \geq 0 \\
  &{} x_2 & &{} \geq 0\phantom{5}\tikzmarkend{a}\\ 
\end{array}
\]
\end{block}
\end{frame}

\end{document}

For some reason the first run of the above code produces the error

! Package tikz Error: Cannot parse this coordinate.

The second run produces the desired output:

enter image description here

Moriambar
  • 11,466
Gonzalo Medina
  • 505,128