texlive[72845] Master: stocksize (13nov24)
commits+karl at tug.org
commits+karl at tug.org
Wed Nov 13 22:12:42 CET 2024
Revision: 72845
https://tug.org/svn/texlive?view=revision&revision=72845
Author: karl
Date: 2024-11-13 22:12:42 +0100 (Wed, 13 Nov 2024)
Log Message:
-----------
stocksize (13nov24)
Modified Paths:
--------------
trunk/Master/tlpkg/bin/tlpkg-ctan-check
trunk/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
Added Paths:
-----------
trunk/Master/texmf-dist/doc/latex/stocksize/
trunk/Master/texmf-dist/doc/latex/stocksize/README.md
trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf
trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex
trunk/Master/texmf-dist/tex/latex/stocksize/
trunk/Master/texmf-dist/tex/latex/stocksize/stocksize.sty
trunk/Master/tlpkg/tlpsrc/stocksize.tlpsrc
Added: trunk/Master/texmf-dist/doc/latex/stocksize/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stocksize/README.md (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/stocksize/README.md 2024-11-13 21:12:42 UTC (rev 72845)
@@ -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 at 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)!
+```
Property changes on: trunk/Master/texmf-dist/doc/latex/stocksize/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf 2024-11-13 21:12:05 UTC (rev 72844)
+++ trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf 2024-11-13 21:12:42 UTC (rev 72845)
Property changes on: trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex 2024-11-13 21:12:42 UTC (rev 72845)
@@ -0,0 +1,129 @@
+%% This is file `stocksize-doc.text',
+%%
+%% Copyright (C) 2024 by João Lourenço <joao.lourenco at 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&\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
Property changes on: trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/stocksize/stocksize.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stocksize/stocksize.sty (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/stocksize/stocksize.sty 2024-11-13 21:12:42 UTC (rev 72845)
@@ -0,0 +1,95 @@
+%% This is file `stocksize.sty',
+%%
+%% Copyright (C) 2024 by João M. Lourenço <joao.lourenco at 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 at setpdfpagesize}[2]{%
+ \@ifundefined{pdfpageheight}{}{\pdfpageheight=#1}%
+ \@ifundefined{pdfpagewidth}{}{\pdfpagewidth=#2}%
+ \@ifundefined{pageheight}{}{\pageheight=31}%
+ \@ifundefined{pagewidth}{}{\pagewidth=#2}%
+}
+
+
+% Fix page layout
+\DeclareRobustCommand{\@ss at fixpagelayout}{%
+ \setlength{\paperheight}{\the\dimexpr\Gm at tmargin+\Gm at height+\Gm at bmargin\relax}
+ \setlength{\paperwidth}{\the\dimexpr\Gm at lmargin+\Gm at width+\Gm at rmargin\relax}
+ \setlength{\stockheight}{\paperheight}
+ \setlength{\stockwidth}{\paperwidth}
+ \setlength{\@colht}{\textheight}
+ \setlength{\@colroom}{\textheight}%
+ \setlength{\vsize}{\textheight}
+ \setlength{\columnwidth}{\textwidth}%
+ \if at twocolumn%
+ \advance\columnwidth-\columnsep
+ \divide\columnwidth\tw@%
+ \@firstcolumntrue%
+ \fi%
+ \setlength{\hsize}{\columnwidth}%
+ \setlength{\linewidth}{\hsize}%
+}
+
+\newcounter{@ss at cnt}
+\newcommand{\pdfsavegeometry}[1]{%
+ \expandafter\edef\csname @sspw@\arabic{@ss at cnt}\endcsname%
+ {\the\dimexpr\Gm at lmargin+\Gm at width+\Gm at rmargin\relax}%
+ \expandafter\edef\csname @ssph@\arabic{@ss at cnt}\endcsname%
+ {\the\dimexpr\Gm at tmargin+\Gm at height+\Gm at bmargin\relax}%
+ \stepcounter{@ss at cnt}%
+ \savegeometry{@ss at cnt@\arabic{@ss at cnt}}%
+ \restoregeometry%
+ \newgeometry{#1}%
+ \@ss at fixpagelayout%
+ \edef\@sspw{\the\dimexpr\Gm at lmargin+\Gm at width+\Gm at rmargin\relax}%
+ \edef\@ssph{\the\dimexpr\Gm at tmargin+\Gm at height+\Gm at bmargin\relax}%
+ \@ss at setpdfpagesize{\@ssph}{\@sspw}%
+}
+
+\newcommand{\pdfrestoregeometry}{%
+ \loadgeometry{@ss at cnt@\arabic{@ss at cnt}}%
+ \@ss at fixpagelayout%
+ \addtocounter{@ss at cnt}{-1}%
+ \@ss at setpdfpagesize{\csname @ssph@\arabic{@ss at cnt}\endcsname}%
+ {\csname @sspw@\arabic{@ss at 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
+
Property changes on: trunk/Master/texmf-dist/tex/latex/stocksize/stocksize.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check 2024-11-13 21:12:05 UTC (rev 72844)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check 2024-11-13 21:12:42 UTC (rev 72845)
@@ -808,7 +808,7 @@
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
Modified: trunk/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc 2024-11-13 21:12:05 UTC (rev 72844)
+++ trunk/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc 2024-11-13 21:12:42 UTC (rev 72845)
@@ -1331,6 +1331,7 @@
depend stdpage
depend stealcaps
depend stex
+depend stocksize
depend storebox
depend storecmd
depend stringstrings
Added: trunk/Master/tlpkg/tlpsrc/stocksize.tlpsrc
===================================================================
More information about the tex-live-commits
mailing list.