nju-lug / NJUThesis

南京大学学位论文模板
https://ctan.org/pkg/njuthesis
LaTeX Project Public License v1.3c
459 stars 62 forks source link

关于引用参考文献的问题 #73

Closed ginkgotyranny closed 2 years ago

ginkgotyranny commented 2 years ago

1.使用\parencite{eckstein1989splitting,eckstein1992douglas,glowinski2008numerical,bertsekas2014parallel}后生成的引用格式为[3-6],请问该怎么引用才能编译出[3,4,5,6]这样的格式 2.使用手册中有写引用可以使用短横线,请问意思是使用短横线连接第一篇和最后一篇引用文献的标题,例如1中写成: \parencite{eckstein1989splitting-bertsekas2014parallel} 就可以输出[3-6]的格式吗? 尝试这样使用会报错 image

hushidong commented 2 years ago

导言区加

\makeatletter

\newbibmacro*{cite}{%
  \printtext[bibhyperref]{%
    \printfield{labelprefix}%
    \printfield{labelnumber}%
    \ifbool{bbx:subentry}
      {\printfield{entrysetcount}}
      {}}}

\DeclareCiteCommand{\cite}[\mkbibsuperscript]%
  {\mkbibleftborder\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\mkbibrightborder\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}%
  {\mkbibleftborder\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\mkbibrightborder\mkbibsuperscriptusp{\usebibmacro{postnote}}}

\makeatother
hushidong commented 2 years ago

比如:


\documentclass[twoside]{article}
\usepackage{ctex}
\usepackage[backend=biber,style=gb7714-2015]{biblatex}

\makeatletter

\newbibmacro*{cite}{%
  \printtext[bibhyperref]{%
    \printfield{labelprefix}%
    \printfield{labelnumber}%
    \ifbool{bbx:subentry}
      {\printfield{entrysetcount}}
      {}}}

\DeclareCiteCommand{\cite}[\mkbibsuperscript]%
  {\mkbibleftborder\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\mkbibrightborder\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}%
  {\mkbibleftborder\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\mkbibrightborder\usebibmacro{postnote}}

\makeatother

\begin{filecontents}{\jobname.bib}

