
\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}
Quero que o número da página da caixa fique alinhado da seguinte forma:
Tentei alterar o valor \raisebox
para -1 em, -2 em e não consigo alterar o layout.
Como fazer com que o número da página da caixa fique alinhado?
Responder1
Você pode remover \renewcommand\footrulewidth{1pt}
e criar o seu próprio \hrule
(ou seja, não \hrule
gerado pelo pacote usado). Your \hrule
pode ser imediatamente seguido por \hbox
, portanto não há espaço entre \hrule
e \hbox
. Por exemplo, pode ser assim:
\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}}%
}
Responder2
Coloque tudo em outro \raisebox
:
\raisebox{4pt}[2em]{\color{myfancycolor}\rule{2em}{2em}\raisebox{0.5em}{\hspace{-2em}\color{white}\makebox[2em][c]{\textsf{\thepage}}}%
\vspace*{-0.8em}}