(Note: I wasn't sure if this fell under the same question as reduce bibliography to one line with dots and reference numbers. I attempted an edit which was rejected due to changing the question too much, so I'm asking this as a new question instead.)
I'm trying to put my references on one line, using code from Mico:
\usepackage[numbers]{natbib}
\renewenvironment{thebibliography}[1]{%
\section*{\refname}
\let\par\relax\let\newblock\relax
\inparaenum[{[}1{]}]}{\endinparaenum}
However, this produces extra spaces between some entries:
Note the extra space between the end of entry 2 and the beginning of entry 3.
Adding the following code fixes the extra space, but makes all in-text citations show up as question marks:
\renewcommand{\bibitem}[2][]{\item}
In addition, removing the numbers
option from \usepackage{natbib}
gets rid of the extra space as well, but I'd like to avoid using author-year citations.
Does anyone know how to get rid of the extra space while using the numbers option, without breaking in-text citations?
MWE:
\documentclass{article}
\usepackage[numbers]{natbib} % Removing numbers option fixes extra space
\usepackage{paralist}
\begin{filecontents}{bib.bib}
@article{test1,
Author = {Test Test},
Year = {0000},
Title = {Some title},
Journal = {Some journal},
Volume = {0},
Pages = {0}
}
@article{test2,
Author = {Test2 Test2},
Year = {0001},
Title = {Some other title},
Journal = {Some other journal},
Volume = {1},
Pages = {1}
}
@article{test3,
Author = {Test3 Test3},
Year = {0002},
Title = {Yet another title},
Journal = {Yet another journal},
Volume = {2},
Pages = {2}
}
\end{filecontents}
% Redefine the bibliography to go on one line
\renewenvironment{thebibliography}[1]{%
\section*{\refname}%
\let\par\relax\let\newblock\relax
\inparaenum[{[}1{]}]}{\endinparaenum}
% Uncommenting the following makes the extra space go away but breaks in-text citations
%\renewcommand{\bibitem}[2][]{\item}
\begin{document}
\citet{test1,test2,test3}
\bibliography{bib}{}
\bibliographystyle{plainnat}
\end{document}
\hfil
in the\item
command in\@lbibitem
. Unfortunately, trying to redefine\@lbibitem
in the document's preamble results in me getting an error about the paragraph ending before\NAT@bare
is complete. I'm not sure if there are any terrible consequences to redefining\hfil
to\hskip 0pt plus 0fil minus 0pt
, or if there's a way to avoid the\NAT@bare
error to allowing for removing it from\@lbibitem
directly.