5

How to remove brackets around a specific citation in the text:

See [1] and [2], but 3 is what I need, and [4] is ok.

Here, what command would give 3 and not [3] as \cite gives? For the other citations in the same document, brackets like [1] are OK.

This is not a duplicate of "Remove brackets from a single citation" because the command \citenum recommended there needs an additional package (probably natbib).

My motivation is citing two papers, each with page numbers. It seems it is impossible using normal citing commands:

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

so I expect to simulate it with commands like

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.

For this, I need a command like \citeNoBrackets that behaves as \cite but does not add brackets. How do I do it?

Note: \def\@biblabel#1{#1} does just the opposite: it changes the References list, but does not change how citations appear in the text.

MWE:

\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}}

which produces

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.

with unwanted double brackets.

  • 1
    Why do you not want to use natbib? It is very widely used and accepted by publishers. – Michael Palmer Aug 4 '17 at 12:34
  • natbib was created to do what you want. Where is the problem? – Johannes_B Aug 4 '17 at 12:42
  • 1
    I am not sure if it will not alter a given style. In addition, I cannot get it working with the particular style I have to use, svjour3.cls. – Alexander Gelbukh Aug 4 '17 at 12:42
  • A minimal working example with bibliography (MWEB), that illustrates your problem would help a lot. – Bobyandbob Aug 4 '17 at 12:51
  • 3
    The svjour3.cls has a natbib option, so it's definitely compatible with natbib. You're asking people to reinvent the wheel. – Alan Munn Aug 4 '17 at 13:00
6

Lightly tested.

\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}

output of code

| improve this answer | |
  • I wonder whether the same effect cannot be achieved by just removing the first and last character from the result of \cite. – Alexander Gelbukh Aug 4 '17 at 14:57
  • @AlexanderGelbukh I've simplified the code. – Alan Munn Aug 4 '17 at 17:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.