一英寸边距和几何包

一英寸边距和几何包

使用

\usepackage[margin=1in]{geometry}

我可以在文档周围创建 1 英寸的边距。如果我使用原生 LaTeX 命令(例如 \textwidth、\evensidemargin 等),那么等效命令是什么?

答案1

\documentclass{article} 
%\usepackage[margin=1in]{geometry}
\setlength\topmargin{0pt}
\addtolength\topmargin{-\headheight}
\addtolength\topmargin{-\headsep}
\setlength\oddsidemargin{0pt}
\setlength\textwidth{\paperwidth}
\addtolength\textwidth{-2in}
\setlength\textheight{\paperheight}
\addtolength\textheight{-2in}
\usepackage{layout}

\begin{document} 
\layout
\end{document}

答案2

\addtolength{\oddsidemargin}{-.875in}
\addtolength{\evensidemargin}{-.875in}
\addtolength{\textwidth}{1.75in}

\addtolength{\topmargin}{-.875in}
\addtolength{\textheight}{1.75in}

如果我没记错的话,这些是 1 英寸边距的测量值。

答案3

通过将文本高度设置为文本行的整数,并将边距设置为

\usepackage{calc}

\makeatletter
\normalsize
\setlength\textheight{\paperheight-2in}%
\setlength\textwidth{\paperwidth-2in}%

\newlength\my@tdima
\newlength\my@tdimb
\newcounter{my@tcnta}
\newcounter{my@tcntb}

\setlength\my@tdima{\textheight-\topskip}%
\setcounter{my@tcnta}{\my@tdima}%
\setcounter{my@tcntb}{\baselineskip}%
\setcounter{my@tcnta}{\value{my@tcnta}/\value{my@tcntb}}%
\setlength\textheight{\baselineskip*\value{my@tcnta}+\topskip}%
\setlength\my@tdima{\paperheight-\textheight}%
\setlength\topmargin{0.5\my@tdima-\headheight-\headsep-1in}%-- Can add a ratio here
\@settopoint\topmargin

\@settopoint\textwidth
\setlength\my@tdima{\paperwidth-\textwidth}%
\setlength\oddsidemargin{0.5\my@tdima-1in}%------------------- Can add a ratio here
\@settopoint\oddsidemargin
\setlength\evensidemargin{\my@tdima-\oddsidemargin-2in}%
\@settopoint\evensidemargin

\setlength\marginparwidth{\evensidemargin+1in-\marginparsep-0.25in}%
\@settopoint\marginparwidth
\setlength\marginparsep {7pt}%
\setlength\marginparpush{7pt}%
\makeatother

相关内容