Document Classesbeamer | Labeled Equations in an Overlay Area

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Kareem
Posts: 9
Joined: Sat Aug 04, 2012 2:28 pm

beamer | Labeled Equations in an Overlay Area

Post by Kareem »

Hi,

I use TeXnicCenter 2.0 Alpha 4 and beamer for my presentations. Inside the \only environment, I want to activate the label of a certain equation. So I use \label<1>, for instance, if the equation was in the first overlay "\only<1>{}". The problem is: the equations in the slide become flushed to the left, and the location of the equation numbers become centered in the slide, which is very inconvenient (see the figure).

On the other hand, when I remove "<1>" after "\label", things become normal. That is, the equations are centered in the slide, and the equation numbers are flushed to the right as they should be.

Is there anything I can do? Here is an example code of what I'm using:

Code: Select all

\documentclass[t,xcolor=dvipsnames]{beamer}
\usetheme{Madrid}
\setbeamercovered{invisible}
\setbeamertemplate{navigation symbols}{}
\usepackage{graphicx}
\usepackage[scaled]{helvet}
\usepackage[round]{natbib}
\usepackage{fancybox}
\usepackage{algorithmic,algorithm}
\usepackage{epstopdf,subfigure,booktabs}
\usepackage{fixltx2e}
\usepackage{multicol}
\usepackage{bigstrut}
\usepackage{tikz}
\usepackage{ragged2e}
\usepackage{bm}
\usepackage{hyperref}
\usepackage{cleveref}
%
\setbeamertemplate{theorems}[numbered]
\setbeamertemplate{caption}[numbered]
%
\newcommand{\newblock}{}
%
\newtheorem{cor}{Corollary}
\newtheorem{lem}{Lemma}
\newtheorem{ex}{Example}
\newtheorem{pr}{Problem}
%
\title[...]{\textbf{...}}
\author[...]{\textbf{\Large{...}}}
\institute[...]
{
\large{...} \\
\medskip
{\emph{\large{...}}}
}
\date{...}
%
\bibliographystyle{abbrvnat}
%
\justifying
%
\begin{document}
%
\begin{frame}
\titlepage
\end{frame}
%
\AtBeginSection[]
{
\begin{frame}{Inhalt}
\frametitle{Outline}
\begin{multicols}{2}
\footnotesize{
\tableofcontents[currentsection,subsubsectionstyle=show/shaded]
}
\end{multicols}
\end{frame}
}
%
\AtBeginSubsection[]
{
\begin{frame}{Inhalt}
\frametitle{Outline}
\begin{multicols}{2}
\footnotesize{
\tableofcontents[currentsection,currentsubsection,subsubsectionstyle=show/shaded]
}
\end{multicols}
\end{frame}
}
%
\AtBeginSubsubsection[]
{
\begin{frame}{Inhalt}
\frametitle{Outline}
\begin{multicols}{2}
\footnotesize{
\tableofcontents[currentsection,currentsubsection,currentsubsubsection]
}
\end{multicols}
\end{frame}
}
%
\section{Abstract}
%
\begin{frame}
\frametitle{Abstract}
\transboxin
...
\end{frame}
%
\section{Introduction}
%
\begin{frame}
\frametitle{...}
\transboxin<1>
\only<1>{
\begin{subequations}
\begin{align}
{\text{minimize}}\;J(u(t)) &= \Phi(x(1)) + \int_0^1 {L(x(\tau), u(\tau),\tau) d{\tau}} \label<1>{subsec2:tops:eq:perindex1}\\
{\text{subject to }}\dot x(t) &= f(x(t),u(t),t), \label{subsec2:tops:eq:dynsys1}\\
x(0) &= {x^0}, \label{subsec2:tops:eq:dynsys1incond1}
\end{align}
\end{subequations}
}
\only<2>{
\begin{subequations}
\begin{align}
{\text{minimize}}\;J(u(t)) &= \Phi(x(1)) + \int_0^1 {L(x(\tau), u(\tau),\tau) d{\tau}} \label{subsec2:tops:eq:perindex1}\\
{\text{subject to }}\dot x(t) &= f(x(t),u(t),t), \label{subsec2:tops:eq:dynsys1}\\
x(0) &= {x^0}, \label{subsec2:tops:eq:dynsys1incond1}
\end{align}
\end{subequations}
}
\end{frame}
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
\begin{frame}[allowframebreaks]
\frametitle{References}
\bibliography{Bib}
\end{frame}
%
\setbeamercolor{background canvas}{bg=Gray}
%
\begin{frame}[c]
\transdissolve
\makebox[\textwidth][c]{\begin{tikzpicture}
\node[at=(current page.center), minimum width=\paperwidth, minimum height=\paperheight] {
%%%\includegraphics[width=\paperwidth]{bla.jpg}
};
\end{tikzpicture}
}
\end{frame}
% End of slides
\end{document}
Attachments
1.JPG
1.JPG (29.71 KiB) Viewed 8166 times
Last edited by Stefan Kottwitz on Sat Aug 04, 2012 5:14 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Kareem
Posts: 9
Joined: Sat Aug 04, 2012 2:28 pm

beamer | Labeled Equations in an Overlay Area

Post by Kareem »

Hi All,
I removed many parts of the code, yet still facing the same issue :shock:. Here is a very short code of my problem:

