10

When I make a reference at the beginning of a sentence I have one citation style, but when I make a reference at the end I have another.

The class I'm using has the \cite{} command containing only the latter style.

How can I change the citation style for some specific citation?

Example:

The citation style for \cite{kahneman1979prospect} is:

[Kahneman and Tversky 1979]

But I can only use this style at the end of a sentence.

If I start the sentence citing something such as:

"According to..."

My citation style should be:

Kahneman and Tversky (1979)

Is it possible to create this new style (preferably a new command in the preamble)?

I've looked some other classes and they have it implemented in a new command such as\citeN{}:

\def\citeN{\def\@citeseppen{-1000}%
    \def\@cite##1##2{##1\if@tempswa , ##2]\else{]}\fi}%
    \def\citeauthoryear##1##2##3{##2 [##3}\@citedata}

I used the above code in my current class and preamble. Unfortunately it is still not working, but hopefully gives a starting point.

EDIT:

This is a minimal example with correct and incorrect style for each case.

main.tex

\documentclass{article}

\usepackage{natbib}
\bibliographystyle{abbrvnat}

\begin{document}

\section{Citation Style I}

\begin{itemize}
\item According to \cite{kahneman1979prospect} \dots is incorrect.
\item According to \citet{kahneman1979prospect} \dots is incorrect.
\item According to Kahneman and Tversky (1979) \dots is correct.
\end{itemize}

\section{Citation Style II}

\begin{itemize}
\item This is correct \dots \citep{kahneman1979prospect}.
\item This is incorrect \dots (Kahneman and Tversky, 1979).
\end{itemize}

\bibliography{references}

\end{document}

references.bib

@article{kahneman1979prospect,
  title={Prospect theory: An analysis of decision under risk},
  author={Kahneman, Daniel and Tversky, Amos},
  journal={Econometrica: Journal of the econometric society},
  pages={263--291},
  year={1979},
  publisher={JSTOR}
}

Output file

enter image description here

fabda01
  • 203
  • With classic BibTeX you can set the style globally. Local changes are not possible. Nice question tho! ;) Maybe it is possible with biblatex – Ruben Sep 12 '17 at 22:32
  • You could have a look at the usebib package by Enrico Gregorio. – Ruben Sep 12 '17 at 22:36
  • 1
    @Ruben I looked up Natbib reference sheet and could get very close to what I need using \bibpunct{[}{]}{,}{a}{}{;}. This makes \citep{} style correct: [Kahneman and Tversky 1979], but makes \cite{} output Kahneman and Tversky [1979]. I just need the year inside parentheses. Is it possible? Thanks! – fabda01 Sep 12 '17 at 22:58
  • 1
    Did you try \citet{}? Worked fine for me until I switched to Biber/Biblatex. If not, please provide a minimal working example which we can compile to reproduce the problem. That is, code for a small document and one or two bib entries, obviously, since you'll need to cite something. – cfr Sep 13 '17 at 02:17
  • @cfr Included minimal working example, as requested. Thanks! – fabda01 Sep 13 '17 at 11:46
  • 1
    Are you up for using biblatex as tagged? Since your MWE does not use biblatex I'm not sure if you really want that. With biblatex you'd probably use \parencite and \textcite, but you would have to change the bracketing. – moewe Sep 13 '17 at 12:07
  • @moewe Yes! I'm up for it. I included biblatex because the previous comments mentioned it. How do I change the bracketing for \parencite? I tried it and it seems promising, but it messed a little my References section because I have to use a certain bibliography style. Is it possible to use my own bibliography style (.bst file) along with biblatex? Thanks! – fabda01 Sep 13 '17 at 12:35
  • 2
    A quick and dirty natbib solution would be to use \bibpunct{(}{)}{,}{a}{}{;} and then make your own version of \citet defined as [\citealt{...}]. – Alan Munn Sep 13 '17 at 13:04
  • 1
    You can't use a .bst with Biblatex, but it is generally easier to customise than BibTeX as you use regular LaTeX to style things. – cfr Sep 13 '17 at 13:50
  • @AlanMunn Shouldn't the brackets be reversed? That is, [, ] in \bibpunct and (, ) for \citet? – cfr Sep 13 '17 at 13:52
  • As cfr mentions it is definitely not possible to use your exsiting .bst styles together with biblatex. Maybe there is a biblatex style that comes close to the .bst you use, but if you need to stick to the .bst you can't use biblatex. – moewe Sep 13 '17 at 14:29
  • 1
    @AlanMunn This quick and dirty natbib solution is perfect! In fact, it worked exactly as I was expecting, since I could keep the .bst I'm using. The solution to my problem was as simple as \citealt{kahneman1979prospect}] along with \bibpunct{(}{)}{,}{a}{}{;}. Thanks! – fabda01 Sep 13 '17 at 15:17
  • Ok I'll add that as an answer. – Alan Munn Sep 13 '17 at 15:19

1 Answers1

6

Here's a quick and dirty solution using natbib which won't require you to change any of your existing code. The idea is to set natbib to use round parentheses for regular \citet citations and redefine \citep to use the unbracketed \citealp with your own square brackets added.

We redefine \citep rather than \citet since the latter is much more likely to be used with its optional argument for pages etc., whereas \citep is typically used with a simple list of citations.

Here's a full example:

\documentclass{article}
\begin{filecontents}{\jobname.bib}

@article{kahneman1979prospect,
  title={Prospect theory: An analysis of decision under risk},
  author={Kahneman, Daniel and Tversky, Amos},
  journal={Econometrica: Journal of the econometric society},
  pages={263--291},
  year={1979},
  publisher={JSTOR}
}
\end{filecontents}

\usepackage{natbib}
\bibpunct{(}{)}{,}{a}{}{;}
\bibliographystyle{abbrvnat}
\renewcommand{\citep}[1]{[\citealp{#1}]}

\begin{document}

\section{Citation Style I}

\begin{itemize}
\item According to \cite{kahneman1979prospect} \dots is now correct.
\item According to \citet{kahneman1979prospect} \dots is now correct.
\item According to Kahneman and Tversky (1979) \dots is correct.
\end{itemize}

\section{Citation Style II}

\begin{itemize}
\item This is now correct \dots \citep{kahneman1979prospect}.
\item This is incorrect \dots (Kahneman and Tversky, 1979).
\end{itemize}

\bibliography{\jobname}

\end{document}

output of code

Alan Munn
  • 218,180