我的文档中有\lstlistoflistings
。我引用了部分代码。但是,参考书目似乎引用了它们,就好像有明确的引用一样,而对于\listoffigures
,\listoftables
情况并非如此。
这是目录。
这出现在图表中。
这也出现在清单中。
第 3 页的笔记本电脑图片。
在第 16 页列出引文
参考文献/书目。
Latex 认为\listoflistings
我想引用参考文献,但我想在附录中稍后引用它们,而不是在目录区域中引用它们。
问题是,是否可以将代码列表排除在引用之外,\printbibliography
就像图列表和表格列表一样。否则,它们将作为参考书目中的第一项出现。
\documentclass[10pt, titlepage]{report}
%% preamble
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
% To input code
\usepackage{listings}
\renewcommand{\lstlistingname}{Code}% Listing -> Code
\renewcommand{\lstlistlistingname}{List of \lstlistingname s}% List of Listings -> List of Codes
% Bibliography
\usepackage[style=apa,backend=biber,citestyle=numeric,sorting=none,hyperref,backend=biber,backref,backrefstyle=none]{biblatex}
% \usepackage[sorting=none]{biblatex}
\addbibresource{references.bib}
\PassOptionsToPackage{hyphens}{url}
\DeclareLanguageMapping{british}{british-apa}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
\defbibenvironment{bibliography}
{\list
{\printtext[labelnumberwidth]{%
\printfield{labelprefix}%
\printfield{labelnumber}}}
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
\setlength{\bibitemsep}{3pt}
\urlstyle{tt}
\usepackage{url}
\usepackage{nomencl}
\makenomenclature
\begin{document}
\input{title}
\pagenumbering{Roman}
% Modify Table of Contents line spacing
\renewcommand{\baselinestretch}{0.75}\normalsize
\clearpage
% \vspace{10mm} \hfill
\tableofcontents
\clearpage
% \vspace{10mm} \hfill
\cleardoublepage
\phantomsection
\listoffigures
\addcontentsline{toc}{chapter}{List of Figures}
\clearpage
% \vspace{10mm} \hfill
\cleardoublepage
\phantomsection
\listoftables
\addcontentsline{toc}{chapter}{List of Tables}
\FloatBarrier
\clearpage
% \vspace{10mm} \hfill
\renewcommand{\baselinestretch}{2}\normalsize
\cleardoublepage
\phantomsection
\lstlistoflistings
\addcontentsline{toc}{chapter}{List of Codes}
% Re normalise line spacing
\renewcommand{\baselinestretch}{1.25}\normalsize
% \input{sections/00_nomenclature}
\pagenumbering{arabic}
\clearpage
\begin{figure}[H]
\centering
\includegraphics[width=\textwidth]{images/image.jpg}
\caption{source: Unsplash \cite{california_university_specification}}
\label{fig:my_label}
\end{figure}
\clearpage
\lstinputlisting[language=Matlab, label={lst:JB2008_atmospheric_model_function}, caption=Jacchia-Bowman JB2008 Atmospheric Density Model. Source: Matlab and Jacchia-Bowman \cite{Bowman2008_JB2008}.]{Code/Atmospheric_model_JB2008/JB2008.m}
\clearpage \printbibliography
\end{document}
以下是 Overleaf 中的一个例子: https://www.overleaf.com/read/xbnfnbhxxzws
答案1
biblatex
需要向用于构建各种表格/列表的文件中写入一些代码......默认情况下biblatex
有代码来处理.toc
,.lof
和.lot
。
.lol
(listings
'列表列表)的相关代码是
\makeatletter
\AtBeginDocument{%
\blx@immediate@addtocontents{lol}{%
\boolfalse{citerequest}%
\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\boolfalse{backtracker}\relax}}
\makeatother
\blx@immediate@addtocontents
如果收到未定义的错误,请使用
\makeatletter
\newcommand\blx@immediate@addtocontents[2]{%
\blx@auxwrite\@auxout
{\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
{\string\@writefile{#1}{#2}}}
\AtBeginDocument{%
\blx@immediate@addtocontents{lol}{%
\boolfalse{citerequest}%
\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\boolfalse{backtracker}\relax}}
\makeatother
平均能量损失
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=numeric, sorting=none, backref=true]{biblatex}
\usepackage{listings}
\makeatletter
\AtBeginDocument{%
\blx@immediate@addtocontents{lol}{%
\boolfalse{citerequest}%
\boolfalse{citetracker}%
\boolfalse{pagetracker}%
\boolfalse{backtracker}\relax}}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
\lstlistoflistings
\cleardoublepage
Lorem \autocite{sigfridsson}
ipsum \autocite{worman}
\cleardoublepage
\begin{lstlisting}[float,caption=A floating example \autocite{nussbaum}]
Hello world
\end{lstlisting}
\printbibliography
\end{document}