Re: Again eLyXer, but bibtex this time

2011-09-16 Thread Guenter Milde
On 2011-09-16, Alex Fernandez wrote:
 Hi again,

 On Thu, Sep 15, 2011 at 7:08 PM, Murat Yildizoglu myi...@gmail.com wrote:
 I am meeting another problem with elyxer conversion. If I do not put
 the .bib files in the same folder as the .lyx file, elyxer does not
 seem able to find them, and the bibliography is empty. If I put them
 in the same folder, I get the bibliography.

 You can also use relative paths, and they are supposed to work! Where
 are you placing the .bib files?

In all modern LaTeX distributions, bibtex databases are searched along
the bibpath with the kpathsea library. There is the command line utility
kpsewhich for use by other programs.

E.g. bibtex file ``foo.bib`` can be found with the command::

   kpsewhich -format bib foo.bib

(if the filename extension is ``.bib``, the -format specifier can be omitted).

May be there is even a Python wrapper. Looking at the Python-based bibtex
engines could give more info. There are (at least):

 * CrossTeX_, a backwards-compatible, improved bibtex
   re-implementation in Python (including HTML export).
   (development stalled since 2 years)

 * Pybtex_,a drop-in replacement for BibTeX written in Python.

   * BibTeX styles  (experimental) pythonic style API.
   * Database in BibTeX, BibTeXML and YAML formats.
   * full Unicode support.
   * Write to TeX, HTML and plain text.

.. _CrossTeX: http://www.cs.cornell.edu/people/egs/crosstex/
.. _Pybtex:   http://pybtex.sourceforge.net/


BTW: How about using Pybtex for the citation-formatting?

Günter



Re: Again eLyXer, but bibtex this time

2011-09-16 Thread Alex Fernandez
Hi Günter,

On Fri, Sep 16, 2011 at 9:04 AM, Guenter Milde mi...@users.berlios.de wrote:
 In all modern LaTeX distributions, bibtex databases are searched along
 the bibpath with the kpathsea library. There is the command line utility
 kpsewhich for use by other programs.

Aha, I always supposed that the .bib file had to be stored along with
the .lyx file.

 E.g. bibtex file ``foo.bib`` can be found with the command::

   kpsewhich -format bib foo.bib

 (if the filename extension is ``.bib``, the -format specifier can be omitted).

Good idea, it should not take too much effort to write a wrapper.
There is already one for ImageMagick's convert.

 May be there is even a Python wrapper. Looking at the Python-based bibtex
 engines could give more info. There are (at least):

         * CrossTeX_, a backwards-compatible, improved bibtex
           re-implementation in Python (including HTML export).
           (development stalled since 2 years)

         * Pybtex_,a drop-in replacement for BibTeX written in Python.

           * BibTeX styles  (experimental) pythonic style API.
           * Database in BibTeX, BibTeXML and YAML formats.
           * full Unicode support.
           * Write to TeX, HTML and plain text.

 .. _CrossTeX: http://www.cs.cornell.edu/people/egs/crosstex/
 .. _Pybtex:   http://pybtex.sourceforge.net/


 BTW: How about using Pybtex for the citation-formatting?

Perhaps a bit too involved at this stage, it would have been nice to
integrate instead of writing my own stuff (but it sure was fun!).

Alex.


Re: Again eLyXer, but bibtex this time

2011-09-16 Thread Guenter Milde
On 2011-09-16, Alex Fernandez wrote:
 Hi Günter,

 On Fri, Sep 16, 2011 at 9:04 AM, Guenter Milde mi...@users.berlios.de wrote:

 E.g. bibtex file ``foo.bib`` can be found with the command::

   kpsewhich -format bib foo.bib

 Good idea, it should not take too much effort to write a wrapper.
 There is already one for ImageMagick's convert.

There is one in pybtex, see below,

Günter


pybtex/kpatsea.py:

# Copyright (c) 2007, 2008, 2009, 2010, 2011  Andrey Golovizin
# 
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# Software), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from subprocess import Popen, PIPE

def kpsewhich(filename):
p = Popen(['kpsewhich', filename], stdout=PIPE, stderr=PIPE)
path = p.communicate()[0].rstrip()
if p.returncode == 0:
return path



