BibTeX, biblatex and biberDate in Parentheses with "plain" BibTeX style

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
alex.blackbit
Posts: 13
Joined: Tue Aug 26, 2008 9:01 pm

Date in Parentheses with "plain" BibTeX style

Post by alex.blackbit »

Hi,

I am in the process of modifying plain.bst for my needs.
The change I want to achieve is to have the date of a publication in parentheses.
I read the available documentation and some random websites, but obviously I don't get the concept of this "unnamed language".

I tried with the following patch to plain.bst:

Code: Select all

$ diff -u plain.bst.backup sozsbg.bst 
--- plain.bst.backup	2011-09-16 16:32:21.979569012 +0200
+++ sozsbg.bst	2011-09-27 13:50:58.339572761 +0200
@@ -272,7 +272,7 @@
       if$
     }
     { month empty$
-        'year
+        { " (" * year * ")" }
         { month " " * year * }
       if$
     }
$
This does not what I want. The ')' comes after the ','.

It would be very nice if someone who understands bibtex .bst files better than me could correct my patch, to have the year of a publication in parentheses.

Thanks a lot in advance.

Example .tex, .bib files are attached.
I couldn't upload the .bst file ("The extension bst is not allowed").
In case anyone wants a complete .bst file in addition to the patch, I'll post it inline.
Attachments
foogoo.bib
(1.8 KiB) Downloaded 407 times
document.tex
(157 Bytes) Downloaded 354 times
Last edited by alex.blackbit on Tue Sep 27, 2011 6:17 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Date in Parentheses with "plain" BibTeX style

Post by josephwright »

In the first instance, try

Code: Select all

{ "(" year * ")" * }
BibTeX uses a stack language, which means you first add '(' and the year to the stack, then concatenate them, then add ')' to the stack and then concatenate that with the year part.
Joseph Wright
alex.blackbit
Posts: 13
Joined: Tue Aug 26, 2008 9:01 pm

Date in Parentheses with "plain" BibTeX style

Post by alex.blackbit »

that works like a charm.
thanks a lot for your time.

the next task for me will be to have the following for a book:

Code: Select all

address: publisher
instead of

Code: Select all

publisher, address
i already reversed the order, that was easy, i now have

Code: Select all

address, publisher
afaics the ',' is caused by the output function which calls output.nonnull.
any idea on what i can do to get

Code: Select all

address: publisher

Code: Select all

$ diff -u plain.bst.backup sozsbg.bst
--- plain.bst.backup	2011-09-16 16:32:21.979569012 +0200
+++ sozsbg.bst	2011-09-27 17:04:03.597708012 +0200
@@ -567,21 +567,21 @@
     }
   if$
   new.block
+  format.date "year" output.check
   format.btitle "title" output.check
   crossref missing$
     { format.bvolume output
       new.block
       format.number.series output
       new.sentence
-      publisher "publisher" output.check
       address output
+      publisher "publisher" output.check
     }
     { new.block
       format.book.crossref output.nonnull
     }
   if$
   format.edition output
-  format.date "year" output.check
   new.block
   note output
   fin.entry
$
please ignore the moved "year", that's an unrelated change.

Again, thanks in advance.
The help is very much appreciated.
Post Reply