From 6dbb8dfbb59d7e98e7addb0feae7ff9306c49b0e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 11 Mar 2013 23:31:14 +0000 Subject: poetrytex (10mar13) git-svn-id: svn://tug.org/texlive/trunk@29347 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/poetrytex/Makefile | 11 +- .../source/latex/poetrytex/poetrytex.dtx | 269 +++++++++++++++++---- 2 files changed, 235 insertions(+), 45 deletions(-) (limited to 'Master/texmf-dist/source/latex/poetrytex') diff --git a/Master/texmf-dist/source/latex/poetrytex/Makefile b/Master/texmf-dist/source/latex/poetrytex/Makefile index 6f406545723..01a07c9d065 100644 --- a/Master/texmf-dist/source/latex/poetrytex/Makefile +++ b/Master/texmf-dist/source/latex/poetrytex/Makefile @@ -20,6 +20,7 @@ help: @echo ' all - unpack & doc' @echo ' world - all & ctan' @echo ' clean - remove all generated and built files' + @echo ' preview - preview the documentation' @echo ' ' @echo ' install - install the complete package into your home texmf tree' @echo ' sty-install - install the package code only' @@ -82,6 +83,10 @@ gendoc: $(DTX) grep -q "Rerun to get" $(NAME).log ) do true; \ done +COMMAND = command -v $(1) >/dev/null 2>&1 +preview: $(DOC) + ($(COMMAND) evince && evince $(NAME).pdf) || ($(COMMAND) open && open $(NAME).pdf) + $(DOC): $(DTX) @echo "Compiling documentation" $(DO_LATEX) @@ -95,13 +100,13 @@ $(DOC): $(DTX) $(UNPACKED): $(DTX) @$(DO_TEX) -$(CTAN_ZIP): $(CTAN_FILES) $(TDS_ZIP) +$(CTAN_ZIP): $(CTAN_FILES) @echo "Making $@ for CTAN upload." @$(RM) -- $@ @mkdir -p $(NAME)/ @cp $^ $(NAME)/ - @rm $(NAME)/*.zip - @zip -9 $@ $(NAME)/* $(NAME).tds.zip >/dev/null + @rm -f $(NAME)/*.zip + @zip -9 $@ $(NAME)/* >/dev/null @rm -rf $(NAME)/ define run-install diff --git a/Master/texmf-dist/source/latex/poetrytex/poetrytex.dtx b/Master/texmf-dist/source/latex/poetrytex/poetrytex.dtx index 7761a7a1c21..8d8dcee0400 100644 --- a/Master/texmf-dist/source/latex/poetrytex/poetrytex.dtx +++ b/Master/texmf-dist/source/latex/poetrytex/poetrytex.dtx @@ -56,7 +56,7 @@ % %<*poetrytex> \NeedsTeXFormat{LaTeX2e}[1994/06/01] -\ProvidesPackage{poetrytex}[2012/10/03] +\ProvidesPackage{poetrytex}[2013/02/13] %% % %<*driver> @@ -82,7 +82,7 @@ % \name{Sam Whited}\\ % \texttt{sam@samwhited.com} % } -% \date{\today\\v1.3\githead\gitdirty\gituncommitted} +% \date{\today\\\gitdescribe} % % \maketitle % \maketoc @@ -181,6 +181,8 @@ % \begin{macro}{numbertop} % \begin{macro}{resetnumongroup} % \begin{macro}{numberpoems} +% \begin{macro}{usedefaulttitles} +% \changes{1.4}{2012/02/13}{Add package option to use default titles} % \begin{macro}{clearpageafterpoem} % The package can also be loaded with any of the following options: % \begin{macrocode} @@ -188,6 +190,7 @@ \DeclareOption{numbertop}{\numbertop} \DeclareOption{resetnumongroup}{\resetnumongroup} \DeclareOption{numberpoems}{\numberpoems} +\DeclareOption{usedefaulttitles}{\ptusedefaulttitles} \DeclareOption{clearpageafterpoem}{\clearpageafterpoem} \DeclareOption{clearpageafterpoems}{\clearpageafterpoem} \DeclareOption*{% @@ -199,6 +202,7 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % For instance: % @@ -276,26 +280,99 @@ % % \begin{macro}{poemnum} % \begin{macro}{absolutepoemnum} +% \begin{macro}{untitledpoemnum} +% \changes{1.4}{2013/02/12}{Create a new counter to keep track of untitled% +% poems} +% \begin{macro}{absoluteuntitledpoemnum} +% \changes{1.4}{2013/02/12}{Create a new counter to keep track of untitled% +% poems} % The \code{poemnum} and \code{absolutepoemnum} counters will be incremented % every time we include a poem in our document and can be used later to number % the poems. The \code{absolutepoemnum} counter will never be reset by \pkg{% % poetrytex} while \code{poemnum} may sometimes be reset to 0 (at the beginning -% of a new \code{poemgroup} for instance). +% of a new \code{poemgroup} for instance). The \code{untitledpoemnum} and +% \code{absoluteuntitledpoemnum} are similar except that they are only +% incremented when the poem does not have a title. % \begin{macrocode} \newcounter{poemnum} \newcounter{absolutepoemnum} +\newcounter{untitledpoemnum} +\newcounter{absoluteuntitledpoemnum} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\poemvspace} +% \changes{1.4}{2013/02/11}{Allow whitespace before every poem} +% Sometimes you might want to insert a certain amount of vertical space before +% every poem. For instance, maybe you have several poems without titles and you +% need a visual cue to let your readers know that a new poem is starting. This +% can be acomplished by setting \code{\textbackslash poemvspace}: +% +% \begin{macrocode} +\newlength{\poemvspace} +\setlength{\poemvspace}{0em} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\pttitleleftspace} +% \changes{1.4}{2013/02/14}{Add macro to define poem title left hspace} +% \begin{macro}{\pttitlerightspace} +% \changes{1.4}{2013/02/14}{Add macro to define poem title right hspace} +% \begin{macro}{\ptsubtitleleftspace} +% \changes{1.4}{2013/02/14}{Add macro to define poem subtitle left hspace} +% \begin{macro}{\ptsubtitlerightspace} +% \changes{1.4}{2013/02/14}{Add macro to define poem subtitle right hspace} +% To indent the poems title or subtitle to the left or the right, set the length +% of \code{\textbackslash pttitleleftspace} and \code{\textbackslash% +% pttitlerightspace}. +% +% \begin{macrocode} +\newlength{\pttitleleftspace} +\setlength{\pttitleleftspace}{0em} +\newlength{\pttitlerightspace} +\setlength{\pttitlerightspace}{0em} +\newlength{\ptsubtitleleftspace} +\setlength{\ptsubtitleleftspace}{0em} +\newlength{\ptsubtitlerightspace} +\setlength{\ptsubtitlerightspace}{0em} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\ptusedefaulttitles} +% \begin{macro}{\ptdefaulttitle} +% \changes{1.4}{2013/02/12}{Add a default poem title} +% The default title for poems that don't include one. If \code{\textbackslash +% ptusedefaulttitles} is called the default title will be displayed above the +% poem itself as well as in the table of contents. Otherwise the title is left +% blank. +% +% \begin{macrocode} +\newcommand*{\ptusedefaulttitles}{\newcommand*{\@ptusedefaulttitles}{}} +\newcommand*{\ptdefaulttitle}{% + Untitled No. \arabic{absoluteuntitledpoemnum}% +} % \end{macrocode} % \end{macro} % \end{macro} % % \begin{macro}{\ptdefaultenv} % \changes{1.2}{2012/09/20}{Added an option to change the default environment} -% This contains the name of the default environment in which we should wrap -% poems. +% \begin{macro}{\pttitleenv} +% \changes{1.4}{2013/02/13}{Allow changing of the poem title environment} +% These macros contain the names of the default environments in which we should +% wrap poems and poem titles. % \begin{macrocode} \newcommand*{\ptdefaultenv}{verse} +\newcommand*{\pttitleenv}{center} % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro}{\ptannotationenv} % \changes{1.3}{2012/10/30}{Added an option to change the default annotation @@ -361,6 +438,27 @@ \renewcommand*{\listtablename}{\toptitle} % \end{macrocode} % +% \begin{macro}{\beforetoc} +% \changes{1.4}{2012/02/18}{Add hook before table of contents} +% \begin{macro}{\aftertoc} +% \changes{1.4}{2012/02/18}{Add hook after table of contents} +% \begin{macro}{\beforetop} +% \changes{1.4}{2012/02/18}{Add hook before table of poems} +% \begin{macro}{\aftertop} +% \changes{1.4}{2012/02/18}{Add hook after table of poems} +% Several hooks are provided which allow you to insert content before or after +% the tables: +% \begin{macrocode} +\newcommand{\beforetoc}{} +\newcommand{\aftertoc}{} +\newcommand{\beforetop}{} +\newcommand{\aftertop}{} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% % \begin{macro}{\maketoc} % \begin{macro}{\maketop} % \begin{macro}{\maketop*} @@ -373,23 +471,30 @@ % document. % \begin{macrocode} \newcommand*{\maketoc}{% + \beforetoc \tableofcontents \pagestyle{plain} + \aftertoc \clearpage \thispagestyle{empty} } \newcommand*{\maketop}{\@ifstar{\@ptmaketopStar}{\@ptmaketopNoStar}} \newcommand*{\@ptmaketopStar}{% + \cleardoublepage + \beforetop \listoftables \pagestyle{plain} + \aftertop \clearpage } \newcommand*{\@ptmaketopNoStar}{% \cleardoublepage + \beforetop \phantomsection \addcontentsline{toc}{section}{\toptitle} \listoftables \pagestyle{plain} + \aftertop \clearpage } % \end{macrocode} @@ -422,14 +527,16 @@ \newenvironment{poem}[3][\ptdefaultenv]{% % \end{macrocode} % +% \begin{macro}{\@ptwrapenvironment} % By default \code{poem} re-wraps your text in the \code{verse} environment. % However, this can be changed by passing in an optional argument with the name % of another environment to wrap it in (eg. \code{center}) or, for all poems, by % redefining \code{ptdefaultenv}. -% % \begin{macrocode} \newcommand*{\@ptwrapenvironment}{#1} % \end{macrocode} +% \end{macro} +% % For example, a poem wrapped in the \code{center} environment might look like % this: % @@ -473,27 +580,49 @@ \poetryheadings \addtocounter{poemnum}{1} \addtocounter{absolutepoemnum}{1} - \begin{center} + \ifx&% + \addtocounter{untitledpoemnum}{1} + \addtocounter{absoluteuntitledpoemnum}{1} + \fi + \vspace*{\poemvspace} + \begin{\pttitleenv} \phantomsection% \addcontentsline{lot}{\topentrytype}{% \ifx\@ptnumbertop\@ptundefined% \relax% \else% - \arabic{poemnum}.\ % - \fi#2}% + \toppoemnum% + \fi% + \ifx&% + \ptdefaulttitle% + \else% + #2% + \fi% + }% \hypertarget{\@ptpoemlabeltext\arabic{absolutepoemnum}}{} {\poemtitleformat% \ifx\@ptnumberpoems\@ptundefined \relax \else - \arabic{poemnum}\\% - \fi#2}\\% - #3 - \end{center} + \titlepoemnum + \fi% + \ifx&% + \ifx\@ptusedefaulttitles\@ptundefined% + \relax% + \else% + \hspace*{\pttitleleftspace}\ptdefaulttitle% + \hspace*{\pttitlerightspace}\\% + \fi% + \else + \hspace*{\pttitleleftspace}#2\hspace*{\pttitlerightspace}\\% + \fi% + }% + \hspace*{\ptsubtitleleftspace}#3\hspace*{\ptsubtitlerightspace} + \end{\pttitleenv} \begin{\@ptwrapenvironment} - \begingroup\setlength{\parskip}{\stanzaparskip} + \begingroup\setlength{\parskip}{\stanzaparskip}% }{% - \endgroup + \endgroup \end{\@ptwrapenvironment} \ifx\@ptclearpageafterpoem\@ptundefined \relax @@ -519,8 +648,8 @@ % \begin{macrocode} \newcommand*{\poetryheadings}[0]{% \pagestyle{myheadings} - \markboth{ | \MakeUppercase{\pttitle}\hfill } - {\hfill\MakeUppercase{\ptgroup}\ | } + \markboth{\ |\ \textsc{\pttitle}\hfill } + {\hfill\textsc{\ptgroup}\ |\ } } % \end{macrocode} % \end{macro} @@ -545,6 +674,7 @@ % \begin{Example} % \begin{Verbatim} % \numberpoems +% \numbertop % % \begin{poem}{The Highwayman} % {Alfred Noyes} @@ -559,6 +689,7 @@ % \end{Verbatim} % \columnbreak % \numberpoems +% \numbertop % % \begin{poem}{The Highwayman}{Alfred Noyes} % The wind was a torrent of @@ -571,6 +702,76 @@ % \end{poem} % \end{Example} % +% \begin{macro}{\titlepoemnum} +% \changes{1.4}{2012/02/18}{Add hook for poem number formatting} +% \begin{macro}{\toppoemnum} +% \changes{1.4}{2012/02/18}{Add hook for Table of Poems poem number formatting} +% These commands are used to insert the poem number into the poem title and the +% table of poems respectively. By redefining them you can customize how the +% numbering looks. +% \begin{macrocode} +\newcommand*{\titlepoemnum}{\arabic{poemnum}\\} +\newcommand*{\toppoemnum}{\arabic{poemnum}.\ } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% If we want to use uppercase roman numerals on the poems, and lowercase roman +% numerals in the \code{\hyperlink{POETRYTEX:TOP}{Table of Poems}}, we could +% redefine them like so: +% +% \begin{Example} +% \begin{Verbatim} +% \numberpoems +% \numbertop +% \renewcommand*{\titlepoemnum}{% +% \unskip\Roman{poemnum}\\} +% \renewcommand*{\toppoemnum}{ +% \unskip\roman{poemnum}.\ } +% +% \begin{poem}% +% {The Lady of Shalott}% +% {Alfred Tennyson (1842)} +% On either side the river lie\\ +% Long fields of barley and +% of rye,\\ +% That clothe the wold and meet +% the sky;\\ +% And through the field the road +% runs by\\ +% To many-towered Camelot;\\ +% And up and down the people go,\\ +% Gazing where the lilies blow\\ +% Round an island there below,\\ +% The island of Shalott--- +% \end{poem} +% \end{Verbatim} +% \columnbreak +% \numberpoems +% \numbertop +% \renewcommand*{\titlepoemnum}{% +% \unskip\Roman{poemnum}\\} +% \renewcommand*{\toppoemnum}{ +% \unskip\roman{poemnum}.\ } +% +% \begin{poem}% +% {The Lady of Shalott}% +% {Alfred Tennyson (1842)} +% On either side the river lie\\ +% Long fields of barley and +% of rye,\\ +% That clothe the wold and meet +% the sky;\\ +% And through the field the road +% runs by\\ +% To many-towered Camelot;\\ +% And up and down the people go,\\ +% Gazing where the lilies blow\\ +% Round an island there below,\\ +% The island of Shalott--- +% \end{poem} +% \end{Example} +% % \subsection{Spacing and indentation} % % \begin{macro}{\stanzaparskip} @@ -662,7 +863,7 @@ % By redefining \code{\textbackslash poemtitleformat} we can change how the poem % title is rendered. % \begin{macrocode} -\newcommand*{\poemtitleformat}{\normalfont\bfseries\large\centering} +\newcommand*{\poemtitleformat}{\normalfont\bfseries\large} % \end{macrocode} % \end{macro} % @@ -811,6 +1012,7 @@ \relax \else \setcounter{poemnum}{0} + \setcounter{untitledpoemnum}{0} \fi \cleardoublepage \vspace*{\fill} @@ -827,6 +1029,7 @@ \relax \else \setcounter{poemnum}{0} + \setcounter{untitledpoemnum}{0} \fi \cleardoublepage \vspace*{\fill} @@ -895,6 +1098,7 @@ % \addcontentsline{toc}{section}{Change History} % \PrintChanges % \changes{1.1}{2012/07/19}{Added an example table of poems} +% \renewcommand*{\beforetop}{\hypertarget{POETRYTEX:TOP}{}} % \maketop % \Finale % @@ -919,33 +1123,14 @@ \endgroup } -\newcommand*{\githead}{% - \immediate\write18{% - rm githead.tex 2> /dev/null; git rev-parse --short HEAD > githead.tex - }% - \InputIfFileExists{githead.tex}{.}{}\unskip% - \immediate\write18{% - rm githead.tex 2> /dev/null - }% -} - -\newcommand*{\gitdirty}{% - \immediate\write18{% - rm gitdirty.tex 2> /dev/null; git diff-files --quiet || echo "*" > gitdirty.tex - }% - \InputIfFileExists{gitdirty.tex}{\endlinechar=-1\relax}{}\unskip% - \immediate\write18{% - rm gitdirty.tex 2> /dev/null - }% -} - -\newcommand*{\gituncommitted}{% +\newcommand*{\gitdescribe}{% \immediate\write18{% - rm gituncommitted.tex 2> /dev/null; git diff-index --quiet --cached HEAD || echo "+" > gituncommitted.tex + rm gitdescribe.tex 2> /dev/null; (git describe --tags --dirty ||% + echo "v0.0") 2> /dev/null > gitdescribe.tex }% - \InputIfFileExists{gituncommitted.tex}{\endlinechar=-1\relax}{}\unskip% + \InputIfFileExists{gitdescribe.tex}{}{}\unskip% \immediate\write18{% - rm gituncommitted.tex 2> /dev/null + rm gitdescribe.tex 2> /dev/null }% } -- cgit v1.2.3