From 4a1d317cb71ce63b9cf99e38f46c162ed027dd73 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 23 Sep 2017 23:09:23 +0000 Subject: pdfreview (23sep17) git-svn-id: svn://tug.org/texlive/trunk@45391 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/pdfreview/README.md | 42 +++ .../texmf-dist/doc/latex/pdfreview/pdfreview.pdf | Bin 0 -> 451684 bytes Master/texmf-dist/doc/latex/pdfreview/pdfreview.sh | 56 +++ .../texmf-dist/doc/latex/pdfreview/pdfreview.tex | 233 +++++++++++++ Master/texmf-dist/doc/latex/pdfreview/pdfshrink.sh | 60 ++++ .../doc/latex/pdfreview/sample-for-docs.pdf | Bin 0 -> 126391 bytes .../texmf-dist/tex/latex/pdfreview/pdfreview.sty | 376 +++++++++++++++++++++ Master/tlpkg/bin/tlpkg-ctan-check | 2 +- Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 + Master/tlpkg/tlpsrc/pdfreview.tlpsrc | 0 10 files changed, 769 insertions(+), 1 deletion(-) create mode 100644 Master/texmf-dist/doc/latex/pdfreview/README.md create mode 100644 Master/texmf-dist/doc/latex/pdfreview/pdfreview.pdf create mode 100755 Master/texmf-dist/doc/latex/pdfreview/pdfreview.sh create mode 100644 Master/texmf-dist/doc/latex/pdfreview/pdfreview.tex create mode 100755 Master/texmf-dist/doc/latex/pdfreview/pdfshrink.sh create mode 100644 Master/texmf-dist/doc/latex/pdfreview/sample-for-docs.pdf create mode 100644 Master/texmf-dist/tex/latex/pdfreview/pdfreview.sty create mode 100644 Master/tlpkg/tlpsrc/pdfreview.tlpsrc (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/pdfreview/README.md b/Master/texmf-dist/doc/latex/pdfreview/README.md new file mode 100644 index 00000000000..c89ba3e524e --- /dev/null +++ b/Master/texmf-dist/doc/latex/pdfreview/README.md @@ -0,0 +1,42 @@ +The `pdfreview.sty` package +========================= + +The `pdfreview` package lets you add comments in the page margins of PDF files, e.g. when reviewing manuscripts or grading reports. The PDF file to be annotated is included, one page at a time, as graphics, in a manner similar to the `pdfpages` package. Notes are placed in the margin next to the included graphics using a grid of help lines. Alternatively, only numbers are placed in the page margins, and the notes are collected into a numbered list at the end of the document. + +Note that this package is *not* intended for adding notes directly to the LaTeX source of the document that is being reviewed; instead, the document undergoing review is already in PDF format and remains unchanged. Also note that this package does not produce the usual PDF "sticky notes" that must be opened by clicking on them; instead, the notes are simply shown as text on the page. + + +Files included with the package +------------------------------- + +`pdfreview.sty` +: this is the actual package file. + +`pdfreview.tex` +: this provides only the documentation; it does *not* generate the `pdfreview.sty` file. Requires pdfLaTeX for compilation. + +`pdfreview.pdf` +: the docs compiled from `pdfreview.tex` + +`sample-for-docs.pdf` +: a graphics file that is included when latexing the docs. + +`pdfshrink.sh` +: a bash script that uses ghostscript to shrink large PDF files. Can be used to compress the sometimes large output generated by pdfreview. + +`pdfreview.sh` +: a bash script that uses ghostscript to generate a skeleton for a review document. + + +Revision history +---------------- + +May 3rd, 2017: version 1.00 + +September 22nd, 2017: version 1.1 + + +Licence +------- + +The package is subject to the LaTeX Project Public License. diff --git a/Master/texmf-dist/doc/latex/pdfreview/pdfreview.pdf b/Master/texmf-dist/doc/latex/pdfreview/pdfreview.pdf new file mode 100644 index 00000000000..d16190c3c37 Binary files /dev/null and b/Master/texmf-dist/doc/latex/pdfreview/pdfreview.pdf differ diff --git a/Master/texmf-dist/doc/latex/pdfreview/pdfreview.sh b/Master/texmf-dist/doc/latex/pdfreview/pdfreview.sh new file mode 100755 index 00000000000..a6818e4363b --- /dev/null +++ b/Master/texmf-dist/doc/latex/pdfreview/pdfreview.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# this script is part of the pdf-annotation LaTeX package by M. Palmer +# like all files in the package, it is covered by the LPPL. + +# this assumes ghostscript is installed as 'gs - change as needed +ghostscript="gs" + +script_name=`basename "$0"` + +if [ -z $1 ]; then + echo "Usage: $script_name inputfile.pdf > outputfile.tex" + exit 1 +fi + +source_doc=$1 + +# doc_header will become the preamble of your wrapper document +# edit it according it your preferences. + +doc_header="\documentclass[letterpaper,10pt]{article} + +\usepackage[ + sourcedoc=$source_doc, + inline=true, + withnotesonly=false, + grid=true, + gridcolor=black!30, + trim={1cm 1cm 1cm 1cm}, + bodywidth=0.75, + pageoffset=0, + fontsize=footnotesize, + twocolumn=false, + notesbg=yellow, + notesframe=black, + insertpagemargin=2.5cm +]{pdfreview} + +\begin{document} +" + +echo "$doc_header" + +# use ghostscript to obtain the page count from the pdf file +page_count=$($ghostscript -q -dNODISPLAY -c "($source_doc) (r) file runpdfbegin pdfpagecount = quit") + +# write page environment for each of the pages +for (( i=1; i<=$page_count; i++ )) +do + echo "\begin{page}{$i}" + echo "\end{page}" + echo "" +done + +echo "\end{document}" + diff --git a/Master/texmf-dist/doc/latex/pdfreview/pdfreview.tex b/Master/texmf-dist/doc/latex/pdfreview/pdfreview.tex new file mode 100644 index 00000000000..392f3eb7af6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pdfreview/pdfreview.tex @@ -0,0 +1,233 @@ +\documentclass{codedoc} + +\usepackage{lmodern,tikz,graphicx,shortvrb,url,xspace} +\usepackage[small]{titlesec} +\usepackage[margin=1in]{geometry} + +\MakeShortVerb{\|} +\newcommand{\option}[3]{\item [\texttt{#1}] (\meta{#2}; default: \texttt{#3}).} +\newcommand*{\pkgname}{\texttt{pdfreview}\xspace} + +\author{Michael Palmer} +\title{The \pkgname package} +\date{v1.1 (\today)} + +\usepackage{bookmark} + +\begin{document} + +\maketitle + +\begin{abstract} +\noindent The \pkgname package lets you add comments in the page margins of PDF files, e.g.\ when reviewing manuscripts or grading reports. The PDF file to be annotated is included, one page at a time, as graphics, in a manner similar to the \texttt{pdfpages} package. Notes are placed in the margin next to the included graphics using a grid of help lines. Alternatively, only numbers are placed in the page margins, and the notes are collected into a numbered list at the end of the document. \par +Note that this package is \emph{not} intended for adding notes directly to the \LaTeX{} source of the document that is being reviewed; instead, the document undergoing review is already in PDF format and remains unchanged. Also note that this package does not produce the usual PDF `sticky notes' that must be opened by clicking on them; instead, the notes are simply shown as text. +\end{abstract} + +\section{An example} + +Let's assume a student submitted his essay as \texttt{lorem-ipsum.pdf}. In order to review and annotate it, I create this wrapper \LaTeX{} document: + +\begin{verbatim} +\documentclass[letterpaper,10pt]{article} + +\usepackage[ + sourcedoc=lorem-ipsum.pdf, % declare the PDF document being reviewed + grid=true, % draw help lines for margin notes (set false when done) + bodywidth=0.66, % set width of source doc page as fraction of \textwidth + twocolumn=true, % place margin notes on both sides + trim=2cm, % trim all page margins of source doc by this amount +]{pdfreview} + +\begin{document} + +\begin{page}{1} % mount the first page + +\begin{leftnotes} % write notes into the left margin +\cnote{84}{It looks like Latin.} % place note centered on help line 84 +\bnote{68}{Is this really Latin?} % align bottom of note to help line 68 +\tnote{16}{No, not Latin} % align top of note to help line 16 +\end{leftnotes} % notes after this point go into the right margin + +\tnote{48}{You really should be writing proper Latin} +\cnote{12}{Cite your references} +\end{page} + +% \begin{page}{2} % mount the next page +% \note{...}{...} etc. + +\end{document} +\end{verbatim} +\clearpage + +\noindent This gives us the following output (only the first page is shown): + +\begin{center} +\includegraphics[width=\textwidth]{sample-for-docs} +\end{center} + +When you have added all your comments, you can set the package option \texttt{grid=false} in order to hide the help lines. That is essentially it, already; some more options and a few tips and tricks will be given below. + +\section{Package options} + +\begin{description} + +\option{sourcedoc}{file name}{noname} Name of the PDF file to be reviewed. The file extension (\texttt{.pdf}) can be omitted. + +\option{withnotesonly}{boolean}{false} By default, \texttt{pdfreview} will output every page that was mounted with \texttt{\textbackslash{}begin\textbraceleft page\textbraceright\ \ldots\ \textbackslash{}end\textbraceleft page\textbraceright}, even if no notes were placed on the page. If set to true, pages on which no notes were made will be omitted from the output. This can be useful to reduce file size. + +Pages inserted with \texttt{\textbackslash{}begin\textbraceleft insertpage\textbraceright\ \ldots\ \textbackslash{}end\textbraceleft insertpage\textbraceright} will always be included in the output, regardless of whether or not they are empty. + +\option{twocolumn}{boolean}{false} If true, place included page in the middle and arrange for margin notes on both sides. If false, place included page on the left and have margin notes on the right hand side only. + +\option{inline}{boolean}{true} If true, print the note text into the page margin. If false, print only the number of each note into the page margin. In the latter case, the note text will be collected and printed out as an \texttt{enumerate}'d list at the end of the document. Numbers in the margin and list items will be reciprocally hyperlinked. + +\option{notenumbers}{boolean}{false} If true, start each note with its number. If option \texttt{inline} is false, the number is printed regardless of this option. + +\option{grid}{boolean}{true} Draw help lines for margin notes. + +\option{gridcolor}{color name}{black!30} Color to use for help lines and line numbers. + +\option{maxscale}{number}{100} Number of vertical length units/help lines for placing margin notes. If not divisible by 4, you will get a few ugly surplus lines at the top. + +\option{stretch}{number}{1} By default, the vertical scale for placing margin notes is exactly as high as the first source document page. If that doesn't work well for some reason---for example, because you manually trim some pages more than others (see below)---then you can use this fudge factor to adjust the height of the scale manually. The scale will always be the same for all pages though. + +\option{bodywidth}{number}{0.75} Width of the included source doc page, as fraction of \texttt{\textbackslash textwidth} of the wrapper document. The remainder of \texttt{\textbackslash textwidth} will be used for the margin notes. + +The default of 0.75 should be suitable in combination with \texttt{inline=true,twocolumn=false}, that is, with full note text in the right margin only (which is my own most common use case). Use smaller values with \texttt{inline=true,twocolumn=true} or larger ones with \texttt{inline=false}. + +\option{trim}{length(s)}{1cm} How much to trim off the margins of each page of the source document. This option is passed to the \texttt{\textbackslash adjustbox} macro from the package by the same name. Accordingly, you can use two lengths to specify separate trimmings for horizontal and vertical margins, and four lengths to specify separate values for the left, lower, right, and top margins (in this order. No, it doesn't resemble a clock, fuel gauge, or anything else that mere mortals might have encountered). + +Note that multiple lengths values must be surrounded with braces, e.g.\ \texttt{trim=\textbraceleft 1cm 2cm\textbraceright} or \texttt{trim=\textbraceleft 1cm 2cm 0cm 1cm\textbraceright}. If you omit the braces, only the first length value will be used, and the others will be silently ignored. + +\option{alignnotes}{t,b, or c}{c} Vertical alignment of a margin note declared with |\note|. Can be overridden by passing \texttt{t} or \texttt{b} as an optional argument (e.g.~|\note[b]{Go boil your bottoms}| or |\note[t]{I shall taunt you a second time}|). + +\option{notesbg}{color name or `none'}{yellow} Background color to use for the margin notes. If `none', the background will be transparent. + +\option{notesframe}{color name or `none'}{black} Color to use for the box frame of the margin notes. If `none', no box is drawn. + +\option{notesep}{length}{3pt} Empty space between included page and margin notes. + +\option{fontsize}{string}{footnotesize} Font size to use for the margin notes. Use any of the usual font size commands, but without the backslash. + +\option{pageoffset}{number}{0} This option only affects the PDF bookmarks for each page of the current document; it is intended to synchronize the bookmarks with the page numbers of the source document. + +By default, \pkgname simply numbers all included pages consecutively, starting with 1. If the source document has, say, 5 unnumbered (or Roman-numbered) pages preceding the proper page 1, you can declare this with \texttt{pageoffset=-5}; in this case, the first 5 pages will be given Roman numerals, and Arabic numbers will start (at 1) on the sixth physical page. Similarly, if the source document is missing some logical pages at the beginning, you can correct for this using a positive value for \texttt{pageoffset}. + +(As usual, the least useful options require the most explanation.) + +\option{insertpagemargin}{length}{2.5cm} If you have comments of a general nature, or ones that don't fit comfortably into the page margin, you can put them on separate pages insert one or more empty pages using the \texttt{insertpage} environment (see below). + +By default, \pkgname leaves only very narrow empty page margins beyond the margin notes. For inserted text pages, it is more appropriate to use a wider margin; you can adjust it with this option. + +\end{description} + +\section{Macros} + +\begin{description} + +\item [{\texttt{\textbackslash note[\meta{alignment}]\marg{height}\marg{text}}}] + The optional \texttt{alignment} argument is one of \texttt{b}, \texttt{c}, or \texttt{t}. The \meta{height} argument names the help line to align to; \meta{text} is the content of the note. (The \meta{height} argument doesn't have to be an integral number. Also, it can fall outside of the displayed help line scale, within reason. + + Note that the entire text of each note will go inside a \texttt{TikZ} node. This means you cannot use empty lines within a note to insert paragraphs. If you do need paragraphs, use the |\par| macro instead. + +\item [\texttt{\textbackslash bnote}\marg{height}\marg{text}] + Shorthand for \texttt{\textbackslash note[b]\marg{height}\marg{text}}. Analogous |\cnote| and |\tnote|. + +\item [\texttt{\textbackslash sourcedoc}\marg{file name}] Set the file name of the PDF file whose pages are to be included. More commonly, this is done using the \texttt{sourcedoc} package option (see above). However, this macro can be used to switch to another source document halfway through. + +\end{description} + +\section{Environments} + +\begin{description} + +\item [\texttt{\textbackslash begin\textbraceleft page\textbraceright [\meta{graphics options}]\marg{page number} \ldots\ \textbackslash end\textbraceleft page\textbraceright}] + +This environment loads the physical page \meta{page number} from the source document and sets up the container for the margin notes. The formatting and scaling of the included page and of the margin notes is subject to the package options described earlier. + +The optional \meta{graphics options} are passed to the \texttt{\textbackslash adjustbox} macro from the package of the same name. You could use this for example to override the global \texttt{trim} package option for this one page, like so: \texttt{trim=\textbraceleft0cm 1cm\textbraceright}. + +\item [\texttt{\textbackslash begin\textbraceleft leftnotes\textbraceright \ldots\ \textbackslash end\textbraceleft leftnotes\textbraceright}] + +This environment goes inside a \texttt{page} environment. In \texttt{twocolumn} mode, it will move the enclosed |\note| macros to the left page margin; with \texttt{twocolumn=false} it does nothing, that is, notes enclosed in \texttt{leftnotes} will show up in the right margin. + +\item [\texttt{\textbackslash begin\textbraceleft rightnotes\textbraceright \ldots\ \textbackslash end\textbraceleft rightnotes\textbraceright}] Never does anything, ever; it only exists to avoid tripping up users who surmise its existence from that of the \texttt{leftnotes} environment. + +\item [\texttt{\textbackslash begin\textbraceleft insertpage\textbraceright [\meta{heading}] \ldots\ \textbackslash end\textbraceleft insertpage\textbraceright}] + +Inserts one or more extra pages for longer comments. These are not subject to any special formatting, except for the page margin, which can be set using a package option (see above). Alternatively, you can set the margins manually using |\newgeometry| and |\restoregeometry| from the \texttt{geometry} package, which is loaded by \pkgname. (The optional argument \meta{heading} defaults to ``General comments''.) + +\end{description} + +\section{Practical recommendations} + +\subsection{Page space usage} + +Obviously, one needs to make some judicious choices in order to allow enough space for our margin comments yet also keep the included PDF pages legible. Use the \texttt{trim} package option to shave off empty margins from the included PDF pages. + +The \texttt{geometry} package will be loaded to divide up the page. By default, \pkgname leaves 0.25 cm empty margins on both sides. If you load the \texttt{geometry} package yourself, \pkgname will respect your settings and not impose its own margin width. In that case, note that the entire content---included PDF page and margin notes---will go inside |\textwidth|. Any margins you declare using the \texttt{geometry} package will remain entirely empty. Also note that any \texttt{geometry} settings can be declared in the preamble only; if you try to change the margins within the document using |\newgeometry|, things will unravel. + +\subsection{Vertical overlap of margin notes} + +There is no automatic mechanism that would prevent mutual overlap of margin notes; this has to be prevented manually. Where space is tight, it may help to use e.g.\ a |\bnote{60}{some note}| followed by a |\tnote{60}{another note}|; no space is wasted between both notes, yet at the same time they will not overlap. + +The \texttt{bodywidth} package option also decides the horizontal and vertical space available for the margin notes. Should you decide half-way through to reduce the \texttt{bodywidth} parameter, this will create more horizontal space for the notes, but at the same time reduce the vertical space. This may occasionally create some new vertical overlap that would have to be fixed manually. + +Another consideration is what font to use for your notes, and at what size. Times is a nice, space-saving font (in pdfLaTeX, you can load it with |\usepackage{mathptmx}|). You can adjust the font size using the corresponding package option (e.g.~\texttt{fontsize=scriptsize}). + +\subsection{Writing less boiler plate code} + +While the code to set up each page is pretty compact, it can still become tiresome to write for long source documents. The package includes a \texttt{bash} script named \texttt{pdfreview.sh}, which generates a document skeleton containing a \texttt{page} environment for each page of a source document: + +\begin{verbatim} +mpalmer@holzkopf:/data$ pdfreview.sh source.pdf > review.tex +\end{verbatim} + +\noindent The script requires 1) \texttt{ghostscript}, 2) \texttt{bash} (obviously) and 3) that you place it somewhere into your shell's path. + +\subsection{File size} + +Particularly when working with large source files, \pkgname can produce some startlingly large PDF output files. This problem is apparently related to the way |\includegraphics| works and has been described before (see \url{https://tex.stackexchange.com/questions/207527/}). +% +It can be amended by post-processing the output PDF file with ghostscript, for example: + +\begin{verbatim} +gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET \ + -dBATCH -sOutputFile=post-processed.pdf output.pdf +\end{verbatim} + +\noindent The package contains a bash script named \texttt{pdfshrink.sh} that wraps the call to \texttt{ghostscript} and which you can use like + +\begin{verbatim} +mpalmer@holzkopf:/data$ pdfshrink.sh large.pdf +\end{verbatim} + +\noindent An optional second argument controls the resolution of included bitmap graphics, with possible values (in order of decreasing resolution) \texttt{prepress}, \texttt{printer}, \texttt{default} (the default value), \texttt{ebook}, and \texttt{screen}. A optional third argument can be used to indicate the output file name. + +Again, you need to save the script in a directory listed in your shell's search path for this work. + +\subsection{Uncooperative input files} + +Occasionally, I've run into source documents that failed to cooperate with the page-wise inclusion attempted by \pkgname. I got around that by first printing the recalcitrant PDF input file to another PDF file---or, alternatively, running through \texttt{pdfshrink}---and then using the resulting file as the source document instead. (This might also be useful on occasion when using the \texttt{pdfpages} package.) + +\section{Implementation} + +This package depends on several others that are all in TeXLive. Among these is the \texttt{ulem} package, which makes the |\sout{strike me out}| command available for a strike-through effect. The \texttt{geometry} package is used for dividing up the page; if you load it yourself, your settings will be respected, as long you declare them in the preamble (but don't use |\newgeometry| halfway through the document). The \texttt{adjustbox} package is used to scale and trim the included pages, and also to scale the containers for the margin notes. The \texttt{environ} package is used to implement the \texttt{page} environment. The \texttt{tikz} package is used for placing help lines and margin notes. + +For further details, see the package file itself. + +\section{Revision history} + +\begin{description} +\item [May 2017] initial version (1.00) + +\item [September 2017] corrections to documentation; added \texttt{withnotesonly} option (1.1) + +\end{description} + +\section{License} + +All files in this package are subject to the LaTeX project public license (see \url{http://www.latex-project.org/lppl.txt}). + + +\end{document} \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/pdfreview/pdfshrink.sh b/Master/texmf-dist/doc/latex/pdfreview/pdfshrink.sh new file mode 100755 index 00000000000..6e273ee5e89 --- /dev/null +++ b/Master/texmf-dist/doc/latex/pdfreview/pdfshrink.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# this script is part of the pdf-annotation LaTeX package by M. Palmer +# like all files in the package, it is covered by the LPPL. + +# this assumes ghostscript is installed as 'gs - change as needed +ghostscript="gs" + +script_name=`basename "$0"` + +if [ -z $1 ]; then + echo "Usage: $script_name inputfile.pdf [quality [outputfile]]" + exit 1 +fi + +input_pdf=$1 + +# values for 'quality' argument: +# +# 'prepress' is highest quality +# 'printer' or 'default' are 300dpi, both quite good +# 'ebook' is 150 dpi; still reasonable on screen +# 'screen' is 72dpi - looks poor + + +if [ ! -f $input_pdf ]; then + echo "file $input_pdf not found" + exit 1 +fi + +# let quality default to 'default' +quality=${2-default} + +if [ $quality = 'default' ]; then + suffix="shrunk" +else + suffix=$quality +fi + +output_pdf=${3-${1%.pdf}-${suffix}} +output_pdf=${output_pdf%.pdf}.pdf + +echo "converting $input_pdf to $output_pdf using quality '$quality'" + +$ghostscript \ + -sDEVICE=pdfwrite \ + -dCompatibilityLevel=1.4 \ + -dHaveTransparency=true \ + -dFastWebView=true \ + -dPDFSETTINGS=/$quality \ + -dEmbedAllFonts=true \ + -dSubsetFonts=true \ + -dNOPAUSE \ + -dQUIET \ + -dBATCH \ + -sOutputFile="$output_pdf" \ + "$input_pdf" + +chmod 644 "$output_pdf" +echo "done" diff --git a/Master/texmf-dist/doc/latex/pdfreview/sample-for-docs.pdf b/Master/texmf-dist/doc/latex/pdfreview/sample-for-docs.pdf new file mode 100644 index 00000000000..ce46f11eae4 Binary files /dev/null and b/Master/texmf-dist/doc/latex/pdfreview/sample-for-docs.pdf differ diff --git a/Master/texmf-dist/tex/latex/pdfreview/pdfreview.sty b/Master/texmf-dist/tex/latex/pdfreview/pdfreview.sty new file mode 100644 index 00000000000..7b22a61cf1f --- /dev/null +++ b/Master/texmf-dist/tex/latex/pdfreview/pdfreview.sty @@ -0,0 +1,376 @@ +% This package is covered by the LaTeX project public license +% (see \url{http://www.latex-project.org/lppl.txt}). +% Please report bugs to the author (Michael Palmer, mpalmer@uwaterloo.ca) + +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{pdfreview}[2017/09/22 v1.10] + +\RequirePackage{ + adjustbox, + calc, + environ, + etoolbox, + graphicx, + ifthen, + kvoptions, + tikz, + xstring +} + +\usetikzlibrary{calc} + +% improve file name handling +\RequirePackage[extendedchars,space]{grffile} + +% provide \sout (strikeout) +\RequirePackage[normalem]{ulem} + +\SetupKeyvalOptions{% + family=annotation, + prefix=prv@, +} + +\DeclareBoolOption[true]{grid} +\DeclareBoolOption[false]{twocolumn} +\DeclareBoolOption[false]{notenumbers} +\DeclareBoolOption[true]{inline} +\DeclareBoolOption[false]{withnotesonly} +% +\DeclareStringOption[black!30]{gridcolor} +\DeclareStringOption[0.75]{bodywidth} +\DeclareStringOption[1cm]{trim} +\DeclareStringOption[0.5pt]{bodyframe} +\DeclareStringOption[noname]{sourcedoc} +\DeclareStringOption[0]{pageoffset} +\DeclareStringOption[c]{alignnotes} +\DeclareStringOption[yellow]{notesbg} +\DeclareStringOption[black]{notesframe} +\DeclareStringOption[3pt]{notesep} +\DeclareStringOption[footnotesize]{fontsize} +\DeclareStringOption[100]{maxscale} +\DeclareStringOption[1]{stretch} +\DeclareStringOption[2.5cm]{insertpagemargin} + +\ProcessKeyvalOptions* + +% break up trim options - passing raw kvoptions input through to adjustbox fails. +% count spaces +\StrCount{\prv@trim}{ }[\prv@trimspaces] + +\ifthenelse{\equal{\prv@trimspaces}{0}}% + % no spaces - trim all four sides the same + {\edef\prv@trimleft{\prv@trim}% + \edef\prv@trimright{\prv@trim}% + \edef\prv@trimtop{\prv@trim}% + \edef\prv@trimbottom{\prv@trim}% + }{\ifthenelse{\equal{\prv@trimspaces}{1}}% + % one space - apply separate trimming to h and v + {\StrCut{\prv@trim}{ }{\prv@trimh}{\prv@trimv}% + \edef\prv@trimleft{\prv@trimh}% + \edef\prv@trimright{\prv@trimh}% + \edef\prv@trimtop{\prv@trimv}% + \edef\prv@trimbottom{\prv@trimv}} + {% assume it's different parameters for all four sides + \StrCut{\prv@trim}{ }{\prv@trimleft}{\prv@trimtwo}% + \StrCut{\prv@trimtwo}{ }{\prv@trimbottom}{\prv@trimthree}% + \StrCut{\prv@trimthree}{ }{\prv@trimright}{\prv@trimtop}}} + +\newcommand{\sourcedoc}{\prv@sourcedoc} + +% control the split between the included page and the notes pane +\newlength{\prv@noteswidth} +\newlength{\prv@sourcebodywidth} +\newlength{\prv@bodyoffset} +\newlength{\prv@rightnotesoffset} +\newlength{\prv@bodypadding} + +% empty space between body and notes +\setlength{\prv@bodypadding}{\prv@notesep} + +\newlength{\prv@bodyframewidth} +\setlength{\prv@bodyframewidth}{\prv@bodyframe} + +\newcommand{\prv@notesfont}{\csname \prv@fontsize \endcsname} + +\newsavebox{\prv@charbox} +\sbox{\prv@charbox}{\prv@notesfont\phantom{x}\strut} + +\newlength{\prv@xsep} +\setlength{\prv@xsep}{0.75\wd\prv@charbox} + +\newlength{\prv@helpnumwidth} +\setlength{\prv@helpnumwidth}{\widthof{\prv@notesfont$\prv@maxscale$}+2\prv@xsep} + +\RequirePackage[hidelinks]{hyperref} +\RequirePackage{bookmark} + +\newlength{\prv@notestextwidth} +\newlength{\prv@pageheight} +\newlength{\prv@unitheight} +\newlength{\prv@currentheight} + +\newsavebox{\prv@pagebox} +\newsavebox{\prv@gridboxright} +\newsavebox{\prv@gridboxleft} + +\tikzset{ + notesfont/.style={ + font=\prv@notesfont + }, + % + notes/.style={ + notesfont, + draw=\prv@notesframe, + fill=\prv@notesbg, + rounded corners=0.5pt, + inner xsep=\prv@xsep, + inner ysep=0.4\ht\prv@charbox, + outer ysep=0.5pt, + outer xsep=0pt, + text width=\prv@notestextwidth, + text height=\ht\prv@charbox + }, + % + helpnum/.style={ + notesfont, + draw=none, + text=\prv@gridcolor, + text width=\prv@helpnumwidth, + align=center, + inner xsep=0pt, + inner ysep=-1em, % hack to squash scale y offset caused by node text + }, + % + grid/.style={ + draw=\prv@gridcolor, + very thin, + }, + % + boxnode/.style={ + inner sep=0pt, + outer sep=0pt, + anchor=south west, + draw=none + }, + % + strutline/.style={ + draw=white, + line width=0pt + }, + % + hypertarget/.style={ + notes, + alias=targetnode, + append after command={ + let \p1=(targetnode.north west) in + node[draw=none,at=(\p1)] {\hypertarget{#1}{}} + } + }, + % + hyperlink/.style={ + notes, + alias=sourcenode, + append after command={ + let \p1=(sourcenode.north west), + \p2=(sourcenode.south east), + \n1={\x2-\x1}, + \n2={\y1-\y2} in + node [inner sep=0pt, outer sep=0pt,anchor=north west,at=(\p1)] + {\hyperlink{#1}{\phantom{\rule{\n1}{\n2}}}} + } + } +} + +\newcommand{\prv@drawgridboxright}{% + \ifthenelse{\ht\prv@gridboxright<10}{% + \global\sbox{\prv@gridboxright}{% + \begin{tikzpicture}[y=\prv@unitheight,grid]% + \foreach \y in {0, 4, ..., \prv@maxscale}{% + \begin{scope}[yshift=\y\prv@unitheight]% + \draw (0,0) -- ++(\prv@noteswidth-\prv@helpnumwidth,0) node[helpnum,anchor=west]{$\y$}; + \ifthenelse{\equal{\y}{\prv@maxscale}}{}{% + \foreach \z/\w in {1/0.25,2/0.5,3/0.25}{% + \draw (0,\z) -- ++(\w,0); + }}% + \end{scope} + } + \end{tikzpicture}}}{}% + \usebox{\prv@gridboxright}% +} + +\newcommand{\prv@drawgridboxleft}{% + \ifthenelse{\ht\prv@gridboxleft<10}{% + \global\sbox{\prv@gridboxleft}{% + \begin{tikzpicture}[y=\prv@unitheight,grid,xscale=-1]% + %\draw[blue](0,0) rectangle (\prv@noteswidth,\prv@pageheight); + \foreach \y in {0, 4, ..., \prv@maxscale}{% + \begin{scope}[yshift=\y\prv@unitheight]% + \draw (0,0) -- ++(\prv@noteswidth-\prv@helpnumwidth,0) node[helpnum,anchor=east]{$\y$}; + \ifthenelse{\equal{\y}{\prv@maxscale}}{}{% + \foreach \z/\w in {1/0.25,2/0.5,3/0.25}{% + \draw (0,\z) -- ++(\w,0); + }}% + \end{scope} + } + \end{tikzpicture}}}{}% + \usebox{\prv@gridboxleft}% +} + +\newcounter{prv@offsetpage} +\newcommand*{\prv@pagelabel}{} + +% boolean switch for suppressing output of empty pages +\newbool{prv@isempty} +\setbool{prv@isempty}{true} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 + +\newsavebox{\prv@wrapper} + +\NewEnviron{page}[2][]{% +% now, start the actual page content. we use a minipage for vertical centering +% +\clearpage% +\setcounter{prv@offsetpage}{#2+\prv@pageoffset}% +\ifthenelse{\value{prv@offsetpage}<1}% + {\renewcommand*{\prv@pagelabel}{\roman{page}}}% + {\renewcommand*{\prv@pagelabel}{\arabic{prv@offsetpage}}}% +\ifbool{prv@withnotesonly}{}% + {\phantomsection% + \bookmark[level=1,page=\arabic{page}]{p. \prv@pagelabel}}% +\begin{lrbox}{\prv@wrapper}% +\noindent\begin{minipage}[c][\textheight]{\textwidth}% +\noindent\begin{center}% +\begin{adjustbox}{width=\textwidth}% +\begin{tikzpicture}[y=\prv@unitheight]% +\ifprv@twocolumn + \ifprv@grid + \node[boxnode] at (0,0){\prv@drawgridboxleft}; + \else + \draw[strutline](0,0) -- (\prv@noteswidth,0); + \fi +\fi +\ifprv@grid + \node[boxnode,anchor=south east] at (\textwidth,0) {\prv@drawgridboxright}; +\else + \draw[strutline](\textwidth,0) -- ++(-\prv@noteswidth,0); +\fi +\begin{scope} +\setlength{\fboxsep}{0pt} +\node[boxnode] at (\prv@bodyoffset,0) + {\adjustbox{clip, trim=\prv@trimleft{} \prv@trimbottom{} \prv@trimright{} \prv@trimtop{},% + #1,width=\prv@sourcebodywidth,fbox=\prv@bodyframe}% + {\includegraphics[page=#2]{\sourcedoc}}};% +\end{scope} +\begin{scope}[xshift=\prv@rightnotesoffset]% +%}% +% +\BODY +%{ +\end{scope}\end{tikzpicture}% +\end{adjustbox}% +\end{center}% +\end{minipage}% +\end{lrbox} +%\ifbool{prv@isempty}% +\ifboolexpr{bool {prv@isempty} and bool {prv@withnotesonly}}% + {\global\deadcycles=0}% + {\noindent\usebox{\prv@wrapper}}% +\global\setbool{prv@isempty}{true}\ignorespaces +} + +\newenvironment{leftnotes}% +{\ifprv@twocolumn + \begin{scope}[xshift=\prv@helpnumwidth-\prv@rightnotesoffset]% + \else% + \begin{scope} + \fi} +% +{\end{scope}} + +% a no-op environment for the bureaucratically inclined +\newenvironment{rightnotes}{}{} + +% use an insertpage environment for putting out the list of notes if requested +\newcommand{\prv@noteslist}{\begin{insertpage}[List of notes]\begin{enumerate}} + +\newcommand{\prv@notealignment}{north west} +\newcounter{note} + +\newcommand{\note}[3][\prv@alignnotes]{% +\ifbool{prv@isempty}% + {% + \ifbool{prv@withnotesonly}% + {\phantomsection% + \bookmark[level=1,page=\arabic{page}]{p. \prv@pagelabel}}{}% + \global\setbool{prv@isempty}{false}% + }% + {}% +\stepcounter{note}% +\ifthenelse{\equal{#1}{b}}{\renewcommand{\prv@notealignment}{south west}}{% + \ifthenelse{\equal{#1}{t}}{\renewcommand{\prv@notealignment}{north west}}{% + \renewcommand{\prv@notealignment}{west}}} +% +\ifprv@inline + \node[anchor=\prv@notealignment,hypertarget=note\arabic{note}] at (0,#2){% + \bookmark[level=2,dest=note\arabic{note}]{Note \arabic{note}}% + \raggedright\setlength{\parindent}{1em}\noindent% + \ifprv@notenumbers\arabic{note})\ \fi% + #3 + }; +\else + \node[anchor=\prv@notealignment,hypertarget=note\arabic{note},% + hyperlink=noteitem\arabic{note}] at (0,#2){% + \bookmark[level=2,dest=note\arabic{note}]{Note \arabic{note}}% + \raggedright\setlength{\parindent}{1em}\noindent% + \g@addto@macro\prv@noteslist{\item \hypertarget{noteitem\arabic{enumi}}{}{#3}% + \hyperlink{note\arabic{enumi}}{~$\uparrow$}}% + \arabic{note}. + }; +\fi +}% + +\newcommand{\cnote}[2]{\note[c]{#1}{#2}} +\newcommand{\bnote}[2]{\note[b]{#1}{#2}} +\newcommand{\tnote}[2]{\note[t]{#1}{#2}} + +% provide for extra pages with text +\newenvironment{insertpage}[1][General comments]%{}{}% +{\clearpage% +\phantomsection\addcontentsline{toc}{section}{#1}% +\newgeometry{margin=\prv@insertpagemargin} +\section*{#1}} +% +{\clearpage\aftergroup\restoregeometry} + + +\AtBeginDocument{% divide up the page. Use package geometry if not yet loaded by user. + \@ifpackageloaded{geometry}{}% use of both package options and \newgeometry is intentional. + {\RequirePackage[hmargin=0.25cm,vmargin=2.5cm]{geometry}% + \newgeometry{hmargin=0.25cm,vmargin=2.5cm}}% + \setlength{\prv@sourcebodywidth}{\prv@bodywidth\textwidth}% + \ifprv@twocolumn% + \setlength{\prv@noteswidth}{0.5\textwidth-0.5\prv@sourcebodywidth-\prv@bodypadding}% + \setlength{\prv@bodyoffset}{\prv@noteswidth+\prv@bodypadding-\prv@bodyframe}% + \else% + \setlength{\prv@noteswidth}{\textwidth-\prv@sourcebodywidth-\prv@bodypadding}% + \setlength{\prv@bodyoffset}{0pt}% + \fi% + \setlength{\prv@rightnotesoffset}{\textwidth-\prv@noteswidth}% + \setlength{\prv@notestextwidth}{\prv@noteswidth-\prv@helpnumwidth-2\prv@xsep}% + \sbox{\prv@pagebox}{% + {\setlength{\fboxsep}{0pt}% + \adjustbox{clip,trim=\prv@trimleft{} \prv@trimbottom{} \prv@trimright{} \prv@trimtop{},% + width=\prv@sourcebodywidth,fbox=\prv@bodyframe}{\includegraphics[page=1]{\sourcedoc}}% + }}% + \setlength{\prv@pageheight}{\ht\prv@pagebox}% + \setlength{\prv@unitheight}{\prv@stretch\prv@pageheight/\prv@maxscale}% +}% + +\AtEndDocument{% +\ifprv@inline% do nothing +\else% close the notes list and print it out + \g@addto@macro\prv@noteslist{\end{enumerate}\end{insertpage}} + \clearpage + \prv@noteslist +\fi} \ No newline at end of file diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 8684ca92290..f3ae9b72168 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -471,7 +471,7 @@ my @TLP_working = qw( pdf14 pdf-trans pdfbook2 pdfcomment pdfcprot pdfcrop pdfjam pdflatexpicscale pdfmarginpar - pdfpagediff pdfpages pdfscreen pdfslide pdfsync + pdfpagediff pdfpages pdfreview pdfscreen pdfslide pdfsync pdftricks pdftricks2 pdfx pdfxup pecha pedigree-perl perception perfectcut perltex permute persian-bib diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index 5e81de02064..8b93a89c835 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -799,6 +799,7 @@ depend pdfcomment depend pdfcprot depend pdfmarginpar depend pdfpagediff +depend pdfreview depend pdfscreen depend pdfslide depend pdfsync diff --git a/Master/tlpkg/tlpsrc/pdfreview.tlpsrc b/Master/tlpkg/tlpsrc/pdfreview.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d -- cgit v1.2.3