# Extraneous space inserted before citealp command

I am defining a citation (using the citealp) command and using it like this:

\documentclass{article}
\usepackage[super]{natbib}

\setcitestyle{square,citesep={; }}
\newcommand*{\citesquare}[2]{\mbox{\textsuperscript{[}\citealp{#1}\textsuperscript{#2]}}}

\begin{document}

This\citesquare{lamport94}{, pp.~20-30} is a citation
used for experimentation and demonstration purposes only.

\begin{thebibliography}{9}
\bibitem{lamport94}
Leslie Lamport,
\emph{\LaTeX: A Document Preparation System}.
2nd Edition,
1994.
\end{thebibliography}

\end{document}


The problem is that there appears an extraneous space after the opening square bracket in the output. A hacky solution would be to insert something like \hspace with a negative argument after the opening square bracket in the command's definition, but this doesn't scale (if used in footnotes - actually is that right? I tried a negative em-argument (which didn't scale) but perhaps there are scalable ways of doing this?), and I'm looking for a real solution that exactly removes the space.

Note that I'm really looking for something that makes citations look exactly like shown, (bare numbers embedded in superscript square brackets, with additional text possibly before (which I have another macro for) and after). While my personal citation style is not important, the emphasis in my question is that I would like this particular approach fixed (so please not a reference to an alternative package/style that gives me something that looks almost like what I am interested in: I'm likely aware of those).

-

\citealp inserts a 1pt kern between the word and the superscript reference, so

\newcommand*{\citesquare}[2]{%
\mbox{\kern1pt\textsuperscript{[}\kern-1.5pt\citealp{#1}\kern-.5pt\textsuperscript{#2]}}}


should be what you want. If you prefer, you can omit the first \kern1pt. The insertion of the superscript in three pieces requires also a supplementary back up of 0.5pt.

Here's an example to show the result; I added some mock bib items just to not have 1 as the reference number. The digit 1 appears thinner and it's not to be used for judging spaces.

\documentclass{article}

\usepackage[super]{natbib}

\setcitestyle{square,citesep={; }}
\newcommand*{\citesquare}[2]{%
\mbox{\kern1pt\textsuperscript{[}\kern-1pt\citealp{#1}\textsuperscript{#2]}}}

\begin{document}
This\citesquare{lamport94}{, pp.~20-30} is a citation

\def\ts{\textsuperscript} % just a shorthand

This\kern1pt\ts{[}\ts{7}\ts{, pp.~20-30]} is a citation

\begin{thebibliography}{9}
\bibitem{1}
\bibitem{2}
\bibitem{3}
\bibitem{4}
\bibitem{5}
\bibitem{6}
\bibitem{lamport94}
Leslie Lamport,
\emph{\LaTeX: A Document Preparation System}.

Many thanks for your answer! I tried both \negthinspace (your original suggestion) and \kern-1pt. The former gives me slightly too narrow spacing and the latter slightly too wide spacing. Ideally, the spacing between [ and 1 would be exactly the same as if I were writing \textsuperscript{[1]} directly (abstracting away from the question of thin spacing before the [). –  Lover of Structure Jun 13 '12 at 19:52
Try with another figure. I get exactly the same box width when I do x\citesquare{lamport94}{} (definition with \kern) and x\mbox{\kern1pt\ts{[}\ts{1}\ts{]}} (\ts is short for \textsuperscript). The fact is that 1 appears thinner than, say, 2. –  egreg Jun 13 '12 at 19:59
Hmm, I'm trying exactly my posted sourcecode but with (1) your definition (with \kern1pt and \kern-1pt) and (2) with the string "This\citesquare{lamport94}{} is\textsuperscript{[1]} a\citep{lamport94} citation [...]"). I see that the latter two superscripts have identical spacing between the respective [1 and 1] symbol pairs, but the first superscript is wider around the 1 on both sides. –  Lover of Structure Jun 13 '12 at 20:11
(And I get the same difference when I end the line prematurely using \\ after the word citation, thereby effectively disabling tracking.) I did try the number 7 as well. The two lines you have shown are naturally identical since the second is essentially a macro expansion of the first. The question is whether it's possible to have the appearance be identical to writing \textsuperscript{[7]} directly. (I tried and unfortunately I still observe the difference.) –  Lover of Structure Jun 13 '12 at 21:33