summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ppt-slides/ppt-slides.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/ppt-slides/ppt-slides.dtx')
-rw-r--r--macros/latex/contrib/ppt-slides/ppt-slides.dtx662
1 files changed, 662 insertions, 0 deletions
diff --git a/macros/latex/contrib/ppt-slides/ppt-slides.dtx b/macros/latex/contrib/ppt-slides/ppt-slides.dtx
new file mode 100644
index 0000000000..5f21146d16
--- /dev/null
+++ b/macros/latex/contrib/ppt-slides/ppt-slides.dtx
@@ -0,0 +1,662 @@
+% \iffalse meta-comment
+% (The MIT License)
+%
+% Copyright (c) 2021-2022 Yegor Bugayenko
+%
+% Permission is hereby granted, free of charge, to any person obtaining a copy
+% of this software and associated documentation files (the 'Software'), to deal
+% in the Software without restriction, including without limitation the rights
+% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+% copies of the Software, and to permit persons to whom the Software is
+% furnished to do so, subject to the following conditions:
+%
+% The above copyright notice and this permission notice shall be included in all
+% copies or substantial portions of the Software.
+%
+% THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+% SOFTWARE.
+% \fi
+
+% \CheckSum{0}
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+
+% \GetFileInfo{ppt-slies.dtx}
+% \DoNotIndex{\endgroup,\begingroup,\let,\else,\s,\n,\r,\\,\1,\fi}
+
+% \iffalse
+%<*driver>
+\ProvidesFile{ppt-slides.dtx}
+%</driver>
+%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\ProvidesPackage{ppt-slides}
+%<*package>
+[2022-12-03 0.2.0 Slide Decks a la Power Point]
+%</package>
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[T1]{fontenc}
+\usepackage[tt=false, type1=true]{libertine}
+\usepackage{microtype}
+\AddToHook{env/verbatim/begin}{\microtypesetup{protrusion=false}}
+\usepackage{graphicx}
+\usepackage{xcolor}
+\usepackage[runs=2,dtx,margin=0,small]{docshots}
+\usepackage{href-ul}
+\PageIndex
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+\begin{document}
+ \DocInput{ppt-slides.dtx}
+ \PrintChanges
+ \PrintIndex
+\end{document}
+%</driver>
+% \fi
+
+% \title{|ppt-slides|: \LaTeX{} Package for \\ Slide Decks \`{a} la Power Point\thanks{The sources are in GitHub at \href{https://github.com/yegor256/ppt-slides}{yegor256/ppt-slides}}}
+% \author{Yegor Bugayenko \\ \texttt{yegor256@gmail.com}}
+% \date{\filedate, \fileversion}
+%
+% \maketitle
+%
+% \section{Introduction}
+%
+% This package helps you render slide decks in PowerPoint\texttrademark{} style:
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[template,scheme=dark]{ppt-slides}
+% \begin{document}
+% \pptMiddle{\pptTitle{Hello, world!}{How are you?}}
+% \end{document}
+% \end{docshot}
+
+% It is recommended to use this package together with
+% \href{https://github.com/yegor256/clicks}{clicks}:
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[template,scheme=dark]{ppt-slides}
+% \usepackage[static]{clicks}
+% \begin{document}
+% We help you make slide decks in \LaTeX:
+% \plick{\pptBanner{Making Slides Is Easy}}
+% \plick{Just use this package...}
+% \plush{together with 'clicks' package.}
+% They will look similar to what PowerPoint can
+% make, but with the precision of \LaTeX. We
+% recommend using us together with ``clicks.''
+% \end{document}
+% \end{docshot}
+
+% \section{Layout}
+
+% \DescribeMacro{\pptToc}
+% \DescribeMacro{\pptChapter}
+% First, split your story into chapters:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\documentclass{article}
+\usepackage{clicks}
+\usepackage[template,scheme=light]{ppt-slides}
+\begin{document}
+\pptToc
+\plush{\pptChapter{About Me}}
+...
+\plush{\pptChapter[Idea]{My Idea Is Novel}}
+...
+\plush{\pptChapter[FAQ]{Discussion \& Questions}}
+...
+\end{document}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+% |\pptToc| will render the table of contents in an interactive ``clickable'' format.
+% Thanks to the use of \href{https://github.com/yegor256/crumbs}{crumbs}, there will
+% be a navigation at the top left corner.
+
+% \DescribeMacro{\pptSection}
+% Then, put sections inside chapters:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\begin{document}
+\pptToc
+\plush{\pptChapter{About Me}}
+\plush{\pptSection[Student]{I'm a Student}}
+...
+\plush{\pptSection[Athlete]{Also, I'm an Athlete}}
+...
+\plush{\pptChapter[Idea]{My Idea Is Novel}}
+\plush{\pptSection{Novelty}}
+\plush{\pptSection{Impact}}
+\end{document}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+% The |\pptChapter| and |\pptSection| commands used together will render
+% nice two-level nagivation menu at the top left corner.
+
+% \DescribeMacro{\pptLeft}
+% \DescribeMacro{\pptRight}
+% You can place the title of the presentation and your name at the bottom
+% of each slide, on the left and on the right respectively:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\documentclass{article}
+\usepackage{clicks}
+\usepackage[template,scheme=light]{ppt-slides}
+\pptLeft{How Did I Spend Last Summer}
+\pptRight{Yegor Bugayenko}
+\begin{document}
+...
+\end{document}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+% If you don't use the |\pptLeft| or |\pptRight| commands, nothing will
+% be printed at the bottom.
+
+% \section{Commands}
+
+% \DescribeMacro{\pptPic}
+% You can add an image to the slide (the first argument is the width
+% of the image in relation to |\textwidth|,
+% while the second one is the path of it):
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[template,scheme=dark]{ppt-slides}
+% \begin{document}
+% \pptPic{0.2}{socrates.jpg} \\
+% This is Socrates, a Greek philosopher.
+% \end{document}
+% \end{docshot}
+
+% \DescribeMacro{\pptHeader}
+% You can add a piece of code to the slide (we recommend using \href{https://github.com/yegor256/ffcode}{ffcode}):
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[template,scheme=dark]{ppt-slides}
+% \usepackage{ffcode}
+% \begin{document}
+% \pptHeader{This is How You Print to Console:}
+% \begin{ffcode}
+% void main(char** args) {
+% printf("Hello, world!");
+% }
+% \end{ffcode}
+% \end{document}
+% \end{docshot}
+% Don't use |\plick| or |\plush|, they won't work with code snippets.
+% The |\pptHeader| command prints a header similar to what the |\pptSection| command prints, but
+% doesn't start a new section.
+
+% \DescribeMacro{\pptQuote}
+% \DescribeMacro{\pptBanner}
+% You can put a quote next to the image, by using the |\pptQuote| command:
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[template,scheme=dark]{ppt-slides}
+% \begin{document}
+% \pptBanner{My Favorite Quote}
+% \pptQuote{socrates.jpg}{The only true wisdom
+% is in knowing you know nothing}{Socrates}
+% \end{document}
+% \end{docshot}
+
+% \DescribeMacro{\pptThought}
+% For an interesting thought in the middle of the slide, use |\pptThought|:
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[template,scheme=dark]{ppt-slides}
+% \begin{document}
+% \pptThought{Socrates said that the only true
+% wisdom is in knowing you know nothing. Was he
+% a wise man?...}
+% \end{document}
+% \end{docshot}
+
+% \DescribeMacro{\pptQR}
+% Sometimes it's convenient to show a QR code to your audience instead of
+% a URL, since it's easier to use --- they can scan it:
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[template,scheme=dark]{ppt-slides}
+% \begin{document}
+% Check my blog post by this link: \\
+% \pptQR{https://www.yegor256.com}
+% \end{document}
+% \end{docshot}
+% The code will look like this, thanks to \href{https://ctan.org/pkg/qrcode}{qrcode} package that
+% we use behind the scene.
+
+% \DescribeMacro{pptWide}
+% \DescribeMacro{pptWideOne}
+% Sometimes you need your slide content to take all visible horizontal space:
+% \begin{docshot}
+% \documentclass{article}
+% \usepackage[template,scheme=dark]{ppt-slides}
+% \begin{document}
+% \begin{pptWideOne}
+% This paragraph is too long for some reasons,
+% that's why must take all visible horizontal
+% space, while normally the content has a wide
+% margin on the left side of the page.
+% \end{pptWideOne}
+% \end{document}
+% \end{docshot}
+% You can also use |\begin{pptWide}{X}|,
+% where |X| is the number of columns to render.
+
+% \section{Package Options}
+
+% \DescribeMacro{template}
+% You start with a template for your slide deck:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\documentclass{article}
+\usepackage[template=9x6]{ppt-slides}
+\begin{document}
+...
+\end{document}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+% There is only one template, which is used by default: |9x6|. If you don't
+% specify the name, it will be used. If you don't use the |template| option at all,
+% the default |article| will be rendered, which is not what you want.
+
+% \DescribeMacro{scheme}
+% You can choose a color scheme for your slides, using the |scheme| option
+% of the package:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\usepackage[template,scheme=light]{ppt-slides}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+% There are a few out-of-the-box schemes available: |light|, |dark|,
+% |light-mono|, and |dark-mono|. You can design your own, using
+% |ppt-light.tex| file as an example:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\usepackage[template,scheme=/usr/local/my-colors.tex]{ppt-slides}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+
+% \DescribeMacro{directory}
+% You can change the location of the templates and schemes by means of the |directory| package option:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\usepackage[directory=/tmp,template=foo]{ppt-slides}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+
+% \DescribeMacro{nominutes}
+% By default, if you render your slide deck in non-static mode (the |static| option for the ``clicks'' package),
+% there will be minutes tracking in the right top corner of each slide. You can turn this off
+% by using the |nominutes| option of the package:
+%\iffalse
+%<*verb>
+%\fi
+\begin{verbatim}
+\usepackage[nominutes]{ppt-slides}
+\end{verbatim}
+%\iffalse
+%</verb>
+%\fi
+
+% \StopEventually{}
+
+% \section{Implementation}
+% \changes{0.0.1}{2022/09/11}{First draft.}
+% \changes{0.1.4}{2022/09/15}{The \texttt{nominutes} package option added.}
+% \changes{0.1.5}{2022/09/19}{The default directory fixed.}
+% \changes{0.2.0}{2022/12/03}{We migrated to the \texttt{ltxdoc} format and \texttt{.dtx} file.}
+
+% First, we parse the package options:
+% \begin{macrocode}
+\RequirePackage{pgfopts}
+\makeatletter
+\pgfkeys{
+ /ppt-slides/.is family,
+ /ppt-slides,
+ template/.estore in = \ppt@template,
+ template/.default = 9x6,
+ scheme/.estore in = \ppt@scheme,
+ directory/.estore in = \ppt@directory,
+ directory/.default = ,
+ nominutes/.estore in = \ppt@nominutes,
+ directory
+}
+\ProcessPgfPackageOptions{/ppt-slides}
+\makeatother
+% \end{macrocode}
+
+% Then, we include the template:
+% \begin{macrocode}
+\makeatletter\ifdefined\ppt@template
+ \input{\ppt@directory ppt-templates/ppt-\ppt@template.tex}
+\else
+ \message{^^Jppt: No template is loaded, because
+ the 'template' option is not specified}
+\fi\makeatother
+% \end{macrocode}
+
+% Then, we include the scheme:
+% \begin{macrocode}
+\makeatletter\ifdefined\ppt@scheme
+ \RequirePackage{xcolor}
+ \input{\ppt@directory ppt-schemes/ppt-\ppt@scheme.tex}
+\else
+ \message{^^Jppt: No color scheme is loaded, because
+ the 'scheme' option is not specified}
+\fi\makeatother
+% \end{macrocode}
+
+% Then, we include a few packages:
+% \begin{macrocode}
+\RequirePackage{ifthen} % for if/then/else in LaTeX
+\RequirePackage{href-ul} % for nice hyperlinks
+\RequirePackage{pagecolor} % to change page color
+\RequirePackage{varwidth} % for pptWide
+\RequirePackage{qrcode} % to print QR codes
+\RequirePackage{tikz} % for drawings in TOC
+ \usetikzlibrary{calc} % for positioning of pinned boxes
+\RequirePackage{tikzpagenodes} % for pptPin
+\RequirePackage[inline]{enumitem} % for lists in crumbs
+\RequirePackage{crumbs} % for crumbs
+% \end{macrocode}
+
+% \begin{macro}{\pptMiddle}
+% Then, we define the |\pptMiddle| command:
+% \begin{macrocode}
+\newcommand\pptMiddle[1]{%
+ \vspace*{\fill}#1\vspace*{\fill}%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptBanner}
+% Then, we define the |\pptBanner| command:
+% \begin{macrocode}
+\newcommand\pptBanner[2][green]{%
+ \par%
+ {\setlength{\fboxsep}{6pt}%
+ \colorbox{#1}{\color{\thepagecolor}\large #2}}
+ \par%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptChapter}
+% Then, we define the |\pptChapter| command:
+% \begin{macrocode}
+\newcommand\pptChapter[2][]{%
+ \crumbection[#1]{#2}%
+ \pptMiddle{%
+ {\large\ttfamily Chapter \#\the\value{section}:}%
+ \newline%
+ \rotatebox{1}{\pptBanner[blue]{\LARGE#2}}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptSection}
+% Then, we define the |\pptSection| command:
+% \begin{macrocode}
+\newcommand\pptSection[2][]{%
+ \subcrumbection[#1]{#2}%
+ \pptHeader{#2}%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptHeader}
+% Then, we define the |\pptHeader| command:
+% \begin{macrocode}
+\newcommand\pptHeader[1]{%
+ \vspace*{-0.75in}\hspace*{-0.5in}%
+ \rotatebox{1}{\pptBanner[orange]{\Large #1}}\vspace*{0.15in}%
+ \par%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptTitle}
+% Then, we define the |\pptTitle| command:
+% \begin{macrocode}
+\newcommand\pptTitle[2]{%
+ {\pptBanner{\Huge #1}}%
+ {\pptBanner{\large #2}}%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptToc}
+% Then, we define the |\pptToc| command:
+% \begin{macrocode}
+\newcommand*\pptTOC{}
+\newcommand\pptToc[1][]{%
+ \renewcommand*\pptTOC{}%
+ \print{%
+ \def\param{#1}%
+ \ifx\param\empty\else%
+ \pptBanner{#1}%
+ \fi%
+ \tikz{%
+ \node (z) {%
+ \begin{varwidth}{\textwidth}%
+ \ifx\pptTOC\empty\else%
+ \begin{itemize}[label={}]
+ \pptTOC
+ \end{itemize}
+ \fi%
+ \end{varwidth}%
+ };%
+ \path [draw=blue,line width=4pt] (z.north west) -- (z.south west);%
+ }%
+ }%
+ \begin{@empty}%
+ \renewcommand\crumb[2]{%
+ \ifx\pptTOC\empty\else\ifdefined\click\click[0]\fi\fi
+ \gappto\pptTOC{\item ##2}
+ }
+ \crumbs
+ \end{@empty}%
+ \ifdefined\flush\flush[1]\fi%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptQuote}
+% Then, we define the |\pptQuote| command:
+% \begin{macrocode}
+\RequirePackage{tabularx}
+\newcommand\pptQuote[3]{%
+ \begin{tabularx}{\columnwidth}{c>{\raggedright\arraybackslash}X}%
+ \raisebox{\dimexpr-\height+\ht\strutbox}{\pptPic{0.25}{#1}}%
+ &%
+ ``#2''%
+ \def\param{#3}%
+ \ifx\param\empty\else%
+ \newline\newline%
+ \small%
+ --- #3%
+ \fi%
+ \\%
+ \end{tabularx}%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptPic}
+% Then, we define the |\pptPic| command:
+% \begin{macrocode}
+\newcommand\pptPic[2]{%
+ {%
+ \setlength{\fboxsep}{0pt}%
+ \setlength{\fboxrule}{1pt}%
+ \fcolorbox{gray}{white}{%
+ \includegraphics[width=#1\columnwidth]{#2}%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptPin}
+% Then, we define the |\pptPin| command:
+% \begin{macrocode}
+\newcommand\pptPin[2][right]{%
+ \begin{tikzpicture}[remember picture,overlay]%
+ \ifthenelse{\equal{#1}{left}}%
+ {%
+ \node[anchor=north east] at
+ ($(current page text area.north west) - (24pt, 18pt)$) {%
+ \begin{minipage}{0.25\textwidth}%
+ \raggedleft #2%
+ \end{minipage}%
+ };%
+ }%
+ {%
+ \node[anchor=north east] at (current page text area.north east) {%
+ \begin{minipage}{0.25\textwidth}%
+ \raggedright #2%
+ \end{minipage}%
+ };%
+ }%
+ \end{tikzpicture}%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptThought}
+% Then, we define the |\pptThought| command:
+% \begin{macrocode}
+\newcommand\pptThought[1]{%
+ \pptMiddle{%
+ \tikz{%
+ \node [inner sep=18pt] (z) {%
+ \begin{varwidth}{0.8\textwidth}
+ \Large
+ #1
+ \end{varwidth}
+ };
+ \path [draw=green,line width=8pt] (z.north west) -- (z.south west);
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptSnippet}
+% Then, we define the |\pptSnippet| command:
+% \begin{macrocode}
+\newcommand\pptSnippet[2][\small]{%
+ \begin{samepage}%
+ #1\verbatiminput{#2}%
+ \end{samepage}%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptQR}
+% Then, we define the |\pptQR| command:
+% \begin{macrocode}
+\newcommand\pptQR[2][2in]{%
+ \tikz{%
+ \node[draw=white]{%
+ \href{#2}{%
+ \qrcode[height=#1]{#2}%
+ }%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{\pptPinQR}
+% Then, we define the |\pptPinQR| command:
+% \begin{macrocode}
+\RequirePackage{seqsplit}
+\newcommand\pptPinQR[2][right]{%
+ \pptPin[#1]{%
+ \begin{minipage}{1.4in}%
+ \raggedleft%
+ \pptQR[1in]{#2}%
+ \\[3pt]
+ \ttfamily\fontsize{8pt}{10pt}\selectfont%
+ \seqsplit{#2} \href{#2}{$\rightarrow$}%
+ \\
+ \end{minipage}%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+
+% \begin{macro}{pptWide}
+% Finally, we define the |pptWide| and |pptWideOne| environments:
+% \begin{macrocode}
+\newenvironment{pptWideOne}
+ {\begin{adjustwidth}{-2in}{-1in}}
+ {\end{adjustwidth}}
+\newenvironment{pptWide}[1]
+ {\begin{pptWideOne}\begin{multicols}{#1}}
+ {\end{multicols}\end{pptWideOne}}
+% \end{macrocode}
+% \end{macro}
+
+\endinput
+
+% \Finale
+
+% \clearpage
+% \printbibliography
+% \clearpage
+
+% \PrintChanges
+% \clearpage
+% \PrintIndex