\parindent
所以我知道這不是最佳實踐,但我有一個需要複製的模板,而且單字可以輕鬆做到這一點......我需要根據等級縮排全文(而不僅僅是)。我需要分別為標題和文字設定這個,例如
- 部分、標題(整數)位於左邊距
- 部分、文字從左邊界縮排 0.7 厘米
- 小節,標題在帶有部分的文字上,例如從左邊距縮排 0.7 厘米
- 分節,文本距左邊距 1.4 厘米
有沒有一種簡單的方法可以使用 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
(問題:無分頁符),或addmargin
,甚至可能是tcolorbox
,或者您可以操縱\leftskip
.在下面的範例中,我執行最後一個(並使用 2020 年 10 月 1 日起的 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 頁,這似乎符合要求:
但第 3 頁和第 4 頁的清單縮排不正確:
如果這與您相關,您還應該\leftmargini
在鉤子內進行更改等。或者,您可以使用套件enumitem
來調整清單。
更改\leftskip
幾乎完整的文檔可能會出現其他問題。例如,源自trivlist
類似的環境addmargin
也可以行為怪異。
所以恕我直言,你的問題的答案
有沒有一種簡單的方法可以使用 KOMA 來實現此目的?
會是:不,不容易。