0

I'd like to change the behavior of \citetitle for a specific source type, which is standardisodin (which I got from here).

I already managed to get the right order in the bibliography to my liking but I can't figure out how to tune it for citing the title in the document.

Question on the side: should Type and Number be in italics as well? I like the version I intend to use, unless there is something fundamentally wrong with it I suppose.

Edit

I'd be happy to manually print out the other fields as well, so I would to write something along the lines of

\print{Type}{abc}~\print{Number}{abc}:~\citetitle{abc}

or so.

Picture

enter image description here

MWE

\documentclass[
a4paper,
12pt,
]{scrartcl}

%%%Tipps: https://tex.stackexchange.com/questions/12806/guidelines-for-customizing-biblatex-styles/13076#13076

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage[
language=auto,
style=authoryear-ibid,
backend=biber,
hyperref=true,
dashed=false,
isbn=false,
doi=false,
maxcitenames=2,
maxbibnames=99,
sorting=nyt,
firstinits=true,
uniquename=init,
uniquelist=false,
autocite=footnote,
ibidtracker=true,
date=comp,
mincrossrefs=1,
]{biblatex}
\usepackage{xpatch}

%definition of new source type: Standard (ISO, DIN, or other guidelines)
\DeclareDatamodelEntrytypes{standardisodin}
\DeclareDatamodelEntryfields[standardisodin]{type,number}
\DeclareBibliographyDriver{standardisodin}{%
    \usebibmacro{bibindex}%
    \usebibmacro{begentry}%
    \usebibmacro{author}%
    \setunit{\labelnamepunct}\newblock
    \printfield{type}\addspace%
    \printfield{number}\addcolon\addspace%
    \usebibmacro{title}\addspace%
    \newunit\newblock
    \usebibmacro{location+date}%
    \newunit\newblock
    \iftoggle{bbx:url}
    {\usebibmacro{url+urldate}}
    {}%
    \newunit\newblock
    \usebibmacro{addendum+pubstate}%
    \setunit{\bibpagerefpunct}\newblock
    \usebibmacro{pageref}%
    \newunit\newblock
    \usebibmacro{related}%
    \usebibmacro{finentry}}


