TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bibliography in which URLs are printed with a following "." I would like to omit the URLs to save space and I could do this by redefining the URL command, but this would leave me with a dot. Is there a way to define a command that eats a following "."?

share|improve this question
If all the URLs are in the form \url{...}., then redefine \url with two arguments to do nothing with them. Otherwise something slightly more complicated should be done. – egreg Nov 14 '12 at 9:28
Maybe you can pick or design a bibliography style that will omit the url fields? That would look like a more natural way of doing it, for example in case you have urls elsewhere in your text. – T. Verron Nov 14 '12 at 9:35
I have a bibliography that contains URLs they are set like \url{ ... }. I cannot influence this. So I have to redifine the url command to eat this dot. – Stefan Müller Nov 14 '12 at 9:37
@StefanMüller: but it should be easy to modify your bibliography style file. – Herbert Nov 14 '12 at 12:04
up vote 16 down vote accepted
  • The redefinition of \url is not trivial, because the argument might contain the percent character. Therefore the argument needs to be read with verbatim catcodes.

  • The dot can be removed using \@ifnextchar.\@gobble{}. This also catches the case that \url{...} is not followed by a dot. As side effect \@ifnextchar removes spaces. This can be avoided by using \ltx@ifnextchar@nospace of package ltxcmds instead of \@ifnextchar.

Example file:

    % set verbatim catcodes
    % restore catcode of argument braces
    \catcode`\{=1 %
    \catcode`\}=2 %
  % eats the URL in #1
  % skip an optional dot

Normal url:

Skipped urls:


share|improve this answer
Great answer (as usual); I've changed \urlgobble into \url in the final example, which seemed to be your intent, as \skipurl was given. – egreg Nov 14 '12 at 10:31
@egreg Thanks, it was a leftover from testing that I have forgotten to revert. – Heiko Oberdiek Nov 14 '12 at 10:47

Works only if the URL has no special characters!




Not printed: \url{http://www.dante.de}.



enter image description here

share|improve this answer

Your Answer


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.