1

I'm trying to get square brackets to appear inside the year field in bibtex, but they disappear in the output. Here's what I've tried:

year = {2000 [1939]}
year = {2000 \[1939\]}  
year = {2000 {[}1939{]}}

The expected output is:

  • Smith (2000 [1939])

But instead I get:

  • Smith (2000 1939)

I'm using the Association for Computational Linguistics (ACL) style (\bibliographystyle{acl}), which clashes with natbib. A copy can be found here for example:

https://github.com/jonsafari/acl.bst/blob/master/acl.bst

I'm not sure how to provide a MWE - I could paste the whole acl.bst here, but it's 1300 lines... Sorry, new to tex exchange!

Here is an entire package with a sample document to reproduce this in:

http://coling2018.org/wp-content/uploads/2018/01/coling2018.zip

An entry like this produces the problem:

@Book{Smith2000,
  title                    = {Some Book},
  author                   = {W. E. Smith},
  publisher                = {Clarendon Press},
  year                     = {2000 [1939]},
  address                  = {Oxford}
}
  • No escaping (i.e. just year = {2000 [1939]} appears to be necessary in either natbib nor BibLaTeX. Could you provide a MWE? – Coby Viner May 24 '18 at 18:34
  • 1
    Please tell us which bibliography style you employ. (Some styles are programmed to show only the first four or last four characters in the year field and/or to remove non-numeric characters.) – Mico May 24 '18 at 18:36
  • I see, sorry, I'm using the ACL style (\bibliographystyle{acl}), which clashes with natbib sadly. I'll update the question. – azeldes May 24 '18 at 19:51
  • @Mico I just checked and I can add other characters, so it's not truncating to last four or only numeric. – azeldes May 24 '18 at 19:59
  • The acl bibliography style appears to require a package file called acm2015.sty (or, maybe, acm2016.sty). Is that file available online somewhere? – Mico May 24 '18 at 21:27
1

Consider the following MWE

\documentclass[11pt]{article}
\usepackage{coling2018}
\usepackage{times}
\usepackage{url}

\begin{filecontents}{\jobname.bib}
@Book{Smith2000,
  title      = {Some Book},
  author     = {W. E. Smith},
  publisher  = {Clarendon Press}, 
  year       = {2000 [1939]},
  address    = {Oxford}
}
\end{filecontents}

\begin{document}
\cite{Smith2000}
\bibliographystyle{acl}
\bibliography{\jobname}
\end{document}

which produces the .bbl entry

\bibitem[\protect\citename{Smith}2000 1939]{Smith2000}
W.~E. Smith.
\newblock 2000 [1939].
\newblock {\em Some Book}.
\newblock Clarendon Press, Oxford.

and the output

The citation reads: "(Smith, 2000 1939)", the bibliography has "W. E. Smith. 2000 [1939]. ..."

The culprit is ll. 1100-1103 of acl.bst

  "\protect\citename{" swap$ * "}" *
  year field.or.null purify$ *
  'label :=
  year field.or.null purify$ *

In particular the behaviour you see is caused by purify$. That function (page 7 of Designing BibTeX Styles)

removes nonalphanumeric characters except for white-space characters and hyphens and ties (these all get converted to a space) [and] removes certain alphabetic characters contained in the control sequences associated with a “special character”

So because your year field gets purify$'d it loses its brackets. That means we need to stop acl.bst purifying your year. That is, however, not enough because with the raw year you would end up with

\bibitem[\protect\citename{Smith}2000 [1939]]{Smith2000}
W.~E. Smith.
\newblock 2000 [1939].
\newblock {\em Some Book}.
\newblock Clarendon Press, Oxford.

in the .bbl, that will lead to errors because we can't have unprotected square brackets in the optional argument, see ] inside an optional argument. So we need to brace the entire year field to be sure.

You will have to modify the .bst style to get the output you want. For paper submissions that might not be the best idea, because you probably can't send your modified .bst file, but it will work if the .bbl is sent along or just pasted into the document.

  1. Copy acl.bst to a location where TeX can find it. The document directory will do fine.
  2. Rename the file to acl-rawyear.bst
  3. Open the file and find the function FUNCTION {calc.label}, replace its second block (ll. 1100-1103)

      "\protect\citename{" swap$ * "}" *
      year field.or.null purify$ *
      'label :=
      year field.or.null purify$ *
    

    with

      "\protect\citename{" swap$ * "}" *
      "{" * year field.or.null * "}" *
      'label :=
      label *
    
  4. Add your name and date and explain the modification in the comments at the top of the file.

  5. Use \bibliographystyle{acl-rawyear} instead of \bibliographystyle{acl} in your document.

Now

%\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Book{Smith2000,
  title      = {Some Book},
  author     = {W. E. Smith},
  publisher  = {Clarendon Press}, 
  address    = {Oxford},
  year       = {2000 [1939]},
}
@Book{elk:bronto,
  title      = {Bronto},
  author     = {Anne Elk},
  publisher  = {Clarendon Press}, 
  address    = {Oxford},
  year       = {1972},
}
@Book{elk:trice,
  title      = {Triceratops},
  author     = {Anne Elk},
  publisher  = {Clarendon Press}, 
  address    = {Oxford},
  year       = {1972},
}
@Book{elk:ptero,
  title      = {Pterodactylus},
  author     = {Anne Elk},
  publisher  = {Clarendon Press}, 
  address    = {Oxford},
  year       = {1973},
}
\end{filecontents}

\documentclass{article}
\usepackage{coling2018}

\begin{document}
\cite{Smith2000,elk:bronto,elk:trice,elk:ptero}
\bibliographystyle{acl-rawyear}
\bibliography{\jobname}
\end{document}

outputs

enter image description here

| improve this answer | |
  • Fantastic, I really appreciate the thorough response! I'll mention this to the organizers (I really wish that natbib would just work with this...) – azeldes May 26 '18 at 18:39
  • @azeldes natbib can't really be blamed here. It is the .bst file supplied by the conference that causes the square brackets to disappear. Coming from a biblatex background I don't think it is entirely unreasonable of the .bst file to do this: Ideally the year is only an integer and nothing more. But unlike with biblatex where other fields and means are available to display the year of first publication, many .bst files don't offer any other way than year. – moewe May 26 '18 at 20:43
  • Oh, I completely agree it's not natbib's fault - I meant I wished this conference's stylesheet would not clash with natbib! I prefer natbib for a bunch of reasons. – azeldes May 27 '18 at 21:48

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.