如何删除文中特定引用的括号:
See [1] and [2], but 3 is what I need, and [4] is ok.
这里,哪个命令会给出3
而不是[3]
给出\cite
?对于同一文档中的其他引用,[1]
可以使用括号。
这不是“的重复删除单个引文中的括号“因为那里推荐的命令\citenum
需要额外的包(可能natbib
)。
我的动机是引用两篇论文,每篇都有页码。使用常规引用命令似乎是不可能的:
See [1, p 12] and [2, p 23], but [3, p 34; 5, p 45] is what I need, and [4, p 56] is ok
所以我希望用类似的命令来模拟它
See \cite[p 12]{A} and \cite[p 23]{B},
but [\citeNoBrackets[p 34]{C}; \citeNoBrackets[p 45]{E}] is what I need,
and \cite[p 56]{D} is ok.
为此,我需要一个像\citeNoBrackets
这样的命令\cite
但它不会添加括号。我该怎么做?
笔记:\def\@biblabel#1{#1}
恰恰相反:它改变了参考文献列表,但并没有改变文本中引用的出现方式。
梅威瑟:
\documentclass{article}
\begin{document}
See \cite[p 12]{A} and \cite[p 23]{B},
but [\cite[p 34]{C}; \cite[p 45]{E}] is what I need,
and \cite[p 56]{D} is ok.
\bibliographystyle{plain}
\bibliography{test}
\end{document}
test.bib
:
@Article{A, author = {A}, title = {A}, journal = {A}, year = {A}}
@Article{B, author = {B}, title = {B}, journal = {B}, year = {B}}
@Article{C, author = {C}, title = {C}, journal = {C}, year = {C}}
@Article{D, author = {D}, title = {D}, journal = {D}, year = {D}}
@Article{E, author = {E}, title = {E}, journal = {E}, year = {E}}
产生
See [1, p 12] and [2, p 23], but [[3, p 34]; [5, p 45]] is what I need, and [4, p 56] is ok.
带有不需要的双括号。
答案1
经过轻微测试。
\documentclass[]{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{Knuth1984texbook,
Author = {Knuth, D.E.},
Publisher = {Addison-Wesley, Reading, Massachusetts,},
Title = {The TEXbook, volume A of Computers and typesetting},
Year = {1984}}
@book{Chomsky1965,
Address = {Cambridge Mass.},
Author = {Noam Chomsky},
Publisher = {{MIT} Press},
Title = {Aspects of the Theory of Syntax},
Year = {1965}}
\end{filecontents*}
\bibliographystyle{plain}
\makeatletter
\newif\ifnobrackets
\renewcommand\@cite[2]{\ifnobrackets\else[\fi{#1\if@tempswa , #2\fi}\ifnobrackets\else]\fi\nobracketsfalse}
\newcommand\nbcite{\nobracketstrue\cite}
\makeatother
\begin{document}
[\nbcite[p.4]{Knuth1984texbook} and \nbcite[p.5]{Chomsky1965}] show that ...
\cite[p.4]{Knuth1984texbook} and \cite[p.5]{Chomsky1965} show that ...
\bibliography{\jobname}
\end{document}