ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: Bibtex change short key
@ 2010-03-26  1:30 Hubertus
  2010-03-26  6:24 ` Taco Hoekwater
  0 siblings, 1 reply; 6+ messages in thread
From: Hubertus @ 2010-03-26  1:30 UTC (permalink / raw)
  To: ntg-context

Dear Taco,
> > I use the excellent BibTex module with this setup:
> > \setupbibtex[database=biblio,sort=author]
> > \setuppublications[alternative=apa,refcommand=short,sorttype=bbl,criterium=cited]
> > So if I have something like this
> > @ARTICLE{Akimoto2005,
> > author = {R. Akimoto and B. S. Li and K. Akita and T. Hasama},
> > ...
> > }
> > in my *.bib file, the \cite[Akimoto2005] results in [ALAH05]. Is there a way
> > to
> > get only the first author with three letters and the year ([Aki05]) in the
> > citation?
> 
> Patch the generated .bbl file by hand. after its initial creation, it
> will not be modified by context itself anymore.
May be I should have tried it first, before editting about 200 entries as you
suggested. As far as I can judge from the timestamp, at my system the bbl file 
is generatet every time I run texexec. Have I missed something?

Thanks
Hubertus
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bibtex change short key
  2010-03-26  1:30 Bibtex change short key Hubertus
@ 2010-03-26  6:24 ` Taco Hoekwater
  2010-03-26 15:10   ` Hubertus
  0 siblings, 1 reply; 6+ messages in thread
From: Taco Hoekwater @ 2010-03-26  6:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hubertus wrote:
> Dear Taco,
>>> I use the excellent BibTex module with this setup:
>>> \setupbibtex[database=biblio,sort=author]
>>> \setuppublications[alternative=apa,refcommand=short,sorttype=bbl,criterium=cited]
>>> So if I have something like this
>>> @ARTICLE{Akimoto2005,
>>> author = {R. Akimoto and B. S. Li and K. Akita and T. Hasama},
>>> ...
>>> }
>>> in my *.bib file, the \cite[Akimoto2005] results in [ALAH05]. Is there a way
>>> to
>>> get only the first author with three letters and the year ([Aki05]) in the
>>> citation?
>> Patch the generated .bbl file by hand. after its initial creation, it
>> will not be modified by context itself anymore.
> May be I should have tried it first, before editting about 200 entries as you
> suggested. As far as I can judge from the timestamp, at my system the bbl file 
> is generatet every time I run texexec. Have I missed something?

Oh boy, I am sorry! My fault! The *correct* recipe is: run once, so the
bbl exists, then delete the \setupbibtex line from your source, then
edit the bbl, then recompile.

Feeling stupid,
Taco
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bibtex change short key
  2010-03-26  6:24 ` Taco Hoekwater
@ 2010-03-26 15:10   ` Hubertus
  2010-03-26 15:14     ` luigi scarso
  0 siblings, 1 reply; 6+ messages in thread
From: Hubertus @ 2010-03-26 15:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 559 bytes --]

Dear Taco,
> Oh boy, I am sorry! My fault! The *correct* recipe is: run once, so the
> bbl exists, then delete the \setupbibtex line from your source, then
> edit the bbl, then recompile.
Thanks. This works now. I wrote a little python script now to save time and
thought maybe someone else might need it as well. It works for me but it was 
just a quick shot. There was not much time to think about all possibilities, 
and may be the regular expressions need to be modified. I first need to get this
thesis finished. So no guarantee.

All the best

Hubertus

