# Customize citation with bibulous

Is there a way to customize the way of the citation with bibulous similarly to how it is possible to customize the bibliography.

E.g. for books it should be: Said, 2000, S.56.
and for electronic it should be: Büttner, Tages-Anzeiger Online, 14.12.2013 "Der Bundesrat spielt Katz und Maus"

Or just the same style as in the bibliography for the citation.

I add my tex file from another forum post related to bibulous

\documentclass[11pt, a4papter] {scrartcl}
\usepackage{natbib}

\usepackage{filecontents}
\begin{filecontents*}{svenz.bst}
TEMPLATES:
book =  [<au>.] [\textit{\enquote{<title>}}.] [<address> <year>.]
electronic = [<au>.] [\textit{<institution>.}] [<date>.] [\enquote{<title>}.] [<url>.] [<dateofchange>.] [<urldate>.]
oral = [<au>.] [<interviewer>,] [<date>,] [<address>.]
inbook = [<au>.] [\enquote{<title>}.] [In: <booktitle>,] hg. v. [<publisher>.] [<address>] [<place>.] [<pages>.]
article = [<au>.] [\enquote{<title>}.] [\textit{<journal>,] [<year>,] [<number>,}] [<pages>.]

SPECIAL-TEMPLATES:
citelabel = <authorlist.0.last>, <year>
sortkey = <authorlist.0.last><year>

