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.

I use memoir class and I imitate one-sided printing with double-sided printing thanks to the command (find in the memoir manual)

\setlength{\evensidemargin}{\oddsidemargin}

The problem is that I have modified the header width with the command \makerunningwidth (see the minimal example below). On odd-numbered pages, the header ends in the fore-edge margin but I want it begins in the spine margin. To understand my problem it is easier to compile this code with PDFLaTeX.

\documentclass[a5paper]{memoir}
\usepackage{xcolor, calc}

% Laying out the page
\newlength{\myuppermargin}
\setlength{\myuppermargin}{20mm}
\newlength{\mylowermargin}
\setlength{\mylowermargin}{30mm}
\newlength{\myspinemargin}
\setlength{\myspinemargin}{30mm}
\newlength{\myedgemargin}
\setlength{\myedgemargin}{15mm}
\newlength{\myheadheight}
\setlength{\myheadheight}{7mm}
\newlength{\myfootskip}
\setlength{\myfootskip}{10.5mm}
\newlength{\myheadsep}
\setlength{\myheadsep}{5mm}
\newlength{\mymarginparsep}
\setlength{\mymarginparsep}{3mm}
\newlength{\mymarginparwidth}
\setlength{\mymarginparwidth}{12mm}
\newlength{\mymarginparpush}
\setlength{\mymarginparpush}{10mm}
\setlrmarginsandblock{\myspinemargin}{\myedgemargin}{*}
\setulmarginsandblock{\myuppermargin}{\mylowermargin}{*}
\setmarginnotes{\mymarginparsep}{\mymarginparwidth}{\mymarginparpush}
\setheadfoot{\myheadheight}{\myfootskip}
\setheaderspaces{*}{\myheadsep}{*}
\checkandfixthelayout{}
% Imitate one-sided printing but the page style can be customized
\setlength{\evensidemargin}{\oddsidemargin}

% Page style
\newcommand*{\evenheadfont}{\sffamily\mdseries\itshape\normalsize\color{blue}}
\newcommand*{\pagenumfont}{\normalfont\mdseries\itshape\small}
\newcommand*{\oddheadfont}{\evenheadfont}
\setlength{\headwidth}{\textwidth + \marginparsep + \marginparwidth}
\makepagestyle{custom}
\makerunningwidth{custom}{\headwidth}
\makeheadrule{custom}{\headwidth}{\normalrulethickness}
\makeheadfootruleprefix{custom}{\color{blue}}{}
\makeheadposition{custom}{flushright}{flushleft}{}{}
\makepsmarks{custom}{%
  \nouppercaseheads
  \createmark{chapter}{both}{nonumber}{}{}
  \createmark{section}{right}{shownumber}{}{. \space}
  \createplainmark{toc}{both}{\contentsname}
  \createplainmark{lof}{both}{\listfigurename}
  \createplainmark{lot}{both}{\listtablename}
  \createplainmark{bib}{both}{\bibname}
  \createplainmark{index}{both}{\indexname}
  \createplainmark{glossary}{both}{\glossaryname}%
}
\makeevenhead{custom}%
  {\raisebox{-1.2pt}{\colorbox{blue}{\textcolor{white}{\pagenumfont\thepage}}}}%
  {}%
  {\evenheadfont\leftmark}
\makeoddhead{custom}%
  {\oddheadfont\rightmark}%
  {}%
  {\raisebox{-1.2pt}{\colorbox{blue}{\textcolor{white}{\pagenumfont\thepage}}}}
\pagestyle{custom}

\newcommand{\sample}{Some text to experiment with page styles.}

\begin{document}
  \chapter{My chapter}
  \section{My section}
  \newpage
  \sample{} \sample{} \sample{} \sample{} \sample{} \sample{} \sample{}
  \newpage
  \sample{} \sample{} \sample{} \sample{} \sample{} \sample{} \sample{}
\end{document}
share|improve this question
    
If you have an off-centre typeblock in a one-sided page layout, you clearly cannot have a header that is of one length that pretends the typeblock is set up for a two-side page layout. The problem here is your \headwidth command: for odd pages, you need to offset it by the \marginpar stuff, I think. (Didn't test the example, and I've never fiddled with all this \makehead* stuff.) –  jon May 2 '12 at 16:35
    
Hmm, wait. The problem is --- after looking at how it ends up typeset --- that the headwidth is far too wide for your 'outer' margins. I assume this is for a thesis or something, where you only print on one side, but would still like to emulate a two-sided layout. You need to come up with a better calculation of \textwidth and \myedgewidth: the \headwidth needs to fit comfortably in that. And it may always look kind of weird given the off-centre nature of the typeblock on the page ... but that is a matter of taste. –  jon May 2 '12 at 16:39
    
@jon My document will be print on two sides: I need the symmetry betwin the headers on even and odd pages, but the typeblock must remain fixed. I have seen this kind of layout in "Code Complete 2" by Steve McConnell and in "Introduction to Algorithms 3" by Thomas H. Cormen. –  Wondrous May 2 '12 at 17:22
    
Fair enough, but I think my second comment still stands: the \headwidth is (far) too wide for your odd pages. The only solution I see is to shorten it. Also, I think, then, that the outer margin for odd pages is too small. (And of course, this 'fixed' typeblock will not match up when looking 'through' the page to the other side --- but I guess you know that.) –  jon May 2 '12 at 17:38
    
Does exist a command I can invoke to shift left the header on odd pages (the shift length will be \myegdemargin) without modifying the \headwidth? –  Wondrous May 2 '12 at 18:16
add comment

1 Answer

up vote 2 down vote accepted

You need to change

\makeheadposition{custom}{flushright}{flushleft}{}{}

to:

\makeheadposition{custom}{flushright}{flushright}{}{}   

(Though I still think this layout will look strange if it is being printed as a two-sided document.)

share|improve this answer
    
Thanks a lot! This is exactly what I search. –  Wondrous May 2 '12 at 18:35
add comment

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.