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.

Is there a way to set color for header and footer rule in memoir class?

Using the following code:

\documentclass[ebook,12pt,twoside,openany]{memoir}

\usepackage{lipsum}
\usepackage{graphicx}


\usepackage[english,italian]{babel}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}

\usepackage[dvipsnames]{xcolor}  % Allows the definition of hex colors

\newenvironment{dedication}
{
   \cleardoublepage
   \thispagestyle{empty}
   \vspace*{    \stretch{1}}
   \hfill    \begin{minipage}[t]{0.66    \textwidth}
   \raggedright
}%
{
   \end{minipage}
   \vspace*{    \stretch{3}}
   \clearpage
}


\setlength{    \topmargin}{-0.5in}
\setlength{    \textheight}{520pt}


\makepagestyle{myruled}
\makeheadrule {myruled}{    \textwidth}{    \normalrulethickness}
\makefootrule {myruled}{    \textwidth}{    \normalrulethickness}{    \footruleskip}
\makeevenhead {myruled}{}{    \small    \itshape    \leftmark} {}
\makeoddhead {myruled}{}{    \small    \itshape    \rightmark}{}
\makeevenfoot {myruled}{    \small      \thepage}{}{} 
\makeoddfoot {myruled}{}{} {    \small      \thepage}
\makeatletter % because of     \@chapapp
\makepsmarks {myruled}{
\nouppercaseheads
\createmark {chapter} {both} {nonumber}{    \@chapapp    \ }{.     \ }
\createmark {section} {right}{shownumber}{} {.     \ }
\createmark {subsection} {right}{shownumber}{} {.     \ }
\createmark {subsubsection}{right}{shownumber}{} {.     \ }
\createplainmark {toc} {both} {    \contentsname}
\createplainmark {lof} {both} {    \listfigurename}
\createplainmark {lot} {both} {    \listtablename}
\createplainmark {bib} {both} {    \bibname}
\createplainmark {index} {both} {    \indexname}
\createplainmark {glossary} {both} {    \glossaryname}
}
\makeatother
\setsecnumdepth{subsubsection}

\begin{document}


\begin{dedication}
Put dedication here
\end{dedication}

\chapterstyle{thatcher}

\pagestyle{myruled}

\chapter{Lipsum chapter}

\lipsum[1-8]

\end{document}

After loading xcolor packages I tried using \color{colorname} command but while it works for text it won't work when put before or after \makeheadrule or \makefootrule.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

You can use

\makeheadfootruleprefix{<style>}{<for headrule>}{<for footrule>}

An example:

\documentclass[ebook,12pt,twoside,openany]{memoir}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage[english,italian]{babel}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc}
\usepackage[dvipsnames]{xcolor}  % Allows the definition of hex colors

\newenvironment{dedication}
{
   \cleardoublepage
   \thispagestyle{empty}
   \vspace*{\stretch{1}}
   \hfill\begin{minipage}[t]{0.66\textwidth}
   \raggedright
}%
{
   \end{minipage}
   \vspace*{\stretch{3}}
   \clearpage
}

\setlength{\topmargin}{-0.5in}
\setlength{\textheight}{520pt}

\makepagestyle{myruled}
\makeheadfootruleprefix{myruled}{\color{Bittersweet}}{\color{PineGreen}}
\makeheadrule{myruled}{\textwidth}{\normalrulethickness}
\makefootrule{myruled}{\textwidth}{\normalrulethickness}{\footruleskip}
\makeevenhead{myruled}{}{\small\itshape\leftmark}{}
\makeoddhead{myruled}{}{\small\itshape\rightmark}{}
\makeevenfoot{myruled}{\normalcolor\small\thepage}{}{} 
\makeoddfoot{myruled}{}{}{\normalcolor\small\thepage}
\makeatletter % because of \@chapapp
\makepsmarks{myruled}{
\nouppercaseheads
\createmark{chapter}{both}{nonumber}{\@chapapp\ }{. \ }
\createmark{section}{right}{shownumber}{}{. \ }
\createmark{subsection}{right}{shownumber}{}{. \ }
\createmark{subsubsection}{right}{shownumber}{}{. \ }
\createplainmark{toc}{both}{\contentsname}
\createplainmark{lof}{both}{\listfigurename}
\createplainmark{lot}{both}{\listtablename}
\createplainmark{bib}{both}{\bibname}
\createplainmark{index}{both}{\indexname}
\createplainmark{glossary}{both}{\glossaryname}
}
\makeatother
\setsecnumdepth{subsubsection}

\begin{document}

\begin{dedication}
Put dedication here
\end{dedication}

\chapterstyle{thatcher}

\pagestyle{myruled}

\chapter{Lipsum chapter}

\lipsum[1-8]

\end{document}

Notice the use of \normalcolor inside \makeevenfood and \makeoddfoot to prevent the page number to also receive color (remove \normalcolor of you want the number to be also colorized).

An image of one of the pages obtained:

enter image description here

share|improve this answer
    
Just tried your code but latex gives " !Undefined control sequence. l.33 \makeheadfootruleprefix {myruled}{\color{red}}{\color{blue}}" –  Gianluigi Sep 25 '12 at 19:05
    
@Gianluigi update your LaTeX system, or (at least) the memoir bundle. –  Gonzalo Medina Sep 25 '12 at 19:09
    
@Gianluigi works fine for me. Maybe its just an update needed. –  azetina Sep 25 '12 at 19:11
    
I have Texlive 2012 but it seems that memoir.cls is an old 2009 version, will try to update and see if it works. –  Gianluigi Sep 25 '12 at 19:19
    
@Gianluigi OK; in my system (TeX Live2012) I have memoir.cls 2011/03/06 v3.6j configurable book, report, article document class –  Gonzalo Medina Sep 25 '12 at 19:28
show 3 more comments

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.