제목 형식 문제: 목차 및 참고 문헌에 장 스타일을 적용하고 싶지 않습니다.

제목 형식 문제: 목차 및 참고 문헌에 장 스타일을 적용하고 싶지 않습니다.

다음 코드를 고려해보세요:

\documentclass[11pt,twoside,openany]{book}

\usepackage[svgnames,x11names]{xcolor}
\usepackage{wallpaper}
\usepackage{changepage}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
\usepackage{lipsum}
\usepackage{geometry}
\geometry{
   paperwidth=216mm, paperheight=303mm,
   left=23mm,  %% or inner=23mm
   right=18mm, %% or outer=18mm
   top=23mm, bottom=23mm,
   headheight=\baselineskip,
   headsep=7mm,
   footskip=7mm
}


%% Command to hold chapter illustration image
\newcommand\chapterillustration{}

%% Define how the chapter title is printed
\titleformat{\chapter}{}{}{0pt}{
%% Background image at top of page
\ThisULCornerWallPaper{1}{\chapterillustration}
%% Draw a semi-transparent rectangle across the top
\tikz[overlay,remember picture]
  \fill[LightSalmon1,opacity=.7]
  (current page.north west) rectangle 
  ([yshift=-3cm] current page.north east);
  %% Check if on an odd or even page
  \checkoddpage\strictpagecheck
  %% On odd pages, "logo" image at lower right
  %% corner; Chapter number printed near spine
  %% edge (near the left); chapter title printed
  %% near outer edge (near the right).
  \ifoddpage{
    \ThisLRCornerWallPaper{.35}{fern_mo_01}
    \begin{tikzpicture}[overlay,remember picture]
    \node[anchor=south west,
      xshift=20mm,yshift=-30mm,
      font=\sffamily\bfseries\huge] 
      at (current page.north west) 
      {\chaptername\ \thechapter};
    \node[fill=Sienna!80!black,text=white,
      font=\Huge\bfseries, 
      inner ysep=12pt, inner xsep=20pt,
      rounded rectangle,anchor=east, 
      xshift=-20mm,yshift=-30mm] 
      at (current page.north east) {#1};
    \end{tikzpicture}
  }
  %% On even pages, "logo" image at lower left
  %% corner; Chapter number printed near outer
  %% edge (near the right); chapter title printed
  %% near spine edge (near the left).
  \else {
    \ThisLLCornerWallPaper{.35}{fern_mo_01}
    \begin{tikzpicture}[overlay,remember picture]
    \node[anchor=south east,
      xshift=-20mm,yshift=-30mm,
      font=\sffamily\bfseries\huge] 
      at (current page.north east)
      {\chaptername\ \thechapter};
    \node[fill=Sienna!80!black,text=white,
      font=\Huge\bfseries,
      inner sep=12pt, inner xsep=20pt,
      rounded rectangle,anchor=west,
      xshift=20mm,yshift=-30mm] 
      at ( current page.north west) {#1};
    \end{tikzpicture}
  }
  \fi
}
\titlespacing*{\chapter}{0pt}{0pt}{135mm}


\begin{document}
\tableofcontents

\renewcommand\chapterillustration{six-computers-chips-circuits}
\newpage
\chapter{Hello World!}


\renewcommand\chapterillustration{cherry-tomatos}
\newpage
\chapter{Whassup, Doc?}

\end{document}

문제:

"챕터"에 적용한 팬시 설정은 문서의 모든 항목에 적용됩니다. => 목차 및 참고문헌(위 샘플 코드에는 포함되지 않음)이 이제 '장'으로 표시됩니다.

또한 다음을 비활성화해야 합니다.

%\listoffigures
%\listoftables

이러한 섹션을 활성화하면 컴파일 오류가 발생합니다(챕터 설정이 해당 섹션에 적용될 때).

이 문제를 피할 수 있는 방법을 찾도록 도와주세요.

답변1

목차는 번호가 매겨진 장 앞에 오므로 \titleformat\titlespacing명령을 뒤로 이동할 수 있으므로 \tableofcontents영향을 받지 않습니다.

스위치처럼 작동하는 명령을 정의할 수도 있습니다. 하나는 멋진 방식 \titleformat으로 호출하고 다른 하나는 문서 부록에서 찾을 수 있는 기본 설정으로 호출합니다. 따라서 원하는 대로 켜고 끌 수 있습니다.\titlesectiontitlesec

다음은 스타일 전환에 대한 작은 예입니다. 이는 시작이 될 수 있습니다. 색상만 변경하면 됩니다.

\documentclass{book}
\usepackage{color}
\usepackage{titlesec}
\newcommand*{\fancychapterstyle}{%
  \titleformat{\chapter}[display]
  {\normalfont\huge\bfseries\color{blue}}{\chaptertitlename\ \thechapter}
  {20pt}{\Huge\color{blue}}
  \titlespacing*{\chapter}{0pt}{50pt}{40pt}
}
\newcommand*{\standardchapterstyle}{%
  \titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
  \titlespacing*{\chapter}{0pt}{50pt}{40pt}
}
\begin{document}
\tableofcontents
\fancychapterstyle
\chapter{One}
\standardchapterstyle
\begin{thebibliography}{99}
\end{thebibliography}
\end{document}

관련 정보