Skip to content

Instantly share code, notes, and snippets.

@ubnt-intrepid
Last active August 29, 2015 14:22
Show Gist options
  • Save ubnt-intrepid/6de17210ac1abde2b8d7 to your computer and use it in GitHub Desktop.
Save ubnt-intrepid/6de17210ac1abde2b8d7 to your computer and use it in GitHub Desktop.
PowerPointの配布資料マスター風にスライドPDFをまとめるためのパッケージ
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{handout}[2015/06/12 support for handout]
\newif\ifhandout@landscape
\handout@landscapefalse
\DeclareOption{landscape}{\handout@landscapetrue}
\newif\ifhandout@draft
\handout@draftfalse
\DeclareOption{draft}{\handout@drafttrue}
\ProcessOptions\relax
\RequirePackage{background}
\RequirePackage{ifluatex}
\RequirePackage{lastpage}
\RequirePackage{pdfpages}
\RequirePackage{tikz}
\pdfinclusioncopyfonts=1 % PDF読み込み時のフォント置き換えを防ぐ
% フォント設定
\ifluatex
\usepackage[no-math]{fontspec}
\usepackage[ipa-hg,deluxe]{luatexja-preset}
\setmainfont[Ligatures=TeX]{TeXGyreTermes}
\setsansfont[Ligatures=TeX,Scale=0.95]{Segoe UI}
\setmonofont[Scale=MatchLowercase]{Inconsolata}
\else
\usepackage{helvet}
\usepackage[whole]{bxcjkjatype}
\fi
\renewcommand{\familydefault}{\sfdefault}
% 値が消去されてしまうため別変数に保持する
\renewcommand\title[1]{\gdef\@title{#1}\gdef\THETITLE{#1}}
\renewcommand\author[1]{\gdef\@author{#1}\gdef\THEAUTHOR{#1}}
\renewcommand\date[1]{\gdef\@date{#1}\gdef\THEDATE{#1}}
\gdef\THETITLE{EMPTY}
\gdef\THEAUTHOR{EMPTY}
\gdef\THEDATE{EMPTY}
\newcommand\HeadAndFoot{%
\begin{tikzpicture}[remember picture, overlay, every node/.style={text=black}]
% grid line (if draft mode)
\ifhandout@draft
\draw[gray, step=0.5cm, dashed, opacity=0.3] (0,0) grid (\paperwidth, \paperheight);
\fi
% author name
\node[anchor=north west, xshift=7mm, yshift=-7mm] at (0, \paperheight)
{\ifthenelse{\equal{\THEAUTHOR}{EMPTY}}{}{\THEAUTHOR}};
% date
\node[anchor=north east, xshift=-7mm, yshift=-7mm] at (\paperwidth, \paperheight)
{\ifthenelse{\equal{\THEDATE}{EMPTY}}{\today}{\THEDATE}};
% title
\node[anchor=south west, xshift=7mm, yshift=7mm] at (0, 0)
{\ifthenelse{\equal{\THETITLE}{EMPTY}}{}{\THETITLE}};
% page no.
\node[anchor=south east, xshift=-7mm, yshift=7mm] at (\paperwidth, 0)
{\thepage~-~\pageref{LastPage}};
\end{tikzpicture}
}
\SetBgContents{\HeadAndFoot}
\SetBgPosition{current page.south west}
\SetBgOpacity{1.0}
\SetBgAngle{0.0}
\SetBgScale{1.0}
\ifhandout@landscape
\newcommand\outputpdf[2][]{\includepdf[pages=-,nup=3x2,frame,delta=0.3cm 2cm,scale=0.95,#1]{#2}}
\else
\newcommand\outputpdf[2][]{\includepdf[pages=-,nup=2x3,frame,delta=0.3cm 2cm,scale=0.93,#1]{#2}}
\fi
\pagestyle{empty}
\documentclass[a4paper,11pt]{article}
\usepackage{handout} % 横置きにしたい場合は 'landspace' オプションをつける
% ※ クラスファイル側のオプションとは連携していないため注意
% 日付計算
\usepackage{datenumber}
\setdatetoday
\addtocounter{datenumber}{1}
\setdatebynumber{\thedatenumber}
\gdef\tomorrow{\datedate}
% ドキュメント情報
% \title{タイトルテキスト}
\author{Author name}
\date{\tomorrow}
\begin{document}
\outputpdf[pages=1-36]{slam_slide.pdf}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment