# Controlling what \cite prints

I'm making a presentation using Beamer, and I'm trying to figure out how to get the journal information to print with the citation. I am currently using the natbib package with BibTeX. Suppose I want to cite the paper (citeKey="Einstein"):

Einstein, A. (1936). Lens-like action of a star by the deviation of light in the gravitational field. Science, 84(2188), 506-507.

in my presentation. I want the command \citet{Einstein} to produce:

Einstein Science, 84 2188, 506-507 (1936)

(Or some other similarly simple command, I would like to add a piece to my preamble and then do a find-replace to fix this. It's LaTeX, so it has to be easy like that!)

I can't be the first person who has wanted to do this, and I can't believe I haven't found anything in searching on and off for 2 days. Please confirm my stupidity by answering my question quickly or by pointing me to a place where this has been done that I haven't found.

• The gist of it is that you need to use a suitable BibTeX style. Ideally, you can find one already made which produces the kind of output you want. If not, you'll have to write one, which is a pain in the butt because BibTeX syntax is rather complex. I'll leave it to someone who can identify this particular style to provide an actual answer. (A thought: would you consider using biblatex instead?) – David Z Feb 9 '14 at 21:25
• @David If you can suggest a shake and bake biblatex solution, I'm game. I've played with something called \footcite I believe, but that didn't have the desired effect (Or was it \fullcite?) I'm guessing making a BibTeX style requires using makebst, which is just making my head hurt. – wolfste4 Feb 9 '14 at 21:27
• You can write a BibTeX style by hand; makebst is just a tool to aid the process. But if you were using \footcite or \fullcite, those are biblatex commands, so it might be worth just transitioning to biblatex. I'll see what I can come up with. – David Z Feb 9 '14 at 21:37
• @David Yes, I've played with biblatex, emphasis on played :/ BibTeX has served me well, I just don't see the fine-grained controls. Making a bst by hand is just something I've never done. But I've played with it long enough that it would have been faster to do it the dumb way--by hand--by now. – wolfste4 Feb 9 '14 at 21:52

Here's an example of how you can do this with biblatex.

For the example, I'll assume you have a file named einstein.bib with the contents

@article{Einstein,
author = "Einstein, Albert",
title = "Lens-like action of a star by the deviation of light in the gravitational field",
journal = "Science",
volume = "84",
issue = "2188",
pages = "506-507",
year = "1936"
}


With a minimum of effort, this will get you close. It uses biblatex's phys style, and just alters it not to print the title.

\documentclass{beamer}

\usepackage[style=phys,backend=biber]{biblatex}
% change this to the name of your .bib file

% this modifies the biblatex "phys" style to not print the title
% comment this line out if you want to see what it does normally
\renewbibmacro*{title}{}

\begin{document}
\begin{frame}{Test frame}
% \fullcite prints the entire citation as it would appear in a full bibliography
\fullcite{Einstein}
\end{frame}
\end{document}


If this is saved as, say, biblatextest.tex, you'll need to run

pdflatex biblatextest
biber biblatextest
pdflatex biblatextest
pdflatex biblatextest


If you don't have biber installed, you can work around that; just change backend=biber in the LaTeX file to backend=bibtex, and then run bibtex instead of biber when compiling the document. The result is this:

(sorry for the blurriness but you get the idea).

If you want to get an exact match to the style you're looking for, you'll probably have to do something more complicated. Biblatex comes with a lot of styles, and perhaps one of them will give you the exact output you want, but I can't check through them all, and there's a decent chance none of them will be an exact match anyway.

There are two kinds of biblatex styles, those that define what the in-text citations look like, which are stored in .cbx files, and those that define what the bibliography entries look like, which are stored in .bbx files. For a presentation like this, you don't have a traditional bibliography, so it's a judgment call whether you make your style a citation style (.cbx) or a bibliography style (.bbx). Since the format you're going for includes enough information to fully identify the reference, I'll make it a bibliography style.

The (almost) bare minimum you will need to make this style work for this particular citation is something like this:

\ProvidesFile{mystyle.bbx}
\RequireBibliographyStyle{standard}

% make \newunit insert a space
% make volume formatted as bold
\DeclareFieldFormat*{volume}{\mkbibbold{#1}}
% make pages print out without "pp."
\DeclareFieldFormat{pages}{#1}
% make year print out in parentheses
\DeclareFieldFormat{year}{\mkbibparens{#1}\nopunct}
% make name print as only last name
\DeclareNameFormat{last}{\usebibmacro{name:last}{#1}{#3}{#5}{#7}}
% set that to be the default name format
\DeclareNameAlias{default}{last}

% defines the format used for entry type "article"
\DeclareBibliographyDriver{article}{%
\usebibmacro{bibindex}% useful in case bibliography is being indexed
\usebibmacro{begentry}% a hook for begin-entry content
\usebibmacro{author/translator+others}% defined in biblatex.def
\newunit%
\usebibmacro{journal}% defined in biblatex.def
\printfield{volume}% print volume using the format defined above
\newunit%
\printfield{issue}% print issue number
\printfield{pages}% print page numbers using format from above
\newunit%
\printfield{year}% print year using format defined above
\usebibmacro{finentry}% a hook for end-entry content
}


Save this as mystyle.bbx (or if you change the filename, update the \ProvidesFile command to match) in either the directory where your main .tex file is, or somewhere in your texmf tree. (.../texmf/tex/latex/biblatex/bbx/mystyle.bbx would be a typical path but it doesn't matter as long as LaTeX can find it.) Your .tex file can stay the same except for the \usepackage[...]{biblatex} line, which should be changed to

\usepackage[bibstyle=mystyle,backend=biber]{biblatex}


In this line mystyle should be whatever you named the .bbx file, just without the .bbx extension.

After everything is set up, compile the file the same way, and you get this:

Of course, bear in mind that I made this style to work with this one bibliography entry. To make it useful more generally, you'll have to modify it to account for more complex features found in other bibliography entries. Thankfully, this is not as hard as it could be (e.g. with bibtex) because biblatex is rather well documented, but there's still a lot of information to parse. If you want to do this, I would suggest starting with one of the standard styles included with biblatex and modifying it, rather than building your own style from scratch.

• This is starting to work. For some reason, the phys style didn't load right away. Not sure why. But I've got it working now. Thanks so much! – wolfste4 Feb 10 '14 at 2:25
• Hmmm...also, this is throwing an error: > ./testbiblatex.tex:16: Package etoolbox Error: Toggle 'bbx:related' undefined. [ \end{frame}] Any thoughts? – wolfste4 Feb 10 '14 at 2:35
• I should have picked a Phys Rev example, because I'd rather see "Phys Rev" than "Physical Review". (I'm in PER, so I tend to cite "Physical Review Special Topics - Physics Education Research" a whole bunch, and I'd rather see "Phys. Rev. ST-PER" instead!). Is there a good way for BibLaTeX to shorten journal titles? I know that capability exists in BibTeX. – wolfste4 Feb 10 '14 at 2:49
• Not sure about the error. What TeX distribution and version do you have? I'm on TeXLive 2013 so if your version is different, that could account for the incompatibility. For abbreviating journal titles, that is straightforward but I'd suggest asking a separate question about it. (Search first, it might already be on the site.) – David Z Feb 10 '14 at 3:10
• Looks like I'm on TeXLive 2012...guess it is time to update! Thanks for all of your help! – wolfste4 Feb 10 '14 at 14:52

David's biblatex answer is likely better than mine, but since I had been working on it before I saw his answer, here's an alternative:

\documentclass{beamer}
\begin{filecontents}{\jobname.bib}
@article{einstein,
author = "Albert Einstein",
year = "1936",
title = "Lens-like action of a star by the deviation of light in the gravitational field",
journaltitle = "Science",
volume = "84",
number = "2188",
pages = "506--507",
}
\end{filecontents}
\usepackage[backend=bibtex8,citestyle=authoryear]{biblatex}
\newcommand{\citet}[1]{\citeauthor{#1}
\textit{\citefield{#1}{journaltitle}},
\textbf{\citefield{#1}{volume}}
\citefield{#1}{number},
\citefield{#1}{pages}
(\citefield{#1}{year})%
}

\begin{document}
\begin{frame}
\citet{einstein}
\end{frame}
\end{document}


• This also works, and has the advantage of doing it "by hand" if you will. Which isn't a bad thing either. Thanks! – wolfste4 Feb 10 '14 at 2:26