1

it's taken me a bit to determine the root cause of this problem, but beamer slides generated using xelatex and tikzexternalize with a custom frame title containing images does not work. the generated slides do not contain any of the frame content.

the file is processed using "xelatex --shell-escape *.tex"

i've added an image of what it should look like since there were a couple of comments about why i am using images in the frame title the way that i do. please note, the title text is usually centered.

\documentclass[xcolor={dvipsnames},aspectratio=1610]{beamer}

\newdimen\leftlogosize
\newdimen\rightlogosize
\def\leftlogo{Physics_Logo.png}
\def\rightlogo{SanJac_Logo.png}
\leftlogosize=1.2cm
\rightlogosize=1.2cm

\newcommand{\drawlogo}[2]{%
  \begingroup
  \edef\x{\endgroup\noexpand\includegraphics[height=#2]{#1}}%
  \x
}
\addtobeamertemplate{frametitle}{}{%
  \begin{tikzpicture}[remember picture,overlay]
    \node[anchor=north west] at (current page.north west) {
      \drawlogo{\leftlogo}{\leftlogosize}};
    \node[anchor=north east] at (current page.north east) {
      \drawlogo{\rightlogo}{\rightlogosize}};
  \end{tikzpicture}}

\usepackage{pgfplots}
\usepgfplotslibrary{external}

\usepackage{tikz}
\tikzset{
    external/system call={%
    xelatex \tikzexternalcheckshellescape
    -halt-on-error -interaction=batchmode
    -jobname "\image" "\texsource"}}
\tikzset{external/optimize=false}%
\tikzexternalize

\begin{document}

\begin{frame}
  \frametitle{Title}
  \begin{tikzpicture}
    \draw (1,1) -- (2,2);
  \end{tikzpicture}
\end{frame}

\end{document}

enter image description here

  • Welcome! Note that your code does not compile on my machine. Rather, I get a lengthy error starting with "! Package tikz Error: Sorry, the system call 'xelatex -halt-on-error -interacti on=batchmode -jobname "stackexchange-figure0" "\def\tikzexternalrealjob{stackex change}\input{stackexchange}"' did NOT result in a usable output ". I am using xelatex, what are you using? However, despite the error the picture is showing up (if I ignore the error). (Most likely this just means the picture is not getting externalized.) – marmot Dec 3 '17 at 2:04
  • @marmot You used shell escape? – cfr Dec 3 '17 at 3:27
  • @cfr No, I did not. Just called the MWE stackexchange.tex and run xelatex stackexchange. – marmot Dec 3 '17 at 3:29
  • 1
    You need to disable externalisation for cases where images must be compiled twice, such as anything where you're using something like overlay. Why such a convoluted \drawlogo macro? There are better ways of including logos like this into Beamer, using Beamer's facilities. – cfr Dec 3 '17 at 3:29
  • 1
    @jameszabel Using tikz to add logos to the frametitle looks unnecessarily complicate - especially as the left hand image cloaks the frametitle in your example. Can you please add a sketch how the result should look like? I bet the frametitle can be done without tikz. – user36296 Dec 3 '17 at 12:11
1

A simple workaround could be not not use tikz to add simple images to the top of the frame, which seems a bit of overkill.

The image you showed us can easily be reproduces with the following headline:

\documentclass[xcolor={dvipsnames},aspectratio=1610]{beamer}

\setbeamertemplate{headline}{%
    \vskip0.5em%
    \hspace*{0.5em}%
    \includegraphics[height=1.2cm]{example-image-a}%
    \hfill%
    \includegraphics[height=1.2cm]{example-image-b}%
    \hspace*{0.5em}%
}

\usepackage{pgfplots}
\usepgfplotslibrary{external}
\usepackage{tikz}
\tikzset{
    external/system call={%
    xelatex \tikzexternalcheckshellescape
    -halt-on-error -interaction=batchmode
    -jobname "\image" "\texsource"}}
\tikzset{external/optimize=false}%
\tikzexternalize

\begin{document}

\begin{frame}
  \begin{tikzpicture}
    \draw (1,1) -- (2,2);
  \end{tikzpicture}
\end{frame}

\end{document}

enter image description here

If you would like to display the frametitle as well, I suggest the following frametitle definition instead:

\makeatletter
\setbeamertemplate{frametitle}{
  \ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
  \@tempdima=\textwidth%
  \advance\@tempdima by\beamer@leftmargin%
  \advance\@tempdima by -4.2cm%
  \advance\@tempdima by\beamer@rightmargin%
  \vskip-0.4cm%
    \hspace*{0.5em}%
  \hspace*{-\beamer@leftmargin}%
  \raisebox{-0.5cm}{\includegraphics[height=1.2cm]{example-image-a}}%
    \hspace*{0.5em}%
  \begin{beamercolorbox}[sep=0.3cm,left,wd=\the\@tempdima,ht=1.2cm,dp=0cm]{frametitle}
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-1ex%
    \if@tempswa\else\csname beamer@fteleft\endcsname\fi%
    \strut\insertframetitle\strut\par%
    {%
      \ifx\insertframesubtitle\@empty%
      \else%
      {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}\insertframesubtitle\strut\par}%
      \fi
    }%
    \vskip-1ex%
    \if@tempswa\else\vskip-.3cm\fi% set inside beamercolorbox... evil here...
  \end{beamercolorbox}%
  \hspace*{0.5em}%
  \raisebox{-0.5cm}{\includegraphics[height=1.2cm]{example-image-b}}%
    \hspace*{0.5em}%
}
\makeatother

enter image description here

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.