Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to include a logo in the pdf pages included in Beamer.

I tried writing macro and progressed so far.

\documentclass[fleqn,xcolor=dvipsnames]{beamer}

\newlength{\logosize}
\setlength{\logosize}{7.50mm}

\newlength{\logoXinpdf}
\newlength{\logoYinpdf}
\setlength{\logoXinpdf}{0.9\textwidth}
\setlength{\logoYinpdf}{0.8\textheight}


\usepackage{pdfpages}

\def\getpdfpages#1#2{\begingroup
  \setbeamercolor{background canvas}{bg=}
  \includepdf[pages={#1},picturecommand={\put(\logoXinpdf,\logoYinpdf){\pgfimage[width=\logosize]{mylogo}}}]{#2}
  \endgroup}


\begin{document}


\getpdfpages{{9,12}}{mypdf.pdf}


\end{document}

However, when I run pdfLaTeX, I get an error in the line of,

! A <box> was supposed to be here.
<to be read again> 
                   \unitlength 
l.23 \getpdfpages{{9,12}}{mypdf.pdf}

I understand that the problem is with the \put command. If I replace the \logoXinpdf,\logoYinpdf lengths with absolute numbers, everything works fine.

Is there a way I can use these defined lengths with the \put command?

share|improve this question
1  
Your mistake here is that arguments of \put are in \unitlength units, not an usual length. Try to include fp package and compute coordinates by dividing your lengths by value of \unitlength. –  Eddy_Em Feb 3 '13 at 7:50
    
Thanks, @Eddy_Em. Modifying the code in the following manner solved my problem, \makeatletter \FPdiv{\logoX}{\strip@pt\logoXinpdf}{\strip@pt\unitlength} \FPdiv{\logoY}{\strip@pt\logoYinpdf}{\strip@pt \unitlength} \makeatother \def\getpdfpages#1#2{\begingroup \setbeamercolor{background canvas}{bg=} \includepdf[pages={#1},picturecommand={\put(\logoX,\logoY){\pgfimage[width=\logo‌​size]{buetlogo}}}]{#2} \endgroup} –  Masroor Feb 3 '13 at 8:36
    
@MMA: If this solved your problem please post it as an self-answer (after the waiting period) and accept it in order to conclude the question. –  Martin Scharrer Feb 3 '13 at 10:07
add comment

1 Answer 1

up vote 4 down vote accepted

It's actually sufficient just to locally disable \unitlength (assuming this is a picture mode command internally.

\def\getpdfpages#1#2{\begingroup
  \setbeamercolor{background canvas}{bg=}
  \includepdf[pages={#1},picturecommand={{\def\unitlength{}\put(\logoXinpdf,\logoYinpdf){\pgfimage[width=\logosize]{mylogo}}}}]{#2}
  \endgroup}

\put expects a multiplier and does essentially

\setlength\something{#1\unitlength}
\setlength\somethingelse{#2\unitlength}

So if \unitlength is empty it is OK to pass lengths to put. Heiko's picture package takes this a bit further and adds some conditional logic so that you can use either a length or a multiplier, so that \unitlength becomes essentially a default unit. So it is probably enough just to load picture and make no change to your code.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.