Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
3  
Seems like authorship should be given a first and last name separately: \authorship{Bridges,}{D.}, M. E. Fraser... –  Peter Grill Mar 8 '12 at 15:22
add comment

2 Answers 2

up vote 6 down vote accepted

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}
share|improve this answer
3  
#2 is not empty. It is the following comma. –  Andrey Vihrov Mar 8 '12 at 15:26
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

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.