BibTeX, biblatex and biberSubstitute ':' with ',' once in BibTeX Output

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

Substitute ':' with ',' once in BibTeX Output

Post by alex.blackbit »

Hi,

I have a modified plain.bst (@book template) where i have the demand for:

Code: Select all

address: publisher
For now let's say the rest of the .bst stays the same.
Since (at least i believe that) the ',' is the seperator character in the bibtex output, which is produced by the "output"->"output.nonnull" functions, and I did not want to change this seperation character generally I decided to duplicate these two functions with different names, substitute the ',' for the ',' in the clone and use that.
Unfortunately the result does not show a ':' but still a ','. Obviously I get something wrong here.

Here is the modification i made:

Code: Select all

--- plain.bst.backup	2011-09-16 16:32:21.979569012 +0200
+++ sozsbg.bst	2011-09-27 18:11:47.969482722 +0200
@@ -46,6 +46,34 @@
 
 STRINGS { s t }
 
+FUNCTION {outputcomma.nonnull}
+{ 's :=
+  output.state mid.sentence =
+    { ": " * write$ }
+    { output.state after.block =
+        { add.period$ write$
+          newline$
+          "\newblock " write$
+        }
+        { output.state before.all =
+            'write$
+            { add.period$ " " * write$ }
+          if$
+        }
+      if$
+      mid.sentence 'output.state :=
+    }
+  if$
+  s
+}
+
+FUNCTION {outputcomma}
+{ duplicate$ empty$
+    'pop$
+    'outputcomma.nonnull
+  if$
+}
+
 FUNCTION {output.nonnull}
 { 's :=
   output.state mid.sentence =
@@ -567,21 +595,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
+      address outputcomma
       publisher "publisher" output.check
-      address output
     }
     { 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 line, that's an unrelated change.

Any hints on what i could do to achieve my goal are very much appreciated.
Thanks in advance!

Kind regards,
-Alex
Attachments
foogoo.bib
(1.83 KiB) Downloaded 307 times
document.tex
(157 Bytes) Downloaded 322 times
Last edited by alex.blackbit on Mon Oct 03, 2011 9:06 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

alex.blackbit
Posts: 13
Joined: Tue Aug 26, 2008 9:01 pm

Substitute ':' with ',' once in BibTeX Output

Post by alex.blackbit »

I solved this issue myself (with kind help from a very smart friend) by adding a "separator character" parameter to a clone of the output.nonnull and output.check functions and using those.
Here is a unified diff as reference.

Code: Select all

--- plain.bst	2011-09-16 16:32:21.979569012 +0200
+++ sozsbg.bst	2011-10-03 21:01:02.000000000 +0200
@@ -44,12 +44,13 @@
   #3 'after.block :=
 }
 
-STRINGS { s t }
+STRINGS { s t separator }
 
-FUNCTION {output.nonnull}
-{ 's :=
+FUNCTION {output.nonnull*}
+{ 'separator :=
+  's :=
   output.state mid.sentence =
-    { ", " * write$ }
+    { separator * write$ }
     { output.state after.block =
         { add.period$ write$
           newline$
@@ -67,6 +68,9 @@
   s
 }
 
+FUNCTION {output.nonnull}
+{ ", " output.nonnull* }
+
 FUNCTION {output}
 { duplicate$ empty$
     'pop$
@@ -74,14 +78,18 @@
   if$
 }
 
-FUNCTION {output.check}
-{ 't :=
+FUNCTION {output.check*}
+{ 'separator :=
+  't :=
   duplicate$ empty$
     { pop$ "empty " t * " in " * cite$ * warning$ }
-    'output.nonnull
+    { separator output.nonnull* }
   if$
 }
 
+FUNCTION {output.check}
+{ ", " output.check* }
+
 FUNCTION {output.bibitem}
 { newline$
   "\bibitem{" write$
@@ -573,7 +581,7 @@
       new.block
       format.number.series output
       new.sentence
-      publisher "publisher" output.check
+      publisher "publisher" ": " output.check*
       address output
     }
     { new.block
please excuse the moving of the publisher and the year, these are unrelated changes.
Post Reply