texlive[72853] Master/texmf-dist: stocksize (14nov24)

commits+karl at tug.org commits+karl at tug.org
Thu Nov 14 21:42:44 CET 2024


Revision: 72853
          https://tug.org/svn/texlive?view=revision&revision=72853
Author:   karl
Date:     2024-11-14 21:42:43 +0100 (Thu, 14 Nov 2024)
Log Message:
-----------
stocksize (14nov24)

Modified Paths:
--------------
    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/stocksize.sty

Modified: trunk/Master/texmf-dist/doc/latex/stocksize/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stocksize/README.md	2024-11-14 20:42:30 UTC (rev 72852)
+++ trunk/Master/texmf-dist/doc/latex/stocksize/README.md	2024-11-14 20:42:43 UTC (rev 72853)
@@ -1,7 +1,7 @@
 # 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).
+Multiple user defined stock sizes are allowed in the same document, and stock sizes can be nested (in a LIFO order).
 
 ## About
 
@@ -13,7 +13,7 @@
 
 ## 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.
+The package [geometry](https://github.com/LaTeX-Package-Repositories/geometry) is excellent for customising 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 (stock) size.  This package circumvents this situation by resizing the paper (stock) size to the given size.
 
 
 ## User Interface
@@ -29,18 +29,20 @@
 
 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).
+\newstocksize{options} — This command starts a new stock (and paper) size.  The `options` may include:
+    `keepmargins` — The current (left, right, top, and bottom) margins will be prreseved in the new page layout;
+    `other_options` — The `other_options` are passed straight to the \newgeometry command form the`geometry` package.
+\restorestocksize — This command ends the 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.
+  Multiple paper/stock sizes can be nested.  With each `\restorestocksize` command, the previous size is resumed.
   
 ```latex
   This page has the default size  (e.g., a4paper).
 
-    \newstocksize[margin=0pt]{layoutsize={15cm,10cm},margin=1.5cm}
+    \newstocksize{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}

Modified: trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex	2024-11-14 20:42:30 UTC (rev 72852)
+++ trunk/Master/texmf-dist/doc/latex/stocksize/stocksize-doc.tex	2024-11-14 20:42:43 UTC (rev 72853)
@@ -49,7 +49,7 @@
   
   \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).
+    Multiple user defined stock sizes are allowed in the same document, and stock sizes can be nested (in a LIFO order).
   \end{abstract}
 
 \section{Introduction}
@@ -56,7 +56,7 @@
 
   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.
+is excellent for customising 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 (stock) size. This package circumvents this situation by resizing the paper (stock) size to the new page layout.
 
 \section{User Interface}
   
@@ -70,21 +70,25 @@
   
 \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.
+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).
+    \item[] \verb!\newstocksize{options}! — This command starts a new stock (and paper) size.  The \verb!options! may include:
+    \begin{description}
+      \item[] \verb!keepmargins! — The current (left, right, top, and bottom) margins will be preserved in the new page layout;
+      \item[] \verb!other_options! — The \verb!other_options! are passed straight to the \verb!\newgeometry! command form the \verb!geometry! package.
+    \end{description}
+    \item[] \verb!\restorestocksize! — This command ends the 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.
+  Multiple paper/stock sizes can be nested.  With each \verb!\restorestocksize! command, the previous size is resumed.
   
   \begin{verbatim}
   This page has the default size  (e.g., a4paper).
 
-    \newstocksize[margin=0pt]{layoutsize={15cm,10cm},margin=1.5cm}
+    \newstocksize{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}

Modified: trunk/Master/texmf-dist/tex/latex/stocksize/stocksize.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/stocksize/stocksize.sty	2024-11-14 20:42:30 UTC (rev 72852)
+++ trunk/Master/texmf-dist/tex/latex/stocksize/stocksize.sty	2024-11-14 20:42:43 UTC (rev 72853)
@@ -12,8 +12,8 @@
 %% 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}
+\def\fileversion{1.0.2}
+\def\filedate   {2024/11/13}
 \edef\filename  {\@currname}
 
 \ProvidesPackage{stocksize}[%
@@ -22,7 +22,7 @@
 % Load geometry if it was was not loaded by the user
 \AddToHook{begindocument/before}{
   \@ifpackageloaded{geometry}{}{
-    \RequirePackage[pass]{geometry}
+    \RequirePackage[reset]{geometry}
   }
 }
 
@@ -31,32 +31,14 @@
 \newcommand*{\@ss at setpdfpagesize}[2]{%
   \@ifundefined{pdfpageheight}{}{\pdfpageheight=#1}%
   \@ifundefined{pdfpagewidth}{}{\pdfpagewidth=#2}%
-  \@ifundefined{pageheight}{}{\pageheight=31}%
+  \@ifundefined{pageheight}{}{\pageheight=#1}%
   \@ifundefined{pagewidth}{}{\pagewidth=#2}%
+  \paperheight=#1\stockheight=#1%
+  \paperwidth=#2\stockwidth=#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]{%
+\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%
@@ -63,33 +45,26 @@
                 {\the\dimexpr\Gm at tmargin+\Gm at height+\Gm at bmargin\relax}%
   \stepcounter{@ss at cnt}%
   \savegeometry{@ss at cnt@\arabic{@ss at cnt}}%
+  \newdimen\@tempdimd%
+  \@tempdima=\Gm at lmargin\@tempdimb=\Gm at rmargin%
+  \@tempdimc=\Gm at tmargin\@tempdimd=\Gm at bmargin%
+  \define at key{Gm}{keepmargins}[true]{\setkeys{Gm}{lmargin=\the\@tempdima,
+          rmargin=\the\@tempdimb, tmargin=\the\@tempdimc, bmargin=\the\@tempdimd
+  }}%
   \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}{%
+\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*{\newstocksize}{\pdfsavegeometry}
+\newcommand*{\restorestocksize}{\pdfrestoregeometry}
 
-\newcommand{\restorestocksize}{%
-  \pdfrestoregeometry%
-}
-
-% Set stock dimensions to current paper dimensions
-% \stockheight=\paperheight
-% \stockwidth=\paperwidth
-



More information about the tex-live-commits mailing list.