[-- Attachment #2: genBibtexShortKey.py --]
[-- Type: text/x-python, Size: 1641 bytes --]

#!/usr/bin/python
# -*- coding: utf-8 -*-

import re
import shutil

fileName    = 'filename.bbl'            # Change here the filename
fileNameOld = fileName + '-old'         
shutil.copyfile(fileName, fileNameOld)  # Make a copy of the file
f = open(fileNameOld)
out = open(fileName, 'w')

author  = re.compile('a={+( [^}]* ) }', re.VERBOSE) # Find author
author3 = re.compile('(\w{2,3})')                   # Get the first 3 letters
year    = re.compile('y=\d{2,} (\d{2,}\w?)', re.VERBOSE) # Get the year e.g. 09a
shortRe = re.compile('(s=)(.*)\]')                  # Substitute the short key 
while True:
    tmp = [] # Array where from \startpulication[...] ... is saved
    line = f.readline()
    # Look for the start of a new publication
    if line.find('startpublication') >= 0:
        tmp.append(line)
        # Go the end of that publication \startpulication[...]
        while True:
            a = f.readline()
            tmp.append(a)
            if a.find(']') >= 0:
                break
        # Go through tmp to get the needed information
        short = ''
        for i in range(len(tmp)):
            a = tmp[i]
            if author.search(a):
                short = ''
                short = author3.findall(author.findall(a)[0])[0]
            if year.search(a):
                short += year.findall(a)[0]
            if shortRe.search(a):
                a = shortRe.sub(r'\1%s]', a) % short
            out.write(a)
    # If no entry in \startpulication[...] just write it again to the file
    else:
        out.write(line)

    # reached end of file
    if line == '':
        break

f.close()
out.close()

[-- Attachment #3: Type: text/plain, Size: 486 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bibtex change short key
  2010-03-26 15:10   ` Hubertus
@ 2010-03-26 15:14     ` luigi scarso
  0 siblings, 0 replies; 6+ messages in thread
From: luigi scarso @ 2010-03-26 15:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, Mar 26, 2010 at 4:10 PM, Hubertus <stonemonkey@web.de> wrote:
> Dear Taco,
>> Oh boy, I am sorry! My fault! The *correct* recipe is: run once, so the
>> bbl exists, then delete the \setupbibtex line from your source, then
>> edit the bbl, then recompile.
> Thanks. This works now. I wrote a little python script now to save time and
> thought maybe someone else might need it as well.
It's better if it's in luatex .



-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bibtex change short key
  2010-03-24 10:32 Hubertus
@ 2010-03-24 10:37 ` Taco Hoekwater
  0 siblings, 0 replies; 6+ messages in thread
From: Taco Hoekwater @ 2010-03-24 10:37 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hubertus wrote:
> Dear Mailinglist,
> I use the excellent BibTex module with this setup:
>   \setupbibtex[database=biblio,sort=author]
>   \setuppublications[alternative=apa,refcommand=short,sorttype=bbl,criterium=cited]
> So if I have something like this
>   @ARTICLE{Akimoto2005,
>     author = {R. Akimoto and B. S. Li and K. Akita and T. Hasama},
>     ...
>   }
> in my *.bib file, the \cite[Akimoto2005] results in [ALAH05]. Is there a way to
> get only the first author with three letters and the year ([Aki05]) in the
> citation?

Patch the generated .bbl file by hand. after its initial creation, it
will not be modified by context itself anymore.

Best wishes,
Taco
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Bibtex change short key
@ 2010-03-24 10:32 Hubertus
  2010-03-24 10:37 ` Taco Hoekwater
  0 siblings, 1 reply; 6+ messages in thread
From: Hubertus @ 2010-03-24 10:32 UTC (permalink / raw)
  To: ntg-context

Dear Mailinglist,
I use the excellent BibTex module with this setup:
  \setupbibtex[database=biblio,sort=author]
  \setuppublications[alternative=apa,refcommand=short,sorttype=bbl,criterium=cited]
So if I have something like this
  @ARTICLE{Akimoto2005,
    author = {R. Akimoto and B. S. Li and K. Akita and T. Hasama},
    ...
  }
in my *.bib file, the \cite[Akimoto2005] results in [ALAH05]. Is there a way to
get only the first author with three letters and the year ([Aki05]) in the
citation?

Help would be much appreciated.

Thanks

Hubertus
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-03-26 15:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-26  1:30 Bibtex change short key Hubertus
2010-03-26  6:24 ` Taco Hoekwater
2010-03-26 15:10   ` Hubertus
2010-03-26 15:14     ` luigi scarso
  -- strict thread matches above, loose matches on Subject: below --
2010-03-24 10:32 Hubertus
2010-03-24 10:37 ` Taco Hoekwater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).