문서의 장 헤더에 버그가 발생했습니다.

문서의 장 헤더에 버그가 발생했습니다.

장 이름 앞에 이미지가 있는 새로운 책과 같은 장 형식을 만들고자 하며 chapter이를 재정의하여 코드를 생각해 냈는데 tikzpicture이제 문제는 문서 전체에서 장 이름이 각 페이지의 헤더는 '목차'이며 해당 장의 제목은 아닙니다. 헤더가 현재 장의 제목이 되도록 수정하는 방법을 아는 사람이 있나요?

여기 내 문서의 MWE가 있습니다.

\documentclass[letterpaper]{memoir}

\usepackage{lipsum,tikz}
\usepackage{geometry}
    \geometry{top=2cm,bottom=2cm,left=2cm,right=2cm}

\renewcommand{\chapter}[2]{
    \clearforchapter
    \addtocounter{chapter}{1}
    \chapterheadstart
    \begin{tikzpicture}[remember picture, overlay, path image/.style={
            path picture={
                \node[xshift=-1cm] at (path picture bounding box.center) {
                \includegraphics{#2}
        };}}]
        \draw [path image=#2] (current page.north west) rectangle (\paperwidth, 0);
        \draw (-1.5,0) circle (0pt) node [right, rectangle, rounded corners=8pt, fill=blue]
            {\Huge\bfseries\color{yellow}\thechapter\; #1};
    \end{tikzpicture}
    \addcontentsline{toc}{chapter}{\thechapter\hspace{0.5em} #1}
    \par\vspace{1cm}
    }
 
\begin{document}
\tableofcontents*

\chapter{First}{nilum}

\lipsum[1]\newpage
\lipsum[2]

\chapter{Second}{nilum}

\lipsum[3]
\end{document}

답변1

명령 을 재정의하는 방식으로 인해 \chapter기본 형식과 헤더 업데이트가 엉망이 됩니다. 나는 당신이 클래스를 사용하는 이유가 memomir이 클래스의 기본 형식을 따르기 때문이라고 생각합니다. 그렇지 않으면 다른 선택 사항(예: 책, 보고서)이 너무 많습니다. 따라서 패키지 사용을 권장하지 않습니다 geometery. 수업 의 장 제목을 사용자 정의하려면 에 memomir미리 정의된 명령을 사용해야 합니다 memomir. 이런 식으로 형식과 헤더 업데이트가 엉망이 되지 않습니다. 또한 장 제목의 별표 버전(예: contents)도 번호가 매겨진 제목과 동일한 형식을 갖습니다. 이 방법을 사용하면 장 이미지를 지정하는 두 번째 인수가 없습니다. 그래서 명령이 \chapterimage정의되었습니다. \chapterimage새 장을 입력하기 전에 명령을 갱신하면 장 이미지를 변경할 수 있습니다 . 다음 방법으로도 목표를 달성할 수 있지만 권장되지 않습니다.

\documentclass[letterpaper]{memoir}
\usepackage{lipsum,tikz}
\usepackage{geometry}
\geometry{top=2cm,bottom=2cm,left=2cm,right=2cm}

\renewcommand{\printchaptername}{}
\renewcommand{\chapternamenum}{}
\renewcommand{\printchapternum}{\def\chapnumcontents{\thechapter\; }}
\renewcommand{\printchapternonum}{\def\chapnumcontents{}}
\renewcommand{\afterchapternum}{}
\renewcommand{\printchaptertitle}[1]{
\chaptitlefont\begin{tikzpicture}[
remember picture, 
overlay, 
path image/.style={
path picture={
\node at (path picture bounding box.center) {\includegraphics{\chapterimage}};
}
}
]

\draw [path image=\chapterimage](current page.north west) rectangle (\paperwidth-2cm-1pt, 0);

\node [rectangle, rounded corners=8pt, fill=blue,anchor=west] at (-1,0) {\color{yellow}\chapnumcontents#1};
\end{tikzpicture}
}
\setlength{\afterchapskip}{1cm}
\newcommand\chapterimage{example-image}
 
\begin{document}
\tableofcontents*

\renewcommand\chapterimage{example-image-a}
\chapter{First}

\lipsum[1]\newpage
\lipsum[2]

\renewcommand\chapterimage{example-image-b}
\chapter{Second}

\lipsum[3]
\end{document}

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

관련 정보