BibTeX, biblatex and biberUsing Only first Page in Page Range for Bibliography

Information and discussion about BiBTeX - the bibliography tool for LaTeX documents.
Post Reply
corrado33
Posts: 2
Joined: Sun Feb 16, 2014 11:48 pm

Using Only first Page in Page Range for Bibliography

Post by corrado33 »

Hi all,

new LaTeX/BibTeX user here. I've downloaded Bib-it to create my own bibliography style file (*.bst) and it works great! Unfortunately, some of the journals I publish in are obscure and don't have standard styles that I can just download. (Either that, or I'm terrible at searching.)

Anyway, one particular style does not use the page range itself, it only uses the first page given in the range. So, for example, if the page range was 201-205, the citation (in the bibliography) would just have "p. 201" or something similar, where as most journals would have "p. 201-205". In the database file (*.bib) export by any of my reference managers, under the "pages" heading, it has 201-205, so for BibTeX to be able to use only the "first" page it'd have to cut that field in half essentially.

I have no idea how to do this. I downloaded Bib-it because I took one look at the bibliography style files, scrolled for about five minutes to get to the bottom, said "heck no" and found a tool to do it for me.

Now, there are a few ways I could easily get around it. I could write a little bash script that would erase the "-205" and similar from any line that started out with the "pages" heading. That's easy enough, but not everyone has access to bash. I could also play around with the BibTeX output format in Bookends (my reference manager) and probably get it to only output the first page. But again, this isn't universal. If I were to send this style file to my professor or the internet, it has to work 100%.

Now, does anyone know how I'd do this, or, if you have a format that also only uses the first page in the page range, I could take a look at it and copy it over, however I have not found one.

Either way, if you could help me out that would be great!

EDIT: I've searched for a good hour to an answer to this subject, I've only found one result on G00gle, however that link is currently down, so I've found no help whatsoever.

EDIT 2: I attached a ZIP file with a sample .bib, .tex, and .bst. Just run the .tex through latex, then bibtex, then latex a few times and you should have a working example. I think I also included the .save from Bib-it.

EDIT 3 ... Note: This isn't a problem, everything works as advertised currently, I'm asking how to do something that I have no idea where to start, and providing a working environment to do it with.

EDIT 4: As I suspected, it has something to do with the format.pages.whatever function. The format phjcp uses only the first page, and has a few functions that I bet I could copy and paste over, I'm just not sure where.
Attachments
ECS Format.zip
(4.74 KiB) Downloaded 244 times
Last edited by localghost on Mon Feb 17, 2014 11:02 am, 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

corrado33
Posts: 2
Joined: Sun Feb 16, 2014 11:48 pm

Using Only first Page in Page Range for Bibliography

Post by corrado33 »

Well everyone. I've done it. I feel like I've accomplished something amazing. I'm so happy that tears came to my eyes (I'm not joking).

I finally figured out how run latex commands from the command line. I was looking forever for a command line INSIDE one of the latex programs (like TexShop) where I could simply type "latex makebst" or similar, but I couldn't find anything.

I eventually navigated to /usr/texbin/ in terminal (I'm on a mac) and ran the program that way. "./latex makebst".

After answering 1001 questions, it gave me a .dbj batch file which I ran by typing "./latex NameOfFile.dbj"

I guess I could add /usr/texbin to PATH, then this would be a bit easier, as I had to run both of those commands as root because /usr/texbin isn't generally a folder where you'd want to stick random files into.

Anyway, I didn't get it right the first time but I went back and edited the .dbj file. Basically, to edit that file is pretty simple. From what I've gathered, "%" means it's a comment. If all of the options for a particular question are commented (meaning they have % before them) then it'll choose the default answer. If one of the options does not have an % before it, that'll be the choice it uses. So, you can edit the file just by deleting and adding %'s to places. (If you have no idea what I'm talking about, just go look at the .dbj file, it'll be immediately obvious to you.)

Anyway, I'll post the final .bst file here in a few minutes, I just want to make sure it works with other things as well first.

Well, as it turns out it wasn't perfect. The book citaitons did not include page numbers in the references section. After making a few new functions, typing Swap$ a few times in random places... it... uh... works. Don't ask me HOW it works... but it does. This programming language... I swear...


Alas, I still have one problem though, I don't know how to make the in-text citations use parentheses instead of brackets. Now, if my .bst file was compatible with natbib, I could just use the round option, however that is not the case. Technically I could literally type "(/citen{whatever1999}) and it works, but that's... annoying. (Notice the "citen" instead of just "cite".) I'll go look into what makes a .bst file compatible with natbib, then I'll come back.

FINAL EDIT: Well, I give up, there's no way I'm going to be able to make my .bst file compatible with natbib. They're just too different. I've read online that using makebst will make natbib compatible .bst files, but it didn't work in my case.
Attachments
ECS.bst
Final BST file which works.
(23.18 KiB) Downloaded 413 times
Post Reply