# Pretending a package has been loaded

I am trying to use imakeidx and the regexpatch package in the same class. Since imakeidx depends on the xpatch package and xpatch provides the same commands (same names, improved implementation) as regexpatch this gives errors (redefining commands). Is there anyway to pretend I loaded the xpatch package, so the require inside imakeidx won"t load anything? (Since I load regexpatch before, everything should be fine).

While I have a concrete example above, I would be interested in the general answer to prevent require statements from loading packages, a workaround for my particular case is a bonus (I guess either I am doing something wrong or the package author will take a look).

-
@egreg I think you might be the author of both packages, so I wanted to notify you. On page 17 line 37 of the imakeidx manual, it seems like you \RequirePackage{xpatch} unconditionally. – ted Aug 21 '13 at 21:33
\ProvidesFile{wibble.sty} will make latex think that the wibble package has been loaded. – David Carlisle Aug 21 '13 at 21:45
...or \makeatletter\let\ver@wibble\@empty\makeatother (I think). – Werner Aug 21 '13 at 21:52
@Werner \csname ver@wibble.sty\endcsname (so that wibble class and wibble package can both exist – David Carlisle Aug 21 '13 at 21:55
@ted FYI, trying to notify someone the way you did with egreg doesn't work unless egreg is the author of the post, or if he/she has written a comment. If as you type the name it starts to auto-complete, the person will be notified, if it doesn't autocomplete, the person won't. See here: meta.stackexchange.com/questions/123594/… – Chris Gregg Aug 22 '13 at 8:23

One can use David's suggestion, but etoolbox must be loaded anyway:

\ProvidesFile{xpatch.sty}
\usepackage{etoolbox}
\usepackage{imakeidx}
\usepackage{regexpatch}

should do.

-

\documentclass{article}

\ProvidesFile{longtable.sty}

\usepackage{longtable}

\typeout{longtable is: \meaning\longtable}

\stop

produces

longtable is: undefined

showing that the package is not loaded, despite the \usepackage.

-
+1 for the demonstrations of the effect – ted Aug 21 '13 at 22:11