0

I believe I do not need an MWE for this question. I would like to add a word or a few to be part of the references of the type Misc or Online or URL - the types related to online resources. As some publishers prefer, the word "Online" or "on the Internet" and similar should be printed within such references in the list of references.

I did try to go through the biblatex manual, but was not able to figure out where exactly to intervene to get it done. I believe the users who are more proficient will be able to provide me some practical examples to get it done.

1
  • 1
    Hrmmm, I'm not really a fan of this. But there are a couple of styles that do this by default (style=ieee, and style=iso-numeric come to mind) if the entry is marked up correctly (usually as @online with a url and possibly urldate field). It can be done for most other styles as well, but how depends on the exact style and settings you use, how you mark up your .bib entries and the output you expect. This should be shown in an example document.
    – moewe
    Commented Jul 9 at 13:06

1 Answer 1

0

This might work:

\documentclass{article}
\usepackage[style=authoryear]{biblatex}

\renewbibmacro*{url+urldate}{%
  \printtext[online]{%
    [Online]\addspace
    \printfield{url}%
    \iffieldundef{urlyear}
      {}
      {\setunit*{\addspace}%
       \printurldate}}}

\addbibresource{references.bib}

\begin{document}

This is a test document that cites an online resource \cite{ctan}.

\printbibliography
\end{document}

And here you have references.bib file:

@online{ctan,
  author = {CTAN Team},
  title = {The Comprehensive TeX Archive Network},
  url = {https://www.ctan.org},
  urldate = {2022-01-01}
}

And this will be the output:

This is a test document that cites an online resource Team 2022.

References

Team, CTAN (2022). The Comprehensive TeX Archive Network. [Online] url: https://www.ctan.org (visited on 01/01/2022).

6
  • \printtext[online]{...} will usually not do anything useful unless one defines a \DeclareFieldFormat{online}{...}. Normally, you'd probably wrap the [Online] in a \printtext without optional arguments and wrap the \addspace in a \setunit, i.e. \printtext{[Online]}\setunit{\addspace}, though it would be even better to use a bibstring for the "online" bit.
    – moewe
    Commented Jul 11 at 9:15
  • Your example really resolves it, but there is one drawback: this syntax inserts the given word, e.g. "[Online]," in every type of bibliography item. So, not only within those which have a URL declared, but even the @Books or @Article. If you could come up with some remedy for that part, the solution would be complete. BTW, I did not entirely understand your hint about \DeclareFieldFormat{online}, but it perhaps might a path to confine this solution only to specified types of entries.
    – MSJ
    Commented Jul 11 at 12:23
  • @scd Please see my reply above (adding a comment here did not work so I posted an answer).
    – MSJ
    Commented Jul 11 at 12:24
  • @MSJ Please don't post non-answers. If the text is too long for a comment, you could add it to your question. Commented Jul 11 at 12:26
  • @samcarter_is_at_topanswers.xyz I know, but the page did not want to publish my comment even though it was showing I still had 300+ characters to type within it. I'd like to obey the rules, but in this case I could not post a comment to the specific answer.
    – MSJ
    Commented Jul 11 at 12:33

You must log in to answer this question.

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