带有更改页面大小选项的样式文件

带有更改页面大小选项的样式文件

我想要一个nutsi.sty包含该my-definition功能的 latex 样式文件。我还想设置页面大小 (21cm x 21cm),并将整个文档设置为粗体字体。

设法制作一个使用 nutsi.sty 的乳胶文件

    \documentclass{book}
    \usepackage{nutsi}
    
    \end{document}


Although this style file sets a page-size of 21cm x 21cm, how can I
introduce an option that lets the user select either 1) a 21cm x 21cm
pagesize; 2) an A4 pagesize; or a B5 pagesize.   

This is the file `nutsi.sty`.

    \usepackage{geometry}
    \geometry{ paperheight=21cm, paperwidth=21cm, left=8mm, right=8mm,
      top=21mm, bottom=21mm}
    
    \usepackage{fix-cm}
    \makeatletter
    \renewcommand\normalsize{%
       \@setfontsize\normalsize{13pt}{15pt}
       \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
       \abovedisplayshortskip \z@ \@plus3\p@
       \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
       \belowdisplayskip \abovedisplayskip
       \let\@listi\@listI}
    \makeatother
    
    \usepackage{bm}                % makes bold arguments
    \usepackage[x11names]{xcolor}  % loads 317 named rgb colours
    
    \usepackage{amsmath}
    \usepackage{amsthm}
    \usepackage{amssymb}
    
    % use boldface for whole document
    \boldmath
    \renewcommand{\seriesdefault}{\bfdefault}
    
    \newtheoremstyle{my-definition} % name of style
    {8pt}       % measure of space above definition, e.g. {3pt}
    {8pt}       % measure of space below definition, e.g. {3pt}
    {\itshape}  % name of font for body of example
    {}          % measure of space to indent, e.g. {3pt}
    {\bfseries\itshape}           % name of font for heading
    {\textcolor{DarkOrange3}{.}}  % punctuation between heading and body
    { }         % space after theorem heading
    {\thmname{\textbf{\textit{#1}}}
     \textcolor{DarkOrange3}{\textbf{\thmnumber{#2}}}
     \thmnote{\textit{({#3})}} }
    
    \theoremstyle{my-definition}
    \newtheorem{definition}{\textcolor{Blue3}{Definition}}[section]

答案1

以下使用expkv-optkey=value接口来提供包选项。

这样,您就有一个选项paper,可采用三个可能值之一21a4、 和b5

请注意,在包中您应该使用\RequirePackage而不是\usepackage,而不需要\makeatletter

nutsi.sty

\ProvidesPackage{nutsi}[2022-04-25 custom style by Ephram]

\RequirePackage{expkv-opt,expkv-def}
\ekvdefinekeys{nutsi}
  {
    choice-enum paper = \nutsi@paper {21, a4, b5}
  }
\ekvoProcessLocalOptions{nutsi}

\RequirePackage{geometry}
\ifcase\nutsi@paper
  \geometry{paperheight=21cm, paperwidth=21cm}
\or
  \geometry{a4paper}
\or
  \geometry{b5paper}
\fi

\geometry{left=8mm, right=8mm, top=21mm, bottom=21mm}

\RequirePackage{fix-cm}
\renewcommand\normalsize{%
   \@setfontsize\normalsize{13pt}{15pt}
   \abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
   \abovedisplayshortskip \z@ \@plus3\p@
   \belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
   \belowdisplayskip \abovedisplayskip
   \let\@listi\@listI}

\RequirePackage{bm}                % makes bold arguments
\RequirePackage[x11names]{xcolor}  % loads 317 named rgb colours

\RequirePackage{amsmath}
\RequirePackage{amsthm}
\RequirePackage{amssymb}

% use boldface for whole document
\boldmath
\renewcommand{\seriesdefault}{\bfdefault}

\newtheoremstyle{my-definition} % name of style
{8pt}       % measure of space above definition, e.g. {3pt}
{8pt}       % measure of space below definition, e.g. {3pt}
{\itshape}  % name of font for body of example
{}          % measure of space to indent, e.g. {3pt}
{\bfseries\itshape}           % name of font for heading
{\textcolor{DarkOrange3}{.}}  % punctuation between heading and body
{ }         % space after theorem heading
{\thmname{\textbf{\textit{#1}}}
 \textcolor{DarkOrange3}{\textbf{\thmnumber{#2}}}
 \thmnote{\textit{({#3})}} }

\theoremstyle{my-definition}
\newtheorem{definition}{\textcolor{Blue3}{Definition}}[section]

文件

\documentclass{article}

\usepackage[paper=b5]{nutsi}

\usepackage{duckuments}

\begin{document}
\duckument
\end{document}

相关内容