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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The title is self-explanatory.

In my document's current state, I get this rendering result after compiling with XeLaTeX :

result

Here's a MWE of which packages and commands I use to obtain my current header style :

\documentclass{report}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\usepackage{lipsum}% http://www.ctan.org/tex-archive/macros/latex/contrib/lipsum

\usepackage{titlesec}
\usepackage{xcolor}


\renewpagestyle{plain}[\small\sffamily\upshape\color{red}]{
    \headrule
    \sethead{\chaptertitle}{}{Université de la Rochelle}
}


\author{ME}
\title{Bash report}

\pagestyle{plain}
\begin{document}
\maketitle

\tableofcontents
\thispagestyle{empty}

\chapter{Matrices de convolution}
\lipsum

\lipsum
\end{document}

What I actually would like is to color "red" the lines created by the header and footer.

share|improve this question
up vote 4 down vote accepted

titlesec defines helper macros to set up the lines, this drops red into the head line

enter image description here

\documentclass{report}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\usepackage{lipsum}% http://www.ctan.org/tex-archive/macros/latex/contrib/lipsum

\usepackage{titlesec}
\usepackage{xcolor}

\makeatletter

\newcommand\setheadrule[1]{%
  \ifdim#1=\z@
    \let\makeheadrule\@empty
  \else
    \def\makeheadrule{{\color{red}\rule[-.3\baselineskip]{\linewidth}{#1}}}%
  \fi}

\makeatother


\renewpagestyle{plain}[\small\sffamily\upshape]{
    \headrule
    \sethead{\chaptertitle}{}{Universite de la Rochelle}
}


\author{ME}
\title{Bash report}

\pagestyle{plain}
\begin{document}
\maketitle

\tableofcontents
\thispagestyle{empty}

\chapter{Matrices de convolution}
\lipsum

\lipsum
\end{document}

The foot rule command is by default

\newcommand\setfootrule[1]{%
  \ifdim#1=\z@
    \let\makefootrule\@empty
  \else
    \def\makefootrule{\rule[.7\baselineskip]{\linewidth}{#1}}%
  \fi}

But not apparently used in this MWE so I didn't change it/

share|improve this answer
    
I have an error if I insert the hack that you wrote in my current document state, I get the following compilation error (using XeLaTeX) : ! LaTeX Error: Command \setheadrule already defined. Or name \end... illegal, see p.192 of the manual. – 발렌탕 Feb 22 '13 at 20:31
    
I just added [pagestyles] to the \usepackage{titlesec} inclusion, works fine now. – 발렌탕 Feb 22 '13 at 20:38

I solved the problem by slightly modifying David's code:

\makeatletter
\renewcommand\setheadrule[1]{%
  \ifdim#1=\z@
    \let\makeheadrule\@empty
  \else
    \def\makeheadrule{{\color{red}\rule[-.3\baselineskip]{\linewidth}{#1}}}%
  \fi}
\makeatother

Using David's code, I had the same error message reported by 발렌탕 in his first comment (solved by him by adding the pagestyles option to the titlesec package). Since 발렌탕's solution did not work for me, I worked out my own solution by just substituting \renewcommand instead of \newcommand in Dave's code: this simply redefines the command avoiding any "already defined!" run time error, and produces the sought for graphical output.

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.