如何改变geometry
包showframe
选项生成的规则的颜色、间距、线条样式等?
答案1
编译并阅读此 MWE:
\documentclass[a4paper]{scrartcl}
\usepackage{xcolor}
\usepackage[showframe]{geometry}
\usepackage{microtype}
\usepackage{lipsum}
\makeatletter
\def\Gm@hrule{\color{red!20}\hrule height 4pt depth\z@ width\textwidth}%
\def\Gm@vrule{\color{red!20}\vrule width 4pt height\textheight depth\z@}%
\def\Gm@hruled{\color{red!20}\hrule height\z@ depth4pt width\textwidth}%
\makeatother
\title{How to change the color of \texttt{showframe}}
\author{Fran}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
You need change the rules. Not all those of the society, but only the three
defined in \verb|geometry.sty| with the macros
\verb|\Gm@vrule| \verb|\Gm@hrule| and \verb|\Gm@hruled|.
Thus, simply define again these rules in your preamble, adding some color.
Of course, include before the \verb|color| or \verb|xcolor| package.
As these commands contain the character @, remember that you need put
these definitions in a \verb|\makeatletter| \dots \verb|\makeatother| group.
The rest of this the \verb|lipsum| dummy text of any decent
minimal working example.
You do not need read the following text. \lipsum[1]
\lipsum[2-3]
\end{document}
答案2
内部宏\Gm@pageframes
设置框架,因此可以扩展以添加颜色:
\documentclass{article}
\usepackage{lipsum,microtype}
\usepackage[a6paper,showframe]{geometry}
\usepackage{xcolor}
\colorlet{showframe}{red}
\makeatletter
\let\org@Gm@pageframes\Gm@pageframes
\renewcommand*{\Gm@pageframes}{%
\begingroup
\color{showframe}%
\org@Gm@pageframes
\endgroup
}
\makeatother
\begin{document}
\section{Hello World}
\lipsum[2]
\end{document}