Re: Again eLyXer, but bibtex this time

2011-09-16 Thread Guenter Milde
On 2011-09-16, Alex Fernandez wrote:
 Hi again,

 On Thu, Sep 15, 2011 at 7:08 PM, Murat Yildizoglu myi...@gmail.com wrote:
 I am meeting another problem with elyxer conversion. If I do not put
 the .bib files in the same folder as the .lyx file, elyxer does not
 seem able to find them, and the bibliography is empty. If I put them
 in the same folder, I get the bibliography.

 You can also use relative paths, and they are supposed to work! Where
 are you placing the .bib files?

In all modern LaTeX distributions, bibtex databases are searched along
the bibpath with the kpathsea library. There is the command line utility
kpsewhich for use by other programs.

E.g. bibtex file ``foo.bib`` can be found with the command::

   kpsewhich -format bib foo.bib

(if the filename extension is ``.bib``, the -format specifier can be omitted).

May be there is even a Python wrapper. Looking at the Python-based bibtex
engines could give more info. There are (at least):

 * CrossTeX_, a backwards-compatible, improved bibtex
   re-implementation in Python (including HTML export).
   (development stalled since 2 years)

 * Pybtex_,a drop-in replacement for BibTeX written in Python.

   * BibTeX styles  (experimental) pythonic style API.
   * Database in BibTeX, BibTeXML and YAML formats.
   * full Unicode support.
   * Write to TeX, HTML and plain text.

.. _CrossTeX: http://www.cs.cornell.edu/people/egs/crosstex/
.. _Pybtex:   http://pybtex.sourceforge.net/


BTW: How about using Pybtex for the citation-formatting?

Günter



Re: Again eLyXer, but bibtex this time

2011-09-16 Thread Alex Fernandez
Hi Günter,

On Fri, Sep 16, 2011 at 9:04 AM, Guenter Milde mi...@users.berlios.de wrote:
 In all modern LaTeX distributions, bibtex databases are searched along
 the bibpath with the kpathsea library. There is the command line utility
 kpsewhich for use by other programs.

Aha, I always supposed that the .bib file had to be stored along with
the .lyx file.

 E.g. bibtex file ``foo.bib`` can be found with the command::

   kpsewhich -format bib foo.bib

 (if the filename extension is ``.bib``, the -format specifier can be omitted).

Good idea, it should not take too much effort to write a wrapper.
There is already one for ImageMagick's convert.

 May be there is even a Python wrapper. Looking at the Python-based bibtex
 engines could give more info. There are (at least):

         * CrossTeX_, a backwards-compatible, improved bibtex
           re-implementation in Python (including HTML export).
           (development stalled since 2 years)

         * Pybtex_,a drop-in replacement for BibTeX written in Python.

           * BibTeX styles  (experimental) pythonic style API.
           * Database in BibTeX, BibTeXML and YAML formats.
           * full Unicode support.
           * Write to TeX, HTML and plain text.

 .. _CrossTeX: http://www.cs.cornell.edu/people/egs/crosstex/
 .. _Pybtex:   http://pybtex.sourceforge.net/


 BTW: How about using Pybtex for the citation-formatting?

Perhaps a bit too involved at this stage, it would have been nice to
integrate instead of writing my own stuff (but it sure was fun!).

Alex.


Re: Again eLyXer, but bibtex this time

2011-09-16 Thread Guenter Milde
On 2011-09-16, Alex Fernandez wrote:
 Hi Günter,

 On Fri, Sep 16, 2011 at 9:04 AM, Guenter Milde mi...@users.berlios.de wrote:

 E.g. bibtex file ``foo.bib`` can be found with the command::

   kpsewhich -format bib foo.bib

 Good idea, it should not take too much effort to write a wrapper.
 There is already one for ImageMagick's convert.

There is one in pybtex, see below,

Günter


pybtex/kpatsea.py:

# Copyright (c) 2007, 2008, 2009, 2010, 2011  Andrey Golovizin
# 
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# Software), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from subprocess import Popen, PIPE

def kpsewhich(filename):
p = Popen(['kpsewhich', filename], stdout=PIPE, stderr=PIPE)
path = p.communicate()[0].rstrip()
if p.returncode == 0:
return path



