Fancyhdr 왼쪽 표시 및 오른쪽 표시 센터링

Fancyhdr 왼쪽 표시 및 오른쪽 표시 센터링

어떻게 가능했는지 알고 싶습니다.센터이 (MWE) 코드를 사용하여 장과 섹션 표시(그들이 그렇게 부르는지 모르겠습니다)

 \documentclass[10pt,twoside]{book}

 \usepackage{lipsum}

 \usepackage{fancyhdr}

 \fancyhf{}

 \fancyhead[RE]{\leftmark}

  \fancyhead[LO]{\rightmark}

  \fancyhead[LE,RO]{\thepage}

  \renewcommand\headrulewidth{0pt}

  \renewcommand\chaptermark[1]{\markboth{\scshape#1}{}} 

  \renewcommand\sectionmark[1]{\markright{\scshape #1}}

\begin{document}


 \chapter{chapter} % Even page header
 \lipsum[1]
 \section{section} % odd page header
  \lipsum[1-5]


  \end{document}

답변1

여기에 코드가 있습니다. 페이지 스타일을 'fancy'로 선언하는 것을 잊었습니다.

 \documentclass[10pt,twoside]{book}

 \usepackage{lipsum}
 \usepackage{fancyhdr}

 \fancyhf{}
 \fancyhead[CE]{\leftmark}
  \fancyhead[CO]{\rightmark}
  \fancyhead[LE,RO]{\thepage}
  \renewcommand\headrulewidth{0pt}

  \renewcommand\chaptermark[1]{\markboth{\scshape#1}{}}

  \renewcommand\sectionmark[1]{\markright{\scshape #1}}
  \pagestyle{fancy}

    \begin{document}

     \chapter{A First Chapter} % Even page header
     \lipsum
     \section{A section} % odd page header
      \lipsum[1-10]

  \end{document} 

여기에 이미지 설명을 입력하세요

편집하다: 헤더에 제목만 포함하려면 다음을 사용하는 것이 더 쉽습니다 titleps.

 \documentclass[10pt,twoside]{book}

 \usepackage{lipsum}
 \usepackage{titleps}


  \newpagestyle{mine}[\scshape]{%
  \sethead[\thepage][\chaptertitle][]{}{\sectiontitle}{\thepage}
   }
   \pagestyle{mine}
    \begin{document}

     \chapter{A First Chapter} % Even page header
     \lipsum
     \section{A section} % odd page header
      \lipsum[1-10]

  \end{document} 

여기에 이미지 설명을 입력하세요

관련 정보