Koma-script에서 장 제목을 들어올려 장 접두사와 정렬하려면 어떻게 해야 합니까?

Koma-script에서 장 제목을 들어올려 장 접두사와 정렬하려면 어떻게 해야 합니까?

나는 현재 이것을 가지고 있습니다 :

\documentclass{scrbook}
\usepackage{mwe}
\renewcommand*{\chapterformat}{\mbox{\chapappifchapterprefix{\nobreakspace}\scalebox{3}{\thechapter}\enskip}}

\begin{document}
\chapter{\baselineskip{-1em}This chapter caption has multiple lines and does not fit into a single line}
\lipsum[1]
\end{document}

접두사와 제목은 첫 번째 줄에만 정렬됩니다.

그러나 내가 원하는 것은 다음과 유사한 접두사의 기준선에 맞게 장 제목을 정렬하는 것입니다.

내가 갖고 싶은 것

긴 장 제목이 고통스럽다는 것을 알고 있습니다. 그러나 때로는 한 줄에 맞지 않아 첫 번째 결과가 약간 불안하다고 생각합니다.

답변1

a를 사용하면 \Longstack나누기가 수동으로 삽입된 두 줄의 장 이름에 사용할 수 있습니다. 하지만 세 줄에 도달하면 살펴보기에 적합한 방법이 없습니다.

\documentclass{scrbook}
\usepackage{mwe}
\renewcommand*{\chapterformat}{\mbox{\chapappifchapterprefix{\nobreakspace}\scalebox{3}{\thechapter}\enskip}}
\usepackage{lipsum}
\usepackage[usestackEOL]{stackengine}
\begin{document}
\chapter{\Longstack[l]{This chapter caption has multiple lines\\ and does not fit into a single line}}
\lipsum[1]
\end{document}

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

또한 는 \Longstack오른쪽 여백에 오른쪽 가장자리 제목 텍스트를 정렬하지 않습니다. 이곳의 모습은 단지 우연일 뿐입니다.

마지막으로 목차를 사용하려면 \chapter다음과 같은 선택적 인수를 사용해야 합니다.

\chapter[This chapter caption has multiple lines and does not fit into a single line]%
  {\Longstack[l]{This chapter caption has multiple lines\\ and does not fit into a single line}}

toc에 스택이 표시되는 것을 방지합니다.

답변2

미니페이지를 사용한 자동 줄바꿈 솔루션:

미니페이지에는 너비 지정이 필요합니다. 따라서 나는 길이를 측정할 수 있는 \chapmark대부분의 정의를 포함하는 새 명령을 정의했습니다 . \chapterformat이를 위해 나는 패키지의 두 가지 기능 calc, 즉 명령 \widthof과 길이 계산 가능성을 사용했습니다. 기본 방향은 b미니페이지의 선택적 인수로 보호됩니다.

새 명령(대문자 C 포함)은 선택적 인수에 제공되는 KOMA-Script의 향상된 기능을 사용할 수 있는 방식으로 정의되지만 KOMA-Script 옵션이 true로 설정된 \Chapter상태에서는 사용할 수 없습니다 . 대신 chapterprefix기본값을 사용해야 합니다. 참조. \chapter예제에서는 11장과 12장 아래에 출력됩니다.

또한 목차의 출력은 미니페이지의 영향을 받지 않습니다. 아래 출력도 참조하세요.

또한 더 나은 정렬을 위해 대체품으로 \RaggedRightfrom을 사용했습니다 .ragged2e\raggedright

\NewDocumentCommandfrom 대신 패키지 또는 .xparse\newcommand(x)ifthenetoolbox

\documentclass{scrbook}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}

\usepackage{calc} % provides advanced length computation and command "\widthof"
\usepackage{ragged2e}% better text alignment
\usepackage{xparse}% advanced command definitions

\renewcommand*{\raggedchapterentry}{\RaggedRight}% for chapter TOC entries
\renewcommand*{\raggedsection}{\RaggedRight}% for alignment in titles

\newcommand*{\chapmark}{%
  \scalebox{1.5}{\chapappifchapterprefix{\nobreakspace}}\scalebox{3}{\thechapter}\enskip%
}
\renewcommand*{\chapterformat}{%
  \begin{minipage}[b]{\widthof{\chapmark}}
    \chapmark
  \end{minipage}%
}

\NewDocumentCommand\Chapter{o m}{% note the uppercase "C"
  \IfValueTF{#1}% optional argument given or not
  {% with optional argument:
    \chapter[#1]{%
      \begin{minipage}[b]{\textwidth-\widthof{\chapmark}}
      #2
      \end{minipage}}%
  }{% without optional argument:
    \chapter[#2]{%
      \begin{minipage}[b]{\textwidth-\widthof{\chapmark}}
      #2
      \end{minipage}}%
  }
}

\begin{document}
\Chapter{This chapter caption is too long to fit into a single line} % ch. 1

\Chapter[TOC entry for caption with 3 lines] % ch. 2
{This chapter caption is longer than the first one and does not even fit into
two lines}

\setcounter{chapter}{9}

\Chapter{Another chapter caption that is too long to fit into a single line} % ch. 10

\KOMAoption{chapterprefix}{true}

\Chapter[Another TOC entry for caption with 3 lines] % ch. 11
{This chapter caption is also longer than the first one and does not even fit into
two lines}

\chapter{% ch. 12
This caption produced with \textmd{\textbackslash chapter} is too long to fit into
a single line}

\tableofcontents

\end{document}

첫 번째 장의 캡션 출력

두 번째 장의 캡션 출력

세 번째 장의 캡션 출력

네 번째 장의 캡션 출력

다섯 번째 장의 캡션 출력

목차 출력

관련 정보