Re: Again eLyXer, but bibtex this time

2011-09-16 Thread Guenter Milde
On 2011-09-16, Alex Fernandez wrote:
> Hi again,

> On Thu, Sep 15, 2011 at 7:08 PM, Murat Yildizoglu  wrote:
>> I am meeting another problem with elyxer conversion. If I do not put
>> the .bib files in the same folder as the .lyx file, elyxer does not
>> seem able to find them, and the bibliography is empty. If I put them
>> in the same folder, I get the bibliography.

> You can also use relative paths, and they are supposed to work! Where
> are you placing the .bib files?

In all modern LaTeX distributions, bibtex databases are searched along
the bibpath with the kpathsea library. There is the command line utility
kpsewhich for use by other programs.

E.g. bibtex file ``foo.bib`` can be found with the command::

   kpsewhich -format bib foo.bib

(if the filename extension is ``.bib``, the -format specifier can be omitted).

May be there is even a Python wrapper. Looking at the Python-based bibtex
engines could give more info. There are (at least):

 * CrossTeX_, a backwards-compatible, improved bibtex
   re-implementation in Python (including HTML export).
   (development stalled since 2 years)

 * Pybtex_,a drop-in replacement for BibTeX written in Python.

   * BibTeX styles & (experimental) pythonic style API.
   * Database in BibTeX, BibTeXML and YAML formats.
   * full Unicode support.
   * Write to TeX, HTML and plain text.

.. _CrossTeX: http://www.cs.cornell.edu/people/egs/crosstex/
.. _Pybtex:   http://pybtex.sourceforge.net/


BTW: How about using Pybtex for the citation-formatting?

Günter



Re: Again eLyXer, but bibtex this time

2011-09-16 Thread Alex Fernandez
Hi Günter,

On Fri, Sep 16, 2011 at 9:04 AM, Guenter Milde  wrote:
> In all modern LaTeX distributions, bibtex databases are searched along
> the bibpath with the kpathsea library. There is the command line utility
> kpsewhich for use by other programs.

Aha, I always supposed that the .bib file had to be stored along with
the .lyx file.

> E.g. bibtex file ``foo.bib`` can be found with the command::
>
>   kpsewhich -format bib foo.bib
>
> (if the filename extension is ``.bib``, the -format specifier can be omitted).

Good idea, it should not take too much effort to write a wrapper.
There is already one for ImageMagick's convert.

> May be there is even a Python wrapper. Looking at the Python-based bibtex
> engines could give more info. There are (at least):
>
>         * CrossTeX_, a backwards-compatible, improved bibtex
>           re-implementation in Python (including HTML export).
>           (development stalled since 2 years)
>
>         * Pybtex_,a drop-in replacement for BibTeX written in Python.
>
>           * BibTeX styles & (experimental) pythonic style API.
>           * Database in BibTeX, BibTeXML and YAML formats.
>           * full Unicode support.
>           * Write to TeX, HTML and plain text.
>
> .. _CrossTeX: http://www.cs.cornell.edu/people/egs/crosstex/
> .. _Pybtex:   http://pybtex.sourceforge.net/
>
>
> BTW: How about using Pybtex for the citation-formatting?

Perhaps a bit too involved at this stage, it would have been nice to
integrate instead of writing my own stuff (but it sure was fun!).

Alex.


Re: Again eLyXer, but bibtex this time

2011-09-16 Thread Guenter Milde
On 2011-09-16, Alex Fernandez wrote:
> Hi Günter,

> On Fri, Sep 16, 2011 at 9:04 AM, Guenter Milde  wrote:

>> E.g. bibtex file ``foo.bib`` can be found with the command::

>>   kpsewhich -format bib foo.bib

> Good idea, it should not take too much effort to write a wrapper.
> There is already one for ImageMagick's convert.

There is one in pybtex, see below,

Günter


pybtex/kpatsea.py:

# Copyright (c) 2007, 2008, 2009, 2010, 2011  Andrey Golovizin
# 
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
# 
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from subprocess import Popen, PIPE

