我曾经notoccite
避免在标题中引用先编号,而是遵循文档的其余部分。不幸的是,这不起作用。有谁知道我可以做些什么来解决这个问题,或者有谁知道可以使用哪个包来代替notoccite
(我试过了\protect\cite
)?我不知道我的一些代码是否会干扰\usepackage{notoccite}
。我的代码是:
\documentclass[a4paper,12pt, twoside]{report}
\renewcommand{\baselinestretch}{1.15}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in, headsep=50pt]{geometry}
\usepackage{fancyhdr,lipsum}
\usepackage{cite}
\usepackage{hyperref}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{notoccite}
\makeatletter
\def\@makechapterhead#1{%
\vspace*{1\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
%\huge\bfseries \@chapapp\space \thechapter
\Huge\bfseries \thechapter\space%
%\par\nobreak
%\vskip 20\p@
\fi
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 20\p@
}}
\def\@makeschapterhead#1{%
\vspace*{1\p@}%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 20\p@
}}
\makeatother
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{array}
\usepackage{graphicx}
\usepackage{todonotes}
\usepackage[textfont={rm, it}, labelfont={bf}]{caption}
\usepackage{float}
\usepackage[nottoc,numbib]{tocbibind}
\usepackage{url}
\numberwithin{equation}{section}
\newcommand{\degree}{\ensuremath{^\circ}}
\newcommand{\celcius}{\degree{}C}
\usepackage{lastpage}
\usepackage{nomencl}
\usepackage{multirow}
\usepackage{subcaption}
\usepackage{titlesec}
\usepackage{subfiles}
\renewcommand{\contentsname}{Table of Contents}
\newcommand{\aar}{\textit{år}}
\usepackage[version=3]{mhchem}
\numberwithin{figure}{section}
\renewcommand\bibname{References}
\usepackage{enumitem}
\usepackage{etoolbox}
\pagestyle{fancy}
\fancyhead{} % clear all header fields
\fancyhead[R]{
\includegraphics[width=0.25\textwidth]{logoside.png}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\chaptername\ \thechapter. {##1}}}{}}
}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\arabic{section}.\ #1}}
\fancyhead[L]{\fontsize{20}{40} \nouppercase{\leftmark}
\renewcommand{\plainheadrulewidth}{0.4pt}}
\begin{filecontents}{\jobname.bib}
@misc{foo,
author = {Foo},
title = {Title of Foo},
}
@misc{bar,
author = {Bar},
title = {Title of Bar},
}
@misc{ba,
author = {Ba},
title = {Title of Ba},
}
\end{filecontents}
\begin{document}
this is the text \cite{foo} and it should be cited first \cite{bar}
\begin{figure} [h]
\centering
\includegraphics[scale=0.65]{A figure}
\caption[the caption in the list of figure]{the caption in the text\cite{ba}}
\label{X}
\end{figure}
\bibliographystyle{unsrt}
\bibliography{\jobname}
\end{document}
答案1
事实证明,这notoccite
与其他包的工作不兼容hyperref
,从而导致其他包的工作被取消。
您可以在 之上重做hyperref
。
请修改相关的设置fancyhdr
:\chaptermark
在标题中重新定义肯定是错误的。
我以更合理的方式重新排列了您的前言。请注意,hyperref
必须是最后一个(只有少数软件包应该在它之后加载,而不是您使用的软件包)。
\begin{filecontents}{\jobname.bib}
@misc{foo,
author = {Foo},
title = {Title of Foo},
}
@misc{bar,
author = {Bar},
title = {Title of Bar},
}
@misc{ba,
author = {Ba},
title = {Title of Ba},
}
\end{filecontents}
\documentclass[a4paper,12pt, twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in, headsep=50pt]{geometry}
\usepackage{fancyhdr}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{cite}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{array}
\usepackage{graphicx}
\usepackage[textfont={rm, it}, labelfont={bf}]{caption}
\usepackage{float}
\usepackage[nottoc,numbib]{tocbibind}
\usepackage{url}
\usepackage{lastpage}
\usepackage{enumitem}
\usepackage{etoolbox}
\usepackage{nomencl}
\usepackage{multirow}
\usepackage{subcaption}
\usepackage{titlesec}
\usepackage{subfiles}
\usepackage[version=3]{mhchem}
\usepackage{hyperref}
\makeatletter
% do the same as notoccite on top of the redefinitions by hyperref
\AtBeginDocument{%
\patchcmd{\@starttoc}{\begingroup}{\begingroup\@fileswfalse}{}{}%
\patchcmd{\@starttoc}{\if@filesw}{\endgroup\begingroup\if@filesw}{}{}%
}
\makeatother
\makeatletter
\def\@makechapterhead#1{%
\vspace*{1\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
%\huge\bfseries \@chapapp\space \thechapter
\Huge\bfseries \thechapter\space%
%\par\nobreak
%\vskip 20\p@
\fi
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 20\p@
}}
\def\@makeschapterhead#1{%
\vspace*{1\p@}%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 20\p@
}}
\makeatother
\numberwithin{equation}{section}
\newcommand{\degree}{\ensuremath{^\circ}}
\newcommand{\celcius}{\degree{}C}
%\renewcommand{\contentsname}{Table of Contents} % already default
\newcommand{\aar}{\textit{år}}
\numberwithin{figure}{section}
\renewcommand\bibname{References}
\pagestyle{fancy}
\fancyhead{} % clear all header fields
% the following is very wrong
%\fancyhead[R]{
%\includegraphics[width=0.25\textwidth]{logoside.png}
%\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\chaptername\ \thechapter. {##1}}}{}}
%}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\arabic{section}.\ #1}}
% the following is very wrong
%\fancyhead[L]{\fontsize{20}{40} \nouppercase{\leftmark}
% \renewcommand{\plainheadrulewidth}{0.4pt}}
\linespread{1.15}
\begin{document}
\listoffigures
this is the text \cite{foo} and it should be cited first \cite{bar}
\begin{figure} [h]
\centering
\includegraphics[width=4cm]{example-image}
\caption{the caption in the text \cite{ba}}
\label{X}
\end{figure}
\bibliographystyle{unsrt}
\bibliography{\jobname}
\end{document}