From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/flipbook/flipbook.sty | 164 +++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 macros/latex/contrib/flipbook/flipbook.sty (limited to 'macros/latex/contrib/flipbook/flipbook.sty') diff --git a/macros/latex/contrib/flipbook/flipbook.sty b/macros/latex/contrib/flipbook/flipbook.sty new file mode 100644 index 0000000000..67ce84d6b5 --- /dev/null +++ b/macros/latex/contrib/flipbook/flipbook.sty @@ -0,0 +1,164 @@ +% flipbook.sty --- style file for flip books +%% Copyright 2011 Olivier Buffet +% +% This material is subject to the LaTeX Project Public License. See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the details of that license. +% +% This program consists of the files flipbook.sty and documentation.tex (and some less important files). +% +% Report bugs and comments to: +% buffet-AT-AT-loria-DOT-DOT-fr +% +% $Id: flipbook.sty,v 0.1 2011/12/05 16:26:53 buffet Exp $ +% +% PACKAGES REQUIRED: +% +% - fancyhdr +% - graphicx +% - scalefnt +% - verbatim +% - everypage +% - ifthen + +\NeedsTeXFormat{LaTeX2e}[1994/12/01] +\ProvidesPackage{flipbook}[2011/12/05 Standard LaTeX class] + +% The type of headings that allows for customization: +\RequirePackage{fancyhdr} +\RequirePackage{graphicx} +\RequirePackage{scalefnt} +\RequirePackage{verbatim} +\RequirePackage{everypage} +\RequirePackage{ifthen} +\pagestyle{fancyplain} + +\newcommand{\fbDebug}[1]{} +\DeclareOption{debug}{% + \renewcommand{\fbDebug}[1]{{\tiny #1} \@latex@warning{#1}} +} +\ProcessOptions + +\newcounter{fbpage} +\setcounter{fbpage}{0} +\AddEverypageHook{ + \addtocounter{fbpage}{1} +} + +% How to get the total number of pages. Inspired from the files +% lastpage.sty and beamerbasemisc.sty . + +\newcounter{numpages} + +\AtEndDocument{% + \clearpage \setcounter{numpages}{\thefbpage} + \if@filesw + \immediate\write\@auxout{\noexpand\setcounter{numpages}{\the\c@page}} + \fi +}% + +% The important command (but which can probably be improved): +% 3 parameters: +% - prefix of your images +% - suffix (extension) of your images +% - displaying options of your images +\makeatletter +\newcommand\fbImageF[3]{ % flip-book \includegraphics{...} forward + \@tempcnta 0 + \advance\@tempcnta+\thefbpage + \if@twoside + \divide\@tempcnta2 + \fi + \IfFileExists{#1\number\@tempcnta .#2} + { + \includegraphics[#3]{#1\number\@tempcnta .#2} + }{ + \fbDebug{``#1\number\@tempcnta .#2'' NOT FOUND} + } +} +\newcommand\fbImageB[3]{ % flip-book \includegraphics{...} backward + \@tempcnta\value{numpages} + \advance\@tempcnta-\thefbpage + \if@twoside + \divide\@tempcnta2 + \fi + \IfFileExists{#1\number\@tempcnta .#2} + { + \includegraphics[#3]{#1\number\@tempcnta .#2} + }{ + \fbDebug{``#1\number\@tempcnta .#2'' NOT FOUND} + } +} +\makeatother + +\makeatletter +\newcommand\fbInputF[3]{ % flip-book \input{...} forward + \@tempcnta 0 + \advance\@tempcnta+\thefbpage + \if@twoside + \divide\@tempcnta2 + \fi + \IfFileExists{#1\number\@tempcnta .#2} + { + \scalefont{#3} + \input{#1\number\@tempcnta .#2} + }{ + \fbDebug{``#1\number\@tempcnta .#2'' NOT FOUND} + } +} +\newcommand\fbInputB[3]{ % flip-book \input{...} backward + \@tempcnta\value{numpages} + \advance\@tempcnta-\thefbpage + \if@twoside + \divide\@tempcnta2 + \fi + \IfFileExists{#1\number\@tempcnta .#2} + { + \scalefont{#3} + \input{#1\number\@tempcnta .#2} + }{ + \fbDebug{``#1\number\@tempcnta .#2'' NOT FOUND} + } +} +\makeatother + +\makeatletter +\newcommand\fbVerbF[3]{ % flip-book \verbatiminput{...} forward + \@tempcnta 0 + \advance\@tempcnta+\thefbpage + \if@twoside + \divide\@tempcnta2 + \fi + \IfFileExists{#1\number\@tempcnta .#2} + { + \scalefont{#3} + \verbatiminput{#1\number\@tempcnta .#2} + }{ + \fbDebug{``#1\number\@tempcnta .#2'' NOT FOUND} + } +} +\newcommand\fbVerbB[3]{ % flip-book \verbatiminput{...} backward + \@tempcnta\value{numpages} + \advance\@tempcnta-\thefbpage + \if@twoside + \divide\@tempcnta2 + \fi + \IfFileExists{#1\number\@tempcnta .#2} + { + \scalefont{#3} + \verbatiminput{#1\number\@tempcnta .#2} + }{ + \fbDebug{``#1\number\@tempcnta .#2'' NOT FOUND} + } +} +\makeatother + +% Fancyhdr moves the center of pages. +% To compensate this I have found the following piece of code. +% But there must be a better solution. +\makeatletter +\@tempdima=\paperwidth +\advance\@tempdima by -\textwidth +\divide\@tempdima by 2 +\advance\@tempdima by -1in +\oddsidemargin=\@tempdima +\let\evensidemargin=\oddsidemargin +\makeatother -- cgit v1.2.3