44

I'm using a this freely downloadable latex class file and the style is set to \bibliographystyle{ieeetr}. But when I cite something with \cite{} I get it inside ().

For example I get it as abc et al. (1) but what I want to get is abc et al. [1].

Please tell me how to get my citations inside [ ] ?

3
  • I found the line 50: \usepackage[round, sort, numbers]{natbib} It is possible that "round" makes the trouble
    – MasterPJ
    Nov 13, 2012 at 14:24
  • 8
    The class is meant for submission to IEEE conferences. So the output is like they want.
    – egreg
    Nov 13, 2012 at 14:25
  • 1
    @egreg no this is a thesis template. And even in IEEE papers I haven't seen citing with parenthesis, it's using [].
    – samsamara
    Nov 13, 2012 at 14:59

4 Answers 4

51

You can simply say

\setcitestyle{square}

in your document preamble (see natbib documentation, section 2.9).

However, if you're using the class for a submission to an IEEE conference, leave as they want.

1
  • I have also the same problem, I want to use citation with square. I have set natbib=true, but when I write "\setcitestyle{square}", it comes out error "! Undefined control sequence. <recently read> \setcitestyle l.20 \setcitestyle". Could you have a look? Thank you .tex.stackexchange.com/questions/342866/…
    – Vivian
    Dec 8, 2016 at 12:29
18

The reason why you are getting citation numbers inside parentheses instead of square brackets is that in the class file you use, the package natbib is loaded with the option round, see line 51:

\usepackage[round, sort, numbers]{natbib}

Just replace this line with

\usepackage[sort, numbers]{natbib}

save your class file, compile your .tex file and you should get square brackets. Alternatively, simply adding \setcitestyle{square} in the preamble of your document without modifying the class file itself should work.

Note, however, that you may also have to edit the bibliographic style to change the style of the bibliographic number (at present, is it enclosed by parentheses or square brackets?) for each item in the Bibliography section.

3
  • 1
    There's no need to modify the class
    – egreg
    Nov 13, 2012 at 14:34
  • should be \setcitestyle{square}? :)
    – samsamara
    Nov 13, 2012 at 15:10
  • 1
    How the numbers appear in the bibliography is not governed by the .bst file, but by the LaTeX command \bibitem. There will be square brackets.
    – egreg
    Nov 13, 2012 at 15:15
2

To complement egreg's answer, class files (like for the journal Annual Review) can set the open and close characters at \begin{document}. In that case, \setcitestyle{square} only works if it comes after \begin{document}.

2
  • Why would this be the case? Could you be using a specific document class? Can you provide example code (in minimal form) that replicates this?
    – Werner
    Jun 11, 2020 at 15:58
  • @Werner, this is when using the class file for the journal Annual Reviews. I will edit my answer to reflect this.
    – user942648
    Jun 12, 2020 at 16:14
-1

This works for me:

\usepackage{natbib}
\setcitestyle{numbers}
\setcitestyle{square}

Output:

[x]

x denotes the number of the reference.

3
  • You could probably combine them - \setcitestyle{numbers,square}.
    – Werner
    Mar 10, 2022 at 16:52
  • I tried that and it did not work
    – TomGiavas
    Mar 10, 2022 at 17:40
  • Strange how this is the way its provided in the natbib documentation; see section 2.9 Selecting Citation Punctuation: "...the \setcitestyle command, which takes as argument a comma-separated list of keywords."
    – Werner
    Mar 10, 2022 at 20:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .