TransWikia.com

Spurious shifting of headline when conditionally placing logo on beamer slide using pgfputat

TeX - LaTeX Asked by Christoph90 on January 23, 2021

I have a macro taken from this question that places a logo on all frames following placelogotrue and on no frame following placelogofalse. It largely works as intended, but it causes headline and foodline of the frames with the logo to be slightly shifted to the left, leaving some spurious whitespace (compare the upper image footline with the lower image headline in the pictures below):

frame with logo
frame without logo

Here’s the code to reproduce:

% !TeX program = lualatex
documentclass{beamer}

usetheme{Malmoe}
% graphics
DeclareGraphicsExtensions{.jpg,.jpeg,.png,.pdf}

% TikZ/PGF
usepackage{pgf}

% customization of beamer style
setbeamertemplate{bibliography item}{}
setbeamertemplate{navigation symbols}{}

% define logo
newififplacelogo
placelogotrue
logo{ifplacelogopgfputat{pgfxy(-0.1,7.72)}{pgfbox[right,base]{%
            includegraphics[height=7mm]{example-image-a}
    }}fi}%

% define custom headline
setbeamertemplate{headline}
{%
    leavevmode%
    begin{beamercolorbox}[wd=.5paperwidth,ht=2.5ex,dp=1.125ex]{section in head/foot}%
        hbox to .5paperwidth{hfilinsertsectionheadhfil}
    end{beamercolorbox}%
    begin{beamercolorbox}[wd=.5paperwidth,ht=2.5ex,dp=1.125ex]{subsection in head/foot}%
        hbox to .5paperwidth{hfilinsertsubsectionheadhfil}
    end{beamercolorbox}%
}

begin{document}

begin{frame}
end{frame}

placelogofalse
begin{frame}
end{frame}


end{document}

Why is that? I would have expected pgfputat not to alter spacing on the frame at all…

I’m compiling with LuaLaTeX Version 1.12.0 (TeX Live 2020) on Arch Linux.

2 Answers

Lets explore it by trial and error (Unfortunately I couldn't find the problem). First if we replace the pgfbox[right,base]{includegraphics[height=7mm]{example-image-a}} with a space then same problem appears but without that space it is fine:

logo{ifplacelogopgfputat{pgfxy(-0.1,7.72)}{ }fi}%

enter image description here

The output of the following code (pgfputat{ }) is also similar to the above image:

logo{ifplacelogopgfputat{ }{}fi}%

If we insert logo directly by includegraphic then the situation will get worse:

logo{ifplacelogopgfputat{pgfxy(-0.1,7.72)}{includegraphics[height=7mm]{example-image-a}}fi}%

enter image description here

One can also fix this white space by inserting hspace{-0.5mm} before pgfbox or pgfxy:

logo{ifplacelogopgfputat{pgfxy(-0.1,7.72)}{hspace{-0.5mm}pgfbox[right,base]{%
            includegraphics[height=7mm]{example-image-a}
    }}fi}%

or using makebox[0pt][r]{} instead of pgfbox

logo{ifplacelogopgfputat{pgfxy(-0.1,7.72)}{makebox[0pt][r]
{includegraphics[height=7mm]{example-image-a}}}fi}%

See also this post for llap and rlap and this (not completely related) post.

Correct answer by user108724 on January 23, 2021

Replace the logo command by

logo{ifplacelogopgfputat{pgfxy(-0.1,7.72)}{llap{includegraphics[height=7mm]{example-image-a}}}fi}

I didn't check the source of the problem, which is probably related to pgfbox.

enter image description here

Answered by gernot on January 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP