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 % pbk , phv, pnc, qcs
\newcommand{\openquote}[2]{\tikz[baseline]{% \newcommand{\openquote}[2]{\tikz[baseline]{%
\useasboundingbox (0, 0) rectangle (1ex, 1.7ex); \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]{% \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); \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}; \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}% \usebeamercolor{#1 source}%
#2\insertquotesource#3% #2\insertquotesource#3%
\fi} \fi}
% linebreaking from
% https://tex.stackexchange.com/questions/13756/quote-environment-with-reference-at-the-end-right :
\newcommand{\quote@source@rightline}[3]{% \newcommand{\quote@source@rightline}[3]{%
\ifx\insertquotesource\@empty\else% \ifx\insertquotesource\@empty\else%
\hfill% \leavevmode\unskip\nobreak\hfil\penalty50\hskip2em\hbox{}\nobreak\hfil%
\usebeamerfont{#1 source}% \usebeamerfont{#1 source}%
\usebeamercolor{#1 source}% \usebeamercolor{#1 source}%
#2\insertquotesource#3% \makebox{#2\insertquotesource#3}%
\parfillskip=0pt \finalhyphendemerits=0 \endgraf%
\fi} \fi}
% for improvement see
% https://tex.stackexchange.com/questions/13756/quote-environment-with-reference-at-the-end-right
% quotation environment % quotation environment
\defbeamertemplate{quotation symbol}{default}{} \defbeamertemplate{quotation symbol}{default}{}
\defbeamertemplate{quotation symbol}{openquote}[1][4]{\usebeamercolor[fg]{quotation symbol}\openquote{quotation}{#1}} \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}{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}{default}{}
\defbeamertemplate{quotation source}{left}{\quote@source@left{quotation}{}{}} \defbeamertemplate{quotation source}{left}{\quote@source@left{quotation}{}{}}
@ -695,8 +706,10 @@
\defbeamertemplate{quote symbol}{default}{} \defbeamertemplate{quote symbol}{default}{}
\defbeamertemplate{quote symbol}{openquote}[1][4]{{\usebeamercolor[fg]{quote symbol}\openquote{quote}{#1}}} \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}{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}{default}{}
\defbeamertemplate{quote source}{left}{\quote@source@left{quote}{}{}} \defbeamertemplate{quote source}{left}{\quote@source@left{quote}{}{}}

View File

@ -599,15 +599,24 @@
\vfill \vfill
} }
\newcommand{\quotesymboldemo}[1]{ \newcommand{\quotesymboldemo}[2]{
\setbeamertemplate{quote symbol}[#1] \setbeamertemplate{quote symbol}[#1]#2
\begin{small} \begin{small}
\texttt{\textbackslash setbeamertemplate\{quote symbol\}[#1]} \texttt{\textbackslash setbeamertemplate\{quote symbol\}[#1]#2}
\end{small} \end{small}
\quotedemo \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]{ \newcommand{\quotesymbolfontdemo}[1]{
\setbeamerfont{quote symbol}{family*=#1} \setbeamerfont{quote symbol}{family*=#1}
\begin{small} \begin{small}
@ -617,14 +626,11 @@
\setbeamerfont{quote symbol}{family*=pbk} \setbeamerfont{quote symbol}{family*=pbk}
} }
\begin{frame}[fragile]{Quote symbol settings} \begin{frame}[fragile]{Font settings for quote symbol}
\quotesymboldemo{default}
\quotesymboldemo{closequote}
\quotesymboldemo{openquote}
\quotesymbolfontdemo{phv}
\quotesymbolfontdemo{pnc}
\quotesymbolfontdemo{pbk} \quotesymbolfontdemo{pbk}
%\quotesymbolfontdemo{qcs} \quotesymbolfontdemo{pnc}
\quotesymbolfontdemo{qcs}
\quotesymbolfontdemo{phv}
\end{frame} \end{frame}
\newcommand{\quotesourcedemo}[1]{ \newcommand{\quotesourcedemo}[1]{
@ -665,6 +671,11 @@
\quotesourcedemo{rightlinebrackets} \quotesourcedemo{rightlinebrackets}
\quotesourcedemo{dashrightline} \quotesourcedemo{dashrightline}
\quotesourcedemo{tilderightline} \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} \end{frame}
\newcommand{\quotecolordemo}[2]{ \newcommand{\quotecolordemo}[2]{