我想找到一种简单的方法来查看正文、页边距以及页眉和页脚的框架。使用包showframe
中的选项可以轻松实现这一点geometry
。但是,此选项会以黑色显示框架,并且不允许选项确定要显示的内容。
\documentclass[draft]{book}
\usepackage[x11names]{xcolor}
\usepackage[a4paper]{geometry}
% BEGIN_FOLD
\geometry{twoside=false, showframe=false}
% Horizontal
\geometry{inner=11mm, outer=11mm, includemp=true, bindingoffset=0mm, marginparsep=2.5mm, marginparwidth=25mm}
% Vertical
\geometry{top=11mm, bottom=11mm, includehead=false, includefoot=false, headheight=3.75mm, headsep=1mm, footskip=\dimexpr 3.75mm + 1mm \relax}
% END_FOLD
\usepackage{tikz,tikzpagenodes}
% BEGIN_FOLD
% Main text
\newcommand{\pageframeMainText}{%c
\tikz[remember picture,overlay] {
\draw [gray, line width=0.1mm, opacity=0.1]
(current page text area.south west)
rectangle
(current page text area.north east);
}
}
% Margins
\newcommand{\pageframeMargins}{%
\tikz[remember picture,overlay] {
\draw [gray, line width=0.1mm, opacity=0.1]
(current page marginpar area.south west)
rectangle
(current page marginpar area.north east);
}
}
% Header and footer
\newcommand{\pageframeHeaderFooter}{%
\tikz[remember picture,overlay] {
% Header
\draw [DodgerBlue3, line width=0.1mm, opacity=0.1]
(current page header area.south west)
rectangle
(current page header area.north east);
% Footer
\draw [DodgerBlue3, line width=0.1mm, opacity=0.1]
(current page footer area.south west)
rectangle
(current page footer area.north east);
}
}
\usepackage{bophook}
\usepackage{ifdraft}
\ifoptiondraft%
{\AtBeginPage{\pageframeMainText\pageframeMargins\pageframeHeaderFooter}}%
{}
% END_FOLD
\begin{document}
\noindent%
\rule{\linewidth}{1pt}
\end{document}
结果如愿以偿。但是,好的框架应该与背景融合,以尽量减少干扰,同时还能够看到框架进行微调。我认为最好对原始代码进行扩充,以实现以下要求
- 应该可以确定
color
所有帧line width
的opacity
- 应该可以启用一些框架并禁用其他框架
答案1
要改变框架的颜色,您可以使用以下方法:
\documentclass[draft]{book}
\usepackage[]{xcolor}
\usepackage[a4paper,showframe]{geometry}
\makeatletter
\let\org@Gm@pageframes\Gm@pageframes
\renewcommand*{\Gm@pageframes}{%
\begingroup
\color{red!50}%
\org@Gm@pageframes
\endgroup
}
\makeatother
\begin{document}
\noindent%
\rule{\linewidth}{1pt}
\end{document}
(对于需要更精细控制的一切,我建议使用你的 tikz 代码)