我找到了一种让章节引用对我有用的方法,但它一定是错的,或者至少是不完整的

我找到了一种让章节引用对我有用的方法,但它一定是错的,或者至少是不完整的

我正在使用 TeXworks Verion 0.67 和 MiKTeX 22.8.28 来写一本书。

我已经设法创建在每章末尾列出的参考资料,但是,我这样做的方式似乎是错误的。

在每个章节文件的末尾,都有以下几行:

\renewcommand{\bibname}{References}
\printbibliography[heading=subbibintoc,title={Chapter Subject References}]

在我的书的主 latex 文件中,有这两行。请注意,其中一行被注释掉了。

%\usepackage[backend=bibtex,style=ieee,natbib=true]{biblatex}
\usepackage[backend=biber,style=ieee,natbib=true]{biblatex}

从一个干净的目录,我可以运行 pdflatex,它会创建一个 .bcf 文件。

然后我可以运行 biber 来编译参考文献。

然后我可以返回并再次运行 pdflatex。但是,我在每章末尾得到的参考资料都是带有文本“[0]”的数字。

如果我取消对第一行“backend=bibtex”的注释,并用“backend=biber”注释掉第二行,然后再次运行 pdflatex,则所有参考文献都会正确编号。

此后,我可以再次注释掉“backend=bibtex”行,并取消注释“backend=biber”行并反复重建,这样我每章的参考文献就会正确编号。

我真的在使用 biber 来引用吗?我不完全理解它是如何工作的。

我主要想知道我必须进行哪些更改才能使用 biber 并使用 \cite{some_bib_key} 在章节中完成一组引用以正确显示,而无需更改我的主要 tex 文件。


这是我的主书文件的内容。我更改了我的名字、书名和每个章节的文件名,以隐藏这本书的内容。

\documentclass[12pt]{book}
\title{BookName}
\author{FirstName LastName}
\date{today}
\usepackage[width=6.5in, height=9.0in, top=1.0in, papersize={8.5in,11.0in}]{geometry}
\usepackage{enumitem}
\usepackage[pdftex]{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tipa}
\usepackage{textcomp}
\usepackage[dvipsnames]{xcolor}
\usepackage{colortbl}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{booktabs}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{placeins}
\usepackage{flafter}
\usepackage{wallpaper}
\usepackage[nottoc]{tocbibind}
\usepackage{imakeidx}
%
%\usepackage[backend=bibtex,style=ieee,natbib=true]{biblatex}
\usepackage[backend=biber,style=ieee,natbib=true]{biblatex}
\addbibresource{mybibfile.bib}
%
\ExecuteBibliographyOptions{refsection=chapter,giveninits=true,backref=true,backrefstyle=two,block=space,defernumbers=true}

\makeindex
%
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{}
\fancyhead[LE,RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\addtolength{\headheight}{0.5pt}
\setlength{\footskip}{0in}
\renewcommand{\footruleskip}{0pt}
\addtolength{\headheight}{0.5pt} % space for the rule
\fancypagestyle{plain}{\fancyhead{} % get rid of headers on plain pages
\renewcommand{\headrulewidth}{0pt} % and the line
}
% Allowing inline font change.
\newcommand\finline[3][]{\begin{myfont}[#1]{#2}#3\end{myfont}}%

% Environement for the new font.
\newenvironment{myfont}[2][]{\csname#2\endcsname[#1]}{}

\newcommand{\Alpine}[1][]{\fontfamily{Alpine}#1\selectfont}
%
\setlength{\headheight}{14.49998pt}
%
\setlength\parindent{20pt}
\parskip 0.05in
\raggedbottom
%
\newcounter{figureNumber}
\setcounter{figureNumber}{0}
%
\newcounter{tableNumber}
\setcounter{tableNumber}{0}
%----------------------------------------------------------------------
\begin{document}
\frontmatter

\definecolor{ltgray}{gray}{0.90}

%
\chapter*{\Huge \center \vspace{-1.5cm}BookName\newline\finline[\fontsize{18}{24}]{Alpine}{\textbf{Some subsitle text}}}
\thispagestyle{empty}
% Add the image to the title page.
\ThisCenterWallPaper{1.0}{coverimage.png}

\section*{\vspace*{\fill} \huge \center by FirstName LastName}
\newpage
\subsection*{\center \normalsize Copyright \copyright 2023 FirstName LastName}
\subsection*{\center \normalsize All rights reserved.}
\subsection*{\center \normalsize 1st edition}
%\subsection*{\center \normalsize ISBN \dots}
%\subsection*{\center \normalsize \dots Publications}
%
\chapter*{\center \normalsize Dedication about the book.}
%
\tableofcontents
%
\mainmatter
%
\include{my_book_introduction}

\include{chapter_one}

\include{chapter_two}

\include{chapter_three}

\include{chapter_four}

\include{chapter_five}

\include{chapter_six}
a
\include{chapter_seven}

\include{chapter_eight}

\backmatter
\printindex
\addcontentsline{toc}{chapter}{\indexname}

\end{document}

相关内容