% gfdl.sty : This custom package creates some commands to make it easy to
% use the GNU Free Documentation License v1.3
%%%%%%%%%%%%%%%%%%%%%%%%
% The following allows for the inclusion of other pdf's in this one.
% It is used for inclusion of the license.  See texdoc pdfpages
\usepackage{pdfpages}
%%%%%%%%%%%%%%%%%%%%%%%%
% The following allows for more complicated command arguments
\usepackage{xparse}
%%%%%%%%%%%%%%%%%%%
% The following snippet removes headers on empty pages before new chapters.
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
    \hbox{}
    \thispagestyle{plain}
    \newpage
    \if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother \clearpage{\pagestyle{plain}\cleardoublepage}
%%%%%%%%%%%%%%%%%%%%%%%%
% The following includes a copy of the GNU free documentation
% license.  Note the file fdl.pdf containing the license must be present.
% \gfdlsingle places it as a single page
% \gfdldouble places it on two pages (more legible)
% Both of these commands place the pages potentially starting on the back
% of a document page.  If in twosided mode this can be avoided by using
% \gfdlsinglenewpage and \gfdldoublenewpage which will insert a page if
% necessary to start on a new physical page.
% The default is to add a toc entry for the license at the section level.
% An optional argument (for example [chapter] ) will put this at the chapter or
% other chosen level.  The starred version of the commands put no entry in
% the toc.  (The section level is default so this will work in article class.)
% 
\NewDocumentCommand\gfdlsingle{sO{section}}{\clearpage%
  \IfBooleanTF{#1}{}{\addcontentsline{toc}{#2}{GNU Free Documentation License}}
\includepdf[offset=.3in 0,angle=90,pages=2-1,nup=1x2,delta=0 -.43in]{fdl.pdf}
}
\NewDocumentCommand\gfdlsinglenewpage{sO{section}}{\cleardoublepage%
  \IfBooleanTF{#1}{}{\addcontentsline{toc}{#2}{GNU Free Documentation License}}
  \includepdf[offset=.3in 0,angle=90,pages=2-1,nup=1x2,delta=0 -.43in]{fdl.pdf}
}
\NewDocumentCommand\gfdldouble{sO{section}}{\clearpage%
  \IfBooleanTF{#1}{}{\addcontentsline{toc}{#2}{GNU Free Documentation License}}
  \includepdf[pages=1-2,noautoscale,scale=.9]{fdl.pdf}
}
\NewDocumentCommand\gfdldoublenewpage{sO{section}}{\cleardoublepage%
  \IfBooleanTF{#1}{}{\addcontentsline{toc}{#2}{GNU Free Documentation License}}
  \includepdf[pages=1-2,noautoscale,scale=.9]{fdl.pdf}
}
% Provides a copyright notice. Arguments are year then author(s).
% \gfdlcopyright{2011}{I. M. Authorone, I. M. Authortwo}
\newcommand{\gfdlcopyright}[2]{Copyright \copyright{} #1 #2.}
% Use xparse (see texdoc xparse) to create commands with defaults, etc.
% Note this license notice is for no invariant texts (see the license)
% Something more sophisticated will be needed if they are required.
\newcommand{\gfdllicensenoticenoinvar}{Permission is granted to
  copy, distribute and/or modify this document under the terms of the
  GNU Free Documentation License, Version 1.3 or any later version
  published by the Free Software Foundation; with no Invariant
  Sections, no Front-Cover Texts, and no Back-Cover Texts.  A copy of
  the license is included in the section entitled ``GNU Free
  Documentation License''.}
% The following statement grants later document modifiers permission to
% retain the title of the document.  This is not necessary in a gfdl
% doc but may be useful.  Note that it is the publisher (i.e. the distributor)
% not the author according to the license that makes this call.
\newcommand{\gfdltitlepermission}{Permission is granted to retain (if
  desired) the original title of this document on modified copies.}
% The following statement grants later document modfiers permission to
% waive the requirement of placing at least five of the principal authors
% of the document (all if there are less than five) on the title page.
\newcommand{\gfdlwaiveauthors}{The principal author(s) of this document waive the requirement that their names be included on the cover page on modified versions of this document.}
% The following is a content disclaimer which is not related to the gfdl
% license, but is convenient for my documents.
\newcommand{\contentdisclaimer}{All numerical data in this document
  should be considered fabricated unless a source is cited directly.
  Comments in the transparent copy of the document may contain
  references indicating inspiration behind some of the data.}