\begin{filecontents}{\jobname.bib}
@Standardisodin{abc,
    Title                    = {Metallische Werkstoffe -- Zugversuch -- Teil 2: Pr{"u}fverfahren bei erhöhter Temperatur},
    Author                   = {{DIN Deutsches Institut für Normung e.~V.}},
    Date                     = {2011-05},
    Location                 = {Berlin},
    Number                   = {6892-2},
    Type                     = {DIN EN ISO},
    Year                     = {2011},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\nocite{*}

\listfiles

\begin{document}
So this is a sentence: as \verb+\citetitle{abc}+ shows, there is no \verb+Number+ nor \verb+Type+ printed:
\begin{flushleft}
\citetitle{abc}
\end{flushleft}
So now, when using \verb+\citetitle+ for this source type, I'd like to have the following output\ldots
\begin{verbatim}
[Type][space][Number][colon][space][Title]
\end{verbatim}
\ldots so it'll produce
\begin{flushleft}
    DIN EN ISO 6892-2: \textit{Metallische Werkstoffe -- Zugversuch -- Teil 2: Prüfverfahren bei erhöhter Temperatur}
\end{flushleft}
in the text.

Question on the side: or should the type and number be in italics as well? I like the version I intend to use, unless there is something fundamentally wrong with it I suppose.
\end{document}
henry
  • 6,594

1 Answers1

1

We can just add a bit of "logic" to the definition of \citetitle: We check, if the entry is a standard and if so, print the additional information

\DeclareCiteCommand{\citetitle}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
   % this is new
   \ifentrytype{standardisodin} 
     {\printfield{type}%
      \setunit{\addspace}%
      \printfield{number}%
      \setunit{\addcolon\space}}
     {}
   % here ends the new stuff
   \printfield[citetitle]{labeltitle}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

As an added bonus, this re-definition

\renewbibmacro*{cite}{%
  \global\boolfalse{cbx:loccit}%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {% this is new
        \ifentrytype{standardisodin}
          {\printfield{type}%
           \setunit{\addspace}%
           \printfield{number}}
        % ... until here (save for two new curly braces below)
          {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
            {\usebibmacro{cite:label}%
             \setunit{\addspace}}
            {\printnames{labelname}%
             \setunit{\nameyeardelim}}%
          \usebibmacro{cite:labelyear+extrayear}}}}
    {\usebibmacro{cite:shorthand}}}

will make \cite{abc} print "DIN EN ISO 6892-2".

While the definition for \citetitle will work with (almost) all (standard) styles, the re-definition for \cite is specific to authoryear-ibid, but the idea can be abstracted and applied to other cite macros as well.

MWE

\documentclass[
a4paper,
12pt,
]{scrartcl}

%%%Tipps: http://tex.stackexchange.com/questions/12806/guidelines-for-customizing-biblatex-styles/13076#13076
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{filecontents}

\usepackage[
language=auto,
style=authoryear-ibid,
backend=biber,
hyperref=true,
dashed=false,
isbn=false,
doi=false,
maxcitenames=2,
maxbibnames=99,
sorting=nyt,
firstinits=true,
uniquename=init,
uniquelist=false,
autocite=footnote,
ibidtracker=true,
date=comp,
mincrossrefs=1,
]{biblatex}


%definition of new source type: Standard (ISO, DIN, or other guidelines)
\DeclareDatamodelEntrytypes{standardisodin}
\DeclareDatamodelEntryfields[standardisodin]{type,number}
\DeclareBibliographyDriver{standardisodin}{%
    \usebibmacro{bibindex}%
    \usebibmacro{begentry}%
    \usebibmacro{author}%
    \setunit{\labelnamepunct}\newblock
    \printfield{type}\addspace%
    \printfield{number}\addcolon\addspace%
    \usebibmacro{title}\addspace%
    \newunit\newblock
    \usebibmacro{location+date}%
    \newunit\newblock
    \iftoggle{bbx:url}
    {\usebibmacro{url+urldate}}
    {}%
    \newunit\newblock
    \usebibmacro{addendum+pubstate}%
    \setunit{\bibpagerefpunct}\newblock
    \usebibmacro{pageref}%
    \newunit\newblock
    \usebibmacro{related}%
    \usebibmacro{finentry}}


\begin{filecontents*}{\jobname.bib}
@Standardisodin{abc,
    Title     = {Metallische Werkstoffe -- Zugversuch -- Teil 2: Prüfverfahren bei erhöhter Temperatur},
    Author    = {{DIN Deutsches Institut für Normung e.~V.}},
    Date      = {2011-05},
    Location  = {Berlin},
    Number    = {6892-2},
    Type      = {DIN EN ISO},
}
\end{filecontents*}

\DeclareCiteCommand{\citetitle}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
   \ifentrytype{standardisodin} 
     {\printfield{type}%
      \setunit{\addspace}%
      \printfield{number}%
      \setunit{\addcolon\space}}
     {}
   \printfield[citetitle]{labeltitle}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\renewbibmacro*{cite}{%
  \global\boolfalse{cbx:loccit}%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
       {\usebibmacro{cite:ibid}}
       {\ifentrytype{standardisodin}
          {\printfield{type}%
           \setunit{\addspace}%
           \printfield{number}}
          {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
            {\usebibmacro{cite:label}%
             \setunit{\addspace}}
            {\printnames{labelname}%
             \setunit{\nameyeardelim}}%
          \usebibmacro{cite:labelyear+extrayear}}}}
    {\usebibmacro{cite:shorthand}}}

\addbibresource{\jobname.bib}
\nocite{*}

\begin{document}
\cite{abc}

So this is a sentence: as \verb+\citetitle{abc}+ shows, there is no \verb+Number+ nor \verb+Type+ printed:
\begin{flushleft}
\citetitle{abc}
\end{flushleft}
So now, when using \verb+\citetitle+ for this source type, I'd like to have the following output\ldots
\begin{verbatim}
[Type][space][Number][colon][space][Title]
\end{verbatim}
\ldots so it'll produce
\begin{flushleft}
    DIN EN ISO 6892-2: \textit{Metallische Werkstoffe -- Zugversuch -- Teil 2: Prüfverfahren bei erhöhter Temperatur}
\end{flushleft}
in the text.

Question on the side: or should the type and number be in italics as well? I like the version I intend to use, unless there is something fundamentally wrong with it I suppose.
\end{document}

enter image description here

Regarding your small question on the side: I think it would look odd, if you set the "DIN EN ISO 6892-2" part in italics as well, as to whether citing standards in this way is sensible: it looks OK to me :-). I would prefer to be able to use \cite to cite the entries instead of using \citetitle. It would be odd to cite those entries with the standard authoryear-ibid \cite though, as "Deutsches Institut für Normung e. V. 2011" really is not that helpful for a label and "DIN EN ISO 6892-2" seems to be the more common form to refer to them (that's what the second definition above is for).

moewe
  • 175,683
  • Your added note on using \cite made me curious. Originally I just intended to put the title together in a proper way. But then, you are right: citing standards in the traditional authoryear way would be weird. However I am using footnotes for citations (-> \footcite). Would I have to change anything for that? (I haven't checked out the definition of \footcite yet.) – henry Sep 04 '14 at 15:52
  • On first glance, it seems to work for \footcite just the same. – henry Sep 04 '14 at 16:10
  • 1
    @henry And so it should; \cite, \footcite and \parencite all use the cite bibmacro internally (in authoryear-ibid at least). It's another story with \textcite though ... – moewe Sep 04 '14 at 16:32
  • Had another though: would you also omit the issuing institution in the bibliography then, as in actually working "against" the characteristics of the authoryear-style(s)? I've seen that before, it would also be in line with the citation then. – henry Sep 05 '14 at 05:59
  • @henry I might have done that, as I don't think the "DIN e.V." is really necessary in finding the citation (it just does not add any useful information - I find). You might think about a separate bibliography for standards and norms then, so our not adhering to the authoryear style does not disturb the appearance of the normal bibliography (via type/nottype p. 74 of the biblatex docs). – moewe Sep 05 '14 at 06:46