0

I wanted to have coloured citation in beamer. I have used the following code,

    \documentclass[12pt]{beamer}
    \usetheme{CambridgeUS}
    \usepackage[utf8]{inputenc}
    \usepackage[english]{babel}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage[T1]{fontenc}
    \usefonttheme[onlymath]{serif}
    \usepackage{amssymb}
    \usepackage{graphicx}
    \usepackage{bm}
    \usepackage{lmodern}
    \usepackage{color}
    %\usepackage{multimedia}
    %\usepackage{movie15}
    %\usepackage{tikz}
    %\tikzset{
    %  every overlay node/.style={
    %    draw=black,anchor=north west,
    %  },
    %}
    %\def\tikzoverlay{%
    %   \tikz[baseline,overlay]\node[every overlay node]
    %}%

    %%for Justifying in itemised 

    \usepackage{ragged2e}

    \let\olditem=\item% 
    \renewcommand{\item}{\olditem \justifying}%
    %--------------------------------------------------
    %for objective theorm enviroment

    \makeatletter
    \def\th@mystyle{%
        \normalfont % body font
        \setbeamercolor{block title example}{bg=red!80,fg=white}
        \setbeamercolor{block body example}{bg=red!20,fg=black}
        \def\inserttheoremblockenv{exampleblock}
      }
    \makeatother
    \theoremstyle{mystyle}
    \newtheorem*{Objective}{Objective}

    %%-------------------------


    \usepackage{csquotes}% Recommended


    \usepackage[backend=biber,
      style=authoryear,
       ]{biblatex}
    \DeclareLanguageMapping{american}{american-apa}

    \addbibresource{DP.bib}

    \makeatletter
    \let\abx@macro@citeOrig\abx@macro@cite
    \renewbibmacro{cite}{%
       \bibhyperref{%
       \let\bibhyperref\relax\relax%
       \abx@macro@citeOrig%
       }%
    }
    \let\abx@macro@parenciteOrig\abx@macro@parencite
    \renewbibmacro{parencite}{%
       \bibhyperref{%
       \let\bibhyperref\relax\relax%
       \abx@macro@parenciteOrig%
       }%
    }%
    \let\abx@macro@textciteOrig\abx@macro@textcite
    \renewbibmacro{textcite}{%
       \bibhyperref{%
       \let\bibhyperref\relax\relax%
       \abx@macro@textciteOrig%
       }%
    }%
    \makeatother
    %\usepackage[colorlinks]{hyperref}
    \hypersetup{colorlinks,
    citecolor=blue,
    linkcolor=.,
    menucolor=white,
    filecolor=pink,   
    anchorcolor=yellow
    }
    \begin{document}
    \begin{frame}{Multiple Model Switching Controllers}
    \begin{itemize}
        \item \textcite{greytak2007exponentially} gave control scheme which switches between Manifold Convergence Controller and LQR controller for underactuated Autonomous Surface Vessel (river) with just a propeller and rudder.
        \item \textcite{hassani2012multiple} proposed multiple model adaptive controller consisting of four LQG controller. The controller switching occurs to compensate for different sea state.
        \item \textcite{brodtkorb2014dynamic} demonstrated a control scheme with four different PID and sensor based observer for switching between them. Switching logic is based on spectral analysis of motion.
        \item \textcite{hassani2013novel} simulated used Robust Multiple Model Adaptive Dynamic Positioning switching Controller designed using mixed $ \mu $ methodology for different sea state.
    \end{itemize}

    \end{frame}

\end{document}

The problem is the ending bracket when using \textcite{} is not the same colour as hyperlink. What might be the issue. I'm doing this on sharelatex.

enter image description here

  • 2
    Welcome. Can you add your complete and compilable MWE, please? – Sebastiano Oct 13 '17 at 7:03
  • @Sebastiano I did. Do i need to add bib file too ? – Kunal Tiwari Oct 13 '17 at 7:36
  • Can you try with \usepackage{xcolor} instead of \usepackage{color}. With Papeeria or Overleaf I have problem with your code. – Sebastiano Oct 13 '17 at 7:50
  • \usepackage{xcolor} did no difference. – Kunal Tiwari Oct 13 '17 at 9:34
2

Based on https://tex.stackexchange.com/a/25972/36296 you could use:

\documentclass[12pt]{beamer}
\usetheme{CambridgeUS}


\usepackage[english]{babel}
\usepackage{csquotes}% Recommended
\usepackage[backend=biber,
  style=authoryear,
   ]{biblatex}
\DeclareLanguageMapping{american}{american-apa}

\addbibresource{\jobname.bib}

\hypersetup{colorlinks,
citecolor=blue,
linkcolor=.,
menucolor=white,
filecolor=pink,   
anchorcolor=yellow
}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{knuth,
  author       = {Knuth, Donald E.},
  title        = {The {\TeX} book},
  date         = 1984,
  maintitle    = {Computers \& Typesetting},
  volume       = {A},
  publisher    = {Addison-Wesley},
  location     = {Reading, Mass.},
  langid       = {english},
  langidopts   = {variant=american},
  sortyear     = {1984-1},
  sorttitle    = {Computers & Typesetting A},
  indexsorttitle= {The TeXbook},
  indextitle   = {\protect\TeX book, The},
  shorttitle   = {\TeX book}
}

@article{einstein,
    author = {Einstein, A.},
    title = {Die Grundlage der allgemeinen Relativitätstheorie},
    journal = {Annalen der Physik},
    volume = {354},
    number = {7},
    doi = {10.1002/andp.19163540702},
    pages = {769--822},
    year = {1916}
}
\end{filecontents*}

\DeclareCiteCommand{\textcite}
 {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
    \printtext[bibhyperref]{\printnames{labelname}%
      \printtext{ (\printfield{year}\printtext{)}}}}
 {\ifbool{cbx:parens}
  {\bibcloseparen\global\boolfalse{cbx:parens}}
  {}%
 \multicitedelim}
{\usebibmacro{textcite:postnote}}

\begin{document}
\begin{frame}{Multiple Model Switching Controllers}
\begin{itemize}
    \item \textcite{einstein} gave control scheme which switches between Manifold Convergence Controller and LQR controller for underactuated Autonomous Surface Vessel (river) with just a propeller and rudder.
\end{itemize}

\end{frame}

\end{document}

enter image description here


Please note that you neither need color nor graphicx with beamer, as beamer already provides this functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.