# [Tex/LaTex] Modifying plainnat.bst to show references in a speficic format

bibtexnatbib

I am trying to modify "plainnat.bst" to format the references as seen in the figure below, to comply to the specifications of a congress known as CILAMCE. Their template for Latex does not include any .bst files, showing an example bibliography written in normal LateX code instead.

I created a copy of the original "plainnat.bst" file and am editing a new "myplainnat.bst" file. So far I have successfully modified the output names by changing everything that was '{ff }{vv }{ll }{jj }' to '{vv~}{ll,}{ f.}' as well as changing every " and " to " \& ". The citations when using \cite or \citep output as desired. The references are shown in alphabetical order, as desired.

Now, I am having an extremely difficult time in: 1- putting all reference blocks in the order shown on the figure above; 2- customizing volume to vol., number to n., page to p. and pages to pp.; 3- removing the blank space on all of the lines after the first line of a reference.

Furthermore, I am not sure if this is altered in the .bst file, but I would also like to maintain my bibliography page in my previously defined fancy settings, as well as change the title from "Bibliography" to "REFERENCES" with the same font as the titles of the sections.

I tried using "latex makebst" in command prompt several times unsuccessfully, but any tips on solving this issue are very much appreciated.

Thank you.

PS.: Does anybody know a user-friendly .bst programming guide? I found one called "Tame the BeaST" and it helped me to modify the reference names, but not much else.

# Introduction

To solve my poblem I first tried following Mico's suggestion in generating my desired .bst file using makebst. The generated file wasn't exactly what I wanted. After fiddling with it for a while I was finally able to find a good solution. Instead of just finishing this question, I decided to write what I did below, in case anyone has a similar problem and finds this helpful.

# My solution

## 1- Makebst

In Windows, enter the Command Prompt and write

latex makebst


Answer the questions to the best of your knowledge. What you do not know just press Enter and the default option will be chosen for you. For beginners (such as myself), I recommend keeping the default Master file (first required input). Then write a name for your personal .bst file (eg. 'mybibstyle').

I will not go into much detail here. Google is your friend on how to configure the options correctly. I did most of them by trial and error. Plus, I am certainly not the most qualified person to explain what exactly to choose in makebst and, ultimately, I wasn't able to get what I wanted with makebst alone.

In short, I chose an author-year style of citations and enabled natbib support, which means that I have to write

\usepackage{natbib}


as one of the preambles in my .tex file.

After generating the .bst file, copy it to the folder where your .tex file is and before adding your bibliography, write:

\bibliographystyle{mybibstyle}


This section is important for me to explain my solution, because almost every function in the .bst file I used to fix my references were done by the makebst program.

## 2- Editing the resulting .bst file

In my question, I wrote 3 things I wanted to solve:

1. Putting all reference blocks in the order shown on the figure;
2. Customizing volume to vol., number to n., page to p. and pages to pp.;
3. Removing the blank space on all of the lines after the first line of a reference.

I will explain how I solved the above problems in descending order:

### 3. Removing the blank space on all of the lines...

I didn't remove it. After verifying the written requirements for the references, the template actually specifies that they have to have an indentation of 0.75 cm (close enough to the default indentation) and that the first line should be the same as the page's margin, which means I didn't have to change anything.

### 2. Customizing volume to vol., number to n., page to p. and pages to pp.

In the generated .bst file, there will be the following functions (or something like what is written below):

FUNCTION {bbl.volume}
{ "volume" }
FUNCTION {bbl.nr}
{ "no." }
FUNCTION {bbl.pages}
{ "pages" }
FUNCTION {bbl.page}
{ "page" }


To get what I wanted, simply change them to

FUNCTION {bbl.volume}
{ "vol." }
FUNCTION {bbl.nr}
{ "n." }
FUNCTION {bbl.pages}
{ "pp." }
FUNCTION {bbl.page}
{ "p." }


### 1. Putting all reference blocks in the order shown on the figure

This was the toughest problem to solve. Small rant: I cannot for the life of me understand how someone thought it was a good idea to create a code written using Reverse Polish Notation (RPN).