@Article{Walls2013-399-418,
  Title                    = {drought, deluge and declines: the impact of precipition extremes on amphibians in a changing climate},
  Author                   = {Walls, S C and barichivich, W. J. and BROWN, m. e.},
  Journal                  = {Biology},
  Number                   = {1},
  Pages                    = {399-418},
  Volume                   = {2},
  Url                      = {http://www.mdpi.com},
  Urldate                  = {2013-11-04},
  Year                     = {2013},
  doi                      = {10.3390/biology2010399}
}

@Article{Zhang2007-500-503,
  Title                    = {The design and experimental investigations of supersonic length shorted nozzle},
  Author                   = {Zhang, Min Li and Yi, Shi He and Zhao, Yu Xin},
  Journal                  = {ACTA AERODYNAMICA SINICA},
  Number                   = {4},
  Pages                    = {500-503},
  Volume                   = {25},
  Year                     = {2007},
  nameformat={quanpin},
}

@Book{Yi2013--,
  Title                    = {Supersonic and hypersonic nozzle design},
  Address                  = {Beijing},
  Author                   = {Yi, Shi He and Zhao, Yu Xin and He, Lin and Zhang, Min Li},
  Publisher                = {National Defense Industry Press},
  Year                     = {2013},
  nameformat={quanpin},
}

@Archive{中国第一历史档案馆2001--,
  author    = {中国第一历史档案馆 and 辽宁省档案馆},
  title     = {中国明朝档案总汇},
  year      = {2001},
  address   = {桂林},
  publisher = {广西师范大学出版社},
}

@Www{萧钰2001--,
  Title                    = {出版业信息化迈入快车道},
  Author                   = {萧钰},
  Url                      = {http://www.creader.com/news/20011219/200112190019.html},
  Urldate                  = {2002-04-15},
  Date                     = {2001-12-19}
}

\end{filecontents}

\addbibresource{\jobname.bib}
%\addbibresource{example.bib}

\begin{document}

文献\cite{Walls2013-399-418,Zhang2007-500-503,Yi2013--,中国第一历史档案馆2001--,萧钰2001--}

文献\parencite{Walls2013-399-418,Zhang2007-500-503,Yi2013--,中国第一历史档案馆2001--,萧钰2001--}

\printbibliography

\end{document} 

结果为: 图片

ginkgotyranny commented 2 years ago

谢谢回复,使用之后成功了,但是发现此段内容不能放在导言区,否则会报错: image 将其放在\begin{document}中才能正确编译 image 编译结果为: image 想请问一下,更改之后,如果想要编译出之前的效果即[3-6]的样式,该怎么做呢?尝试使用-,如: \parencite{eckstein1989splitting-bertsekas2014parallel} 无法编译成功

zepinglee commented 2 years ago

参考文献的引用一般是统一的要么压缩(compress)要么不压缩,你的需要显得非常奇怪。

ginkgotyranny commented 2 years ago

是这样,比如我同时引用两篇参考文献,我希望格式是[1,10],当我引用更多文献时,我希望的格式是[4-9],如果写成[4,5,6,7,8,9]会显得冗长

atxy-blip commented 2 years ago

比如我同时引用两篇参考文献,我希望格式是[1,10],当我引用更多文献时,我希望的格式是[4-9]

这与国标不矛盾,请看下图 10.1.2。楼上 @hushidong 编写的宏包(即本模板采用的 biblatex-gb7714-2015)对此做了适配。

image

atxy-blip commented 2 years ago

@hushidong 导言区加……

njuthesis 把载入 biblatex 宏包挂在了导言区后,所以不能简单放在导言区。

ginkgotyranny commented 2 years ago

请问下采用了楼上的修改后,怎么才能编译出[4-9]这种形式的引用呢?

atxy-blip commented 2 years ago

@ginkgotyranny 请问该怎么引用才能编译出[3,4,5,6]这样的格式

原本就是连续条目使用短横线连接起止编码的格式。楼上回复的是你提出的问题。

ginkgotyranny commented 2 years ago

原本的话使用\parencite{eckstein1989splitting,eckstein1992douglas,glowinski2008numerical,bertsekas2014parallel}是会使用短横线连接起止编码的格式,添加了楼上的代码后,是变成了逗号隔开的格式,我想请问一下,怎么可以在文章中同时使用这两种格式呢?因为使用了楼上的代码后,原来的格式就没有了 我遇到的实际情况是,使用原来的代码,我的文章中想使用第一和第十,这两篇文献时会变成[1-10],所以我希望改成[1,10]这样的形式,添加了楼上提供的代码后,问题得到了解决,但是在文章的其他部分,我引用了第四到第九这六篇文献,而此时会编译出[4,5,6,7,8,9]这样的格式显得比较冗长,我希望在这个地方使用原先[4-9]的格式,所以想请问该怎么同时使用这两种格式

zepinglee commented 2 years ago

我遇到的实际情况是,使用原来的代码,我的文章中想使用第一和第十,这两篇文献时会变成[1-10],所以我希望改成[1,10]这样的形式

这个情况不会出现。原来默认配置的短横线只对连续的编号有效,比如 \cite{key1,key10} 是“[1, 10]”,\cite{key1,key2,key3,key4,key5,key6,key7,key8,key9,key10} 才是“[1-10]”。

atxy-blip commented 2 years ago

我认为你的问题一开始就不存在。

\documentclass[oneside]{njuthesis}

\addbibresource{\jobname.bib}

\begin{document}

文献\cite{Walls2013-399-418,Zhang2007-500-503,Yi2013--,中国第一历史档案馆2001--,萧钰2001--}

文献\cite{Walls2013-399-418,中国第一历史档案馆2001--,萧钰2001--}

文献\parencite{Walls2013-399-418,Yi2013--,萧钰2001--}

\printbibliography

\end{document}

.bib 文件内容来自楼上,这个例子的编译结果见下图。从仓库中的开发版一直测到 v0.13.0 都是这样。请提供你的编译环境,包括操作系统、编译命令、TeX 发行版版本、模板版本。

image