
У меня есть 60-страничный документ с пронумерованными разделами, подразделами и абзацами. Все абзацы пронумерованы. Я хочу, чтобы весь текст имел равномерный отступ после пронумерованных абзацев, как показано в следующем примере:
1. Section
1.1 Subsection
1.1.1 Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec rhoncus non ante faucibus tempus. Quisque ex orci,
faucibus vitae magna sed, blandit fermentum massa.
1.1.2 Some numbered paras interrupted by lists:
* Item 1
* Item 2
* Item 3
and some text to finish the paragraph
1.1.2 Some numbered paras interrupted by sets of equations using AMSmath:
A = B
C = D
and some text to finish the paragraph
В настоящее время у меня есть около 60 страниц текста (включая множество уравнений), построенных вокруг следующего класса koma-script:
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\renewcommand\theparagraph{\thesubsection.\arabic{paragraph}}
\newcommand\p{\paragraph{}}
%
%
% make sure paragraphs reset counting at section and subsections
%
\makeatletter
\@addtoreset{paragraph}{subsection}
\@addtoreset{paragraph}{section}
\makeatother
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}
\p \blindtext
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D^_{l} & = \text{the lower date} \\
D^_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\end{document}
поэтому весь текст возвращается к левому полю. Было бы идеально, если бы я мог использовать что-то вроде \addmargin
команды koma-script для отступа списков и математических операций слева; но отрегулируйте \p
команду нумерованного абзаца так, чтобы ее нумерация начиналась вровень слева, но с рамкой вокруг номера, чтобы задать ему стандартный размер, а затем команду висячего абзаца для оставшейся части \p para, чтобы выровнять ее с остальной частью отступа.
Или что-то другое ....
Но пока это выходит за рамки моих навыков работы с LaTeX.
решение1
Обновлять:КОМА-скриптверсия 3.17 (или новее)
В версии KOMA-Script команда \othersectionlevelsformat
устарела. Вместо нее нужно использовать и т. д \sectionformat
. \subsectionformat
Поэтому код меняется на
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\newcommand\p{\paragraph{}}
\newcommand\secnumindent{1.5cm}
\RedeclareSectionCommands[indent=-\secnumindent]{section,subsection,paragraph}
\RedeclareSectionCommand[afterskip=0pt,counterwithin=subsection]{paragraph}
\renewcommand\sectionformat{\parbox{\secnumindent}{\thesection\autodot}}
\renewcommand\subsectionformat{\parbox{\secnumindent}{\thesubsection\autodot}}
\renewcommand\subsubsectionformat{\parbox{\secnumindent}{\thesubsubsection\autodot}}
\renewcommand\paragraphformat{\parbox{\secnumindent}{\theparagraph\autodot}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
%
% make sure paragraphs reset counting also at sections
%
\makeatletter
\@addtoreset{paragraph}{section}
\makeatother
% to reset headwidth and footwidth
\usepackage[
headwidth=\the\textwidth+\secnumindent:-\secnumindent,
footwidth=head:-\secnumindent,
headsepline,% to show the headwidth
footsepline% to show the footwidth
]{scrlayer-scrpage}
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}\label{sec:first}
\p \blindtext
% a reference
\p See \ref{sec:first}
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D_{l} & = \text{the lower date} \\
D_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\section{Next section}
\subsection{Next subsection}
\p \blindtext
\end{document}
Результат такой же, как на рисунке ниже.
Если это должно быть скомпилировано с версиями 3.15 и 3.16, вставьте
\renewcommand\othersectionlevelsformat[3]{\parbox{\secnumindent}{#3\autodot}}
\providecommand\sectionformat{}\providecommand\subsectionformat{}
\providecommand\subsubsectionformat{}\providecommand\paragraphformat{}
непосредственно перед переопределением \sectionformat
и т.п.
КОМА-скриптверсии 3.15 и 3.16
Вы можете использовать новые команды \RedeclareSectionCommand
или \RedeclareSectionCommands
и переопределить \othersectionlevelsformat
. Таким образом, по-прежнему возможно ссылаться на номер раздела с помощью \ref
:
\setcounter{secnumdepth}{4}
\newcommand\p{\paragraph{}}
\newcommand\secnumindent{1.5cm}
\RedeclareSectionCommands[indent=-\secnumindent]{section,subsection,paragraph}
\RedeclareSectionCommand[afterskip=0pt,counterwithin=subsection]{paragraph}
\renewcommand\othersectionlevelsformat[3]{\parbox{\secnumindent}{#3\autodot}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
%
% make sure paragraphs reset counting also at sections
%
\makeatletter
\@addtoreset{paragraph}{section}
\makeatother
Чтобы восстановить исходную ширину головы и ног, вы можете использовать
\usepackage[
headwidth=\the\textwidth+\secnumindent:-\secnumindent,
footwidth=head:-\secnumindent,
headsepline,% to show the headwidth
footsepline% to show the footwidth
]{scrlayer-scrpage}
Код:
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\newcommand\p{\paragraph{}}
\newcommand\secnumindent{1.5cm}
\RedeclareSectionCommands[indent=-\secnumindent]{section,subsection,paragraph}
\RedeclareSectionCommand[afterskip=0pt,counterwithin=subsection]{paragraph}
\renewcommand\othersectionlevelsformat[3]{\parbox{\secnumindent}{#3\autodot}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
%
% make sure paragraphs reset counting also at sections
%
\makeatletter
\@addtoreset{paragraph}{section}
\makeatother
% to reset headwidth and footwidth
\usepackage[
headwidth=\the\textwidth+\secnumindent:-\secnumindent,
footwidth=head:-\secnumindent,
headsepline,% to show the headwidth
footsepline% to show the footwidth
]{scrlayer-scrpage}
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}\label{sec:first}
\p \blindtext
% a reference
\p See \ref{sec:first}
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D_{l} & = \text{the lower date} \\
D_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\section{Next section}
\subsection{Next subsection}
\p \blindtext
\end{document}
KOMA-Script версии 3.14 (или старше)
Вот еще одно предложение, использующее ответ @Steven, но переопределяющее \othersectionlevelsformat
вместо \thesection
. Так что все еще возможно ссылаться на номер раздела с помощью \ref
:
\newcommand\p{\paragraph{}\hspace*{-1em}}
\newcommand\secnumindent{1.5cm}
\renewcommand\othersectionlevelsformat[3]{\makebox[0pt][r]{\parbox{\secnumindent}{#3\autodot}}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
Код:
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\renewcommand\theparagraph{\thesubsection.\arabic{paragraph}}
\newcommand\p{\paragraph{}\hspace*{-1em}}
\newcommand\secnumindent{1.5cm}
\renewcommand\othersectionlevelsformat[3]{\makebox[0pt][r]{\parbox{\secnumindent}{#3\autodot}}}
% from the answer of @Steven:
\addtolength\hoffset{\secnumindent}
\addtolength\textwidth{-\secnumindent}
% to reset headwidth and footwidth
\usepackage[
headwidth=\the\textwidth+\secnumindent:-\secnumindent,
footwidth=head:-\secnumindent,
headsepline,% to show the headwidth
footsepline% to show the footwidth
]{scrlayer-scrpage}
%
% make sure paragraphs reset counting at section and subsections
%
\makeatletter
\@addtoreset{paragraph}{subsection}
\@addtoreset{paragraph}{section}
\makeatother
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}\label{sec:first}
\p \blindtext
% a reference
\p See \ref{sec:first}
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D_{l} & = \text{the lower date} \\
D_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\section{Next section}
\subsection{Next subsection}
\p \blindtext
\end{document}
решение2
Как я [приблизительно] предложил в комментарии, добавьте эти строки в преамбулу
\let\svthesection\thesection
\def\thesection{\kern-1.5cm\svthesection}
\hoffset=\dimexpr\hoffset + 1.5cm\relax
\textwidth=\dimexpr\textwidth-1.5cm\relax
\paperwidth=\dimexpr\paperwidth -1.5cm\relax
Они выполняют следующие действия: 1) сохраняют копию \thesection
; 2) переопределяют \thesection
кернинг на 1,5 см влево перед печатью заголовка раздела; 3) изменяют его, \hoffset
сдвигая весь документ на 1,5 см вправо; 4) уменьшают \textwidth
на 1,5 см (в сочетании с \hoffset
оставляет правое поле неизменным); и 5) уменьшают ширину бумаги на 1,5 см, чтобы учесть изменение \hoffset
.
Я указал, что у этого подхода есть сопутствующие недостатки, которые можно увидеть на рисунках ниже MWE. Верхний/нижний колонтитулы смещены, что означает, что центрированные номера страниц теперь смещены на 0,75 см вправо по сравнению с исходным кодом OP.
OP указал, что этот подход подходит для его/ее нужды и требует только добавления среды \begin{addmargin}
. Поскольку я не совсем уверен, где OP мог разместить этот дополнительный код, я не пытался вставить его в свой MWE.
Обратите внимание, что лишние надстрочные знаки ^
были удалены из кода OP в align*
среде (по одному на строку), чтобы облегчить компиляцию. Этот код был скомпилирован в XeLaTeX, хотя он также компилируется в pdflatex.
% -*- program: xelatex -*-
\documentclass[english, parskip=full, fontsize=11, DIV12, toc=left, numbers=noenddot]{scrartcl}
\usepackage{babel}
\usepackage{amsmath}
% just so we can see what is going on for now
\usepackage{showframe}
\usepackage{blindtext}
% tighten up spacing of lists
\usepackage{enumitem}
\setlist{noitemsep}
\setcounter{secnumdepth}{4}
\renewcommand\theparagraph{\thesubsection.\arabic{paragraph}}
\newcommand\p{\paragraph{}}
%
%
% make sure paragraphs reset counting at section and subsections
%
\makeatletter
\@addtoreset{paragraph}{subsection}
\@addtoreset{paragraph}{section}
\makeatother
\let\svthesection\thesection
\def\thesection{\kern-1.5cm\svthesection}
\hoffset=\dimexpr\hoffset + 1.5cm\relax
\textwidth=\dimexpr\textwidth-1.5cm\relax
\paperwidth=\dimexpr\paperwidth -1.5cm\relax
%
% AND NOW WE BEGIN
%
\begin{document}
\section{Section}
\subsection {Subsection}
\p \blindtext
% an example numbered paragraph with an embedded list
\p \blindtext
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
and some words at the end of this para
% an example numbered paragraph with a simple equation
\p The period is defined by a pair of days ($D_l$, $D_u$) where
\begin{align*}
D_{l} & = \text{the lower date} \\
D_{u} & = \text{the upper date}
\end{align*}
and things happen for all days $d$ where $D_l <= d< D_u$.
\end{document}
ОРИГИНАЛЬНЫЙ РЕЗУЛЬТАТ ОП
С ПРЕДЛОЖЕННЫМ МНОЙ ИЗМЕНЕНИЕМ