0

I have defined two cite-commands for my document:

\newcommand{\mcite}[1]{\textcolor{black}{\citeauthor{#1} (\citeyear{#1})}}
\newcommand{\hcite}[1]{(\textcolor{black}{\citeauthor{#1}, \citeyear{#1}})}

Citing Author (Date) and (Author Date).

However, I would like these cite-commands to make clickable citations in the document (will not work with hyperref like \cite). Suggestions?

moewe
  • 175,683
  • I guess this is the same issue you raised at the end of https://tex.stackexchange.com/q/488958/35864? So you are using biblatex, right? What exactly do \mcite and \hcite do? What is wrong with the usual \textcite and \parencite? One obvious difference is the \textcolor{black}, why do you need that? – moewe May 04 '19 at 06:14
  • Just to copy my comment about \mcite and \hcite from the other question: Combining \citeauthor and \citeyear as done in \mcite and \hcite is usually ill-advised, since commands defined like this will have problems with multiple citations, don't properly support pre- and postnotes and can at worst mess up citation tracking features. The proper way to define new \...cite macros is most of the time via \DeclareCiteCommand. In this case, though, I would suspect there might be an even easier solution. But I'd need to know what the commands are supposed to do exactly. – moewe May 04 '19 at 06:16
  • The purpose of the new cite commands was to have to simple cite-commands for simple citing throughout the document. This way, not having to write "Author name et. al" before a \citeyear etc. – jonaskir May 09 '19 at 07:33
  • What's wrong with \textcite and \parencite? – moewe May 09 '19 at 07:38
  • Previously I had a problem using them, however it seems to have solved without me knowing why.. (sorry I'm a relatively basic user..) Thanks! – jonaskir May 09 '19 at 07:59
  • Retagged because https://tex.stackexchange.com/q/488958/35864 confirms the OP is using biblatex. – moewe May 09 '19 at 08:07

1 Answers1

0

In general it is a bad idea to try and combine several of biblatex's \...cite commands into a single \newcommand. Commands defined like this often need extensive workarounds to properly handle pre- and postnotes (i.e. \cite[123]{sigfridsson}, \cite[Cf.][]{sigfridsson} and \cite[Cf.][223]{sigfridsson}). Furthermore, they usually have extreme problems when dealing with citations to multiple works (\cite{sigfridsson,worman}). Last but not least, citation commands defined like this can cause biblatex's citation tracker to get confused (this is mostly a theoretical worry, but I guess with enough ingenuity one could create an example where this is problematic).

New biblatex \...cite commands should always in almost all cases be defined via \DeclareCiteCommand.

In your case there is no need for that, however, since \mcite is essentially \textcite and \hcite is more or less \parencite assuming you use an author-year citation style.

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

\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson}

\textcite{sigfridsson}

\parencite{sigfridsson}

\printbibliography
\end{document}

Sigfridsson and Ryde 1998//Sigfridsson and Ryde (1998)//(Sigfridsson and Ryde 1998)

moewe
  • 175,683