0

I am using MiKTeX and running into a very strange issue when using EPS figures within a tabularx environment. Consider the following example:

\documentclass{beamer}

\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{epstopdf}

\graphicspath{{../Icons_Cisco/}}
\epstopdfsetup{outdir=./} %Required since more recent MiKTeX versions - the converted figure is not found otherwise
\begin{document}

\begin{frame}
  \frametitle{Test}

  \begin{figure}
    %\includegraphics{cloud}
  \end{figure}

  \begin{table}
    \begin{tabularx}{\textwidth}{m{0.4\textwidth}m{0.4\textwidth}}
      \begin{figure}
        \includegraphics{cloud}
      \end{figure} & Picture of a cloud\\
    \end{tabularx}
  \end{table}
\end{frame}

\end{document}

This should produce a beamer slide with a cloud icon (when using the icons from http://www.cisco.com/c/dam/en_us/about/ac50/ac47/3015_eps.zip) and the text "Picture of a cloud". However, it fails to generate an output file with the following error message:

! Package pdftex.def Error: File `./cloud-eps-converted-to.pdf' not found.

The weird thing is, though, when uncommenting the commented line which includes the cloud icon outside the tabularx environment, I get a slide with two cloud icons. I presume that the EPS to PDF conversion is run only once per file, but I cannot find an explanation why it does not work inside the tabularx environment.

Is this a known issue or am I missing something obvious? Adding extra figures to my presentations is not really an option.

  • 1
    Why not converting the files before compilation? –  Feb 05 '17 at 10:49
  • There are a lot of files and it is more convenient to have them converted on the fly. Besides, I am curious why the tabularx environment makes the conversion fail. – Andreas Unterweger Feb 05 '17 at 10:51
  • FWIW, I can replicate the issue you're reporting when compiling your code with pdfLaTeX, but not with LuaLaTeX. – Mico Feb 05 '17 at 10:51
  • @AndreasUnterweger: Does it work with a non-beamer class? –  Feb 05 '17 at 10:52
  • Incidentally, you're abusing the tabularx environment: At least one of the columns should be of type X (or based on the X column type). – Mico Feb 05 '17 at 10:52
  • @ChristianHupfer: When I use the article class, I get ! LaTeX Error: Not in outer par mode. Removing the figure environment inside tabularx fails again at the conversion as describe above. – Andreas Unterweger Feb 05 '17 at 10:56
  • I removed the incorrect figure environment in my answer (it doesn't give an error in beamer but it's wrong anyway) – David Carlisle Feb 05 '17 at 11:00
  • 1
    @Mico yes that's because newer luatex don't use \write to implement shell-escape. – David Carlisle Feb 05 '17 at 11:01
  • You should never have a figure environment inside a table environment; that's why you're getting the "not in outer par mode" error message when using the article class. The beamer class disables much of the code of the figure and table environments, since it makes little (actually, no!) sense to use floats in a beamer document. Nevertheless, don't use a figure environment here. – Mico Feb 05 '17 at 11:02
  • @DavidCarlisle - Thanks, I didn't know about this difference in the use of \write. – Mico Feb 05 '17 at 11:17

1 Answers1

5

tabularx disables \writes during trials so you can do

enter image description here

\documentclass{beamer}

\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{epstopdf}

\graphicspath{{../Icons_Cisco/}}
\epstopdfsetup{outdir=./} %Required since more recent MiKTeX versions - the converted figure is not found otherwise
\begin{document}

\begin{frame}
  \frametitle{Test}

  \begin{figure}
    %\includegraphics{cloud}
  \end{figure}

\let\savedwrite\write
  \begin{table}
    \begin{tabularx}{\textwidth}{m{0.4\textwidth}m{0.4\textwidth}}
       \ifx\savedwrite\write\includegraphics[width=\linewidth]{cloud}\fi
       & Picture of a cloud\\
    \end{tabularx}
  \end{table}
\end{frame}

\end{document}

So that it only does the image on the last run, but really doing the conversion on the fly is an unnecessary complication, I'd just convert the EPS file to PDF once on the commandline before running pdftex, then \includegraphics{cloud} would use the PDF not the EPS.

David Carlisle
  • 757,742