scrartcl과 "Chapter X" 레이블의 섹션 아래와 위에 두 개의 수평선을 어떻게 포함합니까?

scrartcl과 "Chapter X" 레이블의 섹션 아래와 위에 두 개의 수평선을 어떻게 포함합니까?

저는 LaTeX에서 문서 클래스를 사용하고 있습니다 scrartcl(여러 가지 이유로 이 클래스를 사용해야 합니다). 이제 모든 섹션에 대해 다음과 같은 것을 얻고 싶습니다.

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

현재 나는 다음을 수행하고 있습니다 :

\usepackage[usenames,dvipsnames]{xcolor}
\colorlet{titlerulecolor}{orange}

\usepackage{titlesec}
\titleformat{\section}{\Huge\scshape\raggedleft}{}{0em}
{ }[{\color{titlerulecolor}\titlerule}]
\titlespacing{\section}{0pt}{3pt}{3pt}

그러면 다음이 생성됩니다.

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

그럼에도 불구하고 나는 다음 사항을 파악하지 못했습니다.

  1. LaTeX에서 위의 X장 텍스트를 자동으로 추가하는 방법

  2. 두 번째 줄을 추가하는 방법

  3. 이 서식이 목차에서도 발생하지 않도록 하는 방법.

답변1

우선: titlesecKOMA-Script 클래스와 함께 사용하지 마십시오.

챕터가 필요한 경우 로 전환하세요 scrreprt. 예:

\documentclass[
  headings=chapterprefix
]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[usenames,dvipsnames]{xcolor}
\colorlet{titlerulecolor}{orange}

\addtokomafont{disposition}{\rmfamily}
\addtokomafont{chapter}{\Huge\scshape}
\addtokomafont{chapterprefix}{\LARGE\upshape}

\RedeclareSectionCommand[%
  afterindent=false,
  beforeskip=3pt,
  innerskip=0pt,
  afterskip=3pt
]{chapter}

\newcommand\titlerule[1][.4pt]{\textcolor{titlerulecolor}{\rule[.5\baselineskip]{\textwidth}{#1}}}
\renewcommand\chapterlineswithprefixformat[3]{%
  \ifstr{#1}{chapter}{%
    \IfArgIsEmpty{#2}{#2#3}{%
      \raggedleft%
      #2%
      \titlerule\\*%
      \kern-1.5ex\nobreak%
      #3\par\nobreak%
      \kern1ex\nobreak%
      \titlerule\par%
    }%
  }{#2#3}%
}

\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\chapter{Test}
\Blindtext
\blinddocument
\end{document}

결과:

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

scrartcl및 섹션 의 예 :

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[usenames,dvipsnames]{xcolor}
\colorlet{titlerulecolor}{orange}

\addtokomafont{disposition}{\rmfamily}
\addtokomafont{section}{\Huge\scshape}
\newkomafont{sectionprefix}{\LARGE\upshape}

\RedeclareSectionCommand[%
  afterindent=false,
  beforeskip=\dimexpr\baselineskip+3pt\relax,
  afterskip=3pt
]{section}
\renewcommand\sectionformat{Section~\thesection\autodot}

\newcommand\titlerule[1][.4pt]{\textcolor{titlerulecolor}{\rule[.5\baselineskip]{\textwidth}{#1}}}
\makeatletter
\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{section}{%
    \ifstr{#3}{}{\@hangfrom{\hskip#2#3}#4}{%
      \raggedleft%
      {\usekomafont{sectionprefix}#3\par\nobreak}%
      \titlerule\\*%
      \kern-1.5ex\nobreak%
      #4\par\nobreak%
      \titlerule\par\nobreak%
    }%
  }{\@hangfrom{\hskip#2#3}#4}%
}
\makeatother

\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\section{Test}
\Blindtext
\blinddocument
\end{document}

결과:

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

관련 정보