Code: Select all

    \documentclass[t,xcolor=dvipsnames]{beamer}
    \usetheme{Madrid}
    \setbeamercovered{invisible}
    \setbeamertemplate{navigation symbols}{}
    \usepackage{multicol}
    \usepackage{tikz}
    \usepackage{ragged2e}
    \justifying
    %
    \begin{document}
    %
    \section{Introduction}
    %
    \begin{frame}
    \frametitle{...}
    \transboxin<1>
    \only<1>{
    \begin{subequations}
    \begin{align}
    {\text{minimize}}\;J(u(t)) &= \Phi(x(1)) + \int_0^1 {L(x(\tau), u(\tau),\tau) d{\tau}} \label<1>{subsec2:tops:eq:perindex1}\\
    {\text{subject to }}\dot x(t) &= f(x(t),u(t),t), \label{subsec2:tops:eq:dynsys1}\\
    x(0) &= {x^0}, \label{subsec2:tops:eq:dynsys1incond1}
    \end{align}
    \end{subequations}
    }
    \only<2>{
    \begin{subequations}
    \begin{align}
    {\text{minimize}}\;J(u(t)) &= \Phi(x(1)) + \int_0^1 {L(x(\tau), u(\tau),\tau) d{\tau}} \label{subsec2:tops:eq:perindex1}\\
    {\text{subject to }}\dot x(t) &= f(x(t),u(t),t), \label{subsec2:tops:eq:dynsys1}\\
    x(0) &= {x^0}, \label{subsec2:tops:eq:dynsys1incond1}
    \end{align}
    \end{subequations}
    }
    \end{frame}
    % End of slides
    \end{document}
Last edited by Stefan Kottwitz on Tue Aug 07, 2012 6:33 pm, edited 1 time in total.
Kareem
Posts: 9
Joined: Sat Aug 04, 2012 2:28 pm

beamer | Labeled Equations in an Overlay Area

Post by Kareem »

Dear All,

I have removed almost the entire preamble...still having the same issue...There is something really wrong here and it's driving me crazy :x ! Here is the reduced code:

Code: Select all

\documentclass[t,xcolor=dvipsnames]{beamer}
\usetheme{Madrid}

\begin{document}
  %
  \section{Introduction}
  %
  \begin{frame}
    \frametitle{...}
    \transboxin<1>
    \only<1>{
    \begin{subequations}
    \begin{align}
    {\text{minimize}}\;J(u(t)) &= \Phi(x(1)) + \int_0^1 {L(x(\tau), u(\tau),\tau) d{\tau}} \label<1>{subsec2:tops:eq:perindex1}\\
    {\text{subject to }}\dot x(t) &= f(x(t),u(t),t), \label{subsec2:tops:eq:dynsys1}\\
    x(0) &= {x^0}, \label{subsec2:tops:eq:dynsys1incond1}
    \end{align}
    \end{subequations}
    }
    \only<2>{
    \begin{subequations}
    \begin{align}
    {\text{minimize}}\;J(u(t)) &= \Phi(x(1)) + \int_0^1 {L(x(\tau), u(\tau),\tau) d{\tau}} \label{subsec2:tops:eq:perindex1}\\
    {\text{subject to }}\dot x(t) &= f(x(t),u(t),t), \label{subsec2:tops:eq:dynsys1}\\
    x(0) &= {x^0}, \label{subsec2:tops:eq:dynsys1incond1}
    \end{align}
    \end{subequations}
    }
  \end{frame}
  % End of slides
\end{document}
Last edited by localghost on Wed Aug 08, 2012 5:35 pm, edited 1 time in total.
Kareem
Posts: 9
Joined: Sat Aug 04, 2012 2:28 pm

beamer | Labeled Equations in an Overlay Area

Post by Kareem »

Hi All,

Got it. There is a bug in beamer :( unfortunately which requires deep attention from those who know about its internals. Finally, the cause of the problem has nothing to do with \only. In fact, the cause is: "THE LENGTH OF THE LABEL NAME MUST NOT BE SUFFICIENTLY LONG IF \label<.> IS TO BE USED INSTEAD OF THE REGULAR \LABEL."
The following very reduced code is a confirmation on this fatal bug in beamer:

Code: Select all

\documentclass{beamer}

\begin{document}
    %
  \begin{frame}
    \frametitle{...}
    \only<1>{
    \begin{subequations}
    \begin{align}
    {\text{minimize}}\;J(u(t)) &= \Phi(x(1)) + \int_0^1 {L(x(\tau), u(\tau),\tau) d{\tau}} \label<1>{s1}
    \end{align}
    \end{subequations}
    }
    \only<2>{
    \begin{subequations}
    \begin{align}
    {\text{minimize}}\;J(u(t)) &= \Phi(x(1)) + \int_0^1 {L(x(\tau), u(\tau),\tau) d{\tau}} \label{s2}
    \end{align}
    \end{subequations}
    }
  \end{frame}
    % End of slides
\end{document}
When we run this simple code, we find that the equation number in the 1st slide is almost centered because LaTeX is struggling with an overfull line. This overfull line happens only when the label is sufficiently long. Try changing "\label<1>{s1}" into "\label<1>{s1dddddddddddddddddddddddddddddddddddddddddd}" for instance and see how things will become very nasty!
In the end, I'd like to thank deeply Prof. Dr. Jan Bredereke whom I couldn't have resolved this problem without his great help.


Cheers,
Kareem
Last edited by localghost on Fri Aug 10, 2012 6:21 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Re: beamer | Labeled Equations in an Overlay Area

Post by Stefan Kottwitz »

Hi Kareem,

welcome to the board!

Thank you for the very good examples, and for the explanation. I tested the examples earlier, could verify the problem, but did not see a fix.

I will speak with a maintainer of the beamer package about this.

Best regards,

Stefan
LaTeX.org admin
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: beamer | Labeled Equations in an Overlay Area

Post by josephwright »

Regrettably, there is not much I can do about this. It happens because the AMS environments typeset content twice, but the first time the label is not handled properly. As Till said in the manual, from the point of view of creating beamer this is 'evil' and there really is little that can be done. Sorry.
Joseph Wright
Post Reply