Latex cite and bibliography

Everything related to our flagship word processor.
Post Reply
dmsilv
Posts: 3
Joined: 2012-02-24 10:23:26

Latex cite and bibliography

Post by dmsilv » 2012-02-24 10:31:07

Hi all, I just start to use Nisus and I'm trying to figure out if anybody else are using Bibdesk to cite documents. I have a script in my computer that works on MS. Word finding \cite{} tags after that building a bibliography section. However, it is not working with Nisus Pro, so, perhaps somebody has a clue for this.

User avatar
phspaelti
Posts: 1015
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Latex cite and bibliography

Post by phspaelti » 2012-02-24 23:56:28

When you say "I have a script" this is what? An apple script, something else? And where/when do you run it? On a saved Nisus file?
philip

dmsilv
Posts: 3
Joined: 2012-02-24 10:23:26

Re: Latex cite and bibliography

Post by dmsilv » 2012-02-25 00:02:12

Yes, it is an AppleScript. In Word I can access and run it throught script menu.

User avatar
phspaelti
Posts: 1015
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Latex cite and bibliography

Post by phspaelti » 2012-02-25 23:15:26

Hello again. I don't use BibDesk myself. If you do still want help with this problem, could you post the script (or a link to where you got it)?

Generally since Nisus has real grep (unlike Word) it is really easy to grab all the \cite{} strings from a Nisus file. But a quick look at BibDesk did not enlighten me on how one would use such a list to generate a bibliography, or get the in-line citations.
philip

dmsilv
Posts: 3
Joined: 2012-02-24 10:23:26

Re: Latex cite and bibliography

Post by dmsilv » 2012-02-26 02:46:53

Voilà

http://bibfuse.sourceforge.net/

In the source above you will find two apple scripts and a template.

Daniel

User avatar
phspaelti
Posts: 1015
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Latex cite and bibliography

Post by phspaelti » 2012-02-26 20:25:51

Hello Daniel,
let me just say the obvious first. The applescript won't work with Nisus because it says

Code: Select all

tell application "Microsoft Word"
But more specifically it relies on the specific applescript hooks that MS Word has, so changing this will require some rewriting. I'll take a look at this, but it may take a few days.
philip

User avatar
phspaelti
Posts: 1015
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Latex cite and bibliography

Post by phspaelti » 2012-02-29 02:28:18

Hello again Daniel,

I have here something of a bare bones version of the script:
BibNisusFormat.scpt.zip
(27.53 KiB) Downloaded 150 times
There are number of things to say.
The original BibFuseFormat script uses a construct called "fields" in Word, which as far as I can make out seem to allow hiding things in a file. Essentially the script hides the cite keys in these fields and displays numbers instead. The one really nice thing is that is allows easy undoing (just extract the hidden info and remove the fields). Nisus has no such fields so the script simply replaces the cite keys. Undoing won't work.
It would be possible to set up some form of undoing, but this will require certain decisions of interface, and since I am actually not that interested in this approach to bibliographies, I am not at this time inclined to take the time to write such a script.

There are some other small differences. The script looks for a temporary file location. This didn't work on my machine, so I just worked around by having the user select the location by hand.

Overall I have to say that the whole reason for doing this with apple script is really due to the limitations of Word. A much better approach under Nisus Writer is to use Nisus' macro capability. I wrote a macro version of this script which I am posting here:
BibNisusFormat.nwm
(33.24 KiB) Downloaded 141 times
This macro does still have some minor issues. But I don't have more time right now.
philip

User avatar
phspaelti
Posts: 1015
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Latex cite and bibliography

Post by phspaelti » 2012-02-29 08:36:16

Here is a slightly improved version of the macro. This removes the problem of leaving the temporary file open at the end. It also cleans up some of the unused variables.
BibNisusFormat.nwm
(32.64 KiB) Downloaded 137 times
One point that I failed to explain in my previous post: When this macro inserts citation numbers in the text it formats them all with a character style called "Citation". This has the advantage that one can easily change the formatting. It also makes it possible to easily select all citations.

Finally this should also be helpful if one wanted to write a macro to unformat the cite keys. One approach that one could take for such a macro would be to store the cite keys in a registry variable. Since $citeKeyList is a single Array, this would be fairly easy. The Unformat macro could then retrieve the $citeKeyList and replace each citation number with the corresponding cite key.
philip

User avatar
phspaelti
Posts: 1015
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Latex cite and bibliography

Post by phspaelti » 2012-02-29 19:55:19

Sorry, discovered another small error. Line 72 should have $bibnameNoExt changed to $bibname, so it should look like this:

Code: Select all

prompt “No \\bibliography command found.”, “Shall I insert one for $bibname at the end of the document?”
Here the corrected macro:
BibNisusFormat.nwm
(32.85 KiB) Downloaded 158 times
philip

martin
Official Nisus Person
Posts: 4567
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Latex cite and bibliography

Post by martin » 2012-03-02 11:44:32

Thanks for putting that macro together Philip! It's quite nice. You even restore the user's prior document view if the macro has to create a Citation style- such a polite macro 8)

Hopefully Daniel and others put your efforts to good use!

User avatar
phspaelti
Posts: 1015
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Latex cite and bibliography

Post by phspaelti » 2012-03-02 18:39:45

martin wrote:Thanks for putting that macro together Philip! It's quite nice. You even restore the user's prior document view if the macro has to create a Citation style- such a polite macro 8)

Hopefully Daniel and others put your efforts to good use!
Thanks, Martin.
Of course, restoring the view would be easier if we had a Doc.viewstate property :wink:

Or better yet, what would really be nice is, if we could define a style something like this:

Code: Select all

$myNewStyle = Style.newWithAttributes $myAttributes
:)
philip

martin
Official Nisus Person
Posts: 4567
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Latex cite and bibliography

Post by martin » 2012-03-06 11:07:21

Those sound like good macro enhancement suggestions to me, thanks Philip!

haver
Posts: 21
Joined: 2007-05-14 11:17:05

Re: Latex cite and bibliography

Post by haver » 2012-05-20 08:08:31

Thanks a lot, Philip. When I wrote my last paper, I had to use Pages. With this macro, you basically makes it possible for me to use NWP again for writing my papers.

Really big kudos to you for taking the time to do this.

Nelson

Post Reply