0

I use the wallpaper package to put a PDF document in the background of my document.

I want the user to be able to select in the preamble which PDF should be use as background image like this:

\output{print} or \output{screen}

I thought I can write the command like this:

\newcommand{\output}[1]{
  \ifstrequal{#1}{print}{
     \ULCornerWallPaper{1}{backgroundPrint.pdf}
   }{
      \ULCornerWallPaper{1}{background.pdf}
   }
}

But this does not work. I have found out that this, however, works:

\newcommand{\print}{
   \ULCornerWallPaper{1}{backgroundPrint.pdf}
}
\newcommand{\screen}{
    \ULCornerWallPaper{1}{background.pdf}
}

which works nicely, but I really want to know what the problem is with my initial approach.

I have also tried the approach described here but without success.

I'm not much into LaTeX programming so any help is highly appreciated.

1
  • Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. What “does not work”? What happens? Error messages? Different output than expected? Have you tried another macro name instead of \output which may already be defined (though this would come up in an error message, as well)? – Qrrbrbirlbel Mar 1 '13 at 19:00
1

The macro \output is already defined (it is a TeX primitive, → Why can't I use \newfloat more than once?) as one can see in the log:

! LaTeX Error: Command \output already defined.
               Or name \end... illegal, see p.192 of the manual.

You will need to use a different macro name, say \Output.

Code

\documentclass{article}
\usepackage{wallpaper,graphicx,etoolbox}
\newcommand*{\Output}[1]{%
  \ifstrequal{#1}{print}{%
     \ULCornerWallPaper{1}{example-image-A.pdf}% example-image-? is from the mwe package
  }{%
     \ULCornerWallPaper{1}{example-image-B.pdf}%
  }%
}
\Output{print}
\begin{document}
Nothing to see here.
\end{document}
1
  • Great, thanks a lot. I missed the info in the log. – Frank Mar 1 '13 at 19:37

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.