

% ### TODO ### parametrize quote color
% ### TODO ### parametrize background color

% thx to http://tex.stackexchange.com/a/16981/28067

\ProvidesPackage{cxltx-style-shadequote}


% ##########################################################################################################
\usepackage{ifxetex,ifluatex}
\usepackage{etoolbox}
% \usepackage[svgnames]{xcolor}

\usepackage{tikz}

\usepackage{framed}

\usepackage{fontspec}
% \usepackage{libertine} % or use \setmainfont to choose any font on your system
% \newfontfamily\quotefont[Ligatures=TeX]{Helvetica}
\newfontfamily\quotefont[Ligatures=TeX]{Arial Unicode MS}

\newcommand*\quotesize{20} % if quote size changes, need a way to make shifts relative
% Make commands for the quotes
\newcommand*{\openquote}
   {\tikz[remember picture,overlay,xshift=-4ex,yshift=-0ex]
   % \node (OQ) {\quotefont\fontsize{\quotesize}{\quotesize}\selectfont\color{gray}{``}};\kern0pt}
   \node (OQ) {\quotefont\fontsize{\quotesize}{\quotesize}\selectfont\color{black}{☛}};\kern0pt}

\newcommand*{\closequote}[1]
  {\tikz[remember picture,overlay,xshift=4ex,yshift={#1}]
   \node (CQ) {\quotefont\fontsize{\quotesize}{\quotesize}\selectfont\color{black}{''}};}

% select a colour for the shading
% \colorlet{shadecolor}{Azure}
\colorlet{shadecolor}{white}

\newcommand*\shadedauthorformat{\emph} % define format for the author argument

% Now a command to allow left, right and centre alignment of the author
\newcommand*\authoralign[1]{%
  \if#1l
    \def\authorfill{}\def\quotefill{\hfill}
  \else
    \if#1r
      \def\authorfill{\hfill}\def\quotefill{}
    \else
      \if#1c
        \gdef\authorfill{\hfill}\def\quotefill{\hfill}
      \else\typeout{Invalid option}
      \fi
    \fi
  \fi}

% Wrap everything in its own environment which takes one argument (author) and one optional argument
% specifying the alignment [l, r or c]
%
\newenvironment{shadequote}[2][r]%
{\authoralign{#1}
\ifblank{#2}
   {\def\shadequoteauthor{}\def\yshift{-2ex}\def\quotefill{\hfill}}
   {\def\shadequoteauthor{\par\authorfill\shadedauthorformat{#2}}\def\yshift{2ex}}
\begin{snugshade}\begin{quote}\openquote}
{\shadequoteauthor%
\quotefill%
% \closequote{\yshift}%
\end{quote}\end{snugshade}}
% ##########################################################################################################
