summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-11-13 21:12:42 +0000
committerKarl Berry <karl@freefriends.org>2024-11-13 21:12:42 +0000
commit62fe2efe49eb878163bef49fe64e4e2ed63de14b (patch)
tree4d617a60324464f55dc4d97464843b777d51da60
parent829fcd3041b854f24585d679a33c26cdce4691f6 (diff)
stocksize (13nov24)
git-svn-id: svn://tug.org/texlive/trunk@72845 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/stocksize/README.md54
-rw-r--r--Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdfbin0 -> 112133 bytes
-rw-r--r--Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex129
-rw-r--r--Master/texmf-dist/tex/latex/stocksize/stocksize.sty95
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rw-r--r--Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/stocksize.tlpsrc0
7 files changed, 280 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/stocksize/README.md b/Master/texmf-dist/doc/latex/stocksize/README.md
new file mode 100644
index 00000000000..778a7c186d4
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/stocksize/README.md
@@ -0,0 +1,54 @@
+# stocksize
+
+This package provides a flexible and easy interface to change the paper (stock) dimensions in LaTeX documents.
+Multiple user defined stock sizes are allowed in the same document, and sock sizes can be nested (in a LIFO order).
+
+## About
+
+* **Package:** stocksize — A flexible and easy interface to paper (stock) dimensions.
+* **Copyright:** 2024 © João M. Lourenço <joao.lourenco@fct.unl.pt>
+* **CTAN:** https://ctan.org/pkg/stocksize
+* **Repository:** https://github.com/joaomlourenco/stocksize
+* **License:** The LaTeX Project Public License 1.3c
+
+## Introduction
+
+The package [geometry](https://github.com/LaTeX-Package-Repositories/geometry) is excellent for customuzing the page layout. However, changing the page size in the middle of the document only changes the typing area and does not affect the real paper (sock) size. This package circunvents this situation, by resizing the paper (stock) size to the given size.
+
+
+## User Interface
+
+### Loading the Package
+
+Simply load the package with (with no options):
+```latex
+\usepackage{stocksize}
+```
+
+### Starting a new Page With a Different Page/Stock Size
+
+To start a new page with a different page/stock size use the \verb!\newstocksize! and \verb!restorestocksize! commands.
+```latex
+\newstocksize{options} — This command starts a new stock (and paper) size. The `options` are passed straight to the \newgeometry command form the `geometry` package.
+\restorestocksize — This command ends trhe current stock size and restores the previous one (in a LIFO fashion).
+```
+
+### Nesting Different Page/Stock Sizes
+
+ Multiple paper/stock sizes can be nested. With each `\restorestocksize` command, the previous size is resmued.
+
+```latex
+ This page has the default size (e.g., a4paper).
+
+ \newstocksize[margin=0pt]{layoutsize={15cm,10cm},margin=1.5cm}
+ This page size is 15cm wide x 10cm high, with margins of 1.5cm.
+
+ \newstocksize{layoutsize={20cm,20cm},margin=4.0cm}
+ This page size is 20cm wide x 20cm high, with margins of 4.0cm.
+
+ \restorestocksize
+ Resuming the page size is 15cm wide x 10cm high, with margins of 1.5cm.
+
+ \restorestocksize
+ Resuming the default paper size and margins (e.g., a4paper)!
+```
diff --git a/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf b/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf
new file mode 100644
index 00000000000..8f5726a9c58
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex b/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex
new file mode 100644
index 00000000000..04ed5a1bd95
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex
@@ -0,0 +1,129 @@
+%% This is file `stocksize-doc.text',
+%%
+%% Copyright (C) 2024 by João Lourenço <joao.lourenco@fct.unl.pt>
+%%
+%% This file may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX
+%% version 2006/05/20 or later.
+%%
+\documentclass[12pt,a4paper,article]{article}
+
+\usepackage[margin=1in]{geometry}
+\usepackage{kantlipsum}
+\usepackage{booktabs}
+\usepackage[colorlinks=true,allcolors=blue]{hyperref}
+\usepackage{stocksize}
+
+\newcommand{\printpagesize}[1][]{%
+ \par\ifx&#1&\else
+ The dimensions given for this page were: #1.
+ \fi
+
+ \par\bigskip\noindent This page's dimensions (in pt) are:\medskip
+
+ \begin{tabular}{lll}
+ \toprule
+ & \textbf{height} & \textbf{width} \\
+ \midrule
+ \textbf{paper} & \the\paperheight & \the\paperwidth \\
+ \textbf{stock} & \the\stockheight & \the\stockwidth \\
+ \textbf{text} & \the\textheight & \the\textwidth \\
+ \bottomrule
+ \end{tabular}\par\bigskip
+}
+
+
+\begin{document}
+
+ \title{The \textsf{\filename} package}
+ \author{João M. Lourenço\\\url{https://github.com/joaomlourenco/stocksize}}
+ \date{\filedate\ (v\fileversion)}
+
+ \maketitle
+
+ \begin{abstract}
+ This package provides a flexible and easy interface to change the paper (stock) dimensions in LaTeX documents.
+ Multiple user defined stock sizes are allowed in the same document, and sock sizes can be nested (in a LIFO order).
+ \end{abstract}
+
+\section{Introduction}
+
+ The package
+ \href{https://github.com/davidcarlisle/geometry}{geometry}
+is excellent for customizing the page layout. However, using the \verb!\newgeometry! command to change the page size in the middle of the document only affects the typing area and does not impact the real paper (sock) size. This package circumvents this situation, by resizing the paper (stock) size to the new page layout.
+
+\section{User Interface}
+
+\subsection{Loading the package}
+
+ Simply load the package with (with no options):
+
+ \begin{verbatim}
+ \usepackage{stocksize}
+ \end{verbatim}
+
+\subsection{Starting a new page with a different page/stock size}
+
+To start a new page with a different page/stock size use the \verb!\newstocksize! and \verb!restorestocksize! commands.
+
+ \begin{description}
+ \item[] \verb!newstocksize{options}! — This command starts a new stock (and paper) size. The \verb!options! are passed straight to the \verb!\newgeometry! command form the \verb!geometry! package.
+ \item[] \verb!restorestocksize! — This command ends trhe current stock size and restores the previous one (in a LIFO fashion).
+ \end{description}
+
+\subsection{Nesting different page/stock sizes}
+
+ Multiple paper/stock sizes can be nested. With each \verb!\restorestocksize! command, the previous size is resmued.
+
+ \begin{verbatim}
+ This page has the default size (e.g., a4paper).
+
+ \newstocksize[margin=0pt]{layoutsize={15cm,10cm},margin=1.5cm}
+ This page size is 15cm wide x 10cm high, with margins of 1.5cm.
+
+ \newstocksize{layoutsize={20cm,20cm},margin=4.0cm}
+ This page size is 20cm wide x 20cm high, with margins of 4.0cm.
+
+ \restorestocksize
+ Resuming the page size is 15cm wide x 10cm high, with margins of 1.5cm.
+
+ \restorestocksize
+ Resuming the default paper size and margins (e.g., a4paper)!
+
+ \end{verbatim}
+
+
+\section{Example of multiple stock size pages}
+
+ % inital (21.0cm x 29.7cm)
+ \printpagesize
+ \kant[1-4]
+
+ % new (15cm x 10cm)
+ \newstocksize{layoutsize={15cm,10cm},margin=1.5cm}
+ \printpagesize[15cm, 10cm, margin=1cm]
+ \kant[1-2]
+
+ % new (20cm x 20cm)
+ \newstocksize{layoutsize={20cm,20cm},margin=4.0cm}
+ \printpagesize[20cm, 20cm, margin=1cm]
+ \kant[1-3]
+ \restorestocksize
+
+ % resume (15cm x 10cm)
+ \printpagesize[15cm, 10cm, margin=1.5cm]
+ \kant[1-2]
+ \restorestocksize
+
+ % resume (21.0cm x 29.7cm)
+ \printpagesize
+ \kant[1-5]
+
+
+\end{document} \ No newline at end of file
diff --git a/Master/texmf-dist/tex/latex/stocksize/stocksize.sty b/Master/texmf-dist/tex/latex/stocksize/stocksize.sty
new file mode 100644
index 00000000000..4b89d4d211d
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/stocksize/stocksize.sty
@@ -0,0 +1,95 @@
+%% This is file `stocksize.sty',
+%%
+%% Copyright (C) 2024 by João M. Lourenço <joao.lourenco@fct.unl.pt>
+%%
+%% This file may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX
+%% version 2006/05/20 or later.
+%%
+\def\fileversion{1.0.1}
+\def\filedate {2024/11/12}
+\edef\filename {\@currname}
+
+\ProvidesPackage{stocksize}[%
+ \filedate\ v\fileversion (João M. Lourenço) User defined PDF paper (stock) size.]
+
+% Load geometry if it was was not loaded by the user
+\AddToHook{begindocument/before}{
+ \@ifpackageloaded{geometry}{}{
+ \RequirePackage[pass]{geometry}
+ }
+}
+
+% Change the physical paper (stock) size
+% Works with pdfLaTeX, XeLaTeX and LuaLaTeX
+\newcommand*{\@ss@setpdfpagesize}[2]{%
+ \@ifundefined{pdfpageheight}{}{\pdfpageheight=#1}%
+ \@ifundefined{pdfpagewidth}{}{\pdfpagewidth=#2}%
+ \@ifundefined{pageheight}{}{\pageheight=31}%
+ \@ifundefined{pagewidth}{}{\pagewidth=#2}%
+}
+
+
+% Fix page layout
+\DeclareRobustCommand{\@ss@fixpagelayout}{%
+ \setlength{\paperheight}{\the\dimexpr\Gm@tmargin+\Gm@height+\Gm@bmargin\relax}
+ \setlength{\paperwidth}{\the\dimexpr\Gm@lmargin+\Gm@width+\Gm@rmargin\relax}
+ \setlength{\stockheight}{\paperheight}
+ \setlength{\stockwidth}{\paperwidth}
+ \setlength{\@colht}{\textheight}
+ \setlength{\@colroom}{\textheight}%
+ \setlength{\vsize}{\textheight}
+ \setlength{\columnwidth}{\textwidth}%
+ \if@twocolumn%
+ \advance\columnwidth-\columnsep
+ \divide\columnwidth\tw@%
+ \@firstcolumntrue%
+ \fi%
+ \setlength{\hsize}{\columnwidth}%
+ \setlength{\linewidth}{\hsize}%
+}
+
+\newcounter{@ss@cnt}
+\newcommand{\pdfsavegeometry}[1]{%
+ \expandafter\edef\csname @sspw@\arabic{@ss@cnt}\endcsname%
+ {\the\dimexpr\Gm@lmargin+\Gm@width+\Gm@rmargin\relax}%
+ \expandafter\edef\csname @ssph@\arabic{@ss@cnt}\endcsname%
+ {\the\dimexpr\Gm@tmargin+\Gm@height+\Gm@bmargin\relax}%
+ \stepcounter{@ss@cnt}%
+ \savegeometry{@ss@cnt@\arabic{@ss@cnt}}%
+ \restoregeometry%
+ \newgeometry{#1}%
+ \@ss@fixpagelayout%
+ \edef\@sspw{\the\dimexpr\Gm@lmargin+\Gm@width+\Gm@rmargin\relax}%
+ \edef\@ssph{\the\dimexpr\Gm@tmargin+\Gm@height+\Gm@bmargin\relax}%
+ \@ss@setpdfpagesize{\@ssph}{\@sspw}%
+}
+
+\newcommand{\pdfrestoregeometry}{%
+ \loadgeometry{@ss@cnt@\arabic{@ss@cnt}}%
+ \@ss@fixpagelayout%
+ \addtocounter{@ss@cnt}{-1}%
+ \@ss@setpdfpagesize{\csname @ssph@\arabic{@ss@cnt}\endcsname}%
+ {\csname @sspw@\arabic{@ss@cnt}\endcsname}%
+}
+
+% To support multiple levels (nesting) of stock sizes
+\newcommand{\newstocksize}[1]{%
+ % #1 = layout arguments to be passed to \newgeometry
+ \pdfsavegeometry{#1}%
+}
+
+\newcommand{\restorestocksize}{%
+ \pdfrestoregeometry%
+}
+
+% Set stock dimensions to current paper dimensions
+% \stockheight=\paperheight
+% \stockwidth=\paperwidth
+
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index 281f37aa9a9..5e79581fe04 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -808,7 +808,7 @@ my @TLP_working = qw(
statex statex2 statistics statistik statmath staves starray
stdclsdv stdpage stealcaps steinmetz
stellenbosch stellenbosch-2 step stepgreek stex
- stickstoo stix stix2-otf stix2-type1 stmaryrd storebox storecmd
+ stickstoo stix stix2-otf stix2-type1 stmaryrd stocksize storebox storecmd
strands stricttex string-diagrams stringenc stringstrings
structmech struktex
sttools stubs studenthandouts sty2dtx styledcmd suanpan suanpan-l3
diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
index f20fb758f4a..bdd458b6f3e 100644
--- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
@@ -1331,6 +1331,7 @@ depend stdclsdv
depend stdpage
depend stealcaps
depend stex
+depend stocksize
depend storebox
depend storecmd
depend stringstrings
diff --git a/Master/tlpkg/tlpsrc/stocksize.tlpsrc b/Master/tlpkg/tlpsrc/stocksize.tlpsrc
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/stocksize.tlpsrc