在main
中使用bst
自动模式的参考文献引用方式如下:
% 两种文献导入方式。如果开启bst自动模式,在format.cls中bibcontrol部分无效
\ifx \refstyle \auto
% bst自动
\addcontentsline{toc}{chapter}{参考文献}
\bibliographystyle{references/gbt7714-2005}
\bibliography{references/paper.bib}
format文件中参考文献控制如下:
%============================= Bibitem control ================================%
\def \auto {auto}
\ifx \refstyle \auto
\else
\usepackage{etoolbox} % Required, for availablility changing the latex env.
% \usepackage{hyperref} % Show a green-border box on each \cite label?
% Pre-define list variables
\makeatletter
\newcommand*{\lodbib@citeorder}{} % Catch normal entries
\newcommand*{\lodbib@notcited}{} % Catch entries that were not cited
% Macro in aux file
\def\citation{%
\forcsvlist{\citation@i}}
\def\citation@i#1{%
\ifinlist{#1}{\lodbib@citeorder}
{}
{\listxadd{\lodbib@citeorder}{#1}}}
\let\ltxorig@lbibitem\@lbibitem
\let\ltxorig@bibitem\@bibitem
% Save bibitems into lists
\def\@lbibitem[#1]#2#3{%
\csdef{lodbib@savedlabel@#2}{#1}%
\@bibitem{#2}{#3}}
\def\@bibitem#1#2{%
\xifinlist{#1}{\lodbib@citeorder}
{}
{\listadd{\lodbib@notcited}{#1}}%
\csdef{lodbib@savedentry@#1}{#2}}
% Re-define \thebibiography command.
\renewenvironment{thebibliography}[1]
{\settowidth\labelwidth{\@biblabel{#1}}}
{\def\@noitemerr
{\@latex@warning{Empty `thebibliography' environment}}%
\chapter*{参考文献} % chapter title
\@mkboth{参考文献}{参考文献} % left page header / right page header
\list{\@biblabel{\@arabic\c@enumiv}}%
{\leftmargin\labelwidth\parsep=0pt
\advance\leftmargin\labelsep
\@openbib@code
\usecounter{enumiv}%
\let\p@enumiv\@empty
\renewcommand\theenumiv{\@arabic\c@enumiv}}%
\sloppy
\clubpenalty4000
\@clubpenalty \clubpenalty
\widowpenalty4000%
\sfcode`\.\@m
\lodbib@biblistloop
\endlist}
% Output the bib list.
\def\lodbib@biblistloop{%
\forlistloop{\lodbib@bibitem}{\lodbib@citeorder}%
\ifdefvoid{\lodbib@notcited}
{}
{\forlistloop{
\lodbib@bibitem
}{
%\lodbib@notcited % Whether listing uncited bib at the end of the references?
}}}
% Modify the \cite num. in the book.
\def\lodbib@bibitem#1{%
\ifcsundef{lodbib@savedlabel@#1}
{\ltxorig@bibitem{#1}}
{\ltxorig@lbibitem[\csuse{lodbib@savedlabel@#1}]{#1}}%
\csuse{lodbib@savedentry@#1}}
\fi
例如我有三条参考文献在paper.bib中:
@article{1966Calculation,
...
}
@article{1972Influence,
...
}
@article{2000The,
...
}
我在章节中使用:
\cite{1966Calculation,1972Influence,2000The}
这样的引用方式编译只能实现[1,2,3]的效果,如果我想实现[1-3]这样连续引用的效果要怎么做?
main
中使用bst
自动模式的参考文献引用方式
这句话实际上只是模板作者的口水话,指的就是令\refstyle
为\auto
,此时默认的bibitem
设置实际上仅有:
\bibliographystyle{references/gbt7714-2005}
\bibliography{references/paper.bib}
\addcontentsline{toc}{chapter}{参考文献}
因此,原问题如果只想要使用\auto
方式进行设置的话,那么一个最小工作示例如下(这一步的简化本就应该由提问者给出,因此需要有一定的LaTeX
使用经验才建议使用模板,切忌在项目期少于三个月的情况下作为新手从零开始套用模板):
\documentclass[12pt,a4paper,openany,twoside]{ctexbook}
\usepackage{geometry}
\begin{filecontents*}[overwrite]{paper.bib}
@article{1966Calculation,
author = {AAAA},
year = {1966},
title = {Calculation of the Influence of the Earth's Magnetic Field on the Magnetic Field of the Moon},
}
@article{1972Influence,
author = {BBBB},
year = {1972},
title = {The Influence of Earth's Magnetic Field in Exploring the world},
}
@article{2000The,
author = {CCCC},
year = {2000},
title = {The The The The paper named The The The},
}
\end{filecontents*}
\begin{document}
\tableofcontents
\chapter{绪\quad 论}
\section{标题}
\subsection{副标题}
这是引用\cite{1966Calculation,1972Influence,2000The}的结果——我想我能吞下玻璃而不伤身体。
\bibliographystyle{gbt7714-2005}
\bibliography{paper.bib}
\addcontentsline{toc}{chapter}{参考文献}
\end{document}
其中\bibliographystyle{gbt7714-2005}
使用的.bst
文件来自:https://github.com/Haixing-Hu/GBT7714-2005-BibTeX-Style/commit/fd23fb5868fb7766a47d290ee513ca5cca547695
(当有官方文件时,务必提供其来源方便追溯)
编译效果如下:
请提供一个完整的可编译的文档例子,例如format.cls
具体是什么,只提供一个切片很难回答这一问题。
一个基于natbib
的例子如下,需要使用pdf-bibtex-pdf-pdf
或者latexmk -pdf
命令编译:
\documentclass{article}
\begin{filecontents*}[overwrite]{reference.bib}
@article{1966Calculation,
author = {AAAA},
year = {1966},
title = {Calculation of the Influence of the Earth's Magnetic Field on the Magnetic Field of the Moon},
}
@article{1972Influence,
author = {BBBB},
year = {1972},
title = {The Influence of Earth's Magnetic Field in Exploring the world},
}
@article{2000The,
author = {CCCC},
year = {2000},
title = {The The The The paper named The The The},
}
\end{filecontents*}
\usepackage[numbers,sort&compress]{natbib}
\bibliographystyle{unsrtnat}
\begin{document}
I want to cite these papaer at here\cite{1966Calculation,1972Influence,2000The} but not there!
\bibliography{reference}
\end{document}
根据我自己给自己做的MWE(真是有够好笑了呢)
\documentclass[12pt,a4paper,openany,twoside]{ctexbook}
\usepackage{geometry}
\begin{filecontents*}[overwrite]{paper.bib}
@article{1966Calculation,
author = {AAAA},
year = {1966},
title = {Calculation of the Influence of the Earth's Magnetic Field on the Magnetic Field of the Moon},
}
@article{1972Influence,
author = {BBBB},
year = {1972},
title = {The Influence of Earth's Magnetic Field in Exploring the world},
}
@article{2000The,
author = {CCCC},
year = {2000},
title = {The The The The paper named The The The},
}
\end{filecontents*}
\usepackage[numbers,sort&compress]{natbib}%加上这一行即可...
\paperheight=15cm % 只是为了截图在同一张图内
\begin{document}
\tableofcontents
\chapter{绪\quad 论}
\section{标题}
\subsection{副标题}
这是引用\cite{1966Calculation,1972Influence,2000The}的结果——我想我能吞下玻璃而不伤身体。
\bibliographystyle{gbt7714-2005}
\bibliography{paper.bib}
\addcontentsline{toc}{chapter}{参考文献}
\end{document}
BTW,你是否看过基础教程lshort-zh-cn
的6.1节....
感谢回答,您这种方式我不知道该如何使用。format中对参考文献的控制是这样的,如果有新的方案麻烦您回复下谢谢
%============================= Bibitem control ================================%
def auto {auto}
ifx refstyle auto
else
usepackage{etoolbox} % Required, for availablility changing the latex env.
% usepackage{hyperref} % Show a green-border box on each cite label?
% Pre-define list variables
makeatletter
newcommand*{lodbib@citeorder}{} % Catch normal entries
newcommand*{lodbib@notcited}{} % Catch entries that were not cited
% Macro in aux file
defcitation{%
forcsvlist{citation@i}}
defcitation@i#1{%
ifinlist{#1}{lodbib@citeorder}
letltxorig@lbibitem@lbibitem
letltxorig@bibitem@bibitem
% Save bibitems into lists
def@lbibitem[#1]#2#3{%
csdef{lodbib@savedlabel@#2}{#1}%
@bibitem{#2}{#3}}
def@bibitem#1#2{%
xifinlist{#1}{lodbib@citeorder}
csdef{lodbib@savedentry@#1}{#2}}
% Re-define thebibiography command.
renewenvironment{thebibliography}[1]
% Output the bib list.
deflodbib@biblistloop{%
forlistloop{lodbib@bibitem}{lodbib@citeorder}%
ifdefvoid{lodbib@notcited}
% Modify the cite num. in the book.
deflodbib@bibitem#1{%
ifcsundef{lodbib@savedlabel@#1}
csuse{lodbib@savedentry@#1}}
fi
@u140818
请用 markdown 语法!!! 下面这样的代码块渲染没有人愿意手动帮你加上
\
请用规范的围栏代码块样式修改原来的问题,并且保证你的代码从
\documentclass
开始到\end{document}
结束并且可编译...请使用补充问题功能,在原问题之后补充你的mwe...
我使用的是OVERLEAF编辑模板,没有围栏代码
@u140818 你在这个论坛编辑的时候需要手动加上三个反引号,查看markdown语法。

你评论中的代码最大的问题是,不完整。请你提供一个最短的文档代码,既能体现你模板的设置,又能让人一复制点击run就能编译出你不想要的
[1,2,3]
的结果,不然没有任何办法提供具有针对性帮助。@u70550 多谢指点,我已经修改了提问,将代码包围起来
@u140818 markdown做得很好,但是请你仔细阅读MWE的定义,你提供了4段代码切片,我知道你是在使用一个模板提供的
format.cls
,同时你还在使用一个.bib
文件,但是作为根本不知道你模板全貌的用户来说,我如何知道你这四段代码切片要如何拼起来?这种拼接不应该由潜在的回答者来尝试,他人无法也不应该去猜测如何组合你的format.cls
。请你,想办法把format.cls
中关于你所谓的自动bst
的设置抽离出来并放到一个测试的最简文档内中(如果实在无法抽离,你可以提供压缩包,并详细说明如何编译可以复现你的问题),要做到既用上了format.cls
配置,又让代码尽可能简单,同时可以体现你的问题。请务必提供完整(从
\documentclass
开始到\end{document}
结束),可编译,能体现你问题的代码。当然,如果该模板有说明文档,你应该优先仔细阅读,很可能在文档中就告诉了你如何实现[1-3]
这样的效果。P.S. 我觉得你的第一段代码和第二段代码有重复之嫌。