부품 제목을 헤더로 사용

부품 제목을 헤더로 사용

~ 안에이 질문나는 pkg를 헤더로 사용하여 정의된 새로운 섹션화 수준의 인수를 사용하는 방법을 물었습니다 titlesec. 이제 동일한 코드를 반복하면서 명령 인수를 헤더로 어떻게 사용할 수 있는지 묻고 싶습니다 \part. 더 쉬울 것 같았고 설명서를 찾아보니 titlesec힌트가 있었지만 사용법을 이해할 수 없었습니다.

    \documentclass[b5paper,twoside]{book}
    \usepackage{geometry}
    \usepackage{titletoc}
    \usepackage[rm,small,center,compact,newparttoc,clearempty,pagestyles]{titlesec}
    \usepackage{kantlipsum}
    \titleclass{\subpart}{page}[\part]
    \newcounter{subpart}
    \renewcommand{\thesubpart}{\Alph{subpart}}
    \newcommand{\subpartname}{Subpart}
    \titleformat{\subpart}[display]{\centering\normalfont\Large\bfseries}%
    {\subpartname~\thesubpart}{1pc}{\Huge\bfseries}
    \titlespacing{\subpart}{0pt}{0pt}{0pt}
    \titlecontents{subpart}[0pt]{\addvspace{1pc}\normalfont\bfseries}%
    {\thecontentslabel\enspace ---\enspace\large}%
    {\normalfont\large\bfseries}{\hspace{2em plus 1fill}\large\contentspage}
    \setcounter{secnumdepth}{-2}

    \newpagestyle{main}{
        \sethead[][\chaptertitle][] 
        {}{\parttitle}{} % Problem: Here I want to have part title. 
        \setfoot[][\thepage][]
        {}{\thepage}{}}
    \pagestyle{main}


    \newpagestyle{preface}{
        \sethead[][\chaptertitle][]
        {}{\parttitle}{}
        \setfoot[][\thepage][]
        {}{\thepage}{}}
    \pagestyle{empty}
    \assignpagestyle{\part}{empty}
    \assignpagestyle{\subpart}{empty}
    \assignpagestyle{\chapter}{empty}
    \settitlemarks{part,chapter}
    \begin{document}\frontmatter
\pagestyle{empty}

\chapter[Preface]{PREFACE}
\pagestyle{preface}
\kant[1-20]

\part{History}
\subpart{Primitive Historians}
\pagestyle{main}
\chapter{The Formation of the Concept of History}
\kant[1-20]
\end{document}

답변1

단순히 질문하는 것보다 더 많이 검색하고 더 주의를 기울였어야 했습니다. 답변의 일부를 혼합하여여기그리고 이것여기, 헤더로 인수를 만들 수 있습니다 \part. 첫 번째 답변은 titlesec pkg의 도움으로 부분 스타일을 수정합니다. 아마도 titlesecpkg에서 이 명령을 쉽게 인식할 수 있을 것입니다. 두 번째 답변, 특히 답변에 대한 그의 마지막 설명을 헤더로 사용할 수 있게 되었습니다.

나는 두 번째 답변의 최소한의 예를 사용했습니다. 이제 파일에는 짝수 페이지의 헤더로 장 제목이 있고 홀수 페이지의 헤더로 부분 제목이 있습니다.

참고: 해당 인수의 위치를 ​​수정하면 \part원래 부품 명령 출력과 비교하여 1밀리미터 단위로 위쪽으로 약간 이동합니다.

\documentclass{book}
\usepackage[a6paper]{geometry}% just for the example
\usepackage[pagestyles]{titlesec}

\assignpagestyle{\part}{empty}     % Works[removes the page number from the part page]
\assignpagestyle{\chapter}{empty}  % Works[removes the page number from the starting page of  the chapter]
\titleformat{\part}[display]
{\normalfont\huge\bfseries\filcenter}{\partname\ \ \thepart}{22pt}{\Huge}

\newpagestyle{main}{
    \sethead[][\chaptertitle][] % even header
    {}{\parttitle}{} % odd header
    \setfoot[][\thepage][] % even footer: making the page number on th bottom of the page and center
    {}{\thepage}{} % odd footer
    \settitlemarks{part,chapter}}
\pagestyle{main}
\usepackage{kantlipsum}
\begin{document}
    \part{Bar}
        \chapter{Foo}
            \kant[1-20]
\end{document}

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

관련 정보