improved line breaks in rightline templates for quotations

This commit is contained in:
Jan Benda 2021-03-07 22:04:56 +01:00
parent d009a765a8
commit 2cbad3ada2
2 changed files with 42 additions and 18 deletions

View File

@ -573,9 +573,17 @@
% pbk , phv, pnc, qcs
\newcommand{\openquote}[2]{\tikz[baseline]{%
\useasboundingbox (0, 0) rectangle (1ex, 1.7ex);
\node[scale=#2, xshift=-0.45ex, yshift=-0.75ex] at (current bounding box.north east) {\usebeamerfont*{#1 symbol}\textquotedblleft};
\node[scale=#2, xshift=-0.28ex, yshift=-0.75ex] at (current bounding box.north east) {\usebeamerfont*{#1 symbol}\textquoteleft};
}}
\newcommand{\closequote}[2]{\tikz[baseline]{%
\useasboundingbox (0, 0) rectangle (1ex, 1.7ex);
\node[scale=#2, xshift=-0.28ex, yshift=-0.75ex] at (current bounding box.north east) {\usebeamerfont*{#1 symbol}\textquoteright};
}}
\newcommand{\opendblquote}[2]{\tikz[baseline]{%
\useasboundingbox (0, 0) rectangle (1ex, 1.7ex);
\node[scale=#2, xshift=-0.45ex, yshift=-0.75ex] at (current bounding box.north east) {\usebeamerfont*{#1 symbol}\textquotedblleft};
}}
\newcommand{\closedblquote}[2]{\tikz[baseline]{%
\useasboundingbox (0, 0) rectangle (1ex, 1.7ex);
\node[scale=#2, xshift=-0.45ex, yshift=-0.75ex] at (current bounding box.north east) {\usebeamerfont*{#1 symbol}\textquotedblright};
}}
@ -598,23 +606,26 @@
\usebeamercolor{#1 source}%
#2\insertquotesource#3%
\fi}
% linebreaking from
% https://tex.stackexchange.com/questions/13756/quote-environment-with-reference-at-the-end-right :
\newcommand{\quote@source@rightline}[3]{%
\ifx\insertquotesource\@empty\else%
\hfill%
\leavevmode\unskip\nobreak\hfil\penalty50\hskip2em\hbox{}\nobreak\hfil%
\usebeamerfont{#1 source}%
\usebeamercolor{#1 source}%
#2\insertquotesource#3%
\makebox{#2\insertquotesource#3}%
\parfillskip=0pt \finalhyphendemerits=0 \endgraf%
\fi}
% for improvement see
% https://tex.stackexchange.com/questions/13756/quote-environment-with-reference-at-the-end-right
% quotation environment
\defbeamertemplate{quotation symbol}{default}{}
\defbeamertemplate{quotation symbol}{openquote}[1][4]{\usebeamercolor[fg]{quotation symbol}\openquote{quotation}{#1}}
\defbeamertemplate{quotation symbol}{closequote}[1][4]{\usebeamercolor[fg]{quotation symbol}\closequote{quotation}{#1}}
\defbeamertemplate{quotation symbol}{opendblquote}[1][4]{\usebeamercolor[fg]{quotation symbol}\opendblquote{quotation}{#1}}
\defbeamertemplate{quotation symbol}{closedblquote}[1][4]{\usebeamercolor[fg]{quotation symbol}\closedblquote{quotation}{#1}}
\setbeamertemplate{quotation symbol}[openquote][4] % default, openquote, closequote
\setbeamertemplate{quotation symbol}[opendblquote][4] % default, openquote, closequote, opendblquote, closedblquote
\defbeamertemplate{quotation source}{default}{}
\defbeamertemplate{quotation source}{left}{\quote@source@left{quotation}{}{}}
@ -695,8 +706,10 @@
\defbeamertemplate{quote symbol}{default}{}
\defbeamertemplate{quote symbol}{openquote}[1][4]{{\usebeamercolor[fg]{quote symbol}\openquote{quote}{#1}}}
\defbeamertemplate{quote symbol}{closequote}[1][4]{{\usebeamercolor[fg]{quote symbol}\closequote{quote}{#1}}}
\defbeamertemplate{quote symbol}{opendblquote}[1][4]{{\usebeamercolor[fg]{quote symbol}\opendblquote{quote}{#1}}}
\defbeamertemplate{quote symbol}{closedblquote}[1][4]{{\usebeamercolor[fg]{quote symbol}\closedblquote{quote}{#1}}}
\setbeamertemplate{quote symbol}[openquote][4] % default, openquote, closequote
\setbeamertemplate{quote symbol}[opendblquote][4] % default, openquote, closequote, opendblquote, closedblquote
\defbeamertemplate{quote source}{default}{}
\defbeamertemplate{quote source}{left}{\quote@source@left{quote}{}{}}

View File

@ -599,15 +599,24 @@
\vfill
}
\newcommand{\quotesymboldemo}[1]{
\setbeamertemplate{quote symbol}[#1]
\newcommand{\quotesymboldemo}[2]{
\setbeamertemplate{quote symbol}[#1]#2
\begin{small}
\texttt{\textbackslash setbeamertemplate\{quote symbol\}[#1]}
\texttt{\textbackslash setbeamertemplate\{quote symbol\}[#1]#2}
\end{small}
\quotedemo
\setbeamertemplate{quote symbol}[openquote]
\setbeamertemplate{quote symbol}[opendblquote]
}
\begin{frame}[fragile]{Quote symbol settings}
\quotesymboldemo{default}{}
\quotesymboldemo{closequote}{}
\quotesymboldemo{openquote}{}
\quotesymboldemo{closedblquote}{}
\quotesymboldemo{opendblquote}{}
\quotesymboldemo{opendblquote}{[2]}
\end{frame}
\newcommand{\quotesymbolfontdemo}[1]{
\setbeamerfont{quote symbol}{family*=#1}
\begin{small}
@ -617,14 +626,11 @@
\setbeamerfont{quote symbol}{family*=pbk}
}
\begin{frame}[fragile]{Quote symbol settings}
\quotesymboldemo{default}
\quotesymboldemo{closequote}
\quotesymboldemo{openquote}
\quotesymbolfontdemo{phv}
\quotesymbolfontdemo{pnc}
\begin{frame}[fragile]{Font settings for quote symbol}
\quotesymbolfontdemo{pbk}
%\quotesymbolfontdemo{qcs}
\quotesymbolfontdemo{pnc}
\quotesymbolfontdemo{qcs}
\quotesymbolfontdemo{phv}
\end{frame}
\newcommand{\quotesourcedemo}[1]{
@ -665,6 +671,11 @@
\quotesourcedemo{rightlinebrackets}
\quotesourcedemo{dashrightline}
\quotesourcedemo{tilderightline}
In case the last line is too long, the source is printed on the next line:
\begin{quote}[Hamlet by William Shakespeare]
To be, or not to be, that is the question:
Whether 'tis nobler in the mind to suffer ...
\end{quote}
\end{frame}
\newcommand{\quotecolordemo}[2]{