2

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

  • I assume you're interested in using some kind of numeric style for citation call-outs. Should the citation call-outs continue to appear as [1], [2], etc. in the body of the document, or should they appear as [25.7.1], [25.7.2], etc? – Mico Apr 6 '17 at 20:59
  • Citations should appear 25.7.1 in the text, no brackets. – grfrazee Apr 6 '17 at 21:01
  • And if cited material is used twice in different sections, I guess it should get the number of the first section it was used in?! – Skillmon Apr 6 '17 at 21:05
  • Not entirely sure what you mean, but there is only one References section in the entire document. – grfrazee Apr 6 '17 at 21:07
  • Oh. Now I think I get it... You just want them all to be 25.7.xx (where 25.7 is the section 'REFERENCES'). First I thought you wanted them to be numbered after the section they were cited in. – Skillmon Apr 6 '17 at 21:18
3

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]}}}
  • This does work, but I realized that it conflicts with the hyperref package that I'm using if I don't load hyperref after your additions for the bib numbering. However, it doesn't account for the margin spacing concerns I brought up via reference to my previous question. Any thoughts on that? – grfrazee Apr 11 '17 at 13:36
  • Thanks for the update. Where you have \labelwidth as the width of the left margin, how would one change this to be 0.75in? I have the section numbers in a 0.75in-wide margin in the rest of the document, and having the reference numbers align left with these is the desired effect. – grfrazee Apr 13 '17 at 15:29
  • You misunderstand, the \labelwidth is in code that is being deleted from the standard definition. Anyway all you need is a different definition of \@biblabel now added to my answer at the end. – Andrew Swann Apr 16 '17 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.