def kpsewhich(filename):
p = Popen(['kpsewhich', filename], stdout=PIPE, stderr=PIPE)
path = p.communicate()[0].rstrip()
if p.returncode == 0:
return path



Re: Again eLyXer, but bibtex this time

2011-09-15 Thread Alex Fernandez
Hi again,

On Thu, Sep 15, 2011 at 7:08 PM, Murat Yildizoglu myi...@gmail.com wrote:
 I am meeting another problem with elyxer conversion. If I do not put
 the .bib files in the same folder as the .lyx file, elyxer does not
 seem able to find them, and the bibliography is empty. If I put them
 in the same folder, I get the bibliography.

You can also use relative paths, and they are supposed to work! Where
are you placing the .bib files?

 Also, I have not been able to find a way to generate a standard agsm
 (harvard) style bibliography reference. I only get a number between
 brackets [1] as reference, even if I choose author-name in the options
 of natbib in the document properties box.

 Only author-name2 gives me a real author-name type of reference (but
 brackets, and also with the key typed in the beginning of the full
 reference in the typest bibliography).

Let me explain you a little bit how BibTeX support works in eLyXer: it
keeps its own templates to transform the variables into references and
formats. These templates can be located in src/conf/base.conf. For
example the one you are using (I assume it is authordate2) looks like
this:

[BibStylesConfig.authordate2]
cite:$surname, $year
default:$authors. $year. i$title/i. $publisher.{ URL a
href=$url$url/a.}{ $note.}
@article:$authors. $year. $title. i$journal/i,
b$volume/b($number), $pages.{ URL a href=$url$url/a.}{
$note.}
@book:$authors. $year. i$title/i. $publisher.{ URL a
href=$url$url/a.}{ $note.}

As you see, the first line defines the style, authordate2; the second
line the citing style, in this case author surname and year. I am
afraid the cites always show the brackets right now. After that you
can see how eLyXer will display the default document type, then an
article and a book.

 These are very commonly necessary functions, so I assume that I am
 doing something strange. How can I correct these problems?

It is just that these templates are user-contributed; apparently you
are the first to request the agsm format. If you want you can edit
your elyxer.py file and insert a new style: just go after the
vancouver style and insert this:

[BibStylesConfig.vancouver]
...

[BibStylesConfig.agsm]
cite:$surname, $year
default:$authors. $title; {$publisher, }$year.{ $howpublished.}{ URL:
a href=$url$url/a.}{ $note.}
@article:$authors. $title. i$journal/i,
$year{;{b$volume/b}{($number)}{:$pages}}.{ URL: a
href=$url$url/a.}{ $note.}
@book:$authors. $title. {$publisher, }$year.{ URL: a
href=$url$url/a.}{ $note.}

Note that each document type (@article) has variables ($title) which
are taken from the .bib file, and some HTML code (i$journal/i) to
format the text.

Now you can play with it until you like the result, and then send it
my way. Alternatively, you can send me another sample privately and I
will work on it.

Thanks,

Alex.


Re: Again eLyXer, but bibtex this time

2011-09-15 Thread Alex Fernandez
Hi again,

On Thu, Sep 15, 2011 at 7:08 PM, Murat Yildizoglu myi...@gmail.com wrote:
 I am meeting another problem with elyxer conversion. If I do not put
 the .bib files in the same folder as the .lyx file, elyxer does not
 seem able to find them, and the bibliography is empty. If I put them
 in the same folder, I get the bibliography.

You can also use relative paths, and they are supposed to work! Where
are you placing the .bib files?

 Also, I have not been able to find a way to generate a standard agsm
 (harvard) style bibliography reference. I only get a number between
 brackets [1] as reference, even if I choose author-name in the options
 of natbib in the document properties box.

 Only author-name2 gives me a real author-name type of reference (but
 brackets, and also with the key typed in the beginning of the full
 reference in the typest bibliography).

Let me explain you a little bit how BibTeX support works in eLyXer: it
keeps its own templates to transform the variables into references and
formats. These templates can be located in src/conf/base.conf. For
example the one you are using (I assume it is authordate2) looks like
this:

