![Koma-script에서 장 제목을 들어올려 장 접두사와 정렬하려면 어떻게 해야 합니까?](https://rvso.com/image/286992/Koma-script%EC%97%90%EC%84%9C%20%EC%9E%A5%20%EC%A0%9C%EB%AA%A9%EC%9D%84%20%EB%93%A4%EC%96%B4%EC%98%AC%EB%A0%A4%20%EC%9E%A5%20%EC%A0%91%EB%91%90%EC%82%AC%EC%99%80%20%EC%A0%95%EB%A0%AC%ED%95%98%EB%A0%A4%EB%A9%B4%20%EC%96%B4%EB%96%BB%EA%B2%8C%20%ED%95%B4%EC%95%BC%20%ED%95%A9%EB%8B%88%EA%B9%8C%3F.png)
나는 현재 이것을 가지고 있습니다 :
\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장 아래에 출력됩니다.
또한 목차의 출력은 미니페이지의 영향을 받지 않습니다. 아래 출력도 참조하세요.
또한 더 나은 정렬을 위해 대체품으로 \RaggedRight
from을 사용했습니다 .ragged2e
\raggedright
\NewDocumentCommand
from 대신 패키지 또는 .xparse
\newcommand
(x)ifthen
etoolbox
\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}