Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can one change the colour, pitch, line style, etc of the rules generated by the geometry package's showframe option?

share|improve this question

2 Answers 2

The internal macro \Gm@pageframes sets the frames, thus it can be extended to add a color:

\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}

Result

share|improve this answer

MWE

Compile and read this 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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.