1

The nag packages gives a warning when using floats in beamer presentations. When removing the figure or table environment, no warnings are given. How to proceed from here? Tried \begin{center}...\end{center}, but that didn't work either.

\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[aspectratio=43]{beamer}
\usepackage{mwe}
\usepackage{lmodern}
\begin{document}
\begin{frame}
\begin{figure}
    \centering
  \includegraphics[width=\textwidth]{example-image-a}
  \caption{text}\label{fig}
\end{figure}
\end{frame}
\end{document}
  • you could just not load nag. floating figures do not really make sense in a fixed page break slide context as in beamer, but it supports the syntax so you you can use it if you wish. – David Carlisle Apr 8 '15 at 16:51
  • It's just a good old habit, loading nag, but I see your point. – TobiasDK Apr 8 '15 at 17:02
  • just looking at nag now, you don't need to use \centering in beamer as the class redefines figure to use \begin{center} internally (which is why nag complains:-) – David Carlisle Apr 8 '15 at 17:04
  • So one can not get rid of the warning at all, even if you remove \centering? – TobiasDK Apr 8 '15 at 17:09
  • 1
    Not without redefining nag internals to remove the check – David Carlisle Apr 8 '15 at 17:11
3

beamer adds center to figure which causes nag to complain whatever you do.

You could not load nag or if you want to load it you can stop it messing with center

\let\zcenter\center
\let\zendcenter\endcenter
\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[aspectratio=43]{beamer}

\usepackage{mwe}
\usepackage{lmodern}
\begin{document}
\let\center\zcenter
\let\endcenter\zendcenter

\begin{frame}

\begin{figure}
  \includegraphics[width=\textwidth]{example-image-a}
  \caption{text}\label{fig}
\end{figure}
\end{frame}
\end{document}
  • Thanks! I shortened it down to: \let\zendcenter\endcenter\RequirePackage[l2tabu,orthodox]{nag}\let\endcenter\zendcenterin the first line. That also did the job. Is that bad coding btw? – TobiasDK Apr 8 '15 at 17:27
  • @TobiasDK Oh OK yes that works too, I had to experiment a bit to see exactly where nag was hooking in to things, stopped once I got something that worked, but simpler is good:-) – David Carlisle Apr 8 '15 at 17:29

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.