섹션별 KOMA 스크래치 들여쓰기

섹션별 KOMA 스크래치 들여쓰기

그래서 이것이 모범 사례는 아니라는 것을 알고 있지만 재현해야 하는 템플릿이 있고 단어를 사용하면 쉽게 그렇게 할 수 있습니다.... \parindent레벨에 따라 전체 텍스트(단지 )를 들여쓰기해야 합니다. 제목과 텍스트에 대해 별도로 설정해야 합니다. 예:

  1. 섹션, 제목(포함 번호) 왼쪽 여백
  2. 섹션, 텍스트왼쪽 여백에서 0.7cm 들여쓰기
  3. 하위 섹션, 제목섹션이 있는 텍스트(예: 왼쪽 여백에서 0.7cm 들여쓰기)
  4. 하위 섹션, 텍스트왼쪽 여백에서 1.4cm 들여쓰기

KOMA를 사용하여 이를 수행하는 쉬운 방법이 있습니까?

문서의 현재 상태

\documentclass[11pt, oneside, a4]{scrartcl}

% Packages, Design
\usepackage[top=1.5cm, bottom=2.5cm, left=2.5cm, right=1.6cm]{geometry}
\usepackage{lipsum}
\pagestyle{empty}
%\usepackage{showframe}

% Section style
\setkomafont{section}{\bfseries\fontsize{14pt}{14pt}\selectfont}
\setkomafont{subsection}{\bfseries}
\setkomafont{subsubsection}{\bfseries}

\RedeclareSectionCommand[
beforeskip=-2\baselineskip,
afterskip=0.2\baselineskip,
]{section}

\RedeclareSectionCommands[
beforeskip=-2\baselineskip,
afterskip=0.2\baselineskip
]{subsection, subsubsection}

% Opening
\title{Report}
\author{A Anme}

\begin{document}

\section{Test 1}
Text\\
More text on a second line\par
\lipsum
\section{Test 2}
Text\\
Equation: 
\begin{equation}
    E = m\cdot c^2
\end{equation}
\subsection{Test 2 2}
Text
\subsubsection{TestSub}
Something

\end{document}

답변1

이와 같은 작업을 수행하는 것은 보기만큼 간단하지 않습니다. 왼쪽 여백은 전체 페이지에 항상 사용되는 값입니다. 따라서 왼쪽 여백을 추가하려면 하위 섹션의 전체 콘텐츠를 환경(예: 들여쓰기 minipage(문제: 페이지 나누기 없음) 또는 ) 으로 이동하거나 addmargintcolorbox조작할 수 있습니다 \leftskip. 다음 예에서는 마지막 작업을 수행하고(2020/10/01부터 LaTeX의 일반 후크 사용) 추가로 재정의합니다 \sectionlinesformat(이에 대한 자세한 내용은 KOMA-Script 매뉴얼 참조).

\documentclass{scrartcl}% All default options removed

% Packages, Design
\usepackage[top=1.5cm, bottom=2.5cm, left=3.2cm, right=1.6cm]{geometry}% left
                                % margin increased by the text indent of
                                % sections

\usepackage{mwe}
\pagestyle{empty}
%\usepackage{showframe}

% Section style
\setkomafont{section}{\bfseries\fontsize{14pt}{14pt}\selectfont}
\setkomafont{subsection}{\bfseries}
\setkomafont{subsubsection}{\bfseries}

\makeatletter
\renewcommand*{\sectionlinesformat}[4]{%
  \hskip#2\parbox{\dimexpr\linewidth+0.7cm}{%
    \@hangfrom{#3}{#4}%
  }%
}
\makeatother

\RedeclareSectionCommand[
  indent=-0.7cm,
  runin=false,
  afterindent=false,
  beforeskip=2\baselineskip,
  afterskip=0.2\baselineskip,% IMHO not enough
]{section}

\RedeclareSectionCommands[
  indent=0cm,
  afterindent=false,
  beforeskip=2\baselineskip,
  afterskip=0.2\baselineskip,% IMHO not enough
]{subsection, subsubsection}

\AddToHook{cmd/section/before}{%
  \par
  \setlength{\leftskip}{0pt}%
  \setlength{\linewidth}{\textwidth}%
}
\AddToHook{cmd/subsection/before}{%
  \par
  \setlength{\leftskip}{0.7cm}%
  \setlength{\linewidth}{\textwidth}%
  \addtolength{\linewidth}{-\leftskip}%
}

% Opening
\title{Report}
\author{A Anme}

\begin{document}
\tableofcontents

\section{Test 1}
\lipsum[1]
\begin{itemize}
\item Testitem
\item Testitem
\end{itemize}
\lipsum[2-3]

\section{Test 2}
\lipsum[1]
\begin{equation}
    E = m\cdot c^2
\end{equation}
\lipsum[2]
\subsection{Test 2 2}
\lipsum[3]
\subsubsection{TestSub}
\lipsum[4]

\blinddocument

\end{document}

1페이지와 2페이지에서 이는 요청에 맞는 것 같습니다.

요청된 들여쓰기가 포함된 페이지 1 및 2

그러나 3페이지와 4페이지의 목록 들여쓰기가 올바르지 않습니다.

목록 들여쓰기가 잘못된 두 페이지

이것이 귀하에게 해당된다면 \leftmargini후크 내에서도 변경해야 합니다. 또는 패키지를 사용하여 enumitem목록을 조정할 수 있습니다.

\leftskip거의 완전한 문서를 변경하는 데 다른 문제가 있을 수 있습니다 . 예를 들어 trivlist다음과 같은 환경에서 파생되었습니다 .addmargin 될 수도 있습니다.이상하게 행동하다.

그래서 IMHO, 귀하의 질문에 대한 답변

KOMA를 사용하여 이를 수행하는 쉬운 방법이 있습니까?

될 것입니다 : 아니요, 쉽지 않습니다.

관련 정보