[BibStylesConfig.authordate2]
cite:$surname, $year
default:$authors. $year. i$title/i. $publisher.{ URL a
href=$url$url/a.}{ $note.}
@article:$authors. $year. $title. i$journal/i,
b$volume/b($number), $pages.{ URL a href=$url$url/a.}{
$note.}
@book:$authors. $year. i$title/i. $publisher.{ URL a
href=$url$url/a.}{ $note.}

As you see, the first line defines the style, authordate2; the second
line the citing style, in this case author surname and year. I am
afraid the cites always show the brackets right now. After that you
can see how eLyXer will display the default document type, then an
article and a book.

 These are very commonly necessary functions, so I assume that I am
 doing something strange. How can I correct these problems?

It is just that these templates are user-contributed; apparently you
are the first to request the agsm format. If you want you can edit
your elyxer.py file and insert a new style: just go after the
vancouver style and insert this:

[BibStylesConfig.vancouver]
...

[BibStylesConfig.agsm]
cite:$surname, $year
default:$authors. $title; {$publisher, }$year.{ $howpublished.}{ URL:
a href=$url$url/a.}{ $note.}
@article:$authors. $title. i$journal/i,
$year{;{b$volume/b}{($number)}{:$pages}}.{ URL: a
href=$url$url/a.}{ $note.}
@book:$authors. $title. {$publisher, }$year.{ URL: a
href=$url$url/a.}{ $note.}

Note that each document type (@article) has variables ($title) which
are taken from the .bib file, and some HTML code (i$journal/i) to
format the text.

Now you can play with it until you like the result, and then send it
my way. Alternatively, you can send me another sample privately and I
will work on it.

Thanks,

Alex.


Re: Again eLyXer, but bibtex this time

2011-09-15 Thread Alex Fernandez
Hi again,

On Thu, Sep 15, 2011 at 7:08 PM, Murat Yildizoglu  wrote:
> I am meeting another problem with elyxer conversion. If I do not put
> the .bib files in the same folder as the .lyx file, elyxer does not
> seem able to find them, and the bibliography is empty. If I put them
> in the same folder, I get the bibliography.

You can also use relative paths, and they are supposed to work! Where
are you placing the .bib files?

> Also, I have not been able to find a way to generate a standard agsm
> (harvard) style bibliography reference. I only get a number between
> brackets [1] as reference, even if I choose author-name in the options
> of natbib in the document properties box.
>
> Only author-name2 gives me a real author-name type of reference (but
> brackets, and also with the key typed in the beginning of the full
> reference in the typest bibliography).

Let me explain you a little bit how BibTeX support works in eLyXer: it
keeps its own templates to transform the variables into references and
formats. These templates can be located in src/conf/base.conf. For
example the one you are using (I assume it is authordate2) looks like
this:

[BibStylesConfig.authordate2]
cite:$surname, $year
default:$authors. $year. $title. $publisher.{ URL $url.}{ $note.}
@article:$authors. $year. $title. $journal,
$volume($number), $pages.{ URL $url.}{
$note.}
@book:$authors. $year. $title. $publisher.{ URL $url.}{ $note.}

As you see, the first line defines the style, authordate2; the second
line the citing style, in this case author surname and year. I am
afraid the cites always show the brackets right now. After that you
can see how eLyXer will display the default document type, then an
article and a book.

> These are very commonly necessary functions, so I assume that I am
> doing something strange. How can I correct these problems?

It is just that these templates are user-contributed; apparently you
are the first to request the agsm format. If you want you can edit
your elyxer.py file and insert a new style: just go after the
vancouver style and insert this:

[BibStylesConfig.vancouver]
...

[BibStylesConfig.agsm]
cite:$surname, $year
default:$authors. $title; {$publisher, }$year.{ $howpublished.}{ URL:
$url.}{ $note.}
@article:$authors. $title. $journal,
$year{;{$volume}{($number)}{:$pages}}.{ URL: $url.}{ $note.}
@book:$authors. $title. {$publisher, }$year.{ URL: $url.}{ $note.}

Note that each document type (@article) has variables ($title) which
are taken from the .bib file, and some HTML code ($journal) to
format the text.

Now you can play with it until you like the result, and then send it
my way. Alternatively, you can send me another sample privately and I
will work on it.

Thanks,

Alex.