3

My code:

\documentclass{book}

\bibliographystyle{sn-aps}

\begin{document}
\def\bibcommenthead{}
This is for test 

\nocite{*}

\bibliography{test}

\end{document}

Test.bib

@article{Hirt1974,
      author = "Hirt, C. W. and Amsden, A. A. and Cook, J. L.",
       title = "An arbitrary Lagrangian-Eulerian computing method for all flow speeds",   
       year = "1974",
       journal = "J. Comput. Phys.",
      volume = "14",
      number = "3",
       pages = "227--253"
}

@article{Liska2010,
      author = "Liska, R. and Shashkov, M. and Vachal, P. and Wendroff, B. and Author, A. B. and Author, B. B. and Author, C. C.",
       title = "Optimization-based synchronized flux-corrected conservative interpolation (remapping) of mass and momentum for arbitrary {L}agrangian-{E}ulerian methods",
        year = "2010",
     journal = "J. Comput. Phys.",
      volume = "229",
      number = "5",
       pages = "1467--1497"
}

Current output as:

enter image description here

But the expected output should be as (e.g., end period should come every entry's end, and space should come between initials, etc.):

enter image description here

Please suggest how to achieve it, also it is helpful that anyone advise how to modify the .bst file as I'm entirely new to modify .bst file...

Advance thanks...

Else, can anyone suggest which .bst file suits for the required output? please...

3
  • The "easy" way to make a custom .bst (note the quotes) is take two kilograms of patience and run tex makebst. Alternatively , you could try to switch to biblatex that allow a "easier" (note the quotes) customization without dealing with .bst files.
    – Fran
    Commented Aug 16, 2022 at 17:12
  • The editions you say you need are not so difficult to do, but it takes some effort to find which FUNCTION inside the .bst must be edited. Please, could you confirm if the sn-aps.bst is the same from this link? If it is, I'll take a look inside the file and write an answer with the editions.
    – FHZ
    Commented Aug 17, 2022 at 18:55
  • 1
    @FHZ Yes, exactly, I also downloaded from the same link ... Much thanks for your kind words...
    – GowriSaro
    Commented Aug 18, 2022 at 4:35

1 Answer 1

3

Preparation

The following files are the ones I used to test and edit the sn-aps.bst file from this Overleaf link. The bst file has 1531 lines. I won't copy it here, I'll constantly refer to its lines.

MWE

\documentclass{book}
\bibliographystyle{sn-aps}
\def\bibcommenthead{}
\begin{document}
\nocite{*}
\bibliography{test.bib}
\end{document}

bib file

Please, notice I added a book entry and also the url field to all entries.

@article{Hirt1974,
    author    = "Hirt, C. W. and Amsden, A. A. and Cook, J. L.",
    title     = "An arbitrary Lagrangian-Eulerian computing method for all flow speeds",
    year      = "1974",
    journal   = "J. Comput. Phys.",
    volume    = "14",
    number    = "3",
    pages     = "227--253",
    url       = "url"
}
@article{Liska2010,
    author    = "Liska, R. and Shashkov, M. and Vachal, P. and Wendroff, B. and Author, A. B. and Author, B. B. and Author, C. C.",
    title     = "Optimization-based synchronized flux-corrected conservative interpolation (remapping) of mass and momentum for arbitrary {L}agrangian-{E}ulerian methods",
    year      = "2010",
    journal   = "J. Comput. Phys.",
    volume    = "229",
    number    = "5",
    pages     = "1467--1497",
    url       = "url"
}
@book{Book1974,
    author    = "Book, C. W. and Buch, A. A. and Livro, J. L.",
    title     = "The title of the book",
    year      = "2022",
    publisher = "J. Comput. Phys.",
    pages     = "100",
    url       = "url"
}

Let's edit the BeaST

How to proceed when you must edit a bst.

  1. Keep calm and Tame The BeaST.
  2. Read about RPN Reverse Polish Notation.
  3. Create a copy of the original bst.
  4. Don't be afraid of inserting any nonsense set of letters to find out what does what.

That said. Let's proceed to how the bst works. For quick reference, check session 15 The structure of a .bst file in the Tame the BeaST documentation.

At the very end there will be a set of instructions with READ, EXECUTE, ITERATE and some others. They are the ones that actually "do the work", it means, this is the section that calls whatever is behind the bst file, for our porpoises here, the FUNCTIONs.

FUNCTIONs are often related to the ENTRYs, but not strictly related. In this example, we'll look for FUNCTION {article}, there is an ENTRY for article, it means this bst recognizes article (article is the most common, for example, phdthesis is not that common).

In sn-aps.bst, the FUNCTION {article} is at line 1117. Its second instruction reads format.authors "author" output.check.

FUNCTION {format.authors} is at line 495, but it doesn't do much, it calls another function to format author's names.

FUNCTION {format.names} is at line 450 (Are you realizing we are always going backwards? Each function can only depend on a previous defined function.). Here we can recognize some interesting names such as duplicate, nameptr (name pointer), format.name at line 461, and a very important ", " * at line 467 and "," * -- these are the commas between names and the comma before the last name.

For example, I edited ", AA " * ", BB" * and the results were


enter image description here


Moving on. Still on this function, as we found the comma insertion code, the point for abbreviations must be before line 467. That's exactly at line 460 "{f{.}.~}{vv~}{ll}{, jj}" the one before format.name.

For our first test, let's be silly and write: "{f{. +}.~}{vv~}{ll}{, jj}",


enter image description here


For our real porpoise, let's just add and space: "{f{. }.~}{vv~}{ll}{, jj}". If you need a different size space, you may code it there.


enter image description here


Quick Note: Remember of compiling latex and BibTeX in order to update results.

Next issue, the period at the end of each reference block.

Once again, let's focus on the FUNCTION {article}. At line 1130 there is: format.date "year" output.check. It is fair enough to guess this instruction writes (YYYY) at the reference block. And more important, that's not the last instruction of this FUNCTION. Without loss of generality, let me add url = "url" to each of your bib entries.

Now the result is:


enter image description here


That's very interesting. I shall not edit format.date, I shall add an instruction to write a period at the end of the whole FUNCTION {article} block. The last instruction is fin.entry, but look, there is new.block between each type of field inserted. If I comment % new.block at line 1130, we'll get a comma instead of a period between (YYYY) and URL.


enter image description here


So I have a few options:

  1. Change fin.entry for a new.block, but it would imply in doing it for each FUNCTION that formats entries, I should repeat the process for FUNCTION {book} (line 1148), FUNCTION {booklet} (line 1184), etc. It seems to be too much work for any lazy person like me.
  2. Why not editing FUNCTION {fin.entry} at line 123?
  • Editing line 124: { "\!\!." * duplicate$ empty$. It does correctly the period of your first reference block, but does wrong the second. Where \! is a negative space. Not elegant, not totally correct.

enter image description here


  • Editing line 124: { add.period$ duplicate$ empty$. It keeps the previous problem.

What is actually going on? There is an instruction named add.blank at line 1143, which is used only for FUNCTION {article}, it adds some white space that will only be needed if format.primaryClass is used. I don't feel comfortable adding negative spaces, so I prefer to comment add.blank and edit FUNCTION {fin.entry} because it'll be applied for every other type of bib entry recognized in this bst file.

Therefore. Let's comment add.blank at line 1143, and change line 124 into: { add.period$ duplicate$ empty$ or { "." empty$, as both have the same effect for FUNCTION {fin.entry}.

In order to have a more complete example, I added a book entry in the bib file in order to test the final period. It works like a charm.


enter image description here


Notes

About other possible editing you might desire.

If you need to change the sequence which contents from fields are displaced, change the order at the respective FUNCTION, but you shall not take it as a standard procedure.

Correcting this or that small detail, such as a comma, an italic, a bold number, etc. is acceptable since whoever created the style might have missed it. Changing the conjunction and for your local language is also a very acceptable edition.

Changing the whole sequence in which fields are presented is quite odd and basically tell us the style you are using is not the style you should be using. If this is the case, you shall look for the correct BibTeX style that actually creates the style you need. If there is no one, then (1) edit the closest bst as you need, or (2) take "two kilograms of patience and run makebst".

About this answer.

I honestly hope this answer helps you and future people coming into this forum to understand how to perform small editions into a bst file, and how to think and what to look for while hunting for the correct place to change something.

Editing bst files is always complicated, it is a mess, it takes time to understand the work of someone else. I learned it the hard way in 2015, because I needed a style given by a standard whose closest bst was out of dated and no one was in charge of its maintenance, and no one I had contact knew how to edit bst files.

4
  • 1
    First of all, I should say Much thanks for your kind help (your definitions are very neat and easy to understand clearly) on my request, I'll check all the process step by step, and will confirm you by tomorrow...My apology for the late in reply...
    – GowriSaro
    Commented Aug 18, 2022 at 14:15
  • 2
    Clean and Very neat explanation ... +1
    – MadyYuvi
    Commented Aug 18, 2022 at 14:59
  • 1
    Sorry for the late reply, I was sick for the past few days... Its working perfect....Thanks a lot....
    – GowriSaro
    Commented Sep 2, 2022 at 5:16
  • @GowriSaro, Nice!
    – FHZ
    Commented Sep 2, 2022 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .