1

Following on from this question, I want j.a.'s to appear thus:

Biernacki, P. and Waldorf, D. (1981). “Snowball sampling: Problems and techniques
of chain referral sampling”, Sociological methods & research
10.2, pp. 141–163.

which moewe's fabulous solution does (getting rid of 'In:'):

\renewbibmacro*{in:}{%
  \setunit{\addcomma\space}%
  \ifentrytype{article}
    {}
    {\printtext{%
       \bibstring{in}\intitlepunct}}}

BUT at the same time I want incollections to appear as:

Froestad, J., Shearing, C., and Van der Merwe, M. (2015) ‘Criminology: Re-
Imagining Security and Risk.’, in Bourbeau, P. (ed) Security: Dialogue across
Disciplines. Cambridge: Cambridge University Press., pp. 177–195.

but the ', in' appears as ' In:'. So I want to add a comma before, lowercase the I and remove the colon. I have tried repeating similar code to moewe's answer but I cannot get it to work: only the last renewbibmacro does anything. TIA!!

schoon
  • 133
  • 2
    Please show us a full example (and MWE/MWEB) not just snippets. And include the two example entries as .bib entries. – moewe Jul 03 '18 at 15:50
  • Because there is no MWE I can't say for sure yet, but it seems to me that the title field of the @incollection reads title = {Criminology: Re-Imagining Security and Risk.}, with a full stop at the end. That confuses biblatex's punctuation tracker. Remove it and the comma should appear as desired. – moewe Jul 03 '18 at 15:54
  • BTW: Is there any reason why you copied the code snippet with changed indentation? I noticed that in another question (https://tex.stackexchange.com/q/439086/35864) a few minutes ago. I normally try to use readable indentation in my answers, and while there are several styles of indentation and you need not agree with my choice I feel that the indentation in your question is just arbitrary and makes the whole thing much harder to read. – moewe Jul 03 '18 at 15:57
  • Thanks for changing the indentation. I must say that I was more interested in why and how the change in indentation happened, especially considering that I saw something similar just moments ago. (Does it have to do with your editor?) My primary goal was not to pressure you into changing the indentation. I would however like to pressure you into showing us a fully working example. – moewe Jul 03 '18 at 16:09
  • @moewe Off-topic: I don't know how this came about for the OP, but I believe auto-indentation in Emacs would produce something similar to the original post (as far as I get it, it recognizes open braces and similar constructs, but not the conditional by itself). – gusbrs Jul 03 '18 at 16:23
  • PhD handed in tomorrow, desperately trying to get MWE to work, but can't. Pasted wrong. – schoon Jul 03 '18 at 16:25
  • @gusbrs I figured that it must have been some automatic indentation script from looking at https://tex.stackexchange.com/q/439086/35864. There is definitely a pattern to it. I can't really blame the editor for not following the biblatex indentation style, it is a bit idiosyncratic at times. – moewe Jul 03 '18 at 16:25
  • I appreciate that you are under time pressure. But as I said under my other answer the code usually actually does what it should do. If it does not work for you, there must be something else going on that we are not seeing. With that little information the only guess I can come up with was that of my second comment above. If that does not help, I'm afraid it is: "No MWE, no answer." I hate to be so blunt, but that is basically what it comes down to. Sorry. – moewe Jul 03 '18 at 16:29
  • Not a problem, I understand. – schoon Jul 03 '18 at 16:29
  • Hang on! Where did the \setunit{\addcomma\space}% go? You should be using the third code block of my answer (mangled version: \renewbibmacro*{in:}{% \setunit{\addcomma\space}% \ifentrytype{article} {} {\printtext{% \bibstring{in}\intitlepunct}}}) That definitely works as can be seen from https://gist.github.com/moewew/02246a34f3dbeef82c7d908c982bf81c – moewe Jul 03 '18 at 16:32
  • Oh yes, I forgot I deleted that to try and get it to work how I wanted it to. I'll put it back in. – schoon Jul 03 '18 at 16:35
  • Your question https://tex.stackexchange.com/q/439104/35864 confirms that I was right in my suspicions about the title field of your @incollection. Remove the . so that it only reads title = "Criminology: Re-Imagining Security and Risk", and then try again with the code from this question. – moewe Jul 03 '18 at 16:37
  • Close. It is ', in:' instead of ' in'. – schoon Jul 03 '18 at 16:48
  • \renewcommand*{\intitlepunct}{\addspace} – moewe Jul 03 '18 at 17:01

1 Answers1

5
\renewbibmacro*{in:}{%
  \setunit{\addcomma\space}%
  \ifentrytype{article}
    {}
    {\printtext{%
       \bibstring{in}\intitlepunct}}}

\renewcommand*{\intitlepunct}{\addspace}

is the correct solution for what you want.

But there is a slight catch to this that becomes apparent when we use the code with the minimal example from your question Why can't my MWE see the references?.

If you have additionally modified the field format of the title field (I'm speculating here, because you have not shared an MWE, but it is not entirely outlandish that such a thing happened because you must have modified the style heavily to obtain the output you show) the periods that you placed at the ends of the fields of froestad2015Criminology could confuse biblatex's punctuation tracker.

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{friedman2001greedy,
  title     = {Greedy function approximation: a gradient boosting machine},
  author    = {Friedman, Jerome H.},
  journal   = {Annals of Statistics},
  pages     = {1189--1232},
  year      = {2001},
  publisher = {JSTOR},
}
@incollection {froestad2015Criminology,
  author    = {Froestad, J. and Shearing, C. and {Van der Merwe}, M.},
  title     = {Criminology:  Re-Imagining  Security  and  Risk.},
  booktitle = {Security: Dialogue across Disciplines.},
  publisher = {Cambridge: Cambridge University Press.},
  year      = {2015},
  pages     = {177--195},
  editor    = {Bourbeau, P.},
}
\end{filecontents}


\documentclass{article}

\usepackage[%
  backend=biber,
  style=authortitle,
  sorting=nyt,
]{biblatex}
\addbibresource{\jobname.bib}

\DeclareFieldFormat[incollection]{title}{\enquote{#1}}

\renewbibmacro*{in:}{%
  \setunit{\addcomma\space}%
  \ifentrytype{article}
    {}
    {\printtext{%
       \bibstring{in}\intitlepunct}}}

\renewcommand*{\intitlepunct}{\addspace}

\begin{document}
  \textcite{friedman2001greedy,froestad2015Criminology}

  \printbibliography
\end{document}

gives

enter image description here

biblatex tries to suppress double punctuation and so the full stop at the end of

“Criminology: Re-Imagining Security and Risk.”

suppresses the comma that would normally follow it because a full stop can not be followed by a comma.

The effect is not really visible (if you look really closely it is actually) for the

Security: Dialogue across Disciplines.

because that would be followed by a full stop anyway (but if you have the . in the booktitle field the period is in italics, while it is upright if biblatex adds it itself).

The comma is not suppressed in

Cambridge University Press., 2015

because biblatex (incorrectly in this field) assumes that a . in the publisher field always signifies an abbreviation after which a comma is fine.

The solution is to remove the superfluous periods from your .bib file.

@incollection {froestad2015Criminology,
  author    = {Froestad, J. and Shearing, C. and {Van der Merwe}, M.},
  title     = {Criminology:  Re-Imagining  Security  and  Risk},
  booktitle = {Security: Dialogue across Disciplines},
  publisher = {Cambridge University Press},
  location  = {Cambridge},
  year      = {2015},
  pages     = {177--195},
  editor    = {Bourbeau, P.},
}

works just fine and gives the expected

enter image description here

moewe
  • 175,683
  • As I was trying to accomplish the same result sought in the question posed (save that I need commas inside quote marks), I was pleased to read @moewe's solution to the problem. In implementing it, I noticed an unwanted period appearing so as to produce "in." for entries of the bookinbook and inbook types, and jammed text in some entries of the article and incollection types. I found that this was eliminable by a slight addition to the last line so as to read \renewcommand*{\intitlepunct}{\nopunct\addspace}. – Louis Nov 26 '18 at 03:39
  • This might have to do with https://tex.stackexchange.com/q/175730/35864. Without the actual code it is hard to say whether the issue was indeed the same. I'm a bit worried about the jammed text appearing with some entry types, I didn't expect such a thing to happen (but I should probably not be too surprised should something like this happen). – moewe Dec 01 '18 at 07:37