我尝试为我的 Beamer 演示文稿中的文内引文添加颜色。我每篇文章都使用多个引文,主要是通过 \parencite。为了提高可读性,我希望将参考文献(包括括号)打印为灰色。不幸的是,所有解决方案和解决方法(使用 Beamer + Hyperref + Natbib 进行引文着色,Beamer:Biblatex biber,全局更改引文颜色和Beamer 忽略 hyperref 中的 citecolor) 不起作用。要么所有链接(部分和子部分)都变成彩色,要么什么都没有改变。
\documentclass[presentation]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage[germanb]{babel}
\beamertemplatenavigationsymbolsempty
\setbeamertemplate{footline}[frame number]
\usepackage{csquotes}
\usepackage{xpatch}
\usepackage[backend=biber, uniquename=false, maxbibnames=99, maxcitenames=2, citestyle=authoryear, bibstyle=authoryear]{biblatex}
\DefineBibliographyStrings{german}{andothers = {{et\, al\adddot}},}
\DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{default}{last-first}
\renewcommand*{\multinamedelim}{\addslash}
\renewcommand*{\finalnamedelim}{\multinamedelim}
\renewbibmacro*{journal+issuetitle}{\usebibmacro{journal} \setunit*{\addcomma\space}\iffieldundef{series}{}{\newunit \printfield{series}\setunit{\addspace}}\usebibmacro{volume+number+eid} \setunit{\addspace}\usebibmacro{issue+date}\setunit{\addcolon\space}\usebibmacro{issue}\newunit}
\DeclareFieldFormat[article]{pages}{#1}%
\DeclareFieldFormat[incollection]{pages}{#1}%
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}
\renewcommand{\labelnamepunct}{\addcolon\space}
\renewbibmacro*{volume+number+eid}{\printfield{volume}\setunit*{\adddot}\setunit*{\addnbthinspace}\printfield{number}\setunit{\addcomma\space}\printfield{eid}}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}
\renewcommand*{\bibpagespunct}{\addcolon\space}
\renewbibmacro*{byeditor+others}{\ifnameundef{editor}{}{\setunit{\addspace}\printnames[byeditor]{editor}\clearname{editor}\setunit{\addspace}\usebibmacro{byeditor+othersstrg}\newunit}\usebibmacro{byeditorx} \usebibmacro{bytranslator+others}}
\DefineBibliographyStrings{german}{byeditor ={\addspace\mkbibparens {Hrsg\adddot}\addcolon},}
\newbibmacro*{byeditor:in}{\ifnameundef{editor}{}{\printnames[editorin]{editor}\addspace\bibsentence \mkbibparens{\usebibmacro{editorstrg}}\clearname{editor}\printunit{\addcolon\space}}}
\xpatchbibdriver{inbook}{\usebibmacro{in:}\usebibmacro{bybookauthor}\newunit\newblock\usebibmacro{maintitle+booktitle} \newunit\newblock\usebibmacro{byeditor+others}}{\usebibmacro{in:}\usebibmacro{bybookauthor}\newunit\newblock\usebibmacro{byeditor:in} \newunit\newblock\usebibmacro{maintitle+booktitle}\newunit\newblock\usebibmacro{byeditor+others}}{}{}
\xpatchbibdriver{incollection}{\usebibmacro{in:}\usebibmacro{maintitle+booktitle}\newunit\newblock \usebibmacro{byeditor+others}}{\usebibmacro{in:}\usebibmacro{byeditor:in}\setunit{\labelnamepunct}\newblock \usebibmacro{maintitle+booktitle}\newunit\newblock\usebibmacro{byeditor}}{}{}
\xpatchbibdriver{inproceedings}{\usebibmacro{in:}\usebibmacro{maintitle+booktitle}\newunit\newblock \usebibmacro{event+venue+date}\newunit\newblock\usebibmacro{byeditor+others}}{\usebibmacro{in:}\usebibmacro{byeditor:in} \setunit{\labelnamepunct}\newblock\usebibmacro{maintitle+booktitle}\newunit\newblock\usebibmacro{event+venue+date}\newunit\newblock \usebibmacro{byeditor+others}}{}{}
\DeclareFieldFormat{edition}{\mkbibparens{\ifinteger{#1}{\mkbibordedition{#1}~\bibstring{edition}}{#1\isdot}}}
\renewcommand*{\postnotedelim}{\addcolon\space}
\addbibresource{/home/tassilo/Dokumente/01-Literaturdatenbank/Masterfile/references.bib}
\usetheme{Malmoe}
\usecolortheme{seagull}
\author{Vorname Nachname}
\date{30. Mai 2017}
\title{Titel}
\usepackage{filecontents}
\begin{filecontents}{references.bib}
@Book{bartolini-mair-1990,
author = {Bartolini, Stefano AND Mair, Peter},
title = {Identity, Competition and Electoral
Availability. The Stabilization of European
Electorates 1885-1985},
publisher = {Cambridge University Press},
year = 1990,
address = {Cambridge},
}
\end{filecontents}
\begin{document}
\maketitle
\begin{frame}{Outline}
\setcounter{tocdepth}{1}
\tableofcontents
\end{frame}
\section{Einleitung}
\label{sec:orgheadline6}
\begin{frame}[label={sec:orgheadline1}]{Einleitung}
Text \cite{bartolini-mair-1990}
\end{frame}
\end{document}
答案1
您可以使用以下方式设置超链接的颜色
\hypersetup{
colorlinks,
citecolor=green,
linkcolor=black
}
(这只会为引文的可点击部分添加颜色)或将颜色手动添加到引文命令中:
\documentclass[presentation]{beamer}
\usepackage[backend=biber, uniquename=false, maxbibnames=99, maxcitenames=2, citestyle=authoryear, bibstyle=authoryear]{biblatex}
\addbibresource{references.bib}
\DeclareCiteCommand{\cite}
{\color{red}\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\parencite}[\mkcolorbibparens]
{\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\makeatletter
\newrobustcmd{\mkcolorbibparens}[1]{%
\begingroup
\color{red}%
\blx@blxinit
\blx@setsfcodes
\bibopenparen#1\bibcloseparen
\endgroup}
\makeatother
\usepackage{filecontents}
\begin{filecontents}{references.bib}
@Book{bartolini-mair-1990,
author = {Bartolini, Stefano AND Mair, Peter},
title = {Identity, Competition and Electoral Availability. The Stabilization of European Electorates 1885-1985},
publisher = {Cambridge University Press},
year = 1990,
address = {Cambridge},
}
\end{filecontents}
\begin{document}
\begin{frame}
Text \cite{bartolini-mair-1990} text
Text \parencite{bartolini-mair-1990} text
\end{frame}
\begin{frame}
\printbibliography
\end{frame}
\end{document}