First of all I want to recommend to avoid the old package chicago
instead use biblatex
The package hyperref
has a small support for the package chicago
. It redefines some internal commands of chicago.sty
to get the correct hyperlink. The internal definition is:
\@ifpackageloaded{chicago}{%
\def\citeN{%
\def\@citeseppen{-1000}%
\def\@cite##1##2{##1}%
\def\citeauthoryear##1##2##3{##1 (##3\@cite@opt)}%
\@citedata@opt
}%
\def\shortciteN{%
\def\@citeseppen{-1000}%
\def\@cite##1##2{##1}%
\def\citeauthoryear##1##2##3{##2 (##3\@cite@opt)}%
\@citedata@opt
}%
\def\@citedata@opt{%
\let\@cite@opt\@empty
\@ifnextchar [{%
\@tempswatrue
\@citedatax@opt
}{%
\@tempswafalse
\@citedatax[]%
}%
}%
\def\@citedatax@opt[#1]{%
\def\@cite@opt{, #1}%
\@citedatax[{#1}]%
}%
}{}
Based on this modification I took the original definition of \citeyearNP
and \citeyear
and modified them after the scheme of hyperref
:
The original definition of chicago.sty
:
\def\citeyear{\def\@citeseppen{-1000}%
\def\@cite##1##2{(##1\if@tempswa , ##2\fi)}%
\def\citeauthoryear##1##2##3{##3}\@citedata}
\def\citeyearNP{\def\@citeseppen{-1000}%
\def\@cite##1##2{##1\if@tempswa , ##2\fi}%
\def\citeauthoryear##1##2##3{##3}\@citedata}
Modified version:
\def\citeyear{\def\@citeseppen{-1000}%
\def\@cite##1##2{(##1)}%
\def\citeauthoryear##1##2##3{##3\@cite@opt}\@citedata@opt}
\def\citeyearNP{\def\@citeseppen{-1000}%
\def\@cite##1##2{##1}%
\def\citeauthoryear##1##2##3{##3\@cite@opt}\@citedata@opt}
With this redefinition you will get:
Here the complete code. Of course the other cite commands must be redefined too. But I think that it can be done easily by you.
\documentclass{article}
\usepackage{chicago}
\usepackage{filecontents}
\usepackage[colorlinks=true,citecolor=red]{hyperref}
\makeatletter
\def\citeyear{\def\@citeseppen{-1000}%
\def\@cite##1##2{(##1)}%
\def\citeauthoryear##1##2##3{##3\@cite@opt}\@citedata@opt}
\def\citeyearNP{\def\@citeseppen{-1000}%
\def\@cite##1##2{##1}%
\def\citeauthoryear##1##2##3{##3\@cite@opt}\@citedata@opt}
\makeatother
\begin{filecontents*}{references.bib}
@book{ref,
author = {Donald E. Knuth},
title = {The TeXbook},
publisher = {Addison-Wesley},
year = {1986}
}
\end{filecontents*}
\begin{document}
\begin{tabular}{llll}
& cite & \cite[p.\,1]{ref} & \cite{ref} \\
& citeNP & \citeNP[p.\,1]{ref} & \citeNP{ref} \\
& citeA & \citeA[p.\,1]{ref} & \citeA{ref} \\
& citeANP & \citeANP[p.\,1]{ref} & \citeANP{ref} \\
$\rightarrow$ & citeN & \citeN[p.\,1]{ref} & \citeN{ref} \\
& shortcite & \shortcite[p.\,1]{ref} & \shortcite{ref} \\
& shortciteNP & \shortciteNP[p.\,1]{ref} & \shortciteNP{ref} \\
& shortciteA & \shortciteA[p.\,1]{ref} & \shortciteA{ref} \\
& shortciteANP & \shortciteANP[p.\,1]{ref} & \shortciteANP{ref}\\
$\rightarrow$ & shortciteN & \shortciteN[p.\,1]{ref} & \shortciteN{ref} \\
& citeyear & \citeyear[p.\,1]{ref} & \citeyear{ref} \\
& citeyearNP & \citeyearNP[p.\,1]{ref} & \citeyearNP{ref} \\
\end{tabular}
\bibliographystyle{chicago}
\bibliography{references}
\end{document}
Environment NoHyper
should help:
\begin{NoHyper}\cite{foobar}\end{NoHyper}
A star form is problematic, because some citing commands already have one (e.g. \citep
, \citet
). But macros can be defined, e.g.:
\newcommand*{\nolink}[1]{%
\begin{NoHyper}#1\end{NoHyper}%
}
\nolink{\cite{foobar}}
Best Answer
\cite
is not expandable and will therefore not work, when the subsection title is expanded to a bookmark string.\texorpdfstring
can be used to provide an alternative or omit it:Or use the optional argument to remove the citation in the table of contents, too.