
Estoy usando el siguiente código y no puedo entender cómo justificar el encabezado a la izquierda en la página izquierda y a la derecha en la página derecha y poner el número de página en el margen en lugar de dentro de la geometría definida.
\makeatletter
\def\chapapp2{Chapter}
\def\appendix{\par
\setcounter{chapter}{0}
\setcounter{section}{0}
\def\chapapp2{Appendix}
\def\@chapapp{Appendix}
\def\thechapter{\Alph{chapter}}}
\def\ps@uheadings{\let\@mkboth\markboth
% modifications
\def\@oddhead{\protect\makebox[\textwidth][l]
{\small\scshape\MakeUppercase{\rightmark}\hfill\thepage}}
\def\@oddfoot{}
\def\@evenfoot{}
\def\@evenhead{\protect\makebox[\textwidth][l]
{\thepage\hfill\small\scshape\MakeUppercase{\leftmark}}}
% end of modifications
\def\chaptermark##1{\markboth {\ifnum \c@secnumdepth >\m@ne
\chapapp2\ \thechapter. \ \fi ##1}{}}%
\def\sectionmark##1{\markright {\ifnum \c@secnumdepth >\z@
\thesection. \ \fi ##1}}}
\makeatother