Which modifications have to be done to use \textcite to cite standards inline

I am trying to cite a standard within my document text. Regarding this topic How to cite a standard (ISO, etc.) in BibLaTeX? I created a labelalpha and a bibliography entry that is suitable for my needs but I failed to modify the textcite command.

Here a MWE:

\documentclass{article}

\begin{filecontents}{Biblio.bib}
@standard{ASI1234_1,
year = {1999},
title = {somethings special in the world, that has to be defined},
urldate = {2012-09-10},
number = {1234-1},
date = {1999-04},
type = {ASI},
version = {1999-04},
organization = {{ASI}}
}
\end{filecontents}

%%Definition einer Normenklasse für Biblatex
\begin{filecontents}{standards.dbx}
%Modifikation für Normen in Biblatex
\DeclareDatamodelEntryfields[standard]{number,type}
\end{filecontents}

%Pakete für das Literaturverzeichnis mit BibLatex und Einstellung
\usepackage[
style=alphabetic,
%   style=draft,
backend=biber,
datamodel=standards]{biblatex}
%\DefineBibliographyStrings{ngerman}{and={\&}} % und zu & machen
\renewcommand*{\labelalphaothers}{} %Zeichen für mehrere Authoren in Abkürzung löschen

%Label für Standard
\DeclareLabelalphaTemplate[standard]{
\labelelement{ %
\field{type} %
} %
\labelelement{ %
\field{number} %
} %
\labelelement{ %
\literal{:} %
} %
\labelelement{ %
\field{year} %
} %
} %
%Eintrag Bibliographie
\DeclareBibliographyDriver{standard}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{type}%
\printfield{number}%
\printfield{year}%
\iffieldundef{month}{%
\printfield{month} %
\usebibmacro{title}%
\usebibmacro{finentry}}

\begin{document}
Blablablabba \textcite[10-12]{ASI1234_1} Balbabab
\printbibliography
\end{document}


I want to modify the textcite command only for the entrytype standard. I figured out that the textcite command first checks the labelname field and if that's empty it will use the labeltitle field. That is the reason why the full title will be printed using the textcite command. The labeltitle field analysis a couple of title field in a certain order. Because I have a large number of standards defining a shorttitle within the .bib file is not a good option. Is is possible to create a user defined shorttitle on the fly so that the textcite command will use this instead of the full title?

The result should look like this: ASI 1234 [ASI1234:1999, S. 10-12]

• What shall the short title be like? – samcarter_is_at_topanswers.xyz Feb 12 '18 at 16:18
• @samcarter a short Version of the labelalpha would be nice. ASI1234 without the year. – DMZ Feb 12 '18 at 16:23
• Why don't you go simply with \cite in this case? If you add the labeltitle with a short version of labelalpha the information would be redundant anyway. – gusbrs Feb 12 '18 at 16:25
• @gusbrs You are right with the redundancy but this are not my rules I have to play with. :-) – DMZ Feb 12 '18 at 16:51

It looks like a job for \DeclareSourcemap:

\documentclass{article}

\begin{filecontents}{Biblio.bib}
@standard{ASI1234_1,
year = {1999},
title = {somethings special in the world, that has to be defined},
urldate = {2012-09-10},
number = {1234-1},
date = {1999-04},
type = {ASI},
version = {1999-04},
organization = {{ASI}}
}
\end{filecontents}

%%Definition einer Normenklasse für Biblatex
\begin{filecontents}{standards.dbx}
%Modifikation für Normen in Biblatex
\DeclareDatamodelEntryfields[standard]{number,type}
\end{filecontents}

%Pakete für das Literaturverzeichnis mit BibLatex und Einstellung
\usepackage[
style=alphabetic,
%   style=draft,
backend=biber,
datamodel=standards]{biblatex}
%\DefineBibliographyStrings{ngerman}{and={\&}} % und zu & machen
\renewcommand*{\labelalphaothers}{} %Zeichen für mehrere Authoren in Abkürzung löschen

%Label für Standard
\DeclareLabelalphaTemplate[standard]{
\labelelement{ %
\field{type} %
} %
\labelelement{ %
\field{number} %
} %
\labelelement{ %
\literal{:} %
} %
\labelelement{ %
\field{year} %
} %
} %
%Eintrag Bibliographie
\DeclareBibliographyDriver{standard}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{type}%
\printfield{number}%
\printfield{year}%
\iffieldundef{month}{%
\printfield{month} %
\usebibmacro{title}%
\usebibmacro{finentry}}

\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\pertype{standard}
\step[fieldsource=type, fieldset=shorttitle, origfieldval]
\step[fieldsource=number, fieldset=shorttitle, origfieldval, append]
}
}
}

\begin{document}
Blablablabba \textcite[10-12]{ASI1234_1} Balbabab
\printbibliography
\end{document}


