如何自定义创建文本引用中的作者年份但在末尾编号参考列表?

如何自定义创建文本引用中的作者年份但在末尾编号参考列表?

我在谷歌上搜索有关使用软件包管理 LaTeX 中的引用的问题natbib,幸运的是,我也遇到了同样的问题巴特沃米耶·斯泰皮恩艾伦·芒恩对这个问题给出了一个很好的答案,可以找到这里

我实际上需要用方括号括住参考编号而不是句点,为了实现这一点,我刚刚做了

\patchcmd{\@lbibitem}{\item[}{\item[\hfil\stepcounter{bibcount}{[\thebibcount]}}{}{}

现在,除了一个问题之外,一切都很好。参考编号现在看起来

在此处输入图片描述

如上所示,数字 [9] 与数字 [10] 不在同一水平线上,也就是说,我希望这些参考编号像下面这样右对齐。同时,我还想减少参考编号和文本之间的距离,您可以在下面的示例中看到这一点。

在此处输入图片描述

如果有人能回答这个问题就太好了。

我非常感谢您付出的时间和精力。

以下是一个简短的、可编译的代码,但我的.bst文件也是定制的。

\documentclass[12pt, openany]{book}
\usepackage{etoolbox}
\usepackage[round,sort,comma]{natbib}
\newcounter{bibcount}
\usepackage{hyperref,url}
\usepackage [english]{babel}

\makeatletter
\patchcmd{\@lbibitem}{\item[}{\item[\hfill\stepcounter{bibcount}{[\thebibcount]}}{}{}
\setlength{\bibhang}{2.00\parindent}
\renewcommand\NAT@bibsetup%
[1]{\setlength{\leftmargin}{\bibhang}\setlength{\itemindent}{-\parindent}%
\setlength{\itemsep}{\bibsep}\setlength{\parsep}{\z@}}
\makeatother

\bibliographystyle{refStyle}

\begin{document}
\noindent
These are the materials in Algebra:
\\~\\
\cite{MR1034353}.
\\~\\
\cite{MR600654}.
\\~\\
These are the materials in Complex Analysis:
\\~\\
\cite{MR510197}.
\\~\\
\cite{MR2730573}.
\\~\\
\cite{MR1344449}.
\\~\\
These are the materials in Real Analysis and Probability:
\\~\\
\cite{MR2893652}.
\\~\\
\cite{MR1681462}.
\\~\\
\cite{MR1121940}.
\\~\\
These are the materials in PDE:
\\~\\
\cite{MR2597943}.
\\~\\
\cite{MR1121940}.
\\~\\
And, finally these are the materials in Topology:
\\~\\
\cite{MR0464128}.
\\~\\
\cite{MR0163320}.

\bibliography{bibRef}
\thispagestyle{myheadings}
\pagestyle{headings} \thispagestyle{headings}

\end{document} 

bibRef.bib文件内容如下:

@book {MR510197,
AUTHOR = {Ahlfors, Lars V.},
TITLE = {Complex analysis},
EDITION = {Third},
NOTE = {An introduction to the theory of analytic functions of one
complex variable,
International Series in Pure and Applied Mathematics},
PUBLISHER = {McGraw-Hill Book Co., New York},
YEAR = {1978},
PAGES = {xi+331},
ISBN = {0-07-000657-1},
MRCLASS = {30-01},
MRNUMBER = {510197},
}
@book {MR2730573,
AUTHOR = {Ahlfors, Lars V.},
TITLE = {Conformal invariants},
NOTE = {Topics in geometric function theory,
Reprint of the 1973 original,
With a foreword by Peter Duren, F. W. Gehring and Brad Osgood},
PUBLISHER = {AMS Chelsea Publishing, Providence, RI},
YEAR = {2010},
PAGES = {xii+162},
ISBN = {978-0-8218-5270-5},
MRCLASS = {30-02},
MRNUMBER = {2730573},
URL = {https://doi.org/10.1090/chel/371},
}
@book {MR2893652,
AUTHOR = {Billingsley, Patrick},
TITLE = {Probability and measure},
SERIES = {Wiley Series in Probability and Statistics},
NOTE = {Anniversary edition [of MR1324786],
With a foreword by Steve Lalley and a brief biography of
Billingsley by Steve Koppes},
PUBLISHER = {John Wiley \& Sons, Inc., Hoboken, NJ},
YEAR = {2012},
PAGES = {xviii+624},
ISBN = {978-1-118-12237-2},
MRCLASS = {60-01 (28-01)},
MRNUMBER = {2893652},
}
@book {MR1344449,
AUTHOR = {Conway, John B.},
TITLE = {Functions of one complex variable. {II}},
SERIES = {Graduate Texts in Mathematics},
VOLUME = {159},
PUBLISHER = {Springer-Verlag, New York},
YEAR = {1995},
PAGES = {xvi+394},
ISBN = {0-387-94460-5},
MRCLASS = {30-01},
MRNUMBER = {1344449},
MRREVIEWER = {P. Lappan},
URL = {https://doi.org/10.1007/978-1-4612-0817-4},
}
@book {MR2597943,
AUTHOR = {Evans, Lawrence C.},
TITLE = {Partial differential equations},
SERIES = {Graduate Studies in Mathematics},
VOLUME = {19},
EDITION = {Second},
PUBLISHER = {American Mathematical Society, Providence, RI},
YEAR = {2010},
PAGES = {xxii+749},
ISBN = {978-0-8218-4974-3},
MRCLASS = {35-01},
MRNUMBER = {2597943},
MRREVIEWER = {Diego M. Maldonado},
URL = {https://doi.org/10.1090/gsm/019},
}
@book {MR1681462,
AUTHOR = {Folland, Gerald B.},
TITLE = {Real analysis},
SERIES = {Pure and Applied Mathematics (New York)},
EDITION = {Second},
NOTE = {Modern techniques and their applications,
A Wiley-Interscience Publication},
PUBLISHER = {John Wiley \& Sons, Inc., New York},
YEAR = {1999},
PAGES = {xvi+386},
ISBN = {0-471-31716-0},
MRCLASS = {00A05 (26-01 28-01 46-01)},
MRNUMBER = {1681462},
}
@article {MR1034353,
AUTHOR = {Hungerford, Thomas W.},
TITLE = {A counterexample in {G}alois theory},
JOURNAL = {Amer. Math. Monthly},
FJOURNAL = {American Mathematical Monthly},
VOLUME = {97},
YEAR = {1990},
NUMBER = {1},
PAGES = {54--57},
ISSN = {0002-9890},
MRCLASS = {12F10},
MRNUMBER = {1034353},
URL = {https://doi.org/10.2307/2324007},
}
@book {MR600654,
AUTHOR = {Hungerford, Thomas W.},
 TITLE = {Algebra},
SERIES = {Graduate Texts in Mathematics},
VOLUME = {73},
  NOTE = {Reprint of the 1974 original},
 PUBLISHER = {Springer-Verlag, New York-Berlin},
  YEAR = {1980},
 PAGES = {xxiii+502},
  ISBN = {0-387-90518-9},
   MRCLASS = {00A05 (15-01 16-01)},
  MRNUMBER = {600654},
}
@book {MR1121940,
AUTHOR = {Karatzas, Ioannis and Shreve, Steven E.},
TITLE = {Brownian motion and stochastic calculus},
SERIES = {Graduate Texts in Mathematics},
VOLUME = {113},
EDITION = {Second},
PUBLISHER = {Springer-Verlag, New York},
YEAR = {1991},
PAGES = {xxiv+470},
ISBN = {0-387-97655-8},
MRCLASS = {60J65 (35K99 35R60 60G44 60H10 60J60)},
MRNUMBER = {1121940},
URL = {https://doi.org/10.1007/978-1-4612-0949-2},
}
@book {MR0464128,
AUTHOR = {Munkres, James R.},
TITLE = {Topology: a first course},
PUBLISHER = {Prentice-Hall, Inc., Englewood Cliffs, N.J.},
YEAR = {1975},
PAGES = {xvi+413},
MRCLASS = {54-01},
MRNUMBER = {0464128},
}
@book {MR0163320,
AUTHOR = {Munkres, James R.},
TITLE = {Elementary differential topology},
SERIES = {Lectures given at Massachusetts Institute of Technology, Fall},
VOLUME = {1961},
PUBLISHER = {Princeton University Press, Princeton, N.J.},
YEAR = {1963},
PAGES = {xi+107pp},
MRCLASS = {57.00 (53.45)},
MRNUMBER = {0163320},
MRREVIEWER = {M. W. Hirsch},
}

并且,输出文件如下所示:

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

可以看出,右边的大括号符号,即]数字 9 和 10 不在同一垂直线上,即它们没有右对齐,但我希望它们右对齐。

答案1

这里的问题是,我们必须删除\@lbibitem包含的定义\hfil。因此,请在您的序言中添加以下补丁:

\patchcmd{\@lbibitem}%
  {\hfil \NAT@anchor {#2}{\NAT@num }]}%
  {]}% <=================================================================
  {}%
  {}

使用以下 MWE

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book {MR510197,
AUTHOR = {Ahlfors, Lars V.},
TITLE = {Complex analysis},
EDITION = {Third},
NOTE = {An introduction to the theory of analytic functions of one
complex variable,
International Series in Pure and Applied Mathematics},
PUBLISHER = {McGraw-Hill Book Co., New York},
YEAR = {1978},
PAGES = {xi+331},
ISBN = {0-07-000657-1},
MRCLASS = {30-01},
MRNUMBER = {510197},
}
@book {MR2730573,
AUTHOR = {Ahlfors, Lars V.},
TITLE = {Conformal invariants},
NOTE = {Topics in geometric function theory,
Reprint of the 1973 original,
With a foreword by Peter Duren, F. W. Gehring and Brad Osgood},
PUBLISHER = {AMS Chelsea Publishing, Providence, RI},
YEAR = {2010},
PAGES = {xii+162},
ISBN = {978-0-8218-5270-5},
MRCLASS = {30-02},
MRNUMBER = {2730573},
URL = {https://doi.org/10.1090/chel/371},
}
@book {MR2893652,
AUTHOR = {Billingsley, Patrick},
TITLE = {Probability and measure},
SERIES = {Wiley Series in Probability and Statistics},
NOTE = {Anniversary edition [of MR1324786],
With a foreword by Steve Lalley and a brief biography of
Billingsley by Steve Koppes},
PUBLISHER = {John Wiley \& Sons, Inc., Hoboken, NJ},
YEAR = {2012},
PAGES = {xviii+624},
ISBN = {978-1-118-12237-2},
MRCLASS = {60-01 (28-01)},
MRNUMBER = {2893652},
}
@book {MR1344449,
AUTHOR = {Conway, John B.},
TITLE = {Functions of one complex variable. {II}},
SERIES = {Graduate Texts in Mathematics},
VOLUME = {159},
PUBLISHER = {Springer-Verlag, New York},
YEAR = {1995},
PAGES = {xvi+394},
ISBN = {0-387-94460-5},
MRCLASS = {30-01},
MRNUMBER = {1344449},
MRREVIEWER = {P. Lappan},
URL = {https://doi.org/10.1007/978-1-4612-0817-4},
}
@book {MR2597943,
AUTHOR = {Evans, Lawrence C.},
TITLE = {Partial differential equations},
SERIES = {Graduate Studies in Mathematics},
VOLUME = {19},
EDITION = {Second},
PUBLISHER = {American Mathematical Society, Providence, RI},
YEAR = {2010},
PAGES = {xxii+749},
ISBN = {978-0-8218-4974-3},
MRCLASS = {35-01},
MRNUMBER = {2597943},
MRREVIEWER = {Diego M. Maldonado},
URL = {https://doi.org/10.1090/gsm/019},
}
@book {MR1681462,
AUTHOR = {Folland, Gerald B.},
TITLE = {Real analysis},
SERIES = {Pure and Applied Mathematics (New York)},
EDITION = {Second},
NOTE = {Modern techniques and their applications,
A Wiley-Interscience Publication},
PUBLISHER = {John Wiley \& Sons, Inc., New York},
YEAR = {1999},
PAGES = {xvi+386},
ISBN = {0-471-31716-0},
MRCLASS = {00A05 (26-01 28-01 46-01)},
MRNUMBER = {1681462},
}
@article {MR1034353,
AUTHOR = {Hungerford, Thomas W.},
TITLE = {A counterexample in {G}alois theory},
JOURNAL = {Amer. Math. Monthly},
FJOURNAL = {American Mathematical Monthly},
VOLUME = {97},
YEAR = {1990},
NUMBER = {1},
PAGES = {54--57},
ISSN = {0002-9890},
MRCLASS = {12F10},
MRNUMBER = {1034353},
URL = {https://doi.org/10.2307/2324007},
}
@book {MR600654,
AUTHOR = {Hungerford, Thomas W.},
 TITLE = {Algebra},
SERIES = {Graduate Texts in Mathematics},
VOLUME = {73},
  NOTE = {Reprint of the 1974 original},
 PUBLISHER = {Springer-Verlag, New York-Berlin},
  YEAR = {1980},
 PAGES = {xxiii+502},
  ISBN = {0-387-90518-9},
   MRCLASS = {00A05 (15-01 16-01)},
  MRNUMBER = {600654},
}
@book {MR1121940,
AUTHOR = {Karatzas, Ioannis and Shreve, Steven E.},
TITLE = {Brownian motion and stochastic calculus},
SERIES = {Graduate Texts in Mathematics},
VOLUME = {113},
EDITION = {Second},
PUBLISHER = {Springer-Verlag, New York},
YEAR = {1991},
PAGES = {xxiv+470},
ISBN = {0-387-97655-8},
MRCLASS = {60J65 (35K99 35R60 60G44 60H10 60J60)},
MRNUMBER = {1121940},
URL = {https://doi.org/10.1007/978-1-4612-0949-2},
}
@book {MR0464128,
AUTHOR = {Munkres, James R.},
TITLE = {Topology: a first course},
PUBLISHER = {Prentice-Hall, Inc., Englewood Cliffs, N.J.},
YEAR = {1975},
PAGES = {xvi+413},
MRCLASS = {54-01},
MRNUMBER = {0464128},
}
@book {MR0163320,
AUTHOR = {Munkres, James R.},
TITLE = {Elementary differential topology},
SERIES = {Lectures given at Massachusetts Institute of Technology, Fall},
VOLUME = {1961},
PUBLISHER = {Princeton University Press, Princeton, N.J.},
YEAR = {1963},
PAGES = {xi+107pp},
MRCLASS = {57.00 (53.45)},
MRNUMBER = {0163320},
MRREVIEWER = {M. W. Hirsch},
}
\end{filecontents*}


\documentclass[12pt, openany]{book}

\usepackage[english]{babel}
\usepackage{etoolbox}
\usepackage[round,sort,comma]{natbib}
\newcounter{bibcount}
\usepackage{url,hyperref}

\makeatletter
\patchcmd{\@lbibitem}%
  {\item[}%
  {\item[\hfill\stepcounter{bibcount}{[\thebibcount]}}% <================
  {}%
  {}
\patchcmd{\@lbibitem}%
  {\hfil \NAT@anchor {#2}{\NAT@num }]}%
  {]}% <=================================================================
  {}%
  {}
\setlength{\bibhang}{2.00\parindent}
\renewcommand\NAT@bibsetup[1]{%
  \setlength{\leftmargin}{\bibhang}%
  \setlength{\itemindent}{-\parindent}%
  \setlength{\itemsep}{\bibsep}%
  \setlength{\parsep}{\z@}%
}
\makeatother

\bibliographystyle{plainnat} % refStyle

\begin{document}
\noindent
These are the materials in Algebra:
\\~\\
\cite{MR1034353}.
\\~\\
\cite{MR600654}.
\\~\\
These are the materials in Complex Analysis:
\\~\\
\cite{MR510197}.
\\~\\
\cite{MR2730573}.
\\~\\
\cite{MR1344449}.
\\~\\
These are the materials in Real Analysis and Probability:
\\~\\
\cite{MR2893652}.
\\~\\
\cite{MR1681462}.
\\~\\
\cite{MR1121940}.
\\~\\
These are the materials in PDE:
\\~\\
\cite{MR2597943}.
\\~\\
\cite{MR1121940}.
\\~\\
And, finally these are the materials in Topology:
\\~\\
\cite{MR0464128}.
\\~\\
\cite{MR0163320}.

\bibliography{\jobname}
\thispagestyle{myheadings}
\pagestyle{headings} \thispagestyle{headings}

\end{document}

你得到了想要的结果:

希望的结果

相关内容