diff options
author | Karl Berry <karl@freefriends.org> | 2014-03-22 22:31:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-03-22 22:31:08 +0000 |
commit | fcbe1f2e86b4786a3143654b64e797ed088f8ff5 (patch) | |
tree | a05eb18419b8cbd208f6aa1f3b2e185de477dca0 /Master/texmf-dist/tex/latex/handout | |
parent | 6c2849b1103ceaad47b6adfbca0c187d113b537e (diff) |
handout (22mar14)
git-svn-id: svn://tug.org/texlive/trunk@33260 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/handout')
-rw-r--r-- | Master/texmf-dist/tex/latex/handout/handout.sty | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/handout/handout.sty b/Master/texmf-dist/tex/latex/handout/handout.sty new file mode 100644 index 00000000000..8b728dd6595 --- /dev/null +++ b/Master/texmf-dist/tex/latex/handout/handout.sty @@ -0,0 +1,125 @@ +%% Copyright 2014 Maïeul Rouquette +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Maïeul Rouquette +% This work consists of the files handout.sty and example and documentation files. + +\ProvidesPackage{handout}[2014/03/20 1.0.0 Handout package] +\RequirePackage{kvoptions,etoolbox} + +% Options +\DeclareBoolOption[false]{disabled} +\DeclareBoolOption[false]{numbering} +\DeclareBoolOption[false]{sectioning} + +\DeclareStringOption[.]{dir} + +\ProcessKeyvalOptions* + +% Warning tools +\newcommand{\handout@warning}[1]{\@latex@warning{Handout: #1}} + +% Opening the handout file +\newwrite\@handout +\immediate\openout\@handout=\jobname.handout + + +% The main command, to be used by people +\newcommand{\handout}[1]{% + \ifhandout@disabled\else%Only if not disabled, of course! + \ifhandout@numbering% + \stepcounter{handoutnumber}% + \handoutnumberintxt{\thehandoutnumber}% + \fi% + \immediate\write\@handout {\string\csuse{handout@input}{#1}}% + \fi% + \input{\handout@dir/#1}% Add the handout +} + + +% The special commands to be used by people + +\newcommand{\nothandout}[1]{#1} +\newcommand{\onlyhandout}[1]{} +\newcommand{\forhandout}[1]{% + \immediate\write\@handout{\noexpand #1}% +} + +% The command written in the .handout file +\newcommand{\handout@input}[1]{% + \ifhandout@numbering% + \stepcounter{handoutnumber}% + \handoutnumber{\thehandoutnumber}% + \fi% + \input{\handout@dir/#1}% +} +% Output the sectionning commands in the .handout file + +\ifhandout@sectioning%Only if needed by option + + \apptocmd{\@sect}{% + \immediate\write\@handout{\string\csuse{#1}{\unexpanded{#8}}}% + }{}{\handout@warning{Can't patch sectioning commands}} + +\fi +% Call the handout file at the end, if need +\ifhandout@disabled\else + + \AtEndDocument{% + \immediate\closeout\@handout% + \before@handout% + \ifdef{\beforehandout}{\beforehandout}{\handout@warning{No command defined to be run before handout}} + \input\jobname.handout% + } +\fi + +% Standard command before handout +\newcommand{\before@handout}{% + % New page + \newpage% + % Reset counter + \setcounter{page}{1}% + \setcounter{footnote}{0}% + \ifhandout@sectioning% + \setcounter{section}{0}% + \setcounter{subsection}{0}% + \setcounter{subsubsection}{0}% + \fi + \ifhandout@numbering + \setcounter{handoutnumber}{0}% + \fi + % No new data in content or in label or index + \def\addcontentsline##1##2##3{} + \let\label\@gobble + \let\index\@gobble + + % Switches onlyhandout and nothandout commands + \renewcommand{\nothandout}[1]{} + \renewcommand{\onlyhandout}[1]{##1} + +} + +\AtBeginDocument{% + \@ifpackageloaded{biblatex}{% + \apptocmd{\before@handout}{\citereset}{}{}% + }{}} + +% Handout numbering + +\ifhandout@numbering + \newcounter{handoutnumber} + \renewcommand{\thehandoutnumber}{\fbox{\arabic{handoutnumber}}} +\fi +\newcommand{\handoutnumberintxt}[1]{\handoutnumber{#1}} +\newcommand{\handoutnumber}[1]{\marginpar{#1}} + + |