
\documentclass[twoside,11pt]{book}
\usepackage{fancyhdr,xcolor,lipsum}
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot{}
\colorlet{myfancycolor}{black}
\fancypagestyle{mystyle}{
\renewcommand*\footrulewidth{1pt}
\fancyfoot[OR]{%
\color{myfancycolor}\rule{2em}{2em}\raisebox{0.5em}{\hspace{-2em}\color{white}\makebox[2em][c]{\textsf{\thepage}}}%
\vspace*{-0.8em}%
}
\fancyfoot[OL]{%
\leftmark
}
\fancyfoot[EL]{%
\color{myfancycolor}\rule{2em}{2em}\raisebox{0.5em}{\hspace{-2em}\color{white}\makebox[2em][c]{\textsf{\thepage}}}%
\vspace*{-0.8em}%
}
\fancyfoot[ER]{%
\rightmark
}
}
\pagestyle{mystyle}
\begin{document}
\frontmatter
\chapter{PREFACE}
\lipsum[1-2]
\tableofcontents
\mainmatter
\chapter{LALALA}
\lipsum[1-3]
\end{document}
Quiero que el número de página del cuadro esté alineado de la siguiente manera:
Intenté cambiar el valor de \raisebox
a -1 em, -2 em y no puedo cambiar el diseño.
¿Cómo hacer que el número de página del cuadro esté en línea?
Respuesta1
Puede eliminarlo \renewcommand\footrulewidth{1pt}
y crear el suyo propio \hrule
(es decir, no \hrule
generado por el paquete usado). Puede \hrule
ir seguido inmediatamente de \hbox
, por lo que no hay espacio entre \hrule
y \hbox
. Por ejemplo, puede verse así:
\fancyfoot[EL]{%
\kern-3ex % all material is shifted up by 3ex
\color{myfancycolor}
\hrule height1pt % your \hrule
\hbox{\rlap{\vrule height1.3em width2em depth.7em}% you black box
\hbox to2em{\hss\color{white}{\textsf{\thepage}}\hss}}%
}
Respuesta2
Pon todo en otro \raisebox
:
\raisebox{4pt}[2em]{\color{myfancycolor}\rule{2em}{2em}\raisebox{0.5em}{\hspace{-2em}\color{white}\makebox[2em][c]{\textsf{\thepage}}}%
\vspace*{-0.8em}}