我正在准备一本照相排版的书。我的出版商给了我一个基于 Microsoft Word 模板的样式表。我无法使用和包设置纸张的精确尺寸geometry
,fancyhdr
尤其是页眉和页脚的位置,主要是因为在 Word 中,您可以设置页眉(或页脚)与纸张边缘的距离以及文本主体与纸张边缘的距离。我在这个论坛上查看了各种解决方案(例如这里),但我发现它们对我的问题没用或不相关。
简而言之,我需要按照以下规格格式化文本:
- 纸张尺寸:16cm x 22cm
- 上边距(即上边缘与正文之间的距离):2.5cm
- 下边距(即底边到正文的距离):2cm
- 左边距:2.35厘米;右边距:2.75厘米;镜像
- 标题:距顶边 1.8 厘米
- 页脚:距底边缘 1.5 厘米。
对于标题距离,我使用了指示的解决方案这里,但:a) 我不明白为什么我必须输入,top=2.4cm
而实际上顶部边距为 2.5 厘米;b) 页眉与顶部边缘的距离似乎因页面而异。对于页脚距离,我尚未找到可行的解决方案。
请参阅附件中的 MWE:
\documentclass[10pt, twoside]{memoir}
\usepackage[papersize={16cm, 22cm},top=2.4cm,headheight=4.22mm,headsep=2.78mm,bottom=2cm,left=2.35cm,right=2.75cm,twoside]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[CE]{\small{Header2}}
\fancyhead[CO]{\small{Header1}}
\renewcommand{\headrulewidth}{0pt}
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\begin{center}
\end{center}
\vspace{\fill}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\cfoot{\thepage}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Nunc sed blandit libero volutpat sed cras ornare arcu dui. Sed viverra tellus in hac. Iaculis eu non diam phasellus vestibulum. Libero id faucibus nisl tincidunt. Orci phasellus egestas tellus rutrum tellus pellentesque eu tincidunt tortor. Tortor pretium viverra suspendisse potenti nullam ac. Eget nullam non nisi est sit amet facilisis magna etiam. Pulvinar pellentesque habitant morbi tristique senectus et. Eget gravida cum sociis natoque penatibus. Ut porttitor leo a diam sollicitudin. Blandit massa enim nec dui nunc mattis enim. Tincidunt praesent semper feugiat nibh sed pulvinar. Facilisis gravida neque convallis a cras semper. Consectetur adipiscing elit pellentesque habitant morbi tristique. Id porta nibh venenatis cras sed felis eget. Lacus suspendisse faucibus interdum posuere lorem ipsum dolor sit amet. Sagittis nisl rhoncus mattis rhoncus urna neque viverra. Risus quis varius quam quisque id diam vel quam.
Lobortis elementum nibh tellus molestie nunc non blandit massa. Vitae ultricies leo integer malesuada. Massa tempor nec feugiat nisl pretium fusce id velit ut. Vestibulum mattis ullamcorper velit sed ullamcorper. Dui vivamus arcu felis bibendum ut tristique et. In aliquam sem fringilla ut morbi. Nec dui nunc mattis enim ut tellus elementum. Ac turpis egestas sed tempus. Egestas maecenas pharetra convallis posuere morbi leo urna. Mauris nunc congue nisi vitae. Vitae turpis massa sed elementum tempus egestas sed sed risus. Augue neque gravida in fermentum. Lobortis feugiat vivamus at augue eget arcu.
Integer malesuada nunc vel risus commodo viverra maecenas accumsan lacus. Lacus viverra vitae congue eu. Mattis pellentesque id nibh tortor id aliquet lectus proin nibh. Id aliquet lectus proin nibh nisl. Integer malesuada nunc vel risus commodo viverra maecenas. Pellentesque sit amet porttitor eget dolor morbi non arcu. Nec tincidunt praesent semper feugiat nibh. Id aliquet risus feugiat in ante. Sagittis nisl rhoncus mattis rhoncus urna. Sapien et ligula ullamcorper malesuada proin.
Dui id ornare arcu odio ut sem nulla pharetra. Dignissim cras tincidunt lobortis feugiat vivamus. Nisi scelerisque eu ultrices vitae auctor. Etiam dignissim diam quis enim lobortis scelerisque fermentum dui faucibus. Non curabitur gravida arcu ac tortor dignissim convallis. A erat nam at lectus urna duis convallis convallis tellus. Massa tincidunt nunc pulvinar sapien. Ac odio tempor orci dapibus. Odio euismod lacinia at quis. Venenatis lectus magna fringilla urna porttitor rhoncus dolor. Nisl condimentum id venenatis a condimentum. Viverra mauris in aliquam sem. Sed vulputate odio ut enim blandit volutpat. Et odio pellentesque diam volutpat commodo sed egestas. Tristique senectus et netus et malesuada. Quisque sagittis purus sit amet volutpat consequat mauris. Cursus risus at ultrices mi tempus imperdiet nulla malesuada. Amet porttitor eget dolor morbi. Consequat mauris nunc congue nisi vitae suscipit tellus mauris.
\end{document}
答案1
请注意,您的标题不会填满为其保留的空间。文本也不会到达文本区域的顶部。(第一个基线位于顶部下方的 \topskip。)
\documentclass[10pt, twoside]{memoir}
\usepackage[papersize={16cm, 22cm},top=2.5cm,headheight=4.22mm,headsep=2.78mm,
bottom=2cm,footskip=.5cm,left=2.35cm,right=2.75cm,twoside,showframe]{geometry}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[CE]{\small{Header2}}
\fancyhead[CO]{\small{Header1}}
\renewcommand{\headrulewidth}{0pt}
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\begin{center}
\end{center}
\vspace{\fill}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\cfoot{\thepage}
%\topskip=\ht\strutbox
\begin{document}
Distance to header \the\dimexpr \topmargin+1in\relax=\the\dimexpr 1.8cm\relax
Distance to body \the\dimexpr \topmargin+1in+\headheight+\headsep\relax=\the\dimexpr 2.5cm\relax
Distance from footer to bottom \the\dimexpr \paperheight-\topmargin-1in-\headheight-\headsep-\textheight-\footskip\relax
=\the\dimexpr 1.5cm\relax
\end{document}
这里我缩小了\topskip
和\headheight
。请注意 fancyhdr 喜欢\headheight
根据标题的内容进行更改。更重要的是,缩小到\headheight
10pt 以下会产生不寻常的效果。
\documentclass[10pt, twoside]{memoir}
\usepackage[papersize={16cm, 22cm},top=2.5cm,headheight=10pt,headsep={\dimexpr 0.7cm-10pt},
bottom=2cm,footskip=.5cm,left=2.35cm,right=2.75cm,twoside,showframe]{geometry}
\usepackage{fancyhdr}
\usepackage{pgfmath}
\newcommand{\showstrut}{\rule[-\dp\strutbox]{1pt}{\dimexpr \baselineskip}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[CE]{\small{Header2}}
\fancyhead[CO]{\small{Header1} \showstrut}
\renewcommand{\headrulewidth}{0pt}
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\begin{center}
\end{center}
\vspace{\fill}
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\cfoot{\thepage}
\topskip=\ht\strutbox
\begin{document}
Distance to header \the\dimexpr \topmargin+1in\relax=\the\dimexpr 1.8cm\relax
Distance to body \the\dimexpr \topmargin+1in+\headheight+\headsep\relax=\the\dimexpr 2.5cm\relax
Distance from footer to bottom \the\dimexpr \paperheight-\topmargin-1in-\headheight-\headsep-\textheight-\footskip\relax
=\the\dimexpr 1.5cm\relax
\end{document}