2

I was trying to write a macro to bold a name. I used:

\newcommand{\authorship}[2]{\textbf{#1 #2}}

then in the text used

\authorship{Dave Bridges}

Unfortunately when run through pdflatex I get an extra space after the name. So for example the line

\authorship{Bridges, D.}, M. E. Fraser and G. B. G. Moorhead.  2005.  Cyclic Nucleotide Binding Domains in the Arabidopsis thaliana and Oryza satviva Genomes.  BMC Bioinformatics 6(1): 6.

adds an extra space between the period after D and the comma. How do I get rid of that extra space?

1
  • 3
    Seems like authorship should be given a first and last name separately: \authorship{Bridges,}{D.}, M. E. Fraser... Mar 8, 2012 at 15:22

2 Answers 2

7

Although you specify you command \authorship to take two arguments, you actually only supply it with one during a call like:

\authorship{Dave Bridges}

As such, #2 is the following token (a , in this case), but TeX still prints #1, followed by a space, followed by #2 (a bold comma). Using a macro like this

\newcommand{\authorship}[1]{\textbf{#1}}%

or even just

\let\authorship\textbf

would suffice. Of course, if you intend to highlight (bold) certain parts of a name, then something else needs to be done, like keeping your original definition, but with usage of the form:

\authorship{Bridges}{Dave}
1
  • 3
    #2 is not empty. It is the following comma. Mar 8, 2012 at 15:26
1

Although Werner has identified the issue and provided a solution to this problem, you might also look into the xspace package available on CTAN. It can be especially handy when defining commands like these that might then be followed by punctuation of some sort.

xspace, however, would not have solved this issue given the example code provided because, as @Andrey Vihrov pointed out, the comma would still have been interpreted as the second argument.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .