我尝试让我的书目编号样式以章节编号开头,后跟每个条目的阿拉伯数字。例如:
25.7 REFERENCES
25.7.1 First Reference
25.7.2 Second Reference
类似于我的上一个问题在对齐章节标题时,我希望参考书目项目编号也位于左边距。
这是我的 MWE,它有明显的问题。这是我能得到的最接近的结果。
\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}
答案1
您可以通过修补内部命令来实现此目的\@bibitem
,该命令标准上仅使用简单的列表计数器,并按\@biblabel
如下方式更改命令:
\makeatletter
\patchcmd{\@bibitem}{\the\value{\@listctr}}{\thesection.\the\value{\@listctr}}{}{Bib patch failed}
\def\@biblabel#1{[\thesection.#1]}
\makeatother
请注意,您已经加载etoolbox
并设置好\thesection
以生成所需的信息。在下面的代码中,我删除了与此问题无关的许多其他格式设置。根据您的评论,我现在添加了显示hyperref
它适用于此(您只需注意执行顺序)并对环境进行了进一步调整bibliography
,\@biblabel
因此标签会打印在页边距中。
\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}
上面的代码打印标签时,标签右对齐,然后在左边距前留一个空格。如果您希望准确复制您的部分标签样式,则可以使用以下定义\@biblabel
:
\def\@biblabel#1{\llap{\makebox[0.75in][l]{[\thesection.#1]}}}