모든 장 번호가 장 제목 위에 나타나는 장 스타일

모든 장 번호가 장 제목 위에 나타나는 장 스타일

디자인 중인 문서의 일부로 문서의 모든 장 번호를 포함하는 장 스타일을 만들고 싶습니다. 예를 들어, 총 6개의 장이 있는 경우 다음과 같이 장 제목 위에 1부터 6까지의 숫자가 표시되어야 합니다.

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

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

숫자는 위와 같이 tikz 원 안에 표시되어야 합니다. 현재 장 번호는 나머지 장 번호보다 커야 하며 진한 파란색 윤곽선이 있는 파란색 원으로 강조 표시되어야 합니다. 나머지 원은 단일 수평 그라데이션(윤곽선에 대해 더 어두운 그라데이션 사용)으로 채워야 하며, 파란색 원에서 멀어질수록 원이 어두운 회색에서 흰색으로 희미해지게 됩니다. 지금까지 나는 이것을 달성할 수 없었으며 도움을 주시면 대단히 감사하겠습니다. 지금까지 내가 가진 것은 다음과 같습니다.

\documentclass[oneside,11pt,a4paper]{memoir}
\usepackage[margin=2.5cm]{geometry}
\usepackage{tikz}

\usepackage{titletoc}
\usepackage{lipsum}

\makechapterstyle{mystyle}{%
  \chapterstyle{default}
  \renewcommand*{\chapnumfont}{\normalfont\Huge\sffamily\bfseries}
  \renewcommand*{\chaptitlefont}{\normalfont\huge\sffamily\bfseries\color{black}}
  \renewcommand*{\printchapternum}{%
  \centering\begin{tikzpicture}[baseline={([yshift=-.775ex]current bounding box.center)}]
  \node[fill=blue!50,circle,text=white,draw=blue!50!black] {\thechapter};
  \end{tikzpicture}\\[1ex]}
  \renewcommand*{\printchaptertitle}[1]{%
    {\chaptitlefont ##1}}
}
\let\chaptername\relax
%use new chapter style
\chapterstyle{mystyle}
\begin{document}
\chapter{Logarithms}
\chapter{Exponentials}
\chapter{Determinants}
\chapter{Vectors}
\chapter{Differentiation}
\chapter{Integration}
\end{document}

원하는 결과를 얻는 데 도움을 주시면 감사하겠습니다.

답변1

흥미로운 아이디어입니다. 다음과 같이 할 수 있습니다.

\documentclass[oneside,11pt,a4paper]{memoir}
\usepackage[margin=2.5cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{positioning}

\usepackage{titletoc}

\pgfmathtruncatemacro{\chaptercount}{6}
\makechapterstyle{mystyle}{%
  \chapterstyle{default}
  \renewcommand*{\chaptername}{}
  \renewcommand*{\chapnumfont}{\Huge\sffamily\bfseries}
  \renewcommand*{\chaptitlefont}{\huge\sffamily\bfseries}
  \renewcommand*{\printchapternum}{%
  \centering\begin{tikzpicture}
  \coordinate (t0) at (0,0);
  \foreach \i [count=\j from 0] in {1,...,\chaptercount} {
    \pgfmathsetmacro{\opacity}{
        \i < \thechapter ? 
            1 / (\chaptercount - 1) * (\chaptercount - (\thechapter - \i)) :
            1 / (\chaptercount - 1) * (\chaptercount + (\thechapter - \i)) 
    }
    \ifnum\thechapter=\i\relax
        \node[
            circle, 
            right={10pt of t\j},
            fill={blue!50},
            draw={blue!50!black},
            text={white},
        ] (t\i) {\i};
    \else
        \node[
            circle, 
            right={10pt of t\j},
            fill=gray!50,
            draw=blue!50!black,
            text=white,
            fill opacity={\opacity},
            font=\small
        ] (t\i) {\i};
    \fi
  }
  \end{tikzpicture}
}
\renewcommand*{\printchaptertitle}[1]{%
  {\chaptitlefont ##1}}
}
%use new chapter style
\chapterstyle{mystyle}
\begin{document}
\chapter{Logarithms}
\chapter{Exponentials}
\chapter{Determinants}
\chapter{Vectors}
\chapter{Differentiation}
\chapter{Integration}
\end{document}

출력(최소 두 번 컴파일 후):

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

노드 테두리도 희미하게 하려면 fill opacity으로 바꾸면 됩니다 opacity. 이렇게 하면 실제로 텍스트도 희미해지지만 이 예에서는 어쨌든 텍스트가 흰색입니다.

최대 챕터 수는 \pgfmathtruncatemacro{\chaptercount}{6}. 다른 방법을 통해 이를 얻는 것이 가능할 수도 있지만 첫 번째 컴파일 주기 동안 값이 \chaptercount잘못될 가능성이 높기 때문에 계산이 잘못된 값으로도 작동하는지 항상 확인해야 합니다.

관련 정보