
도움을 좀 주실 수 있는지 궁금합니다. 수업 문서 의 섹션 제목을 맞춤설정하고 싶습니다 scrbook
. 이것과 비슷한 것 :
상자 안의 섹션 번호 뒤에 중심선이 옵니다. 섹션 이름과 텍스트 너비를 채우는 또 다른 수직 중심선입니다.
지금까지 이 StackExchange에서 솔루션을 검색했지만 성공하지 못했습니다. 나는코마스크립트 매뉴얼유사한 작업을 수행하는 두 가지 가능한 명령을 찾았습니다. \sectionformat
및 \sectionlinesformat
. 그러나 솔직히 말해서 라텍스에 대한 나의 제한된 지식으로는 언제 둘 중 하나를 사용해야 하는지 이해할 수 없습니다.
이 포럼에서 찾은 유사한 솔루션을 살펴보면 다음과 같은 결과를 얻을 수 있습니다.
\documentclass[openright]{scrbook}
\usepackage{geometry}
\geometry{a4paper,twoside, margin=3cm}
\usepackage{blindtext}% only dummy text
\usepackage{xcolor}
\renewcommand*{\sectionformat}{%
\usekomafont{section}
\makebox[0pt][r]{\fboxrule=1.5pt\fcolorbox{black}{white!0}{\color{black}\thesection}\rule[.7ex]{10pt}{1.5pt}}
}
\begin{document}
\chapter{Introduction}
\section{Section 1}
\Blindtext[2]
\section{Section 2}
\Blindtext[2]
\section{Section 3}
\Blindtext[2]
\section{Section 4}
\Blindtext[2]
\end{document}
하지만 텍스트 너비를 채우기 위해 가로-세로 텍스트 높이 정렬 선을 추가하는 방법을 찾지 못했습니다.
내가 시도한 또 다른 옵션은 다음을 사용하는 것입니다.
%%%%% Simple + underline
\renewcommand{\sectionlinesformat}[4]{%
\Ifstr{#1}{section}{%
\parbox[c]{\linewidth}{%
\raggedsection{\hskip #2{\color{black}#3}}{#4}\par%
\kern-.75\ht\strutbox\rule{\linewidth}{1pt}%
}%
}{%
{\hskip #2#3}{#4}}%
}
보세요, 여기가 \sectionlinesformat
대신 사용되었지만 \sectionformat
이유는 모르겠습니다. 나는 다음을 얻습니다:
내가 찾은 세 번째 옵션은 다음을 사용하는 것 \makeatletter
입니다 \makeatother
.
\makeatletter
\renewcommand\@seccntformat[1]{%
\makebox[0pt][l]{\rule[-\dimexpr\fboxsep+2pt\relax]{\columnwidth}{1.5pt}}%
\colorbox{blue}{%
\rule[-2pt]{0pt}{0pt}%
\color{white}\csname the#1\endcsname
}%
\quad
}
\makeatother
그리고 나는 다음을 얻습니다:
원하는 결과를 얻을 수 있는 방법에 대한 지침이 있습니까?
또한 섹션 번호와 해당 상자를 텍스트나 여백에 정렬할 수 있는 옵션이 있으면 좋을 것입니다.
답변1
이 같은?
\documentclass[openright]{scrbook}
\usepackage{geometry}
\geometry{a4paper,twoside, margin=3cm}
\usepackage{blindtext}% only dummy text
\usepackage{xcolor}
\usepackage{xhfill}
\renewcommand*{\sectionformat}{%
\usekomafont{section}%
\fboxrule=1pt\fcolorbox{blue}{white!0}{\color{black}\thesection}%
\color{blue}\rule[.7ex]{10pt}{1pt}\>%
}
\makeatletter
\renewcommand*{\sectionlinesformat}[4]{%
\@hangfrom{\hskip #2#3}{\color{blue}#4}\>%
\xrfill[.7ex]{1pt}[blue]%
}
\makeatother
\begin{document}
\chapter{Introduction}
\section{Section 1}
\Blindtext[2]
\section{Section 2}
\Blindtext[2]
\section{Section 3}
\Blindtext[2]
\section{Section 4}
\Blindtext[2]
\end{document}
답변2
@Vincent의 답변에 추가로:
섹션(하위 섹션 및 하위 섹션 제외)만 다른 형식을 사용해야 하는 경우:
\documentclass[twoside,open=right]{scrbook}
\usepackage{geometry}
\geometry{margin=3cm}
\usepackage{blindtext}% only for dummy text
\usepackage{xcolor}
\usepackage{xhfill}
\renewcommand*{\sectionformat}{%
\fboxrule=1.5pt\fcolorbox{.}{white}{\color{black}\thesection}%
\rule[.7ex]{10pt}{1pt}\;%
}
\NewCommandCopy{\originalsectionlinesformat}{\sectionlinesformat}
\renewcommand*{\sectionlinesformat}[4]{%
\originalsectionlinesformat{#1}{#2}{#3}{#4\Ifstr{#1}{section}{\;\xrfill[.6ex]{1.5pt}[.]}{}}%
}
\addtokomafont{section}{\color{blue!50!black}}
\begin{document}
\chapter{Introduction}
\section{Section 1}
\subsection{Subsection}
\subsubsection{Subsubsection}
\Blindtext[2]
\end{document}
하위 섹션과 하위 섹션이 동일한 형식이지만 다른 색상을 사용해야 하는 경우:
\documentclass[twoside,open=right]{scrbook}
\usepackage{geometry}
\geometry{margin=3cm}
\usepackage{blindtext}% only for dummy text
\usepackage{xcolor}
\usepackage{xhfill}
\renewcommand*{\sectionformat}{%
\fboxrule=1.5pt\fcolorbox{.}{white}{\normalcolor\thesection}%
\rule[.7ex]{10pt}{1pt}\;%
}
\renewcommand*{\subsectionformat}{%
\fboxrule=1.5pt\fcolorbox{.}{white}{\normalcolor\thesubsection}%
\rule[.7ex]{10pt}{1pt}\;%
}
\renewcommand*{\subsectionformat}{%
\fboxrule=1.5pt\fcolorbox{.}{white}{\normalcolor\thesubsubsection}%
\rule[.7ex]{10pt}{1pt}\;%
}
\NewCommandCopy{\originalsectionlinesformat}{\sectionlinesformat}
\renewcommand*{\sectionlinesformat}[4]{%
\originalsectionlinesformat{#1}{#2}{#3}{#4\;\xrfill[.6ex]{1.5pt}[.]}%
}
\addtokomafont{section}{\color{blue!50!black}}
\addtokomafont{subsection}{\color{green!50!black}}
\addtokomafont{subsubsection}{\color{red!50!black}}
\begin{document}
\chapter{Introduction}
\section{Section 1}
\subsection{Subsection}
\subsubsection{Subsubsection}
\Blindtext[2]
\end{document}