I don't know if one exists already, but issuing the directive
\def\?#1{}
will do the trick: \?abc gives bc, and so on.
Edit: Here is a discussion of the question Tim N raised in the comments: getting a \caption to drop the final period in a figure number. It does not work, even in the default article class, to just let
\renewcommand*\thefigure{\arabic{figure}\?}
which gives a few errors, the first of which is actually "Argument of \? has an extra }" and not "Paragraph ended before \? was complete" (that's the second). A little \tracingmacros-trawling reveals the following phenomenon: when \caption is called, it first increments the figure counter, which calls \refstepcounter so it can be referenced, which sets up (using \edef) the current label \@currentlabel for \ref, which (finally) must contain the value of \thefigure! And guess what: the extra period does not appear after \thefigure in this context, so the \? gobbles the closing brace of the \edef command. Hence the error.
Let's see if we can get what you want. The caption line is constructed in several stages, which in article consist of the following discrete steps:
- Generate the caption "number" (the text "Figure 1.2.", for example);
- Attach it to the caption "text" (the argument of
\caption) by, for example, inserting a colon and a space between them.
These correspond to the internal macros \fnum@figure and \@makecaption, which are defined by the document class, and obviously vary; it seems that Tim N's packages are putting extra periods in, but who knows whether it's in the first stage or the second? Or even in \thefigure itself? Depending on where it happens, you need a different workaround:
If someone erroneously defined \thefigure to contain an extra period, and you know how the rest of the number ought to look, then you can just redefine it. Since there's no way to gobble the previous character, if my solution below doesn't work for you, then you should try this.
If \fnum@figure somehow puts a period after the value of \thefigure, then under some circumstances you will be able to remove it using \?. For example, if they modified the default article definition (see below) then putting \? right after \thefigure will do the trick. However, if they produce the period by some clever device, you will have to be equally clever to unravel it.
Here is that definition:
% The default def'n doesn't have the period
\def\fnum@figure{\figurename\nobreakspace\thefigure.}
- Finally, suppose that the period is inserted in
\@makecaption. Then you may be able to catch it with \?, but only if the command that produces the "number" is dropped in as-is and not fully expanded first. This is the case in the article class and, we hope, also in whatever your situation is.
So it appears the goal is to stick \? right after \thefigure as it appears in \fnum@figure only. You want to patch a command, and there are several ways to go about this, but the etoolbox package is generally useful so I'll go with it. See the following minimal document:
\documentclass{article}
% Cute but not necessary here:
% \def\?#1{}
% BAD:
% \renewcommand\thefigure{\arabic{figure}\?}
% GOOD:
\usepackage{etoolbox}
\makeatletter
\patchcmd\fnum@figure{\thefigure}{\thefigure\@gobble}{}{}
\makeatother
\begin{document}
\begin{figure}
\caption{A figure}
\end{figure}
\end{document}
Since we are going with \makeatletter anyway, I figure the internal \@gobble command that Yiannis pointed out is probably the wiser course, though \? is nice if you are putting it in ordinary text.