2

I need to change the short citation. Right now it looks as follows: enter image description here

It should look like:

Gates, Bill and Melinda Gates Foundation, May 4. 2018, "Save the world..."

The "..." should appear after 3 or 4 words if that is technically possible.

How can I do that?

 \RequirePackage{filecontents}
    \begin{filecontents*}{\jobname.bib}
    @online{gates,
        author       = {Bill Gates},
        title        = {Save the world!},
        url          = {https://www.gatesfoundation.org/de/},
        date         = {2016-07-04},
        organization = {Bill and Melinda Gates Foundation},
    }
    \end{filecontents*}


\documentclass{article}

\usepackage[style=verbose]{biblatex}
\addbibresource{\jobname.bib}


\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\footcite{gates} sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. \footcite{gates}

\printbibliography
\end{document}
moewe
  • 175,683
czer
  • 131
  • Should that happen for all entry types or only for @online? I also feel that in this case the "..." is pretty useless, why not just include the "!" to get the full title? – moewe Dec 22 '18 at 14:25
  • This should only happen for @online. You're right, in this exemple it doesn't make that much sense, but with longer titles it does make sense. – czer Dec 22 '18 at 14:29
  • Do you really want to move the access date urldate between title and organization here? In https://tex.stackexchange.com/q/464205/35864 that place is taken by the normal publication date date. – moewe Dec 22 '18 at 14:38
  • No, the date should be between title and organization. I edited the question. – czer Dec 22 '18 at 16:20
  • If by date you mean the date of publication as given in the date field, my answer should already have you covered. I assumed you did not want the urldate. I suggest you add the date to your example entry so the question makes more sense. – moewe Dec 22 '18 at 16:22
  • 1
    Note that due to the and in the name of the organization you should use double braces, either organization = {{Bill and Melinda Gates Foundation}}, or organization = {Bill {and} Melinda Gates Foundation}, (I mentioned that before in https://tex.stackexchange.com/a/464276/35864). – moewe Dec 22 '18 at 16:23
  • I just realized that your solution doesn't work with ext-authortitle-ibid. I'm really sorry for that. At the point I posted the question I didn't knew that I will need to use ext-authortitle-ibid instead of verbose – czer Dec 22 '18 at 16:55
  • In that case please ask a new question. In particular please do not change the question significantly after you have gotten an answer (see https://tex.meta.stackexchange.com/q/7678/35864). But keep in mind that verbose and ext-authortitle-ibid (or just authortitle-ibid) give completely different output on the first citation. – moewe Dec 22 '18 at 16:56
  • style=ext-authortitle, citestyle=verbose-ibid works perfectly for me. Probably there are some disadvantages to that approach but so far it works for me. – czer Dec 22 '18 at 18:07
  • In that case a simple style=ext-verbose-ibid would be more natural and should give the same results. – moewe Dec 22 '18 at 19:47

1 Answers1

3

Similarly to Custom type disappears in subsequent citations you need to branch the code for cite:short to obtain a different format for @online entries. A short version of the title can be specified in the shorttitle field. But that would require manual intervention, with Biber's sourcemapping you can automate that. I strongly suggest to scrutinise the output carefully in that case since the code is quite naive and chops off everything at the third word.

The MWE builds on the code from Move date before title in bibliography using biblatex to make the output for the full citation match the style of the short citation.

\documentclass{article}

\usepackage[style=verbose, autocite=footnote]{biblatex}

\DeclareFieldFormat[online]{shorttitle}{\mkbibquote{#1\dots\isdot}}
\newbibmacro*{cite:short:online}{%
  \printnames{labelname}%
  \setunit{\addcomma\space}%
  \printlist{organization}%
  \setunit{\addcomma\space}%
  \printdate
  \setunit{\addcomma\space}%
  \printtext[bibhyperlink]{%
    \iffieldundef{shorttitle}
      {\printfield[citetitle]{labeltitle}}
      {\printfield{shorttitle}}}}

% cite:short is really 'cite:subsequent'
\renewbibmacro*{cite:short}{%
  \ifbibmacroundef{cite:short:\strfield{entrytype}}
    {\printnames{labelname}%
     \setunit*{\printdelim{nametitledelim}}%
     \printtext[bibhyperlink]{%
       \printfield[citetitle]{labeltitle}}}
    {\usebibmacro*{cite:short:\strfield{entrytype}}}}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=false]{
      \step[fieldsource=title, match=\regexp{\A(\w+\s+){2}(\w+)}, final]
      \step[fieldset=shorttitle, origfieldval, final]
      \step[fieldsource=shorttitle, match=\regexp{\A(\w+\s+)(\w+\s+)(\w+).*}, replace={$1$2$3}]
    }
  }
}

\DefineBibliographyStrings{english}{
  urlseen = {visited at}
}

\DeclareFieldFormat{urldate}{\bibstring{urlseen}\space#1}

\DeclareListWrapperFormat{organization}{\mkbibemph{#1}}

\DeclareBibliographyDriver{online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \newunit\newblock
  \printlist{organization}%
  \newunit\newblock
  \usebibmacro{date}%
  \newunit\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit
  \printfield{note}%
  \newunit\newblock
  \iftoggle{bbx:eprint}
    {\usebibmacro{eprint}}
    {}%
  \newunit\newblock
  \usebibmacro{url+urldate}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}


\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@online{gates,
  author       = {Bill Gates},
  title        = {Save the world!},
  url          = {https://www.gatesfoundation.org/de/},
  urldate      = {2016-07-04},
  organization = {{Bill and Melinda Gates Foundation}},
}
@online{gates2,
  author       = {Bill Gates},
  title        = {Save the moon with even longer titles},
  shorttitle   = {Save the moon},
  date         = {2016-05-04},
  url          = {https://www.gatesfoundation.org/de/},
  urldate      = {2016-07-04},
  organization = {Bill {and} Melinda Gates Foundation},
}
@online{ex:one,
  author       = {Anne Elk},
  title        = {One},
  url          = {https://example.com/~elk/1},
}
@online{ex:two,
  author       = {Anne Elk},
  title        = {Two Words},
  url          = {https://example.com/~elk/2},
}
@online{ex:three,
  author       = {Anne Elk},
  title        = {Three Words Title},
  url          = {https://example.com/~elk/3},
}
@online{ex:four,
  author       = {Anne Elk},
  title        = {Four Words in Title},
  url          = {https://example.com/~elk/4},
}
@online{ex:five,
  author       = {Anne Elk},
  title        = {Five Words in a Title},
  url          = {https://example.com/~elk/5},
}
@online{ex:long,
  author       = {Anne Elk},
  title        = {This Title Is Very Long to Test the Feature},
  url          = {https://example.com/~elk/long},
}
@online{ex:override,
  author       = {Anne Elk},
  title        = {A Long Title That Will Be Overridden},
  shorttitle   = {A Different Title},
  url          = {https://example.com/~elk/over},
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\autocite{gates} sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. \autocite{gates2}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr,\autocite{gates} sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. \autocite{gates2}

Lorem\autocite{ex:one} ipsum\autocite{ex:one}.
Lorem\autocite{ex:two} ipsum\autocite{ex:two}.
Lorem\autocite{ex:three} ipsum\autocite{ex:three}.
Lorem\autocite{ex:four} ipsum\autocite{ex:four}.
Lorem\autocite{ex:five} ipsum\autocite{ex:five}.
Lorem\autocite{ex:override} ipsum\autocite{ex:override}.
Lorem\autocite{ex:long} ipsum\autocite{ex:long}.

\printbibliography
\end{document}

Fn. 1 Bill Gates. Bill and Melinda Gates Foundation. Save the world! url: https://www.gatesfoundation.org/de/ visited at 07/04/2016.//Fn. 2 Bill Gates. Bill and Melinda Gates Foundation. May 4, 2016. Save the moon with even longer titles. url: https://www.gatesfoundation.org/de/ visited at 07/04/2016.//Fn. 3 Gates, Bill and Melinda Gates Foundation, “Save the world...”//Fn. 4 Gates, Bill and Melinda Gates Foundation, May 4, 2016, “Save the moon...”//Fn. 5 Anne Elk. One. url: https://example.com/~elk/1.//Fn. 6 Elk, One.//Fn. 7 Anne Elk. Two Words. url: https://example.com/~elk/2.//Fn. 8 Elk, Two Words.//Fn. 9 Anne Elk. Three Words Title. url: https://example.com/~elk/3.//Fn. 10 Elk, “Three Words Title...”//Fn. 11 Anne Elk. Four Words in Title. url: https://example.com/~elk/4.//Fn. 12 Elk, “Four Words in...”//Fn. 13 Anne Elk. Five Words in a Title. url: https://example.com/~elk/5.//Fn. 14 Elk, “Five Words in...”//Fn. 15 Anne Elk. A Long Title That Will Be Overridden. url: https://example.com/~elk/over.//Fn. 16 Elk, “A Different Title...”//Fn. 17 Anne Elk. This Title Is Very Long to Test the Feature. url: https://example.com/~ elk/long.//Fn. 18 Elk, “This Title Is...”

In the matchreplace RegExp I went with the naive

match=\regexp{\A(\w+\s+)(\w+\s+)(\w+).*}, replace={$1$2$3}

if you want a more sophisticated solution that can be extended more easily, you could try

match=\regexp{\A((?:\w+\s+){2})(\w+).*}, replace={$1$2}

where ((?:\w+\s+){2}) captures the first 2 words and the (\w+) the following word.

moewe
  • 175,683