0

I would like to list references in a single line continuously without line breaks. There is a good example of doing this: Reduce natbib bibliography to one line

In the above link, I tried Lev Bishop's answer and it worked very well. But in this answer, I would like to change the bullets to just numbering (e.g., if I have three references, then "1...; [2]...; [3]..."). So, I played some time with the \olditem[\textbullet] part. But, I couldn't find the solution.

How can I use the auto-numbering (e.g., [item number]) in this code, instead of the bullet?

EDIT

Here I give a short example of my latex code of the issue.

\documentclass[12pt,a4paper]{article}

\usepackage{hyperref}
\hypersetup{colorlinks,linkcolor={blue},citecolor={blue},urlcolor={blue}} 
\usepackage[numbers]{natbib}
\usepackage{textgreek}
\setlength{\bibsep}{0pt}
\usepackage{paralist}

\let\olditem\item
\renewenvironment{thebibliography}[1]{%
  \setlength{\itemsep}{0pt}%
  \section*{3~~~References}
  \let\par\relax\let\newblock\relax
%  \renewcommand{\item}[1][]{\olditem[\textbullet]}%
  \inparaenum}{\endinparaenum}

\textheight=247mm
\textwidth=180mm
\topmargin=-7mm
\oddsidemargin=-10mm
\evensidemargin=-10mm
\parindent 10pt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Start of document %%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagestyle{plain}
\pagenumbering{arabic}
%================================================================================
\section{Good day}

Hello.

\begin{thebibliography}{}
\bibitem[abcde et al.(2999)]{abcde}
abcde, z., et al. 2999, GGG, 123, 4;

...
...(this is just a short description, so all references are omitted)
...

\end{thebibliography}
\end{document}

Thanks to frabjous's suggestion, now all references start with [number] automatically. But, I have two more questions. As you can see the capture image (resultant reference section produced by the above example) below,

[Q1] There are unwanted empty spaces between references. How can I remove them?

[Q2] Is there a way to give a color only to the heading numbers in the Reference section? For example, (1)...; (2)... --> colored (1)...; colored (2)...

The numbering works, but ugly empty spaces appeared

8
  • Welcome to TeX.SE!
    – Mensch
    Apr 10, 2022 at 15:46
  • Are the citations themselves numeric? If so, then you should use \usepackage[numbers]{natbib} and you could probably just remove the line \renewcommand{\item}[1][]{\olditem[\textbullet]} from Lev Bishop's answer and use the default definition of \item. If they're author-year, then add in something like \newcounter{bibitem}\setcounter{bibitem}{0}\renewcommand{\item}[1][]{\refstepcounter{bibitem}\olditem[{[\thebibitem]}]}? Not sure exactly what you're looking for. If these suggestions don't help, post a minimal working example.
    – frabjous
    Apr 10, 2022 at 22:28
  • 1
    You have tagged your question with many tags. Some of the packages/methods mentioned in the tags are incompatible with each other. (Specifically biblatex is incompatible with natbib and \bibitem.) From the linked question it looks like you are looking for a BibTeX/\bibitem/natbib-based answer, but it would really help if you could edit your question to clarify that.
    – moewe
    Apr 11, 2022 at 5:42
  • Thanks for your comments. I just removed biblatex from the textbody. I also tested frabjous's answer and it worked, thanks! But as you can see this edited version, I have two more questions. Do you happen to know how to solve them?
    – sadradio
    Apr 11, 2022 at 18:43
  • @frabjous Hi, I edited the text. Do you happen to know how to solve the above mentioned questions? Thanks.
    – sadradio
    Apr 14, 2022 at 14:06

1 Answer 1

0

To sum up what I wrote in the comments, to return the list labels to numbers, use \usepackage[numbers]{natbib} and remove the line \renewcommand{\item}[1][]{\olditem[\textbullet]} line from Lev Bishop's answer in the linked answer.

To remove the gaps between the list items, add \let\hfil\relax to \let\par\relax\let\newblock\relax in that answer.

To color the labels, you could do, for example, \let\oldbibitem\bibitem \RenewDocumentCommand{\bibitem}{om}{{\color{blue}\oldbibitem[#1]{#2}}}; change the color to whatever you want, and load the xcolor package with one of its options to add to the possible color names. (See its documentation.)

So all in all, we have something like:

\documentclass[12pt,a4paper]{article}

\usepackage[svgnames]{xcolor}
\usepackage[numbers]{natbib}
\usepackage{hyperref}
\hypersetup{colorlinks,linkcolor={blue},citecolor={blue},urlcolor={blue}} 
\usepackage{textgreek}
\setlength{\bibsep}{0pt}
\usepackage{paralist}

\renewenvironment{thebibliography}[1]{%
  \setlength{\itemsep}{0pt}%
  \section*{3~~~References}
  \let\par\relax\let\newblock\relax\let\hfil\relax
  \inparaenum}{\endinparaenum}

\let\oldbibitem\bibitem
\RenewDocumentCommand{\bibitem}{om}{{\color{blue}\oldbibitem[#1]{#2}}}

\textheight=247mm
\textwidth=180mm
\topmargin=-7mm
\oddsidemargin=-10mm
\evensidemargin=-10mm
\parindent 10pt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Start of document %%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagestyle{plain}
\pagenumbering{arabic}
%================================================================================
\section{Good day}

Hello.

\begin{thebibliography}{}

\bibitem[abcde et al.(2999)]{abcde}
abcde, z., et al. 2999, GGG, 123, 4;

...

\end{thebibliography}

\end{document}
1
  • Thank you very much! This answer is perfect!
    – sadradio
    Apr 17, 2022 at 16:06

You must log in to answer this question.

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