[Tex/LaTex] Bibliography entry numbering to start with section number

bibliographiescross-referencing

I'm attempting to make my bibliography numbering style begin with the section number followed by an arabic number for each entry. For example:

25.7      REFERENCES

25.7.1    First Reference
25.7.2    Second Reference

Similar to my previous question on aligning section headers, I would want the bibliography item numbers also in the left margin.

Here's my MWE, which has obvious issues. This is as close as I can get.

\documentclass[letterpage,10pt]{report}

\usepackage{chngcntr}
\usepackage{enumitem}
\usepackage[colorlinks=true,urlcolor=black,hypertexnames=false]{hyperref}

%Set page margins
\usepackage[left=1.75in,right=1in,headheight=1in,bottom=1.5in,footskip=0.5in,showframe]{geometry}

\usepackage{titlesec}
\renewcommand\thesection{25.\arabic{section}}   %Add "25." before section numbering
\setcounter{section}{6}   %Set first section number to "7" for this MWE
%https://tex.stackexchange.com/questions/361509/align-all-text-excluding-section-list-numbers
\titleformat{\section}{\normalfont\bfseries}{\llap{\makebox[0.75in][l]{\thesection}}}{0em}{\MakeUppercase}

\usepackage{etoolbox} %Patch bibliography style to it doesn't go to the next page
\patchcmd{\thebibliography}{\chapter*}{\section*}{}{}

\setlength\parindent{0pt}   %no indent for all paragraphs

\begin{document}

\section{References}

\renewcommand{\bibname}{} %Remove "Bibliography" header

\renewcommand\bibitem{25.\arabic{section}. }   %Add section number before reference numbering

\begin{thebibliography}{9}

    \bibitem{Reference 1}

    \bibitem{Reference 2}

\end{thebibliography}

\end{document}

enter image description here

Best Answer

You can do this by patching the internal command \@bibitem, which as standard uses only a simple list counter, and changing the \@biblabel command as follows:

\makeatletter
\patchcmd{\@bibitem}{\the\value{\@listctr}}{\thesection.\the\value{\@listctr}}{}{Bib patch failed}
\def\@biblabel#1{[\thesection.#1]}
\makeatother

Note that you have already loaded etoolbox and you have already set-up \thesection to produce the information you wish. In the code below, I have removed much of your other formatting set-up that is not relevant to this problem. Further to your comment, I have now added hyperref to show it works with this (you just need to be careful about the execution order) and have added further adjustments to the bibliography environment and \@biblabel so the labels are printed in the margin.

Sample output

\documentclass{report}

\renewcommand\thesection{25.\arabic{section}}

\setcounter{section}{6}

\usepackage{etoolbox}
\usepackage{hyperref}
\patchcmd{\thebibliography}{\chapter*}{\section*}{}{}
\patchcmd{\thebibliography}{\leftmargin\labelwidth}{\leftmargin0pt}{}{}
\patchcmd{\thebibliography}{\advance\leftmargin\labelsep}{}{}{}
\makeatletter
\patchcmd{\@bibitem}{\the\value{\@listctr}}{\thesection.\the\value{\@listctr}}{}{Bib patch failed}
\def\@biblabel#1{\llap{[\thesection.#1]\ }}
\makeatother

\renewcommand{\bibname}{}

\begin{document}

\section{Text}

\cite{R1} and \cite{R2}

\section{References}

\begin{thebibliography}{9}
\bibitem{R1} Reference 1

\bibitem{R2} Reference 2
\end{thebibliography}

\section{More text}

\cite{S1,R1}

\section{More references}

\begin{thebibliography}{9}
\bibitem{S1} Reference 3
\end{thebibliography}

\end{document}

The above prints the labels right aligned followed by a space before the left margin. If you wished to copy your section labelling style exactly then use the following definition for \@biblabel instead:

\def\@biblabel#1{\llap{\makebox[0.75in][l]{[\thesection.#1]}}}
Related Question