# Why a space make failed the evaluation of a command in \bibliography

I created a command containing a list of bib files separated by a comma and a space. Then, I give this command to \bibliography, which produce no bibliography.

If I create the same list but only separated by comma (without space), the bibliography is produced.

Here is a MWE:

\documentclass{article}
\newcommand{\PathBaseBib}{./biblioA.bib, ./biblioB.bib} % this is not working
%\newcommand{\PathBaseBib}{./biblioA.bib,./biblioB.bib} % this (without space) is working
\usepackage{natbib}
\bibliographystyle{plain}

\begin{document}
\cite{Knuth81} \cite{Lamport94}

\bibliography{\PathBaseBib}
\end{document}


So I would like to understand why this simple space make fail the command \bibliogrpahy. And for esthetic reasons, I wonder if it is possible to correct this and so feed \bibliography with a command containing a list with spaces.

• You shouldn't have to specify the extension .bib in the argument of \bibliography. What happens if you run \newcommand{\PathBaseBib}{biblioA,biblioB}?
– Mico
Feb 1 at 17:52
– R. N
Feb 1 at 17:59

Since \bibdata, which is written in the aux file, doesn't want spaces in its argument because of how BibTeX reads its input, the standard \bibliography command does \zap@space, but this fails if the argument is a macro.

You can fix this as follows:

\documentclass{article}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\bibliography}{\zap@space #1}{\expandafter\zap@space\expanded{#1}}{}{}
\makeatother

\newcommand{\PathBaseBib}{./biblioA, ./biblioB} % this is not working

\bibliographystyle{plain}

\begin{document}

\cite{Knuth81} \cite{Lamport94}

\bibliography{\PathBaseBib}

\end{document}


This will be written in the .aux file:

\relax
\bibstyle{plain}
\citation{Knuth81}
\citation{Lamport94}
\bibdata{./biblioA,./biblioB}
\gdef \@abspage@last{1}


and you see that the space has been removed.

Beware that adding .bib to the files is not allowed generally. Only MiKTeX allows it, but it shouldn't.