
\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}
ボックスのページ番号を次のように並べます。
値を\raisebox
-1 em、-2 em に変更しようとしましたが、レイアウトを変更できません。
ボックスのページ番号を一列に並べるにはどうすればいいですか?
答え1
を削除し\renewcommand\footrulewidth{1pt}
て独自の を作成できます (つまり、使用したパッケージによって生成された で\hrule
はありません)。の直後に を続けることができるため、との間にはスペースが入りません。たとえば、次のようになります。\hrule
\hrule
\hbox
\hrule
\hbox
\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}}%
}
答え2
全体を別の場所に移します\raisebox
:
\raisebox{4pt}[2em]{\color{myfancycolor}\rule{2em}{2em}\raisebox{0.5em}{\hspace{-2em}\color{white}\makebox[2em][c]{\textsf{\thepage}}}%
\vspace*{-0.8em}}