\ifdefined\nobibcompress
  \usepackage[square,numbers,sort]{natbib}
\else
  \usepackage[square,numbers,sort&compress]{natbib}
\fi
\usepackage{xparse}
\usepackage{letltxmacro}
% \usepackage{etoolbox}

\LetLtxMacro\oldcitep\citep
\RenewDocumentCommand\citep{o o m}{%
  \textsuperscript{%
    \IfNoValueTF{#1}{%
      \oldcitep{#3}%
    }{%
      \IfNoValueTF{#2}{%
        \oldcitep[#1]{#3}%
      }{%
        \oldcitep[#1][#2]{#3}%
      }%
    }%
  }%
}

% Put year in citet.
\newcommand*{\nolink}[1]{{\protect\NoHyper#1\protect\endNoHyper}}
\let\origcitet\citet
\renewcommand{\citet}[2][]{%
  \nolink{\citeauthor{#2} (\citeyear{#2})}\citep[#1]{#2}%
}

\let\origcitetext\citetext
\renewcommand{\citetext}[1]{\textsuperscript{\origcitetext{#1}}}