Anyway, the makebst program created a .bst file in which the author names are written as needed and the year is written after the authors. But there were certain periods missing in the reference, 'inproceedings' and 'inbook' weren't being output with the orignal book's name and the publisher was being written with the publishing location. I had to change each BibTex entry type separately and the order in which each information appeared.

I was considering going through each modification I made, but that would be messy and take quite a while. Instead, I will show an example of a before and after reference from an inbook BibTex entry. After understanding (or accepting) the modifications I made, one can probably change other entries alone.

I will use the following BibTex entry as an example:

@inbook{Ramm1981,
pages = {63--89},
title     = {Strategies for Tracing the Nonlinear Response Near Limit Points},
publisher = {Springer-Verlag},
year      = {1981},
author    = {E Ramm},
editor    = {Wunderlich, W. and Stein, E. and Bathe, K. J.},
address   = {Berlin, Heidelberg},
booktitle = {Nonlinear Finite Element Analysis in Structural Mechanics},
doi       = {10.1007/978-3-642-81589-8_5},
isbn      = {978-3-642-81589-8},
url       = {https://doi.org/10.1007/978-3-642-81589-8_5},
}


The resulting reference output by the .bst file generated using makebst was then modified as shown in "2. Customizing volume to vol. ..." and the reference output is shown below.

The code in the .bst file for a inbook type reference was

FUNCTION {inbook}
{ output.bibitem
author empty${ format.editors "author and editor" output.check editor format.key output } { format.authors output.nonnull crossref missing$
{ "author and editor" editor either.or.check }
'skip$if$
}
if$format.date "year" output.check date.block format.btitle "title" output.check crossref missing$
{
format.bvolume output
format.chapter.pages "chapter and pages" output.check
new.sentence
format.number.series output
}
{
format.chapter.pages "chapter and pages" output.check
new.sentence
format.book.crossref output.nonnull
}
if$format.edition output format.pages "pages" output.check format.note output fin.entry }  First I created an extra function before any of the reference types: FUNCTION {format.publisher} { publisher }  so I could add the publisher without the address. I then modified the inbook function to the following: FUNCTION {inbook} { output.bibitem author empty$
{ format.editors "author and editor" output.check
editor format.key output
}
{ format.authors output.nonnull
crossref missing${ "author and editor" editor either.or.check } 'skip$
if$} if$
format.date "year" output.check
date.block
format.title "title" output.check

%%%% ADDED THIS %%%%
new.sentence                              % Finishes last block with a period
format.editors output                     % Outputs editors
word.in swap$* % Adds an "in" before the editors format.booktitle "title" output.check % Add book title %%%%%%%%%%%%%%%%%%%% crossref missing$
{
format.bvolume output
format.chapter.pages "chapter and pages" output.check
new.sentence
format.number.series output
}
{
format.chapter.pages "chapter and pages" output.check
new.sentence
format.book.crossref output.nonnull
}
if\$

%  format.edition output % I don't need this

format.pages "pages" output.check

%%%% ADDED THIS AS WELL %%%%
new.sentence                   % end last reference block with period
format.publisher output        % output publisher
%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%  format.note output % I don't need this

fin.entry
}


By writing the above modifications I had the desired result shown in the figure below:

Note, however, that I didn't even touch on the crossreferencing part of the code, because it was not necessary for me to do so and because, if I were to try to do so, I would need another few hours wasted trying to understand the RPN method of coding.

## 3- Last difficulties

I fixed my fancy header and title problems by writing

\renewcommand{\bibsection}{\subsection*{REFERENCES}}


before defining the bibliography style and inserting the bibliography, as done by Golar Ramblar in the last answer in a certain TSE Question, who gives credits to a forum for his answer (latex dot org/forum/viewtopic.php?t=4089).

Note: I do not have enough reputation points to show all of the links appropriately.

# Last remarks

Could some LateX guru please create a ".noobbst" file for the bibliography styles, in which RPN isn't used? RPN coding just seems to extremely overcomplicate everything. Either that or make an inteligent "makebst" code which can get a user defined sample reference written in simple LateX and generate an appropriate .bst file. Cheers.