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.

Just a short question: I want to renew the chapter command, so that I can manipulate the distance between the chapter number and the chapter title in my header, currently I have defined my header as:

\renewcommand{\chaptername}{}
\fancyhead[L]{\hspace{4mm}\textcolor{headercolor}{\leftmark}\\ \text{ }\textcolor{headercolor}{\hspace{0.4cm}\rightmark}\hfill\textcolor{headercolor}{}\hspace{2mm}}
\renewcommand{\headrule}{\vspace{-\headheight}\textcolor{headercolor}{\vrule height \headheight width 2pt\relax\rule{\textwidth}{2pt}\vrule height \headheight width 2pt\relax}}

now I want to change the chaptermark/chaptername, so that I can manipulate the distance between the number and the title.

E.g. currently it says 1. INTRODUCTION but I want the space between 1. and INTRODUCTION to increase?

I know this is not a working example, but I hope you get it fast what I mean.

share|improve this question
3  
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Jubobs Mar 5 '13 at 14:56

1 Answer 1

KOMA-Script

It is quite easy with the KOMA-Script classes. There macro \chaptermarkformat sets the chapter number in the headings and can be redefined, e.g.:

\documentclass{scrbook}

\makeatletter
\g@addto@macro{\chaptermarkformat}{\hspace{1em}}
\makeatother

\pagestyle{headings}

\begin{document}
\chapter{First chapter}
\newpage
Some text.
\end{document}

(\g@addto@macro{\cmd}{stuff} appends stuff to parameterless macro cmd).

Package fancyhdr

With package fancyhdr or the standard classes the distance is hardcoded in \chaptermark that is defined in the page style command. Therefore it becomes uglier, because also the page style command needs to be redefined, e.g.:

\documentclass{book}

\usepackage{fancyhdr}

\newlength{\marknumsep}
\setlength{\marknumsep}{1.5em}% Change to your needs

\makeatletter
\def\ps@fancy{%
  \@ifundefined{@chapapp}{\let\@chapapp\chaptername}{}%
  \@ifundefined{MakeUppercase}{\def\MakeUppercase{\uppercase}}{}%
  \@ifundefined{chapter}{%
    \def\sectionmark##1{%
      \markboth{%
        \MakeUppercase{%
          \ifnum \c@secnumdepth>\z@
            % \thesection\hskip 1em\relax % ORIGNAL
            \thesection\hskip\marknumsep % NEW
          \fi
          ##1%
        }%
      }{}%
    }%
    \def\subsectionmark##1{%
      \markright{%
        \ifnum \c@secnumdepth >\@ne
          % \thesubsection\hskip 1em\relax % ORIGINAL
          \thesubsection\hskip\marknumsep % NEW
        \fi
        ##1%
      }%
    }%  
  }{%
    \def\chaptermark##1{%
      \markboth{%
        \MakeUppercase{%
          \ifnum \c@secnumdepth>\m@ne
            % \@chapapp\ \thechapter. \ % ORIGINAL
            \thechapter\hskip\marknumsep % NEW
          \fi
           ##1%
        }%
      }{}%
    }%
    \def\sectionmark##1{%
      \markright{%
        \MakeUppercase{%
          \ifnum \c@secnumdepth >\z@
            % \thesection. \ % ORIGINAL
            \thesection.\hskip\marknumsep % NEW
          \fi
          ##1%
        }%
      }%  
    }%    
  }%      
  \ps@@fancy
  \gdef\ps@fancy{\@fancyplainfalse\ps@@fancy}%
  \ifdim\headwidth<0sp
    \global\advance\headwidth123456789sp%
    \global\advance\headwidth\textwidth  
  \fi
}
\makeatother

\pagestyle{fancy}

\begin{document}
\chapter{First chapter}
\newpage
Some text.
\end{document}

Now the distance between number and text in the headings can be controlled by the length \marknumsep. Also the example has removed the "Chapter"/"Appendix" prefix (\@chapapp).

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.