| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
2010 : 01 02 03 04 05 06 07 08 09 10 11 12
2009 : 01 02 03 04 05 06 07 08 09 10 11 12
2008 : 01 02 03 04 05 06 07 08 09 10 11 12
2007 : 01 02 03 04 05 06 07 08 09 10 11 12
2006 : 01 02 03 04 05 06 07 08 09 10 11 12
revtexとbibtex使用時、referenceで5人以上の著者に対しet al.で省略したいと思った。
こんな機械的な操作は当然便利な方法が用意されているものと思ったが、どうやらそうではない。
http://authors.aps.org/revtex4/revtex4_faq.html#b9
At the request of the editors, the truncation only happens when there are 10 or more authors. You will need to edit the .bbl file manually.
というわけでpythonで書いてみた。出力されたbblを直接いじっているだけ。元のファイルは".orig"を付与し保存する。
fname = 'del.bbl'
maxlen = 5
import re, os
output = ''
fnameorig = fname + '.orig'
if os.access(fnameorig, os.F_OK):
s = open(fnameorig).read()
else:
s = open(fname).read()
open(fnameorig, 'w').write(s)
head, sep, body = s.partition(r'\bibitem')
output += head
reg = re.compile(r'(\\bibitem.+?)\n\n', re.DOTALL)
reg_bibitem = re.compile(r'(.+?)((?: *?\\bibinfo{author}.+?(?=\\bibinfo))+)(.+)', re.DOTALL | re.MULTILINE)
for r in reg.finditer(sep + body):
bibitembody = r.group(1)
rr = reg_bibitem.search(bibitembody)
if rr:
output += rr.group(1) # head
authors = rr.group(2)
a = r'\bibinfo{author}'
authorlist = authors.split(a)[1:] # the first element is blank
if len(authorlist)>maxlen:
output += (a + authorlist[0]).strip().replace(',', ' \\textit{et al.},\n')
else:
output += authors
output += rr.group(3) # tail
output += '\n\n'
else:
print '***** error ! *****\n', bibitembody
output += '\\end{thebibliography}\n'
open(fname, 'w').write(output)
2010 : 01 02 03 04 05 06 07 08 09 10 11 12
2009 : 01 02 03 04 05 06 07 08 09 10 11 12
2008 : 01 02 03 04 05 06 07 08 09 10 11 12
2007 : 01 02 03 04 05 06 07 08 09 10 11 12
2006 : 01 02 03 04 05 06 07 08 09 10 11 12
最終更新時間: 2010-03-08 22:21