• Thank you very much. This is a very well working solution without changing the heart of biblatex. I really like it. I am just curious why the dash in the number field is ignored for the labelalpha? Is a dash not compatible? – DMZ Feb 12 '18 at 17:24
• Well, that was already happening on your original code. I'm not sure, but my guess is that type is defined as a key field in the default data model. Once you are already setting your own datamodel, you might as well try a dedicated field which is set to literal. But that's just a guess. – gusbrs Feb 12 '18 at 17:31
• and it works with \textcites as well. perfect! – DMZ Feb 12 '18 at 17:34
• Yes, you are right. I didn't recorgniced that. I will try a different field and see what will come up. – DMZ Feb 12 '18 at 17:36
• If it's not the case, you can always ask a follow up question on this other issue. – gusbrs Feb 12 '18 at 17:38

If you are looking for a truly on the fly solution, define

\makeatletter
\newcommand*{\redeflabeltitle}[1]{\AtNextCitekey{\csdef{abx@field@labeltitle}{#1}}}
\makeatother


in your preamble and then use it as

\redeflabeltitle{Eine tolle Norm}\textcite{ASI1234_1}


in the document.

But really it would be much, much cleaner to give a shorttitle in the .bib file, so things are indeed consistent.

• That's probably overkill. But that's a neat trick! I didn't know one could do that. – gusbrs Feb 12 '18 at 16:29
• I agree with you that defining a shorttitle would be the cleaner way. I made the mistake to use a database for my literature that seems to be not realy bibtex export friendly... And I don't want to modify the bib file with more than 600 entries by hand.... – DMZ Feb 12 '18 at 16:29
• @gusbrs Absolutely. I didn't really know what the expected outcome was, so I went for the completely manual approach. Standards are always a bit tricky since people expect output different from 'normal entries'. – moewe Feb 12 '18 at 16:34

Quick hack:

\documentclass{article}

\begin{filecontents}{Biblio.bib}
@standard{ASI1234_1,
year = {1999},
title = {somethings special in the world, that has to be defined},
urldate = {2012-09-10},
number = {1234-1},
date = {1999-04},
type = {ASI},
version = {1999-04},
organization = {{ASI}}
}
\end{filecontents}

%%Definition einer Normenklasse für Biblatex
\begin{filecontents}{standards.dbx}
%Modifikation für Normen in Biblatex
\DeclareDatamodelEntryfields[standard]{number,type}
\end{filecontents}

%Pakete für das Literaturverzeichnis mit BibLatex und Einstellung
\usepackage[
style=alphabetic,
%   style=draft,
backend=biber,
datamodel=standards]{biblatex}
%\DefineBibliographyStrings{ngerman}{and={\&}} % und zu & machen
\renewcommand*{\labelalphaothers}{} %Zeichen für mehrere Authoren in Abkürzung löschen

%Label für Standard
\DeclareLabelalphaTemplate[standard]{
\labelelement{ %
\field{type} %
} %
\labelelement{ %
\field{number} %
} %
\labelelement{ %
\literal{:} %
} %
\labelelement{ %
\field{year} %
} %
} %
%Eintrag Bibliographie
\DeclareBibliographyDriver{standard}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\printfield{type}%
\printfield{number}%
\printfield{year}%
\iffieldundef{month}{%
\printfield{month} %
\usebibmacro{title}%
\usebibmacro{finentry}}

\makeatletter
\renewbibmacro*{textcite}{%
\iffieldequals{namehash}{\cbx@lasthash}
{\setunit{\multicitedelim}}
{\ifentrytype{standard}{}{\ifnameundef{labelname}
{\printfield[citetitle]{labeltitle}}
{\printnames{labelname}}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{namelabeldelim}\bibopenbracket}%
\stepcounter{textcitecount}%
\savefield{namehash}{\cbx@lasthash}}}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\ifentrytype{standard}{\printfield{type}\printfield{number}}{\usebibmacro{cite}}%
\setunit{%
\ifbool{cbx:parens}
{\bibclosebracket\global\boolfalse{cbx:parens}}
{}%
\textcitedelim}}
\makeatother

\begin{document}
Blablablabba \textcite{ASI1234_1} Balbabab
\printbibliography
\end{document}

• Conceptually nicer than my sledgehammer approach, the effects of your answer can also be obtained with \AtEveryCitekey{\ifentrytype{standard}{\clearfield{labeltitle}}{}}. But of course the redefinition of textcite can be adapted for more shenanigans in a straightforward way, while \AtEveryCitekey has its limits. – moewe Feb 12 '18 at 16:48
• @moewe I tried something like this too, but I could not get rid of the year which is part of the labelalpha. Is there some trick you could suggest? – samcarter_is_at_topanswers.xyz Feb 12 '18 at 16:55
• @samcarter This is a nice solution. It works well – DMZ Feb 12 '18 at 17:02
• Ah, I didn't see you had removed the year as well. There is no easy way to do that since the entire label is generated by Biber and the year is a part of it. It can't be split off or suppressed only for certain citation commands. That's a limitation of \AtEveryCitekey right there! – moewe Feb 12 '18 at 17:03
• @moewe I tried your nice compact version on my large file and I get an error saying unbalanced parantheses. There seems to be other things that limits this solution – DMZ Feb 12 '18 at 17:09