2

I'm having a problem integrating asmems4.bst supplied by my department for my thesis. Several of my references are websites and asmems4.bst doesn't output URLs in my bibliography. From an answer to another question, I modified the .bst file as below, but with worse results. When I include format.url output into my code, the compiled PDF no longer shows the title field of the webpage, only the author and date fields and no contents of the url field.

(No format.url)

[6] Statista, 2019. Electricity prices for households in Spain from 2010 to 2018, semi-annually (in euro cents per kilowatt-hour).

vs.

(With format.url)

[6] Statista, 2019.

This is the function I added:

FUNCTION {format.url}
{ url duplicate$ empty$
    { pop$ "" }
    { "\url{" swap$ * "}" * 
      urldate duplicate$ empty$
        { pop$ }
        { " (Accessed: "  swap$ * ")" * * }
      if$
    }
  if$
}

Then I modified the function misc, which processes entries of type @misc:

FUNCTION {misc}
{ output.bibitem
  format.authors output
  author format.key output              % ASME puts year
  output.year.check                     % after author(s)
  title howpublished new.block.checkb
  format.title output
  howpublished new.block.checka
  howpublished output
  format.date output
  new.block
  note output
%I added this format line
  format.url output
  fin.entry
  empty.misc.check
}

Any suggestions?

UPDATE:

I found another question that was similar and have changed some things. I have been using Mendeley to auto-populate my refs.bib but apparently the access date doesn't make it through the synchronization from Mendeley to Overleaf. So, I have created a 2nd web.bib file for my website references.

In addition to that, I have included url and urldate in the ENTRY of asmems4.bst. Using the same format.url function as included above, I now have a large gap between the website reference and the next reference, but no url or accessed date. In the picture below, references [6] and [7] are both online references with large gaps following them whereas [5] and [8] are journal articles with half the space.

Gaps between website references with no URLs

  • Welcome to TeX.SE. Did you check that the bst file is set up to recognize a field called url? Is the file asmems4.bst available online? – Mico Apr 24 at 20:41
  • asmes4.bst is relatively old (e.g., from before online resources were common). I can't see from your code whether urldate has been defined but you might test with and without in case your { pop$ } line should be {pop$ ""}. – John Apr 25 at 12:07
  • Here is a link to 'asmems4.bst' on GitHub. gist.github.com/anamewing/33860ec263fe5a165a8d904c32c4f6e7 – Aaron Bame Apr 25 at 13:31
  • @John I'm using a reference manager (Mendeley) to auto-populate my .bib file and it seems that it isn't including the accessed date in the misc items in my refs.bib. I tried commenting out sections of my format.url with no success in my References section. FUNCTION {format.url} { url duplicate$ empty$ { pop$ "" } { "\url{" swap$ * "}" * % urldate duplicate$ empty$ { pop$ ""} % { " (Accessed: " swap$ * ")" * * } if$ } if$ } – Aaron Bame Apr 25 at 13:37
  • Hi Aaron, There are many cross-dependencies among the functions in a bst file, so it's not always obvious how one problem leads to another. I just pasted your original format.url and misc edits into my copy of asmems4.bst and they seem to work. Since I want to post the codes, I'm going to put it into an answer, although it's more of a comment. – John Apr 26 at 0:47
1

Aaron -- This continues my comment above, with code.

I added your FUNCTION {format.url} and your edit to the FUNCTION {misc} to my copy of amsems4.bst, using the following sample file:

\documentclass[11pt]{article}

\usepackage{hyperref}

\begin{document}

\nocite{*}
\bibliographystyle{asmems4}
\bibliography{asmejour-sample}

\end{document}  

The bibliography I have is a long list of entries, not at all set up for this particular .bst, but here are two examples:

@misc{mpl,
    title={mpl colormaps},
    author={St{\'e}fan {van der Walt} and Nathaniel Smith},
    URL = {http://bids.github.io/colormap/},
    urldate = {Aug. 26, 2018},
    year = 2015,
    organization = {GitHub},
    address = {San Francisco, CA},
    month = {September},
}

@misc{GSL,
    title    =  {{GNU} Scientific Library Release 2.4},
    URL = {https://www.gnu.org/software/gsl/},
   author = {Mark Galassi 
    and Jim Davies
    and James Theiler
    and Brian Gough
    and Gerard Jungman
    and Patrick Alken
    and Michael Booth
    and Fabrice Rossi
    and Rhys Ulerich},
   year = 2017,
   organization = {Free Software Foundation},
   address = {Boston, MA},
   urldate = {Dec. 12, 2018},
   month = {June},
}

and they come out like this: enter image description here

Note that I have hyperref loaded so the hyperlinks are set, as indicated by the thin cyan boxes around the urls.

Hope this helps.

  • It still isn't working for me... I tried copy and pasting your GitHub reference into my .bib, but there still is no URL in the reference. Does the order matter in the ENTRY section? As in, should the order things show up in my .bib entries match the order they show up in the .bst ENTRY section? That's the last thing I can think of aside from trying a different compiling environment. – Aaron Bame Apr 26 at 13:27
  • Order does not matter for the .bib entries. There's nothing wrong with the two pieces of code you posted, so far as I can see, but it could be something else in the specific .bst file you are running. Why don't you open the .bbl file that you generated and see whether it matched this: \bibitem{GSL} Galassi, M., Davies, J., Theiler, J., Gough, B., Jungman, G., Alken, P., Booth, M., Rossi, F., and Ulerich, R., 2017. \newblock {GNU} scientific library release 2.4, June. \newblock \url{https://www.gnu.org/software/gsl/} (Accessed: Dec. 12, 2018). ' Do you have the \newblock for the url? – John Apr 26 at 13:35
  • I'm not getting the \newblock. This is what I get for your mpl reference: \bibitem{mpl} {van der Walt}, S., and Smith, N., 2015. \newblock mpl colormaps, September. Does that mean I need to create a new.block for the url? I'm not entirely sure how to do that. – Aaron Bame Apr 26 at 13:45
  • The newblock is created automatically by bibtex. You should not have to do anything. This looks a lot like Overleaf is running the unmodified version of asmems4.bst. Have you checked that your edited bst file is in the same directory from which your .tex file is being processed? You could even go into the .bst and introduce some bad code (e.g., delete the @misc section entirely) to see whether that causes an error message -- that would certainly tell you whether your edits were being seen. You could also move your work to a different tex platform such as TexLive. – John Apr 26 at 14:44
  • You could also try the asmejour.bst style in CTAN - it supports URLs in ASME format (hyperlinked to journal title). – John Apr 29 at 16:06
0

I never did figure out how to make the functions work, but I did find a solution that worked for me. Because Mendeley Online does not properly export web references, I had to create a new .bib file just for my web references. When I did that, I just added the URL and accessed date to howpublished={<url>~(Accessed on dd mo, yyyy)} and that did the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.