OPTIONS:
namelist_format = last_name_first
use_firstname_initials = False
\end{filecontents*}
\begin{filecontents}{\jobname.bib}
@Electronic{gehalt,
author      = {Rütti, Nicole},
institution = {NZZ Online},
year        = {2017},
date        = {2017-07-27},
title       = {Sind Frauen wirklich selber schuld am tieferen Gehalt?},
url         = {https://www.nzz.ch/wirtschaft/frauen-und-lohnverhandlungen-auf-stoeckelschuhen-rueckwaerts-ueber-ein-minenfeld-laufen-ld.1307984},
urldate     = {2018-10-14},
}

@Electronic{ackeret,
author      = {Ackeret, Markus},
institution = {NZZ Online},
year        = {2017},
date        = {2017-05-25},
title       = {Im Übereifer des politischen Gefechts},
url         = {https://www.nzz.ch/international/debatte-um-die-bundeswehr-im-uebereifer-des-politischen-gefechts-ld.1296154},
urldate     = {2018-10-14},
}

@Electronic{Lenz1,
author      = {Lenz, Christoph},
institution = {Tages-Anzeiger Online},
year        = {2017},
date        = {2017-07-04},
title       = {Rechenspiele der Armee haben politische Folgen},
url         = {https://www.tagesanzeiger.ch/schweiz/standard/rechenspiele-der-armee-haben-politische-folgen/story/19945957},
urldate     = {2018-10-16},
}
\end{filecontents}

\begin{document}
Lorem ipsum dolor sit amet, \citet{gehalt} consetetur sadipscing elitr,
\cite{Lenz1}. Lorem ipsum dolor sit amet. \cite{ackeret}

\bibliographystyle{svenz}
\bibliography{\jobname}
\end{document}


I read the guidlines from nzhagen but did not find the answer to this question. If I have overread it I am happy to read it again :)

• Like BibTeX Bibulous has no direct control over the citation output. Limited options to customise the citations are available with natbib but full blown changes like you have them in mind were not intended to be made that way. It is probably possible to hack something together, but it won't be pretty and might break. biblatex would be better at that sort of thing because it has access to all the entry data in the bibliography and citations. – moewe Nov 9 '18 at 16:30
• BTW: Do you people know each other tex.stackexchange.com/q/459160/35864, tex.stackexchange.com/q/458938/35864? The recent spike in interest for Bibulous and Swiss newspaper articles is really curious. – moewe Nov 9 '18 at 16:40
• Thanks for your answer. Maybe I should have a look at customizing bibliographies with biblatex even if I find it quite confusing. Thats funny i noticed it as well. I do not know any of the others but as I was told bibluous was recommanded in a latex course wich propably explains the spike. – svenz Nov 9 '18 at 18:13

# Background

Bibulous is a drop-in replacement for BibTeX and as such inherits its approach to bibliography and citation typesetting as well as its conceptual limitations. The user-facing workings of BibTeX are explained nicely in Question mark or bold citation key instead of citation number. For your endeavour of formatting the citations individually it is important to understand what BibTeX/Bibulous actually produce.

## Standard BibTeX bibliographies

When you run BibTeX or Bibulous that program creates a .bbl file. That file is then read by LaTeX and typeset at the point in your document where you write \bibliography{...}. The .bbl file contains something like

\begin{thebibliography}{2}
\bibitem{elk} Anne Elk: \emph{A Theory on Brontosauruses}. 1972.
\bibitem{appleby} Humphrey Appleby: \emph{On the Importance of the Civil Service}. 1980.
\end{thebibliography}


thebibliography is essentially a glorified list (enumerate) environment that numbers its items and creates a label for each entry key that can be referenced with \cite later. The workings of that mechanism are comparable to \label-\ref: TeX writes the label (number) corresponding to each key into the .aux file, so it can be used right from the start in the next run, see Understanding how references and labels work. \bibitem supports an optional argument to override the citation number with a custom label, so one could use \bibitem[Elk72]{elk} to obtain the label "Elk72" in citations instead of "1".

In this scenario the entry data are not known to LaTeX in any useful way. LaTeX just happens upon the data once, but only as text that is typeset at some point. The only thing that is really 'known' and usable when you \cite an item is its corresponding label.

Note that it would be possible to extract more entry data for more involved use from a .bib file by different means such as the usebib package, which essentially reads the .bib file as a key-value list. usebib in particular is limited by the fact that name lists are not parsed and every other solution would have to overcome this not insignificant obstacle.

## natbib

For most numeric "[1]" and alphabetic "[Elk72]" citation styles this approach is more than sufficient. But for citation styles with author-year labels "(Appleby 1980)" it might be more useful to have LaTeX 'know' the author (Appleby) and year (1980) of an entry separately instead of a fixed label (Appleby 1980). That would allow easier switching between citation formats like "Appleby 1980", "Appleby (1980)", "(Appleby, 1980)". So when you use natbib (and a few other packages with a similar strategy, I don't even know if natbib was the first package to implement such a behaviour, but it is probably the most popular) your .bbl file might contain

\begin{thebibliography}{2}
\bibitem[Elk(1972)]{elk} Anne Elk: \emph{A Theory on Brontosauruses}. 1972.
\bibitem[Appleby(1980)]{appleby} Humphrey Appleby: \emph{On the Importance of the Civil Service}. 1980.
\end{thebibliography}


where the optional argument is used to tell LaTeX that the author of appleby is "Appleby" and that its year label is "1980". With that information natbib can now provide a more fine-grained control over citation output.

natbib understands several slightly different formats to pass the entry data, but all of them just give the author list (possibly a long and a short form) and the year. Additional entry data is not supposed to be passed on.

## jurabib

The package jurabib takes this one step further and provides much more entry data in the optional argument for use in the document

\begin{thebibliography}{}

\backrefparscanfalse
\bibitem[{Appleby\jbdy {1980}}%
{}%
{{0}{}{book}{1980}{}{}{}{}%
{1980}}%
{{On the Importance of the Civil Service}%
{}{}{2}{}{}{}{}{}}%
]{appleby}
\jbbibargs {\bibnf {Appleby} {Humphrey} {H.} {} {}} {Humphrey Appleby} {au}
{sexless} {\bibtfont {On the Importance of the Civil Service}\bibatsep {}
\apyformat {1980}} {\bibhowcited} \jbdoitem {{Appleby}{Humphrey}{H.}{}{}} {}
{} \bibAnnoteFile {appleby}

\end{thebibliography}


Again, that data is passed on through the .aux file and is available from the beginning of the document in the next run. That means that jurabib's citation commands can afford a great bit of freedom and variety in the output, they can even change their format on the fly.

## biblatex

I believe that the completely different approach biblatex takes to bibliographies is inspired by jurabib. But instead of going through the .bbl file and via the label through the .aux, biblatex directly has all entry data in the .bbl file in a format that is accessible for it. Instead of reading the .bbl only at the point in the document where your bibliography is to be typeset, biblatex reads the .bbl at the beginning of the document. That means that all entry data of all entries is accessible from the start. The entry data of the entry shown above would look like

\refsection{0}
\datalist[entry]{nyt/global//global/global}
\entry{appleby}{book}{}
\name{author}{1}{}{%
{{uniquename=0,uniquepart=base,hash=dd90e644e3018ab2c6a7ffa2a58522d0}{%
family={Appleby},
familyi={A\bibinitperiod},
given={Humphrey},
giveni={H\bibinitperiod},
givenun=0}}%
}
\strng{namehash}{dd90e644e3018ab2c6a7ffa2a58522d0}
\strng{fullhash}{dd90e644e3018ab2c6a7ffa2a58522d0}
\strng{bibnamehash}{dd90e644e3018ab2c6a7ffa2a58522d0}
\strng{authorbibnamehash}{dd90e644e3018ab2c6a7ffa2a58522d0}
\strng{authornamehash}{dd90e644e3018ab2c6a7ffa2a58522d0}
\strng{authorfullhash}{dd90e644e3018ab2c6a7ffa2a58522d0}
\field{sortinit}{A}
\field{sortinithash}{d77c7cdd82ff690d4c3ef13216f92f0b}
\field{labeldatesource}{}
\field{labelnamesource}{author}
\field{labeltitlesource}{title}
\field{title}{On the Importance of the Civil Service}
\field{year}{1980}
\field{dateera}{ce}
\endentry
\enddatalist
\endrefsection


biblatex can use all entry data when you \cite and entry, which makes it possible to create very flexible and complex citation styles in a way that would be extremely tricky with natbib.

# Customised citations with Bibulous

If your customised citations are static, you can in principle use the optional argument of \bibitem to provide a fixed citation output. This will not work together with natbib any more because natbib requires a particular format and only digests author and year information.

In Bibulous the optional argument of \bibitem can be defined via the SPECIAL-TEMPLATE citelabel, so you would have to populate that variable depending on the entry type. As far as I can see, there is currently no easy way to populate SPECIAL-TEMPLATEs with type-specific values, but that should be possible with VARIABLEs and a short function written in DEFINITIONs. I believe that https://github.com/nzhagen/bibulous/issues/15 is currently blocking this course of action, so I think that it is currently not possible to obtain type-specific citation formats in Bibulous.

But even if we were able to populate the optional argument of \bibitem with a citation label, that would still feel cheap to me since you only pass a string with all the data on to LaTeX and not the actual data in a useful format. You would have to do copy what jurabib does and pass all entry data on to LaTeX in a macro format.

A related request at the Bibulous bug tracker with a similar answer is at https://github.com/nzhagen/bibulous/issues/13.

# Customised citations with biblatex

With biblatex it is possible to produce different citation output for different types.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\letbibmacro{cite:default}{cite}

\renewbibmacro{cite}{%
\ifbibmacroundef{cite:\strfield{entrytype}}
{\usebibmacro{cite:default}}
{\usebibmacro*{cite:\strfield{entrytype}}}}

\newbibmacro*{cite:article}{%
\iffieldundef{shorthand}
{\printnames{labelname}%
\printfield{journaltitle}%
{\usebibmacro{cite:shorthand}}}

\begin{document}
\cite{sigfridsson}

\cite{nussbaum}

\printbibliography
\end{document}