如何在不使用包的情况下编辑边距?

如何在不使用包的情况下编辑边距?

我正在尝试从文件 bk10.clo 手动更改边距,我希望在双面模式下边距对称于 3cm,在单面模式下边距为顶部 = 3cm、左侧 = 4cm、右侧 = 2cm、底部 = 3cm。

这是我的代码但我认为它不正确。

\if@twocolumn
    \setlength\marginparsep {10\p@}
\else
    \setlength\marginparsep{7\p@}
\fi
\setlength\marginparpush{5\p@}
\if@compatibility
    \setlength\oddsidemargin   {.5in}
    \setlength\evensidemargin  {1.5in}
    \setlength\marginparwidth {.75in}
  \if@twocolumn
    \setlength\oddsidemargin  {30\p@}
    \setlength\evensidemargin {30\p@}
    \setlength\marginparwidth {48\p@}
  \fi
\else
  \if@twoside
    \setlength\@tempdima        {\paperwidth}
    \addtolength\@tempdima      {-\textwidth}
    \setlength\oddsidemargin    {.4\@tempdima}
    \addtolength\oddsidemargin  {-1in} 
    \addtolength\oddsidemargin  {-0.3in} % we add -0.3in to get 3cm of left side margin
    \setlength\marginparwidth   {.6\@tempdima}
    \addtolength\marginparwidth {-\marginparsep}
    \addtolength\marginparwidth {-0.4in}
    %\addtolength\textwidth         {1.36in} % we add 1.36in to get 3cm of right side margin
  \else
    \setlength\@tempdima        {\paperwidth}
    \addtolength\@tempdima      {-\textwidth}
    \setlength\oddsidemargin    {.5\@tempdima}
    \addtolength\oddsidemargin  {-1in}
    \addtolength\oddsidemargin  {-0.28in} % we add -0.28in to get 4cm of left side margin
    \setlength\marginparwidth   {.5\@tempdima}
    \addtolength\marginparwidth {-\marginparsep}
    \addtolength\marginparwidth {-0.4in}
    \addtolength\marginparwidth {-.4in}
    %\addtolength\textwidth     {1.36in} % we add 1.36in to get 2cm of right side margin
  \fi
  \addtolength\textwidth        {1.36in} % we add 1.36in to get 3cm (resp. 2cm) of right side margin in mode twoside (resp. mode oneside). 
  \ifdim \marginparwidth >2in
     \setlength\marginparwidth{2in}
  \fi
  \@settopoint\oddsidemargin
  \@settopoint\marginparwidth
  \setlength\evensidemargin  {\paperwidth}
  \addtolength\evensidemargin{-2in}
  \addtolength\evensidemargin{-\textwidth}
  \addtolength\evensidemargin{-\oddsidemargin}
  \@settopoint\evensidemargin
\fi
\if@compatibility
  \setlength\topmargin{.75in}
\else
  \setlength\topmargin{\paperheight}
  \addtolength\topmargin{-2in}
  \addtolength\topmargin{-\headheight}
  \addtolength\topmargin{-\headsep}
  \addtolength\topmargin{-\textheight}
  \addtolength\topmargin{-\footskip}     % this might be wrong!
  \addtolength\topmargin{-.5\topmargin}
  \addtolength\topmargin{-0.56in} % we add -0.56in to get 3cm of top margin
  \addtolength\textheight{1in} % we add 1in to get 3cm of bottom margin (from the limit of the page at body)
  \addtolength\footskip{0.066in} % we add 0.066in to get 2cm of bottom margin (from the limit of the page at footer)
  \@settopoint\topmargin
\fi

提前致谢。

编辑: 使用

\makeatletter
\setlength{\oddsidemargin}{-1in} 
\if@twoside
\addtolength{\oddsidemargin}{3cm} 
\else
\addtolength{\oddsidemargin}{4cm}
\fi 
\setlength{\evensidemargin}{\oddsidemargin} 
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-6cm} % left+ right margins
\setlength{\topmargin}{-1in}
\addtolength{\topmargin}{-\headheight}
\addtolength{\topmargin}{-\headsep} 
\addtolength{\topmargin}{3cm}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-6cm} % top + bottom margins
\makeatother

与几何

无几何形状

我感谢任何帮助...

答案1

尝试理解这一点

\makeatletter
\setlength{\oddsidemargin}{-1in} 
\if@twoside
\addtolength{\oddsidemargin}{3cm} 
\else
\addtolength{\oddsidemargin}{4cm}
\fi 
\setlength{\evensidemargin}{\oddsidemargin} 
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-6cm} % left+ right margins
\setlength{\topmargin}{-1in}
\addtolength{\topmargin}{-\headheight}
\addtolength{\topmargin}{-\headsep} 
\addtolength{\topmargin}{3cm}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-6cm} % top + bottom margins
\makeatother

相关内容