Problem using invoice and wallpaper packages together

For some reason that I don't understand, it seems that I cannot use the invoice package and the wallpaper package at the same time.

Here is my MWE:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{wallpaper}
\usepackage{invoice}

\begin{document}
Just a test
\end{document}


And this is the output I get after running pdflatex:

If I open the transcript file, there's something that seems to be related to the problem:

(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg
File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv
e))
Overfull \hbox (15.31238pt too wide) in paragraph at lines 184--92
[]\OT1/cmr/m/n/10 [2007/09/09]    [2010/03/01]  [2010/12/02]  [2010/09/13]
[2007/11/11]    [2007/09/09]            [2007/09/09]

I also tried loading the packages in a different order, like this:

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{invoice}
\usepackage{wallpaper}

\begin{document}
Just a test
\end{document}


In this case pdflatex gives an error message, complaining about a missing \begin{document} in wallpaper.sty:

(/usr/share/texlive/texmf-dist/tex/latex/wallpaper/wallpaper.sty

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

                                               l.24 \NeedsTeXFormat{LaTeX2e}[
1995/06/01]


If I use only one of the packages, the document gets rendered as expected.

So here are my two questions:

1. Why is this happenning?
2. How can I fix it?
• I've used those two packages together for several years without any issues. This problem started after upgrading my OS, which in turn upgraded my TeX Live environment from an ancient version (~2009) to a less ancient one (2012) Feb 26, 2014 at 6:15
• I get the expected result (first MWE) with an up-to-date system. TeX Live 2012 is "less" ancient, but still ancient. Upgrade to 2013 . Feb 26, 2014 at 6:26
• @mfriedman: I have TexLive 2013 and am able to confirm at least one error message with from pdflatex concerning your MWE, if you include invoice package before wallpaper. However, it works the other way round.
– user31729
Feb 26, 2014 at 7:01
• I had a look on wallpaper.sty -- it is basically 8 years old, at first glance there is nothing strange in that file, but concerning the age of that package, there must be some incompatibility with invoice, which is from 2011.
– user31729
Feb 26, 2014 at 7:09

Someone please contact the invoice author. He is loading fp via \input{fp} instead of \RequirePackage{fp}. If I change that line in invoice.sty then it seems to work just fine.

• I can confirm that replacing input with RequirePackage in invoice.sty solves the problem. When I was trying to solve this issue, I stumbled upon this answer, which mentions the problem of using input in invoice.sty. But I failed to realize that I could try that solution for my case. Thank you very much for pointing me in the right direction! Feb 27, 2014 at 3:26

A minor work-around for this is to make \input{fp} conform to \RequirePackage{fp} when using \usepackage{invoice}. Here's one way of doing that (which uses pdfTeX's \pdfstrcmp):

\let\oldinput\input% Save \input
\renewcommand{\input}[1]{%
\ifnum\pdfstrcmp{#1}{fp}=0
\RequirePackage{fp}% Specifically when finding \input{fp}
\else
\oldinput{#1}% If not \input{fp}
\fi
}
\usepackage{invoice}% http://ctan.org/pkg/invoice
\let\input\oldinput% Restore \input