2

Consider the following MWE from here:

Solution with the hf-tikz package

\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{align}
   \tikzmarkin<1>{a}a_i\tikzmarkend{a} + b_j = 10 & \forall i\in I, j\in J \\
   \tikzmarkin<2>{c}c_j + d_j + \tikzmarkin<1>{b}a_i\tikzmarkend{b} >= 30 & \forall i\in I, j\in J\tikzmarkend{c}
 \end{align}
\end{block}
\end{frame}

\end{document}

If I try to customize the colors of the highlighting box as per the documentation, I get an error. For instance, if I insert the lines

\hfsetfillcolor{blue!10}
\hfsetbordercolor{blue}

right before tikzmarkin<1> I get the error ! Undefined control sequence.

Moreover, I also get an error if I remove overlay specifications <1> i.e. ! Missing number treated as zero. This happens when I remove the marker tikzmarkin<2>{c} completely, and use tikzmarkin<1>{a} without overlay as tikzmarkin{a}. From my understanding of the documentation, overlay specifications are only optional and not compulsory. I am using TeXnicCenter with MiKTeX 2.9.

Thanks for your help.

3

The problem is twofold here.

First, it looks like you miss the customcolors option. Second, if you want the customization to be global, you have to define it in the preamble. Otherwise,

\hfsetfillcolor{blue!10}
\hfsetbordercolor{blue}

given before a \tikzmarkin customize only that command and not he subsequent ones.

Try:

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

\usetheme{Copenhagen}

\hfsetfillcolor{blue!10}
\hfsetbordercolor{blue}

\begin{document}

    \section{Mysection}
    \subsection{A subsection}
    \begin{frame}{The equations}
        \begin{block}{}
            \begin{align}
                \tikzmarkin<1>{a}a_i\tikzmarkend{a} + b_j = 10 & \forall i\in I, j\in J \\
                \tikzmarkin<2>{c}c_j + d_j + \tikzmarkin<1>{b}a_i\tikzmarkend{b} >= 30 & \forall i\in I, j\in J\tikzmarkend{c}
            \end{align}
        \end{block}
    \end{frame}

\end{document}

The result:

enter image description here

The overlay specifications are mandatory only for Beamer class having the beamer option enabled. Indeed, the macro is declared as follows:

\NewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{%

and the r type from xparse allows to declare a required argument with custom delimiters.

Basically, if you do not specify the beamer option and you do not insert overlays, your code works.

  • Thanks, this resolves the first issue. How about the overlay issue? – Adeel Nov 20 '15 at 11:42
  • @AdeelSabir: You're welcome. For the overlays, they are mandatory.. the definition through xparse makes use of the r (required with delimiters) type: \NewDocumentCommand{\tikzmarkin}{r<> o m D(){\belowrightoff} D(){\aboveleftoff}}{% – Claudio Fiandrino Nov 20 '15 at 11:46
  • Elaboration needed. (1) Are they mandatory in all class types, or beamer alone? (2) So, with just a single frame highlighting, one only needs to use overlay option <1>. Beginner level at latex. – Adeel Nov 20 '15 at 11:52
  • @AdeelSabir: They are mandatory only for Beamer class with beamer option enabled. Basically, if you do not specify beamer option and you do not insert overlays, your code works. – Claudio Fiandrino Nov 20 '15 at 12:03
  • If you insert your comments on overlays in the answer, I will mark it as accepted. – Adeel Nov 20 '15 at 12:20

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.