EDIT2: Sorry for this real time updates, but I am really going crazy. I added at the bottom the new code that is compiling correctly with showhexapagesStepOne
I edited the question trying to give more cartesian organization to the whole endeavour. Changed also the code provided with something closer to correctness (I hope).
I would like to use a standard book document and change the numbering of pages inside fancyhdr. In particular I want the pages to be printed in hex style 0xABCD. I have tried almost everything (i am not posting all the code attempts here because it would be embarassing), namely:
- pythonTex (just after immediatepython): stuck at trying to pass a LaTex counter before the counter really could be updated into the document. I renounced after 2 days.
- hex package (very old by Eric Domenjoud) but it is still using documentstyle and I got stuck in converting a old /usename directive
- tried also binhex package but same problem: counter expansion. Now I am trying to make it work with fmtcount package.
My preamble contain this fancyheader part before the document begins (just on top of it there are few experiments with the counters):
\newcounter{hexapages}
\newcommand\showhexapagesStepOne{%
\setcounter{hexapages}{\thepage}%
\thehexapages%
}
\newcommand\showhexapagesStepTwo{% If I make showhexapagesStepOne work, this will work as well
\setcounter{hexapages}{\thepage}%
\HEXADecimal(hexapages)% or maybe thehexapages ???
}
\setlength{\headheight}{15pt}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} }
\renewcommand{\sectionmark}[1]{ \markright{#1} }
\fancyhf{}
%\fancyhead[LE]{{\thepage}} %obviously compiles
%\fancyhead[RO]{{\thepage}} %obviously compiles
\fancyhead[LE]{{\showhexapagesStepOne}} % does not compile
\fancyhead[RO]{{\showhexapagesStepOne}} % does not compile
\fancyhead[RE]{\textit{ \nouppercase{\leftmark}} }
\fancyhead[LO]{\textit{ \nouppercase{\rightmark}} }
\fancyheadoffset[LE]{14mm}
The current error is: (foreword.tex ! Missing number, treated as zero. i l.9
[I think Latex is trying to apply the conversion to something that is numbered in roman style...so I should differentiate between frontmatter and mainmatter....]
What seems to fail is trying to pass any counter (predefined as \thepage or custom made as \thehexapages) into any placeholder of fancy header.
The first attemtps with PythonTex were intended to create a macro that was doing the translation of any number into its hex conversion, but failed when the argument became counters.
How should I do it? Why fancyheader takes \thepage like a charm and refuses whatever else? If a try HEXADecimalnum{459} it prints correctly "1CB". So, it is not the fmtcount package giving issues.
Start of EDIT2: The new code is:
\newcounter{hexapages}
\newcommand\showhexapagesStepOne{%
\setcounter{hexapages}{\thepage}%
\thehexapages%
}
\newcommand\showhexapagesStepTwo{%
\setcounter{hexapages}{\thepage}%
\HEXADecimal(hexapages)% or maybe thehexapages ???
}
\setlength{\headheight}{15pt}
\pagestyle{fancyplain}
\fancyhf{}
\fancypagestyle{plain}{ %
\fancyhf{} % remove everything
\renewcommand{\headrulewidth}{0pt} % remove lines as well
\renewcommand{\footrulewidth}{0pt}
}
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} }
\renewcommand{\sectionmark}[1]{ \markright{#1} }
%\fancyhead[LE]{{\thepage}}
%\fancyhead[RO]{{\thepage}}
\fancyhead[LE]{{\showhexapagesStepOne}}
\fancyhead[RO]{{\showhexapagesStepOne}}
\fancyhead[RE]{\textit{ \nouppercase{\leftmark}} }
\fancyhead[LO]{\textit{ \nouppercase{\rightmark}} }
\fancyheadoffset[LE]{14mm}% slightly less than 0.25in
\fancyheadoffset[RO]{14mm}%
\renewcommand{\headrulewidth}{0pt} % remove lines as well
\renewcommand{\footrulewidth}{0pt}
% and after all the preamble definitions.....
\frontmatter
\pagestyle{plain}
\include{dedication}
\include{foreword}
\include{preface}
\include{acknowledgement}
\tableofcontents
\include{acronym}
\mainmatter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\chaptermark}[1]{ \markboth{#1}{} }
\renewcommand{\sectionmark}[1]{ \markright{#1} }
%\fancyhead[LE]{{\thepage}}
%\fancyhead[RO]{{\thepage}}
\fancyhead[LE]{{\showhexapagesStepTwo}}
\fancyhead[RO]{{\showhexapagesStepTwo}}
\fancyhead[RE]{\textit{ \nouppercase{\leftmark}} }
\fancyhead[LO]{\textit{ \nouppercase{\rightmark}} }
\fancyheadoffset[LE]{14mm}% slightly less than 0.25in
\fancyheadoffset[RO]{14mm}%
\renewcommand{\headrulewidth}{0pt} % remove lines as well
\renewcommand{\footrulewidth}{0pt}
This allows me to remove any heading and numbering in the frontmatter and leaves the fancy style only for the mainmatter. THe point is: now it prints arabic numbers correctly in the LE and RO angles using showhexapagesStepOne. When I switch to the StepTwo (the one containing the conversion) I get the error:
! You can't use `\relax' after \the.
<recently read> \c@(
Any clue?