Re: Hacking bst files... [Was: Show entry type in References]
Ares skrev: As I wrote in a previous post, I would like the references of my PhD thesis to be arranged as follows: References Articles [Art1] article1 [Art2] article2 etc Books [Book1] book1 [Book2] book2 etc etc ... LyX 1.4.1 supports "sectioned bibliography", so it is possible to split the Bibliography chapter in sections. In order to have the citation as [Art1] and [Book1] etc, I need to hack a bst file, as suggested by Jürgen. I had a look to plain.bst and it doesn't sound so easy! In the end I would just like to add a prefix (Book, Art etc) to the reference numbering and to use a separate bst file for each entry (Books, Articles etc), so that the numbering starts with each "section". Is there a resource where I can find how bst files work? or is there someone who can help me? Thanks for support, Diego Hi! I think that a much easier way to get a bst file than to start hack it is to use the makebst utility. (run latex makebst) Then you get a series of multiple choice question on how you want to format oyur bibliographical entries. Then two files are created, a dbj file and a bst file. The bst file is the bibliography file created. The dbj file is a batch file that is run through latex to create the bst file. If you later want to tweak the style file, this can easily be done by changing the dbj file, which is quite easy. Just comment out the option you want to change using a "#", and uncomment the line with the option you prefer instead. The you just run the dbj file thorugh latex to update the bst file! You might not be able to do everything this way, but at least it is easy and it helped me a lot! /Sara
Re: Hacking bst files... [Was: Show entry type in References]
One of the things I personally find annoying about LaTeX is the syntax, and BibTeX is even worse, frankly, but it's not that insanely complicated once you adjust to the stack-oriented character of the language. You may find it useful to keep pen and paper nearby so you can keep track of what's on the stack as you trace the code. If you haven't read it, obviously you should read btxhak.dvi, the guide to hacking BibTeX style files. It takes a while---I know---to get a sense for how the language works, and how these style files work, but it will start to make sense after a while. You should also export to LaTeX, compile the file manually, and look at what is being written to the .bbl file, when various bibliography styles are used. The labels used in the bibliography, and in the text, are set by the \bibitem command that the style file writes to the .bbl file. In many style files, this seems to be written by the output.bibitem function, which is called at the beginning of each of the functions, article, book, etc, that are called for the appropriate sorts of items. Here it is from plain.bst: FUNCTION {output.bibitem} { newline$ "\bibitem{" write$ cite$ write$ "}" write$ newline$ "" before.all 'output.state := } This ends up writing something like: \bibitem{Descartes:Rules} to your .bbl file. Compare this function, from alpha.bst: FUNCTION {output.bibitem} { newline$ "\bibitem[" write$ label write$ "]{" write$ cite$ write$ "}" write$ newline$ "" before.all 'output.state := } This writes something like: \bibitem[Des82]{Descartes:Rules} to the .bbl file, with the result that the label "Des82" is used both in the text and the bibliography. Since there is no such argument to \bibitem in the previous case, the default is used: The cite key is simply a number. The variable "label" is what holds the value of the cite key in alpha.bst. Where was it set? You will note that it is mentioned in the ENTRY declaration, both in plain.bst and in alpha.bst, as a "string variable" that is associated with each item in the bibliography. This is NOT an item set in the .bib file itself---unlike author, title, etc---but rather a new variable that has been declared to be associated with each item and that can be manipulated in the .bst file. In plain.bst, the label variable is set in the function longest.label.pass: FUNCTION {longest.label.pass} { number.label int.to.str$ 'label := % number.label was initialized to 1 in initialize.longest.label % its string form is here being assigned to label number.label #1 + 'number.label := %this increments number.label label width$ longest.label.width > { label 'longest.label := label width$ 'longest.label.width := } 'skip$ if$ } (I've added comments.) This function is called for each item in the bibliography with: ITERATE(longest.label.pass) which is itself called after the list has been sorted and such. If you look at alpha.bst, you will see that label is set for each item in calc.label, which is itself called in the function presort, called with ITERATE(presort). Hint: If you want to know where a variable named "var" is set, search for: 'var, since an assignment to var will look like: 'var :=, the assigned value being whatever is on the top of the stack. (If you see whatever 'var ;=, then the occurrence of "whatever" is just pushing a value onto the stack.) So the label variable exists in plain.bst, but it is not used there. But we can use it. For example, suppose we change the definition of output.bibitem in plain.bst to the following: FUNCTION {output.bibitem} { newline$ "\bibitem[FROG" write$ label write$ "]{" write$ cite$ write$ "}" write$ newline$ "" before.all 'output.state := } Then we get cite keys like: FROG3, FROG25, etc. Your request is more complicated, because we want something different for different types of entries. But that's OK, because we have the entry type in the type$ variable, and we can just check that. The easiest thing to do would seem to be to define a new function that will print the prefix we want depending upon the entry type. This function will handle articles, incollections, and books: FUNCTION {output.prefix} { type$ "incollection" = type$ "article" = + %hack for "or" { "Art" } { type$ "book" = { "Book" } { "Other" } if$ } if$ } If you need to add other types, that's obviously easy to do. (There's no elsif here, so we have to use nested ifs. Exercise: Code up a switch or case statement!) We then redefine output.bibitem as follows: FUNCTION {output.bibitem} { newline$ "\bibitem[" write$ output.prefix write$ label write$ "]{" write$ cite$ write$ "}" write$ newline$ "" before.all 'output.state := } That should do what you need, more or less. Richard Ares wrote: > As I wrote in a previous post, I would like the references of my PhD > thes
Re: Hacking bst files... [Was: Show entry type in References]
Hi, 2006-06-05 18:46 +0200, Ares: > As I wrote in a previous post, I would like the references of my PhD thesis > to be arranged as follows: > > > References > > > > Articles > > [Art1] article1 > > [Art2] article2 > > etc > > Books > > [Book1] book1 > > [Book2] book2 > > etc > > etc > > ... > > LyX 1.4.1 supports "sectioned bibliography", so it is possible to split the > Bibliography chapter in sections. > > In order to have the citation as [Art1] and [Book1] etc, I need to hack a > bst file, as suggested by Jürgen. I had a look to plain.bst and it doesn't > sound so easy! > In the end I would just like to add a prefix (Book, Art etc) to the > reference numbering and to use a separate bst file for each entry (Books, > Articles etc), so that the numbering starts with each "section". Actually, this is an issue related to the \bibitem command in the .bst file. However, adding a text before the number is a bit tricky... I have been testing several solutions but haven't find any yet. I keep testing... Kind regards, Kimmo
Hacking bst files... [Was: Show entry type in References]
As I wrote in a previous post, I would like the references of my PhD thesis to be arranged as follows: References Articles [Art1] article1 [Art2] article2 etc Books [Book1] book1 [Book2] book2 etc etc ... LyX 1.4.1 supports "sectioned bibliography", so it is possible to split the Bibliography chapter in sections. In order to have the citation as [Art1] and [Book1] etc, I need to hack a bst file, as suggested by Jürgen. I had a look to plain.bst and it doesn't sound so easy! In the end I would just like to add a prefix (Book, Art etc) to the reference numbering and to use a separate bst file for each entry (Books, Articles etc), so that the numbering starts with each "section". Is there a resource where I can find how bst files work? or is there someone who can help me? Thanks for support, Diego
Bibliography in TOC [Was: Show entry type in References]
I managed to get the Bibliography in TOC in the output file by using the TeX command \backmatter right before the Bibliography Chapter (not Chapter*) and preceded by a page break. See: http://groups.google.com/group/comp.text.tex/browse_thread/thread/ce999aa747cf4a3e/36b1505bedbf3288?q=starred+TOC&rnum=1#36b1505bedbf3288 In this way, inside LyX you get the Bibliography chapter numbered, and as an appendix (if you have, as in my case, appendixes), also appearing in LyX file TOC. When you view the pdf, for example, you get a nice Bibliography title (without number) in TOC of the compiled document. Perhaps it is a dirty trick, but it works... Anyway the Document settings --> Numbering and TOC pane does not work... is it a bug? how to report it? Regards, Diego -- Forwarded message -- From: Ares <[EMAIL PROTECTED]> Date: 5-giu-2006 10.58 Subject: Show entry type in References To: lyx-users@lists.lyx.org I would probaly try to hack alpha.bst. I'll try this. thanks Jürgen ...but now I have a new problem: I don't manage to get the Bibliography in the Table of Contents. If I use the option Sectioned Bibliography, I cannot check the option "Add bibliography to TOC" in the "BibTeX generated bibliography" dialog. What I did is to define the "Bibliography" section name as a Chapter* (chapter title without numbering). Either this way, the Bibliography does not appear in TOC. I also went to Document settings --> Numbering and TOC, but it is not possible from here to change the behaviour of Chapter* since Chapter* is not there at all! but there are Part* and Section*, so why not Chapter* ? By the way, I noticed that even if I set Part* and Section* to appear in TOC, they don't. What's wrong? is it a bug or maybe I don't get the meaning of it all? Thanks again for your support, Diego -- Messaggio inoltrato -- From: Ares <[EMAIL PROTECTED]> To: lyx-users@lists.lyx.org Date: Sun, 4 Jun 2006 13:16:56 +0200 Subject: Show entry type in References I found that LyX 1.4.1 (on Win) has the option document > settings... > bibliography > sectioned bibliography, so i can insert multiple bibtex generated bibliography and add section (or subsection) names by myself. There's some cons, though: - I have to define myself the "Bibliography" section name - I'm still not able to define the citation style as [Art1], [Art2] etc for articles, [Book1], [Book2] etc for books etc. Should I define a bst file by myself? Thanks for your support Diego From: Sara Stymne <[EMAIL PROTECTED]> To: lyx-users@lists.lyx.org Date: Thu, 18 May 2006 19:51:47 +0200 Subject: Re: Show entry type in References Hi! You might find an answer here: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=multbib /Sara Ares wrote: Hello everyone, I'm using LyX to compile a PhD thesis and a bibtex database for references, and I'm new to both. I would like to group the references according to entry type, and to show the entry type itself in the references. this would look like, for instance: ... References articles [Art1] article1 [Art2] article2 etc Books [Book1] book1 [Book2] book2 etc etc ... Is there anyone who knows how to do that? maybe using an appropriate bst file that does that?? Thanks for your support Diego -- Messaggio inoltrato -- From: Juergen Spitzmueller <[EMAIL PROTECTED]> To: lyx-users@lists.lyx.org Date: Sun, 4 Jun 2006 13:57:05 +0200 Subject: Re: Show entry type in References Ares wrote: I found that LyX 1.4.1 (on Win) has the option document > settings... > bibliography > sectioned bibliography, so i can insert multiple bibtex generated bibliography and add section (or subsection) names by myself. There's some cons, though: - I have to define myself the "Bibliography" section name What's the problem with that? Otherwise it wouldn't simply be possible to add your own bibliography section headings. The option "printheadings" (in Document->Settings->Class Options), however, changes the behaviour. - I'm still not able to define the citation style as [Art1], [Art2] etc for articles, [Book1], [Book2] etc for books etc. Should I define a bst file by myself? yes. I would probaly try to hack alpha.bst. (as an alternative, if you have a manageable number of citations, the package "splitbib" might help). Jürgen
Re: Show entry type in References
Ares wrote: > If I use the option Sectioned Bibliography, I cannot check the option "Add > bibliography to TOC" in the "BibTeX generated bibliography" dialog. Yes, because there isn't a heading to add. > What I did is to define the "Bibliography" section name as a Chapter* > (chapter title without numbering). Either this way, the Bibliography does > not appear in TOC. I also went to Document settings --> Numbering and TOC, > but it is not possible from here to change the behaviour of Chapter* since > Chapter* is not there at all! but there are Part* and Section*, so why not > Chapter* ? By the way, I noticed that even if I set Part* and Section* to > appear in TOC, they don't. What's wrong? is it a bug or maybe I don't get > the meaning of it all? The starred versions of the headings are _by definition_ excluded from the toc. So either add \addcontentsline{toc}{chapter}{Bibliography} in ERT below the heading, or use the KOMA-script classes, which provide \addchap (unnumbered headings that are included in the TOC). HTH, Jürgen
Show entry type in References
I would probaly try to hack alpha.bst. I'll try this. thanks Jürgen ...but now I have a new problem: I don't manage to get the Bibliography in the Table of Contents. If I use the option Sectioned Bibliography, I cannot check the option "Add bibliography to TOC" in the "BibTeX generated bibliography" dialog. What I did is to define the "Bibliography" section name as a Chapter* (chapter title without numbering). Either this way, the Bibliography does not appear in TOC. I also went to Document settings --> Numbering and TOC, but it is not possible from here to change the behaviour of Chapter* since Chapter* is not there at all! but there are Part* and Section*, so why not Chapter* ? By the way, I noticed that even if I set Part* and Section* to appear in TOC, they don't. What's wrong? is it a bug or maybe I don't get the meaning of it all? Thanks again for your support, Diego -- Messaggio inoltrato -- From: Ares <[EMAIL PROTECTED]> To: lyx-users@lists.lyx.org Date: Sun, 4 Jun 2006 13:16:56 +0200 Subject: Show entry type in References I found that LyX 1.4.1 (on Win) has the option document > settings... > bibliography > sectioned bibliography, so i can insert multiple bibtex generated bibliography and add section (or subsection) names by myself. There's some cons, though: - I have to define myself the "Bibliography" section name - I'm still not able to define the citation style as [Art1], [Art2] etc for articles, [Book1], [Book2] etc for books etc. Should I define a bst file by myself? Thanks for your support Diego From: Sara Stymne <[EMAIL PROTECTED]> To: lyx-users@lists.lyx.org Date: Thu, 18 May 2006 19:51:47 +0200 Subject: Re: Show entry type in References Hi! You might find an answer here: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=multbib /Sara Ares wrote: Hello everyone, I'm using LyX to compile a PhD thesis and a bibtex database for references, and I'm new to both. I would like to group the references according to entry type, and to show the entry type itself in the references. this would look like, for instance: ... References articles [Art1] article1 [Art2] article2 etc Books [Book1] book1 [Book2] book2 etc etc ... Is there anyone who knows how to do that? maybe using an appropriate bst file that does that?? Thanks for your support Diego -- Messaggio inoltrato -- From: Juergen Spitzmueller <[EMAIL PROTECTED]> To: lyx-users@lists.lyx.org Date: Sun, 4 Jun 2006 13:57:05 +0200 Subject: Re: Show entry type in References Ares wrote: I found that LyX 1.4.1 (on Win) has the option document > settings... > bibliography > sectioned bibliography, so i can insert multiple bibtex generated bibliography and add section (or subsection) names by myself. There's some cons, though: - I have to define myself the "Bibliography" section name What's the problem with that? Otherwise it wouldn't simply be possible to add your own bibliography section headings. The option "printheadings" (in Document->Settings->Class Options), however, changes the behaviour. - I'm still not able to define the citation style as [Art1], [Art2] etc for articles, [Book1], [Book2] etc for books etc. Should I define a bst file by myself? yes. I would probaly try to hack alpha.bst. (as an alternative, if you have a manageable number of citations, the package "splitbib" might help). Jürgen
Re: Show entry type in References
Ares wrote: > I found that LyX 1.4.1 (on Win) has the option document > settings... > > bibliography > sectioned bibliography, so i can insert multiple bibtex > generated bibliography and add section (or subsection) names by myself. > There's some cons, though: > - I have to define myself the "Bibliography" section name What's the problem with that? Otherwise it wouldn't simply be possible to add your own bibliography section headings. The option "printheadings" (in Document->Settings->Class Options), however, changes the behaviour. > - I'm still not able to define the citation style as [Art1], [Art2] etc > for articles, [Book1], [Book2] etc for books etc. Should I define a bst > file by myself? yes. I would probaly try to hack alpha.bst. (as an alternative, if you have a manageable number of citations, the package "splitbib" might help). Jürgen
Show entry type in References
I found that LyX 1.4.1 (on Win) has the option document > settings... > bibliography > sectioned bibliography, so i can insert multiple bibtex generated bibliography and add section (or subsection) names by myself. There's some cons, though: - I have to define myself the "Bibliography" section name - I'm still not able to define the citation style as [Art1], [Art2] etc for articles, [Book1], [Book2] etc for books etc. Should I define a bst file by myself? Thanks for your support Diego From: Sara Stymne <[EMAIL PROTECTED]> To: lyx-users@lists.lyx.org Date: Thu, 18 May 2006 19:51:47 +0200 Subject: Re: Show entry type in References Hi! You might find an answer here: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=multbib /Sara Ares wrote: Hello everyone, I'm using LyX to compile a PhD thesis and a bibtex database for references, and I'm new to both. I would like to group the references according to entry type, and to show the entry type itself in the references. this would look like, for instance: ... References articles [Art1] article1 [Art2] article2 etc Books [Book1] book1 [Book2] book2 etc etc ... Is there anyone who knows how to do that? maybe using an appropriate bst file that does that?? Thanks for your support Diego
Re: Show entry type in References
Hi! You might find an answer here: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=multbib /Sara Ares wrote: Hello everyone, I'm using LyX to compile a PhD thesis and a bibtex database for references, and I'm new to both. I would like to group the references according to entry type, and to show the entry type itself in the references. this would look like, for instance: ... References articles [Art1] article1 [Art2] article2 etc Books [Book1] book1 [Book2] book2 etc etc ... Is there anyone who knows how to do that? maybe using an appropriate bst file that does that?? Thanks for your support Diego
Show entry type in References
Hello everyone, I'm using LyX to compile a PhD thesis and a bibtex database for references, and I'm new to both. I would like to group the references according to entry type, and to show the entry type itself in the references. this would look like, for instance: ... References articles [Art1] article1 [Art2] article2 etc Books [Book1] book1 [Book2] book2 etc etc ... Is there anyone who knows how to do that? maybe using an appropriate bst file that does that?? Thanks for your support Diego